标题: TL138 uboot是怎么区分配置两款核心板的 [打印本页] 作者: Mr.Loser 时间: 2014-9-11 09:33 标题: TL138 uboot是怎么区分配置两款核心板的 核心板1:DDR2 128M Byte NAND FLASH 4G bit 5 c' r9 d; R) F0 N! {核心板2:DDR2 256M Byte NAND FLASH 8G bit ) {1 H; y7 V u! `6 Y这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?' Z4 {, T* |, C0 W
. M0 N9 D4 e: {2 y是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了? + h) N! p) N/ A1 Q( d# R . L) r) {7 ?) x; J作者: 2532609929 时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下: 9 X; A a$ Q! Z' |' f/*+ D' F, R a) d
* Check memory range for valid RAM. A simple memory test determines- w+ j6 f8 J1 v, _
* the actually available RAM size between addresses `base' and z5 f! n7 Q. y$ s* `base + maxsize'. 8 u1 v1 y- h' F. x& S1 q*/ $ e. q/ h; \5 V: W2 ~long get_ram_size(long *base, long maxsize), R/ s0 |1 w. w A2 a2 w
{3 j" C1 P5 f n3 `
volatile long *addr; ' |7 P- [; p0 n, M long save[32];2 U$ I. v" ]. }3 j T- A
long cnt; 2 M! U2 Q; C t long val; P* n& L* z: i) F5 R3 A8 u, D long size;) T- \0 C; Y F) ?7 A$ u: S
int i = 0;# a& b+ L$ q- T5 y2 ]) Y& x
R z' M5 {/ n" Z, t u for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {7 k* {$ q/ e& V+ n! C3 `4 ]
addr = base + cnt; /* pointer arith! */4 |3 @& ?' t8 [ M+ r
sync (); ! N, `: s i" e( Y) H save[i++] = *addr; 2 } H* n( s$ f# ?8 U6 R sync ();: h- b( Z( ], O, w# F, X8 L& q
*addr = ~cnt; 9 }, \! m$ H0 }9 A }( {: K V$ |9 g; A8 B
7 L& y- x. G$ ` addr = base; 0 a) P7 O$ d" w+ f sync ();$ W% w9 G8 D& g- i$ @4 y( W
save = *addr; 0 E& C2 g5 p$ _5 M9 }: c sync (); 7 S' p5 ^) b' h, `/ y *addr = 0; # ?' q( F* h" z, v; ~0 w, G ; P6 v( }3 ^, Z sync ();: m1 v$ n+ o+ N2 L* r+ x5 w( d# |+ C; y
if ((val = *addr) != 0) { 5 |# N, A+ c! d. o /* Restore the original data before leaving the function." Z/ u* W" l6 b
*/ R: S& p8 ]! P9 B
sync ();5 P$ t) e2 M$ n. {
*addr = save;& q; T+ z9 H% r6 e
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {3 ?( K$ A) L0 B0 S/ C H( N
addr = base + cnt; , b" n. k' J' _( Z% `' t sync ();. V( B6 b z: U9 B+ H7 ~) g2 C
*addr = save[--i];$ B. Q. R2 x: d' ^
} & u' q- W2 P0 g: w, V8 ` return (0);+ Q1 Z4 R- z6 v
}( U/ L6 E2 g% ?2 H) A3 V+ w
% D) e, i# w1 ?0 Y% M7 f
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) { ) m2 g- u1 J( Q0 k- k addr = base + cnt; /* pointer arith! */ 9 A7 n7 t U! J0 _! x# m1 I8 T val = *addr;2 i) Q* Y7 a! c5 ^" M7 N
*addr = save[--i]; % o( w+ t+ `7 U% R if (val != ~cnt) { : Q0 Y$ ?" |6 b& r! U size = cnt * sizeof (long);( K0 Q1 d e" O, w$ t( X
/* Restore the original data before leaving the function. . ?. {6 o1 A5 D4 C8 t */; b( T+ d2 W- v: t
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {. _3 S: {1 p* O( M( F j
addr = base + cnt; L6 p$ n- \* f: H% T2 r2 E& @& b! d *addr = save[--i]; : c/ m8 d6 s; c4 w8 I' D, n) I+ f }# ]' x N% p' {: |
return (size); * Q1 U, C. u% r K9 y7 [/ [ } 4 `, A- x" o% W$ ?% C' J! o } - k- x V( ?( B- g( {2 @6 y+ H: q: H d% ]' S
return (maxsize); $ Z3 S- r3 t9 m4 d2 r' e} * U* o# r, v' u7 S2 Fint dram_init(void)/ i( V) d$ D% Q, O. O
{ 0 k9 w0 U) w' v2 r /* dram_init must store complete ramsize in gd->ram_size */& P4 \7 R' T0 g7 n0 e" V- g! l. y
gd->ram_size = get_ram_size(' t/ u h; q, _) O n, I8 f& u
(void *)CONFIG_SYS_SDRAM_BASE,7 z2 x0 H# u+ r, Z8 b7 b) `
CONFIG_MAX_RAM_BANK_SIZE); # n; J/ R ~% L return 0; * f1 a& M# w+ e( [/ K# c, o5 e, D} 3 v5 u9 g$ n9 {4 {4 X: j6 o5 U1 ~- h: ?" ^9 _9 l
+ F7 b, H: p8 i/ |8 P: G! A5 O$ U& E+ E9 O4 k
$ m! ^! i) F0 L' N6 ~, L4 }FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!+ ?& P( h# t' F# L
3 }; k0 C( l! u& i- R
9 ?9 u. y7 h; m0 l, q9 q( H' J