嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
% N Z1 P; ^, g+ U% d
核心板2:DDR2 256M Byte NAND FLASH 8G bit
9 |! D$ d) [- e: k& `) J$ I
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
1 J. o) U1 X0 k+ q
7 ]. ]' P/ S; \) Y9 E
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
1 Q2 o2 ]+ K+ Z3 }/ P- w
, q* {) j6 B( q
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
( A- ]6 a" ?. f8 D e: e3 b
/*
7 u# q7 z+ k' v6 l6 j
* Check memory range for valid RAM. A simple memory test determines
* S( f- W p# h6 U
* the actually available RAM size between addresses `base' and
6 T' U L0 }# m6 |7 t8 e& ^4 v; L* X
* `base + maxsize'.
% T& \9 _$ i; G, j
*/
- L( o( Q0 d% o# d* G$ O
long get_ram_size(long *base, long maxsize)
6 F9 R* S K- {+ ~/ n2 I1 h
{
: V3 _& _% T; G
volatile long *addr;
7 K6 X7 S0 Z; o/ H9 L& ~
long save[32];
* h( e* O# a+ u6 U! g4 {4 o/ K
long cnt;
! h. E! v0 G A5 Z( e e' p, n% T& @
long val;
! k( ^! \2 O8 ~2 `+ V& T! P3 L
long size;
" \' ~; n3 p( J V+ f: z
int i = 0;
: d2 v6 h9 e5 R
& ]! g+ r' a7 ^& N
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
0 p! S0 H# K0 |8 S+ a
addr = base + cnt; /* pointer arith! */
5 w! n, g+ }( G2 j5 m e/ a
sync ();
9 } y$ o4 K5 p$ I1 k/ {
save[i++] = *addr;
: h) d+ ]! g6 O% j/ e, t, G; x
sync ();
. a; X2 T% H. u- c
*addr = ~cnt;
$ Z) s' o" \9 h& u: {' o
}
! n4 a7 `; Z4 b
3 K: o( x; A) @% Q
addr = base;
2 _9 A6 o: u7 D7 Q: t8 \, q: D
sync ();
( w2 Y3 l5 R5 r/ Q
save
= *addr;
7 C0 O4 H# I/ l) ^- d% ^8 P3 G, P6 E
sync ();
8 @$ m7 G) ~, W& e9 V) T& q
*addr = 0;
* ^& \- A+ U: V+ }" v7 o0 D
) m4 q% c( V/ f) t
sync ();
% ]6 {" M8 p( m5 J7 u' Y
if ((val = *addr) != 0) {
$ w. O o3 Y# ~" c7 y
/* Restore the original data before leaving the function.
1 M$ t* k- e& c) I( y
*/
' s; `3 |% z3 S& Z( U
sync ();
( W/ Y4 C; K6 L: M: D
*addr = save
;
! W5 G, l% w/ z5 J2 Q' }
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
! K2 ~ D4 o! g: b0 `- w
addr = base + cnt;
( J7 o1 k4 g% A# l6 |& K
sync ();
5 S6 x) a H. M* M$ c) [
*addr = save[--i];
) P0 @9 J' K9 r' x0 g6 r
}
6 d: p5 M' [) ^; @' g
return (0);
. Z0 H" u" `& J+ E
}
; z" w, U$ o# G/ K) f \
. O- r9 C% B/ t: u& E) x+ A" R; @1 N6 U
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, E. ~7 I4 \" L9 o
addr = base + cnt; /* pointer arith! */
2 s# a/ `! i9 H! a" ^
val = *addr;
) ?; v$ z0 D$ b5 ~
*addr = save[--i];
5 _3 p. d7 [, p$ i! `- v. Q8 ^6 k
if (val != ~cnt) {
* {* i& ^ L( r3 z) H( \' }9 Y
size = cnt * sizeof (long);
! Q* `# ]1 l% O3 {9 ~/ i8 Q
/* Restore the original data before leaving the function.
4 L9 J9 \! a9 Z- O
*/
# V- b$ _) `+ N8 `; g( L
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" h4 n( o6 P5 w1 f5 Z+ Y
addr = base + cnt;
6 J5 x. E; {# O' t, [2 \2 w* B
*addr = save[--i];
; {9 z% m! C6 }3 o+ D4 b& o
}
' {" k$ ]6 I+ U$ d& p- a0 [2 Q1 k. [
return (size);
; V' Q. E `8 m$ L3 W- L" \! |* z
}
5 ` E8 d1 _8 x
}
; D" f4 T2 }6 ^- g6 X+ b L4 s; h
* O" m! @7 h8 f2 G3 ]3 t; ]
return (maxsize);
8 W7 K# |! F& S/ x1 [7 `* b. D
}
9 Z( R. O6 V: X) h3 D7 J7 \
int dram_init(void)
+ M# ]( _, N3 `
{
7 U5 ?1 {1 K2 e9 s" G
/* dram_init must store complete ramsize in gd->ram_size */
2 G* j5 W0 [& m0 ]1 b! J; l. `
gd->ram_size = get_ram_size(
0 A5 s% d) @+ |+ @& l: }
(void *)CONFIG_SYS_SDRAM_BASE,
x/ ~# _- ]& P L& J7 n: S
CONFIG_MAX_RAM_BANK_SIZE);
) V- F, y/ m4 L w) i* V
return 0;
5 L X& K' k) ?: M3 n) B3 ?$ n9 i
}
' Q9 p! q7 i9 x2 E( E
0 Y4 Z m( u9 A. |# L$ W
3 F( x0 I( r. {2 K
* R# ^3 ^- e' J8 f5 ?' D% G9 T
3 b% Z/ U2 ]- m1 n1 Q
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
2 m! K6 T& w5 m' Z: B2 o) |
/ |) R1 K o% F/ Z& N
2 Q/ Y) V4 \$ Q- q4 d2 j4 C+ f* D
2 |3 y5 ^3 X' K
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4