嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
5 L' V2 ~) s; d6 |: A
核心板2:DDR2 256M Byte NAND FLASH 8G bit
5 |' |8 O. T8 a6 A+ u& J, u2 P3 B
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
( Z# f9 h: E: J. A/ e0 p" z
4 F& d& {$ b/ q
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
5 `; w; v- O1 j- m+ r: D
; V7 J0 [$ p- j, p4 M# U2 G& p
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
/ j( A3 x0 A( G3 Y8 J4 C
/*
; z! h Q! s* m
* Check memory range for valid RAM. A simple memory test determines
) S9 z" d/ P& b! M
* the actually available RAM size between addresses `base' and
# g* e5 m& y4 j0 }
* `base + maxsize'.
3 A3 T( |) F; ]/ c3 S3 M
*/
& u% e, x) ?9 D9 X
long get_ram_size(long *base, long maxsize)
4 c. |- K% ?" i( D* s3 l* \
{
4 ~* R2 ] k& ^; L
volatile long *addr;
! k* a @6 N5 L# b+ a- H# n" [- j
long save[32];
- z+ b! ~" H9 F0 n) r5 D
long cnt;
3 Q/ C# D8 S) l* }8 \* n; W
long val;
9 s3 z% r! O2 D0 ^% S, }
long size;
. k3 c# ]! z6 y+ W ~# J1 s
int i = 0;
* [9 h, P1 v4 ]
& F) C. v$ `9 i! l# C& w
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
& z: K) ?3 m E( }3 n
addr = base + cnt; /* pointer arith! */
H# S( O1 Z( Z9 E7 G
sync ();
1 ]1 J% b$ \$ J" a7 h
save[i++] = *addr;
# Y* T5 c0 i0 v; X: b# T- w
sync ();
. x. U9 G: t# O3 F& m
*addr = ~cnt;
4 f, d4 M! V* J* ]& p6 I) v
}
- F2 W: P0 y4 {1 U* n2 k- y3 k0 F$ n
% D' K1 c5 o1 Q5 l
addr = base;
; N7 X& M. ^: q$ X2 C1 V
sync ();
% }0 ` i, C1 D3 R, O$ q
save
= *addr;
/ s1 F/ {0 P) ^9 W8 ?
sync ();
" w% g2 `& p, C( g! p
*addr = 0;
% z7 N" {% u0 r z2 b6 b/ g
$ ]8 C ]# s0 M; P
sync ();
3 v4 D0 J/ P1 s+ q& c
if ((val = *addr) != 0) {
. p+ s) v* E1 w+ d* j- m' O( K
/* Restore the original data before leaving the function.
( _+ y6 z# U2 `4 A; J
*/
& |7 s+ \( s* ^" H
sync ();
7 r+ c9 A6 x+ W$ ^: t; X4 j A
*addr = save
;
1 w$ @ {) j# t& G- L
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, {- Z3 z7 g. U$ [7 v7 b
addr = base + cnt;
1 h4 M& s( o+ G# f% F5 Y+ z; M
sync ();
~. d. ~2 P+ X7 _" V B
*addr = save[--i];
; ^) k2 Z# m- Z( O, u
}
9 O0 I; N4 Z8 u
return (0);
2 C3 N3 x+ P: t
}
7 q+ i. Z+ Z' F2 f* ?
* I/ M% ~# @& D/ q9 T! a9 i+ }
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' d0 \: ~% F7 F8 x
addr = base + cnt; /* pointer arith! */
: [$ s6 o V- A4 Y% W
val = *addr;
, V7 Y" D8 I: F" y2 d
*addr = save[--i];
) A3 A( d7 |6 j- T6 u, j
if (val != ~cnt) {
$ R6 \& ^+ g& c
size = cnt * sizeof (long);
$ e4 d! M4 B; f" r1 }1 a& S
/* Restore the original data before leaving the function.
% n5 c- N9 k+ T
*/
0 A+ g* ] t- c5 _# [' I2 H3 U
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 X; s' E, j) h
addr = base + cnt;
/ t" { R1 k5 m4 H' H0 J
*addr = save[--i];
7 s0 M2 H6 L \8 }/ E
}
x/ j* Z" v; e1 n6 y9 U
return (size);
- b s+ p6 A- a, N
}
/ w2 ?1 N) i, h: J* d
}
& q6 B( s- P( W5 Y
+ P" J5 z8 g( Z5 `; | o2 w
return (maxsize);
% N' \9 V# e! m, \* m
}
; J: i- _& b0 R- E% S3 v0 U
int dram_init(void)
" [4 l' V; A5 G# F- y
{
* T7 O$ w4 U' E( P6 k
/* dram_init must store complete ramsize in gd->ram_size */
6 e( O; `" t; h% p: [
gd->ram_size = get_ram_size(
0 R0 @. D9 W/ g9 R) q( S
(void *)CONFIG_SYS_SDRAM_BASE,
5 ~8 x; `5 `( \4 u
CONFIG_MAX_RAM_BANK_SIZE);
3 V3 g! m7 x2 V
return 0;
' ]- H L- R$ R' I( [
}
z- ]5 E* f. k
* t- W8 J6 u6 P' j
7 v: i/ F, l3 I
. d& U" @! z& X
0 p6 t% P: y5 ^/ J* r3 d
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
. G: y4 c8 O$ Q( i% h3 {" B
; Q2 A$ ^, Q, P' G3 E7 W- W
5 k4 I: ~: p6 H# t- n
( m# S3 z' `2 d) n& d1 _2 X3 T
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4