嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
& b$ V |) c* t4 E. Z
核心板2:DDR2 256M Byte NAND FLASH 8G bit
) D( P/ ?- V* t9 d! B
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
' O [$ R8 O5 m4 N) c3 X6 W
' c4 x" i6 D( k/ t( K$ W/ \
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
! H8 Z0 \! `5 Q3 {; r
) J3 j- j' U- x& N$ R5 ?1 X
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
P# R3 ?, k2 c) f
/*
) `" `7 D1 g! x7 U
* Check memory range for valid RAM. A simple memory test determines
2 P p4 B# J7 M1 }5 S @9 c& x i
* the actually available RAM size between addresses `base' and
3 R% x8 |+ Z6 I$ f. q( M& C
* `base + maxsize'.
! {9 n) L' {3 J
*/
7 H6 x* ~. \' E5 b& ?
long get_ram_size(long *base, long maxsize)
# d+ i% T$ P8 \8 J7 a+ ^ x
{
% G+ e' S0 A; N' C6 w& ?% x" t
volatile long *addr;
9 f( S0 p5 Y1 }! |% A# [
long save[32];
& t8 r# r$ ?: B- F9 `
long cnt;
6 `0 ]9 p) G0 o2 c5 q
long val;
0 r' Q6 \: O6 a$ H4 N( Y
long size;
( a5 d: o) A6 |' o/ y
int i = 0;
. o8 J. A. u4 |) ?& c1 Y3 g
8 v4 M j$ l0 c2 h0 `
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
. @" s+ V3 z' G* c, g8 U i
addr = base + cnt; /* pointer arith! */
. V n& ^) B! c$ [7 q6 D5 ^9 N. N
sync ();
9 ^- [$ U1 @3 V3 B; ~- }
save[i++] = *addr;
e& u% S/ Y+ s, q8 l+ |2 J5 a
sync ();
: u' N9 N& Q/ z5 K$ b1 j
*addr = ~cnt;
6 N+ n& k- o7 _. {
}
2 Y& z+ | r5 w* S
2 e: F+ s2 @4 }$ `# e/ [% e [& u( d5 D
addr = base;
6 u' m: @ Q5 `& e/ Z
sync ();
% O" V1 p- ^, i! o: G, j
save
= *addr;
0 @+ O+ ^7 r$ o) _( V
sync ();
: a7 y9 D! O* B' K0 G( Y3 Y
*addr = 0;
1 Y* w4 Y8 v) b: S1 `
' g ^& D" v8 J+ R6 ]5 U' W
sync ();
- ]5 J7 B- P0 j& |& _ P) S
if ((val = *addr) != 0) {
/ j/ R' \" W- E7 p, K5 T! L
/* Restore the original data before leaving the function.
5 a* B% t2 ? u8 k/ G$ e
*/
' |2 i6 d7 y4 ]$ {$ R5 p% m
sync ();
* l% d* D# j9 j9 u0 X
*addr = save
;
& F8 p, `; d4 M' d8 X
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- ?& K7 P5 S9 @
addr = base + cnt;
" a/ i& {+ b, N. _8 L
sync ();
# q; Z/ d$ J4 n% I7 |2 N
*addr = save[--i];
/ P3 O6 ]- A, o8 v
}
0 a* p0 z1 j. w* _( {0 l
return (0);
# y1 s6 Q, r8 v# W( H; P8 C1 V/ z
}
, P% r9 X( H2 w1 E( Q
. |' f3 s% N" U& f
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 g6 T9 P" y5 J0 W3 m" x' m# k
addr = base + cnt; /* pointer arith! */
8 z! q3 ]3 ^# l: R# m/ y- A8 k1 U
val = *addr;
4 x8 ]: r! ] r' g/ D9 r( ]
*addr = save[--i];
8 K0 l& s& M* D: t
if (val != ~cnt) {
; {4 m; W! i) P$ A, y* |
size = cnt * sizeof (long);
# @( Z D2 ?3 }6 Y4 ^
/* Restore the original data before leaving the function.
; i8 f w- J# Y. j6 @" d
*/
8 X- Z. L0 `4 s8 K# @5 R- n
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 w p8 j, t- O: z H3 S5 U
addr = base + cnt;
4 a- v# n! Y" w9 f6 h6 \* Q
*addr = save[--i];
9 m. P' \9 k' x7 z1 [5 o# F
}
o1 f/ m+ Q. u* h' p, o
return (size);
' H. M" |% Z4 }
}
) O2 `, E- ^2 W
}
* N2 \7 R) C9 p, r( d! B; p
* i. Y* K' U1 N
return (maxsize);
T# |% V. U' H2 v) O
}
l9 a5 v$ h) P2 _0 g
int dram_init(void)
2 [8 C) H0 ~+ m4 c: Z/ O. ^
{
' O) O S- F8 H4 P$ Y6 G0 G
/* dram_init must store complete ramsize in gd->ram_size */
' g, \; j5 O$ I0 P v' z8 L- f/ q
gd->ram_size = get_ram_size(
2 a K3 h& o7 e; V+ J
(void *)CONFIG_SYS_SDRAM_BASE,
8 M- ^$ V3 O, T* |& u. ]2 t
CONFIG_MAX_RAM_BANK_SIZE);
0 |8 b! E& y; |! C% }
return 0;
* q/ Q8 ]8 g1 m# T
}
4 Z4 d$ S# g* x4 m5 w
" {( ]/ E' l3 t# d; Q) S8 t8 n, S
1 c$ x% A1 \* \4 C
9 }+ o2 L. ]" ]- i/ O
9 u& R6 T) V9 R. d/ I. Y% J
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
5 j9 E& k( w1 v9 l) ] ~
" ^# K: S5 X* ~$ Q
+ U3 s& s5 c6 E. V) _
* O! d! T3 O3 ^: j
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4