嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
, l/ ?) k+ K! F f1 ? ]
核心板2:DDR2 256M Byte NAND FLASH 8G bit
! K6 w# _. E0 O; r: E. _
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- G7 y) T$ w7 e
# i0 L. `5 E6 C
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
: {$ f# _' M3 t, J
/ a0 R# E& _' C5 j* J/ H8 s4 X
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
0 O, }3 p4 G5 G) K! {/ _
/*
+ s8 g) X- M8 t* F" Y
* Check memory range for valid RAM. A simple memory test determines
5 E, z# F1 V& x! E5 Y* N7 d
* the actually available RAM size between addresses `base' and
! `6 R1 F. V; y* t
* `base + maxsize'.
( m9 r1 | N2 s. U1 D
*/
" R2 m4 i8 R% ?7 _
long get_ram_size(long *base, long maxsize)
& G: D* F) P* q
{
& X/ ~8 _3 e8 z _
volatile long *addr;
8 L$ [* j* Z) |% t: y) e8 W2 U) j1 l
long save[32];
' E; l0 L" P" F- I
long cnt;
3 h# z3 I# J3 c4 G$ [9 _+ F
long val;
3 v5 N0 u! }' u9 O
long size;
# z/ z; ?! X0 Y, w2 I7 H x
int i = 0;
& b8 p5 a1 g( ? C" p
" C3 `8 R2 G+ B5 l" W
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
7 l m) u7 C9 l$ `( l! U# h8 L: F/ @: C
addr = base + cnt; /* pointer arith! */
8 H+ m8 x( g; o( ^" o& _
sync ();
/ t/ I- ?2 p- k9 M& @
save[i++] = *addr;
. B/ X" ?9 i. C
sync ();
* d& P! x# O! m
*addr = ~cnt;
" C, w. u1 R' ~5 N
}
3 w* Q+ J: G W A
4 a: K% N) Y1 J' p* e
addr = base;
. X' O% L7 V: ?# l7 ]0 t, s
sync ();
: R8 |4 j. C% X2 f6 ~
save
= *addr;
% ]7 x+ |( p# D; [% Y6 G4 `, d
sync ();
4 H/ i3 z9 R9 J. P3 C2 W$ t( d
*addr = 0;
8 N- Q8 q9 U1 _
6 {% e9 R1 h( j
sync ();
$ B h0 `( D# r$ Y8 z3 _ i# J5 E3 h
if ((val = *addr) != 0) {
' C& q1 I3 j) Q9 V% i7 [2 ^: g
/* Restore the original data before leaving the function.
1 T7 `& ~4 e7 W# Q3 |* l/ ^
*/
2 n: O5 c& g% Z
sync ();
6 [8 J' _7 R) M) @0 z9 k
*addr = save
;
0 o5 }6 B7 w% C: i: n
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- F; z+ s9 s r5 G/ P7 b+ x# \/ Q
addr = base + cnt;
, I- d0 A' i+ h. v
sync ();
e w1 w( I2 Y5 S* ]
*addr = save[--i];
) D3 ?7 m5 _* v1 ]; m( }* _) k
}
5 O# B3 S$ f- Z
return (0);
3 |* e- _# z) ^
}
' X8 K4 u; R5 E) f
3 o# q3 L) \% ?+ m8 y* t9 C
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 S4 I+ L5 s, s5 o% z0 v8 h
addr = base + cnt; /* pointer arith! */
+ L% ]8 B0 @) P- U1 C
val = *addr;
% `: F0 U3 K( Z" A2 c G+ ~
*addr = save[--i];
/ ]3 m8 j% Y$ ?! j, }5 P" l, E
if (val != ~cnt) {
9 l2 ]. I% j4 f" Y
size = cnt * sizeof (long);
9 P% c! c5 W' T8 R7 \9 u
/* Restore the original data before leaving the function.
/ L1 c0 N1 L/ G3 T5 U
*/
$ e6 U2 B/ u% m7 W% S0 c! G0 w2 W
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. ?# c+ a! |6 x. F& y8 w9 v
addr = base + cnt;
' I1 d8 o( |. p4 Y
*addr = save[--i];
3 g' V1 ^- p( r9 A
}
, |4 [/ G4 X3 X/ P
return (size);
. K5 y! Y1 f2 `8 u
}
1 { q7 K1 ?0 u- H7 C
}
P% ?& T, I: {5 M' l- |! z
( e' G4 v, J, @- }+ f# k8 q
return (maxsize);
. }% D7 |4 \2 `3 `; U
}
) z7 U: A, t+ A i! K+ v
int dram_init(void)
7 {6 E, |: O2 y( Y
{
0 Z% P4 v( Y* i9 `5 v7 h
/* dram_init must store complete ramsize in gd->ram_size */
" w1 U! Q6 V$ o/ ~
gd->ram_size = get_ram_size(
, w' R( ]6 v# c7 v- x( i+ B
(void *)CONFIG_SYS_SDRAM_BASE,
1 H3 C; a; o" { e2 k$ q
CONFIG_MAX_RAM_BANK_SIZE);
3 y6 \+ u7 v8 O' S9 }* E* u
return 0;
8 s/ k2 G% N- ?& \5 O
}
+ |5 b [# N/ n0 h, g
5 ^3 c, g5 ]6 F* h
5 M# J9 P# T+ i
1 _& t! L4 W2 C5 _ t3 q/ f4 A
. j0 `, c5 g/ ]; l
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
. e1 ~+ l! P2 i
/ u. z" i, M( k+ ]/ s& c
2 c/ w! W8 E6 h6 D* F. E
- f* d% M* j; v) y1 a! q/ V2 L
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4