标题: TL138 uboot是怎么区分配置两款核心板的 [打印本页] 作者: Mr.Loser 时间: 2014-9-11 09:33 标题: TL138 uboot是怎么区分配置两款核心板的 核心板1:DDR2 128M Byte NAND FLASH 4G bit0 P+ d3 J" `# O1 r- p
核心板2:DDR2 256M Byte NAND FLASH 8G bit- P4 E: I) Q& R& C
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?/ k5 q, h% S2 R e' Y
4 P* R# k C. `9 r7 n2 H是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了? j! H. ~7 a3 n8 L+ N3 M7 |6 w , T8 b1 N3 h1 P: v/ C' Q' [1 z作者: 2532609929 时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:9 O% G5 b7 s4 v/ r0 I$ F
/* 5 H1 B. i& u' {) g, j \! ^% x# k* Check memory range for valid RAM. A simple memory test determines) D# d* @, j6 ?1 l4 c
* the actually available RAM size between addresses `base' and3 D) d& e1 e, n
* `base + maxsize'.0 ?' p! j6 Q3 `2 e' T, k/ d
*/3 H% {& v0 R6 a0 X# r6 o& w
long get_ram_size(long *base, long maxsize)4 z; B- |1 x0 t2 z8 A9 g
{1 T4 G5 }1 V4 G1 L- R; X
volatile long *addr;' Y9 M7 x* B7 Q/ Z# ]7 K: S
long save[32];0 u! q2 }. c; w x/ E
long cnt; $ }' |# m$ D! |0 k, a3 G7 q l. _ long val; , ~5 D+ a) L: |6 S; n* e long size; * Q5 W" E6 M2 }* [/ N int i = 0; . H2 i* _+ Q+ c- f6 U3 a) Z, \" d ^' w
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) { 3 Z* j6 o9 N# j addr = base + cnt; /* pointer arith! */% G# T9 v6 r& A
sync (); 9 B' s( ]7 L# C6 `8 X1 u7 i( { save[i++] = *addr; h; g5 O$ G$ F0 E% U/ b/ h. r sync (); ' G9 x* v" [% o% l; X3 [ *addr = ~cnt;; ]5 v i7 {, Z) P/ t% M7 p
} ( G( t, F, F! {! V- f. [5 G3 Y7 t 6 c# A- w( l0 f3 V- I addr = base;# d, {# K' _& R
sync (); 6 d9 S+ @$ c/ G1 b1 ^1 E9 r8 A save = *addr;3 i3 Q+ M6 U$ y! p- R
sync ();0 _$ m" b) b# ?1 e( O; f; R: N
*addr = 0; 1 y: y( S: }0 M7 ^5 m + F( P! S' ?+ O sync ();8 Q4 L m. m' i8 q6 Y
if ((val = *addr) != 0) { ' N% W) c0 B% m& k /* Restore the original data before leaving the function. 3 h9 {1 m0 y! i1 O/ ?7 O( Y1 ~ */ + d, i7 i# `* ^' G; g sync (); 4 P' V6 I, S+ T1 T6 s *addr = save;2 r6 \9 y) Y: z/ B( G
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {5 V5 |, v Z" N( F& h7 n
addr = base + cnt; / j, w6 K4 m) F% B( R sync ();; d0 q* F4 D5 ~% o/ }+ I
*addr = save[--i]; " P& A& l6 M8 F7 ^0 I7 h } 1 o9 a$ v: Q8 w. O6 _ return (0); 9 V7 }8 Q& W4 y6 k k } , P' N5 j" g: E" @8 ]% c: H- [ ) J8 y B) G8 M$ i, Y for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {5 X/ Y4 m5 i% }' c* X! l
addr = base + cnt; /* pointer arith! */0 ?2 K l2 W" i! q3 f% F" Y
val = *addr; ! X3 a9 e5 R# D( V9 g *addr = save[--i];+ H( _. j2 f v! O3 X
if (val != ~cnt) {6 r( N; H* z0 l/ N/ ~* a7 l! S) H
size = cnt * sizeof (long);9 k! h' C5 i Y
/* Restore the original data before leaving the function. ( l8 T, G" R( W0 l3 q/ g8 h" B+ j# E */ $ M) k6 ^* |" e; y! n/ t W for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) { : |, `) y; Z5 z) d$ r addr = base + cnt; 3 w7 H2 A4 X) {$ S1 I0 B, [" t4 U# B *addr = save[--i];8 ?# D. p" P {0 W, m
} " ` z) D$ ^0 p4 u return (size);+ Z. v2 i1 q* p" \- J
}! b& [8 u* G, F/ H% j& P
}: X" o C4 E) {5 Y( J% t7 W2 a1 S9 ^
; B& N$ E" c& @3 c! G1 W6 T0 | return (maxsize); 5 g6 Y' K0 E9 o}+ r8 _7 s b) x0 Z
int dram_init(void)! N8 V: x1 r/ [( b' m# X
{ % O. f P- g& c( Y9 g /* dram_init must store complete ramsize in gd->ram_size */ " Q1 J4 g* q/ Y. F gd->ram_size = get_ram_size(3 ~3 S5 d( M8 J1 P" N+ a
(void *)CONFIG_SYS_SDRAM_BASE, . C- E5 `. ^/ Z) C' t CONFIG_MAX_RAM_BANK_SIZE); 0 V& u& m5 }1 q" A% N* W- O- |5 d: ` return 0; " m# b& U! Y, }% U} 1 q# V& m* q7 f f. H. q8 [3 I2 E) E # l/ j" Z2 I, d1 ^; P) A, ^( q8 B. c |, L1 F# D
% U9 F) _6 w5 V7 L" O( F) c, ]
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!; Z1 v5 Y* K' F [. N- r$ t$ L+ G& b