嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
: h% Z# B' o; _! f
核心板2:DDR2 256M Byte NAND FLASH 8G bit
% v6 m8 o4 H8 @3 M' b o7 p% y
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
; Y/ k( t" [ l) {4 U' I7 y
1 G7 C4 z5 A( [$ ] }. f
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
$ r% Y6 L1 q9 ^2 t( J& e
" t3 N. J: Q4 N3 S: m& I( w0 p* z
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) e, w V5 u! E+ X
/*
& w0 I4 _+ N, W2 T# e8 \. {& S+ U2 Y
* Check memory range for valid RAM. A simple memory test determines
, U* ?4 S7 N4 M; e5 V
* the actually available RAM size between addresses `base' and
, G# ?8 t" P. r' `! l3 n6 V
* `base + maxsize'.
D) y1 D7 f, X8 S, A* |2 k
*/
" B% w8 \/ {8 V; ~- p
long get_ram_size(long *base, long maxsize)
$ L0 o" X4 c3 Y Q7 g& N0 `
{
9 J b0 L6 _" s5 p9 k4 J- x, M
volatile long *addr;
$ T6 z1 [' Q$ \" v/ t" Y
long save[32];
' a2 r3 H# ]" J0 t6 N
long cnt;
: |4 O" |9 V6 _" w* s: f2 v
long val;
7 O- v- w/ s5 `6 {" a, a' \& E
long size;
, c% j% \! z0 ^/ f0 g, A, ] Z" l- {
int i = 0;
& K1 O" y% v1 V4 @
: ^. f* L. ?3 z& F& {$ `" E
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
# l6 S& j9 L' d4 Q
addr = base + cnt; /* pointer arith! */
5 N) K. \# f3 W; @3 M3 { f8 k9 ]
sync ();
7 ^" i( m1 v& d4 O0 G% A
save[i++] = *addr;
& P/ w2 e" @+ t" W
sync ();
% D; O- p, M4 t
*addr = ~cnt;
+ u' Q; u0 r- J6 w& n
}
' s. @ a& T+ w; U. @1 f
& g3 U/ n3 ?0 n( v+ Z+ ]
addr = base;
$ N1 T/ G, q( r! J8 z
sync ();
: M3 x$ y I% A; {' j w
save
= *addr;
; e1 p7 b- O+ ~7 B: A
sync ();
4 q' y5 t) N6 h( W# b
*addr = 0;
$ W1 L+ w: V# P3 n* Q) K1 c( g/ M
- L" n% P8 Y( ]
sync ();
2 t0 v% o3 @$ [" s6 C
if ((val = *addr) != 0) {
6 S$ V4 }5 N# B# w6 h
/* Restore the original data before leaving the function.
; C6 W7 y+ i8 P4 Z
*/
% J4 e0 o$ M ]) L# d( v" H |
sync ();
* P5 I2 X2 m! \& A. h! }! [% N
*addr = save
;
9 w: v# D+ b5 I% Q3 `
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
a- l+ i- o* w( S& d J2 I. q8 n
addr = base + cnt;
, o) V: z/ Y; ?1 S1 G
sync ();
& U9 p) V# i$ v) @
*addr = save[--i];
. f4 G* d% v$ }& P9 G" A8 W
}
' {" @" y' k8 C- s( r0 W
return (0);
2 I) J, H% z8 p6 ~) P
}
# A/ I- M6 z/ D+ z4 [- `! T
/ A1 r! D8 o' `; V
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
: t' M6 n+ g" m4 L1 Z
addr = base + cnt; /* pointer arith! */
0 r& J5 I$ `4 P9 Y* K+ {
val = *addr;
7 y' C* X. C9 t+ v: _
*addr = save[--i];
2 E$ b. m) h& N+ s0 Q8 \' U
if (val != ~cnt) {
5 W+ @% M, z/ D) b
size = cnt * sizeof (long);
7 W0 P' A, m7 Z
/* Restore the original data before leaving the function.
/ b7 _: N( o- s, d
*/
# X6 {% f" @& i. w1 \+ G
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' E0 ~/ ?* l3 |3 v3 H' \
addr = base + cnt;
6 U' w3 v# D* P' R+ h
*addr = save[--i];
1 c& A3 j. {3 T( t
}
/ R: _. o/ R/ W% v5 B
return (size);
7 t. r# Y( s4 b4 M$ s, x7 z
}
# p0 G; U9 D- m+ _
}
# z& m+ s. A; S' Z4 i" \# L' h
' I* A* h- e a2 L7 u3 C; Y
return (maxsize);
# B* b9 f* o& D# b' ~
}
2 F5 F* Y9 b6 [+ F: e/ C
int dram_init(void)
' n. S/ O& r1 q+ [
{
5 s7 k* n2 C; ]! \
/* dram_init must store complete ramsize in gd->ram_size */
9 i( ~9 n. y1 P! X0 t
gd->ram_size = get_ram_size(
7 P8 c) u9 q) {5 f
(void *)CONFIG_SYS_SDRAM_BASE,
, Q. Z( @: z- U2 ?
CONFIG_MAX_RAM_BANK_SIZE);
0 @# P: K! L6 k5 ~- M
return 0;
% W" U6 u7 N6 m. O. \
}
6 e* K3 g1 ?- z! [" Z
4 q( p0 S) v( Q" a7 u5 d( p0 m7 }
8 @0 U1 [/ y6 D) O: m4 r
; n" M) W; o6 }
+ n, H( O* @& f$ h* E
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
7 Q% T" a, W. z' M" U( ^. J6 e
! }, n& I$ ~4 ?2 L) m9 y! b+ `) n
8 Y% Z" c' {0 f
" y* a9 X8 P* P% y
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4