嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
% m7 O+ V- x' I, y- p' |7 z
核心板2:DDR2 256M Byte NAND FLASH 8G bit
# a, ]/ [0 J) u5 Y) k" I
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
P j+ J; U- b/ l$ i i! I
# v$ g! ]: ?$ y7 K
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
4 _; V- ?5 ~7 C4 w
+ a* F0 M( o' ^9 m8 g! P
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
' O9 Z+ j5 l$ c W4 v' q F
/*
9 U& p$ w" }3 D/ k, A
* Check memory range for valid RAM. A simple memory test determines
2 o& `( y/ P2 {: N; l7 n8 W m
* the actually available RAM size between addresses `base' and
4 {7 w! Y. [+ B* S N% N
* `base + maxsize'.
5 C" B3 e! N% V: }
*/
) w2 w. D: f& D
long get_ram_size(long *base, long maxsize)
) E Z9 ]! _/ D$ g# g& c5 W
{
/ @0 {* m1 d7 A# U# Z6 a
volatile long *addr;
8 i+ v) I1 ?, e3 f# W
long save[32];
5 B3 s+ @3 \" q- z
long cnt;
( b0 l8 D8 h: R3 Z$ T
long val;
/ `- q& z) N" C. S) [ f* n$ Z
long size;
1 Y6 T+ S! p& B1 I2 @, Y
int i = 0;
! K; Z) F; f1 j6 C
; F: B: _8 l1 H d/ f* V2 V
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
. \1 q6 g, x% _( D
addr = base + cnt; /* pointer arith! */
+ q% F2 O5 S5 ?) H# j% S) @
sync ();
# w$ I7 O' ~6 _1 v0 Z; d
save[i++] = *addr;
! y8 m r4 Q7 O& _2 v
sync ();
+ e; _% |: @+ e* W& l
*addr = ~cnt;
% o5 r0 y0 r- w
}
2 A+ g/ R c# M0 G' X9 a! q: g( u
7 s& J2 P' [) ~+ D
addr = base;
9 a- D! K0 j3 q
sync ();
1 w9 R) q! {. ]( H Y: V
save
= *addr;
1 `9 y: m3 H7 `
sync ();
% x, c# A( B+ s, k- \
*addr = 0;
7 `( n6 ^! l0 @% y4 \7 f$ ]: A( R. ~
1 Q) p+ G% A8 O3 d# T
sync ();
+ _. [' q3 K/ Q5 O
if ((val = *addr) != 0) {
9 c" \- a# m2 s* [, p" V8 _* t2 @2 i
/* Restore the original data before leaving the function.
* n$ v7 l5 C% P, g1 O" ?4 @
*/
: ~6 V2 N6 Z4 p* n" Y1 k0 J7 V
sync ();
! U9 |. {3 o7 v3 n% K
*addr = save
;
/ g# t' U: w' M4 `1 b9 a" t
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
1 F' B- I8 `# G A+ R+ G! `
addr = base + cnt;
- L, S# T& a4 r/ L
sync ();
* \) V6 z+ D% v0 ?
*addr = save[--i];
3 K4 ^) x0 _- m. x$ ~
}
8 Y/ `4 E, O; M( C/ K9 }3 P
return (0);
' N, H! {4 d$ p* S R3 C0 t
}
) f5 E9 j. ]7 H0 G; W: b1 f z- t0 H
! J0 B0 `: _. p, H% B. t2 m: J
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, r' k" s I7 G
addr = base + cnt; /* pointer arith! */
8 E7 A% U+ v8 \5 \5 {- g
val = *addr;
4 b* i7 F- H8 r- T* @9 X# M
*addr = save[--i];
/ k2 g( ^0 m1 w. G' F9 Q
if (val != ~cnt) {
* G7 x. y5 l7 o) u
size = cnt * sizeof (long);
2 O5 O! r, v @) U
/* Restore the original data before leaving the function.
1 y% U; a3 l' | F2 @! F! k
*/
! @2 s( F4 L. [
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 j6 R# r2 w) j o4 u
addr = base + cnt;
4 l+ g/ _& E% \) N- J% I
*addr = save[--i];
1 d. d$ K/ D( r( V3 G: X6 C
}
1 [7 ^9 e+ ^9 e$ f8 r# y
return (size);
+ T' j% O- b" F# a
}
, X2 I+ O3 X1 O' U7 `
}
$ ]' B3 d* m7 k& j
6 \ Z1 ~. r% u- n3 m M
return (maxsize);
- X, g$ Q4 I- a' ~+ [# P* M4 r
}
5 i6 b* n; n9 w3 e
int dram_init(void)
, `4 ]' g( p5 R0 J1 n5 }. V- W
{
- D$ v- P. S; B$ h7 F$ B1 O
/* dram_init must store complete ramsize in gd->ram_size */
- S1 b& ?3 I7 \* K- R' b- F
gd->ram_size = get_ram_size(
6 _0 }, ~% V4 _, N) k5 R' O4 F
(void *)CONFIG_SYS_SDRAM_BASE,
, e2 y% E) J/ _8 o* J, U
CONFIG_MAX_RAM_BANK_SIZE);
1 I8 `% B6 Y8 [! z9 g
return 0;
1 U: h z9 n3 ~) b. G, q" Y P
}
^& ] F8 ? r: X4 s" w. S
/ R/ m( @0 @* T
+ |9 E& A* c3 t6 E8 d- r. V
4 c, f' Y4 w: _* |
3 u. C, J( T+ R/ E! c5 X
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
3 z* c( I) }* x# z% n
8 l1 R" z- g; i) ` A
/ Q! h( T. ~0 K
+ u! C( G6 F4 |; [) ]1 |
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4