嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
- s* K- d) D1 I
核心板2:DDR2 256M Byte NAND FLASH 8G bit
, n4 Z; C: H2 [
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
8 o& ]# O& v5 N$ y
, {# {$ y5 ~. u0 @( E
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
2 }6 y: f% X* t. d h L9 n0 L
' X* m4 H" Q) o# [
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
6 ?! r4 o( p5 O% N0 Q4 I! E5 x
/*
9 [' b6 m8 ?$ Y- H) X7 P
* Check memory range for valid RAM. A simple memory test determines
) w! F$ G. D8 x. n' `
* the actually available RAM size between addresses `base' and
, n) H/ R, t# u8 ?% l3 b) W- B$ n
* `base + maxsize'.
- [ R- ]" D: g: w# }; Z6 G
*/
$ ~, Q( G1 _. f- k' o6 b4 h
long get_ram_size(long *base, long maxsize)
" B U5 x6 P H* b' U1 B
{
. ^- `9 @. O8 z6 N- C1 r9 m! g
volatile long *addr;
9 r. p5 O, u p/ C
long save[32];
% b1 |6 X# m }. _$ J0 n: {# \
long cnt;
1 C: C2 m! ^$ p; L+ m
long val;
6 ]* d0 I. |3 ~. J6 N. A% N
long size;
9 E8 v9 l4 d8 W; O& B
int i = 0;
9 {% X( @3 t' F8 g3 C- J( m0 r* f& ]
% S: ] H8 W% X: a U1 x
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
/ x) l. n2 o0 G5 h+ F$ s( C
addr = base + cnt; /* pointer arith! */
0 Z2 j% A Q9 q" {6 ^+ G: ]
sync ();
; |: |, A! ~: @+ B8 K
save[i++] = *addr;
2 x" }0 L5 H4 x' O: _
sync ();
. l. X9 S* J% i) f. h/ x
*addr = ~cnt;
) S/ k, v% Y! c4 f# ?+ A# A
}
7 a$ F& D$ p7 V8 V! G; S' [: z
3 q( r4 Z4 _* g
addr = base;
& P; u5 F5 p0 F5 ^) h# D( `- m3 ?7 @# o2 z
sync ();
3 b F5 v" c& E8 H9 f* @, i
save
= *addr;
. S2 r: Z) q8 U5 E* Y+ a/ j' J
sync ();
. j7 t5 T3 B S R: j! E
*addr = 0;
& z' }5 F# C4 D9 ~) ~
, L2 a# k7 P) d( v
sync ();
3 J/ I# \& S8 @2 G g3 R5 `7 a9 i
if ((val = *addr) != 0) {
, ?7 i& `0 T, O" v2 w! m. Z0 e
/* Restore the original data before leaving the function.
$ y+ K* R2 t: z% l3 J* Q
*/
9 L; D* M" r- b% F$ i f" l! \- G6 L& X. i
sync ();
1 q6 t2 A* e1 [; u
*addr = save
;
& G* u9 ~' }4 W$ ~% d; s1 D
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
% P. S3 }8 H; S( ]2 {0 g f
addr = base + cnt;
+ w0 C9 k i: Z* ?
sync ();
4 y: Y7 S! ^+ p1 c) l, r1 R2 D T
*addr = save[--i];
, S. z& p$ [" ~' H n4 [
}
% l1 P+ u }5 Q8 Q& K
return (0);
7 g1 C U T8 G$ H2 F% ?6 h$ P) s- ^! H
}
# ~% C3 q7 r0 M7 [: D% O2 d
1 W) ^: h( v- v6 }% \
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) v- @9 d. x) l. Q
addr = base + cnt; /* pointer arith! */
& w" t' W) y7 B9 J% V
val = *addr;
+ I( @; y1 q* ^- J8 I t% O. m9 X
*addr = save[--i];
4 T3 W: k4 B! h
if (val != ~cnt) {
: Y7 D( t4 f# f
size = cnt * sizeof (long);
3 N7 G/ q) |6 e1 S
/* Restore the original data before leaving the function.
1 q8 d! r' M5 q [1 A
*/
8 e7 w4 s( c$ c0 \ i
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- O$ C3 t ?% g3 T
addr = base + cnt;
0 j5 D1 f* R8 x4 m, |
*addr = save[--i];
' }# |8 ~8 Z# [" M1 I, I
}
& ^/ q1 r7 }) W
return (size);
# {- Z. P( q4 _5 t: H
}
8 R$ M- {$ T6 i' q/ x; c
}
, E _1 `8 R1 N$ ]8 r+ {
1 _1 J% m/ |4 G
return (maxsize);
/ X% k8 v9 J/ C' d% Q6 A& v: v J
}
; N- G, }5 h1 X
int dram_init(void)
1 l( E( {# T& w' e5 X
{
/ {4 h; W& I$ `
/* dram_init must store complete ramsize in gd->ram_size */
$ D# ^. {* s9 }9 U8 c
gd->ram_size = get_ram_size(
& g9 X9 d1 F5 K. n1 w; i+ w$ Z u
(void *)CONFIG_SYS_SDRAM_BASE,
+ W% y: t( o) J4 m) q/ O
CONFIG_MAX_RAM_BANK_SIZE);
5 U" N- ?, F* d" y# W' `
return 0;
5 E. q- t: d' w+ {5 w' _
}
8 A+ M+ {+ _! }; D: f5 T3 [. N: U
; t/ T1 p4 X% f" A- F/ l
2 u( z, G6 g- A8 G" ~
1 N: D8 h7 K7 t" N' z
0 Z4 R& M; f% p
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
, e6 ~5 |0 z, _
: m% ^) ]9 Y: K1 w+ x9 |# P
! V3 t; y+ I# y$ x
3 P& I, o" c* j
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4