标题: TL138 uboot是怎么区分配置两款核心板的 [打印本页] 作者: Mr.Loser 时间: 2014-9-11 09:33 标题: TL138 uboot是怎么区分配置两款核心板的 核心板1:DDR2 128M Byte NAND FLASH 4G bit 8 U& J% F+ H( o5 L- c9 |核心板2:DDR2 256M Byte NAND FLASH 8G bit9 N/ O* m! f, f0 T( {
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?' E) Z5 B/ F7 k. L H
$ U6 S+ ^4 D& f, M2 x
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?9 H( p! T5 [6 _9 R4 F. h
4 F7 X! h# t! E9 u1 |作者: 2532609929 时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:( F& r) l$ s4 i5 x% h) d
/*, _& R* P0 g3 x9 U- U" B* o1 D
* Check memory range for valid RAM. A simple memory test determines / {, C$ C5 L5 a, o, Z: b* the actually available RAM size between addresses `base' and" Z5 w/ N9 n0 }* X8 X/ W: P' W
* `base + maxsize'.: w3 K3 Z' o4 V& r6 Y
*/* X. L0 }' ]5 y
long get_ram_size(long *base, long maxsize) " s: R B; h* b{: J% a6 B9 b$ Y" x+ I
volatile long *addr; z1 W0 R3 Z7 f, [0 v$ t: @
long save[32];5 ^7 i) }% `* J& d" o$ v1 N- X4 t
long cnt;5 Y7 q% ]8 F4 S% D
long val; ! m9 F) r6 I4 e) F8 n ?% t$ |% d long size; + k) z g) o4 D6 H; A3 w6 `# b0 z int i = 0; , i# C& n( t) C) r& y5 g! k, ]/ i1 D" c% D# A
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) { : Y! F/ a8 [9 y U0 @7 g addr = base + cnt; /* pointer arith! */ `3 v- r/ Q$ X0 c9 z8 d6 Q* v" n
sync ();2 G( P2 z3 U( q! A6 @9 @
save[i++] = *addr; ' Y, s% o h" e$ C1 ?' f' C sync ();% A) }( u5 y* g: X" A4 ^+ `/ f! |: j0 _
*addr = ~cnt;! S' U' m7 U) d8 S
} 5 p, x2 y; m: S y, K( u + r) E7 y" r8 j( r addr = base;7 G6 y$ C. d7 h
sync ();$ c2 T9 h; C& G. j; {: @) q
save = *addr; : C( ~% A; r0 y0 w* } sync ();) a: o; t4 i4 |5 {. x- i
*addr = 0;: _: h+ O7 e4 n6 ^5 U
" k X7 v- K' }% C sync (); 3 Q; a' u2 b& { if ((val = *addr) != 0) { 3 C6 g- t: a( O1 H /* Restore the original data before leaving the function. 4 [! s3 k7 v/ O4 l; ] */, U3 K- {. v; Y. p8 v8 G8 r
sync ();$ u6 f( F- `1 `- t; P+ ]1 A* e( e
*addr = save;% D! @8 ^1 L0 ^* k- ^+ f
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) { / V& a" y+ H% a) e. M addr = base + cnt; $ ]: G) k( s. D1 q+ V" y I7 p! x sync ();( m# b Y9 m$ @9 q1 f9 z
*addr = save[--i];8 h. t \. c- Z
}, }+ f/ `9 V: Y& u8 _$ o7 L/ F
return (0); : @4 k1 p% x1 s }* R( h. ]/ e: s" |# h L* h
: u" y! t' R8 V& g4 ~$ g for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) { ( T6 o/ m R! b" n q! F/ t addr = base + cnt; /* pointer arith! */ 6 Q& r6 \6 A6 X) y' l5 g3 | val = *addr;9 t0 u* M: B b5 H8 s8 q$ W- W" J
*addr = save[--i]; ( ^9 k0 F* W; B9 ?% ^ if (val != ~cnt) { 7 `0 y) X# O% m' d, x: }/ T size = cnt * sizeof (long); i4 y9 C9 s) M' b: ? M* r! n- X /* Restore the original data before leaving the function., r# r! Z$ b) K, _- \
*/ % I' m' c* S' C6 B6 \1 I" X: H% B* p, @ for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) { S' _8 ]) ~) P3 b addr = base + cnt; 1 f/ x: F, O2 n/ j& J \* c0 X *addr = save[--i];- a* d, l1 }' Z5 ~9 q) y' b$ `
} . _/ N( L6 g% t% B; s7 U0 Y return (size); 6 g5 t. r$ o& p; |/ m- E3 i }0 A1 G; \1 o |6 z5 s% [: V7 u5 y# q# e
}+ }$ \4 y& ^* h3 c" L6 w% [
5 V! E* B Y% E* s$ L0 @* Z. F, O
return (maxsize); . w& J. v4 R3 `! I( K4 F8 [) G}& N( n1 {& ~, P+ v, \6 @1 z
int dram_init(void) - ~* _" p; @8 S4 L: L{8 q7 u6 ^" P6 u' u3 N' ^: F$ G
/* dram_init must store complete ramsize in gd->ram_size */$ o2 m8 w) T3 T) [$ F% c
gd->ram_size = get_ram_size(2 i' h4 n2 ] p8 C
(void *)CONFIG_SYS_SDRAM_BASE,8 G* N8 T$ `1 _$ @. z( z7 r4 z
CONFIG_MAX_RAM_BANK_SIZE); / a6 f8 a1 s. a. s return 0; ; j! N4 ^6 X8 d# w}' j' W, m( k [3 ?; S' R+ H4 y