嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
3 d/ }8 e8 ]( _! U4 T+ E
核心板2:DDR2 256M Byte NAND FLASH 8G bit
8 A/ l- k+ v. f/ P' q5 G5 D+ |
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
0 h- f2 z0 _: K. P. W7 u' \7 c7 l. A
5 t7 K3 x4 e+ X9 |2 W, P E
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
O" M; p& p- `' q
8 y5 L' Q8 @) }4 S
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
! l7 x6 X- z/ d: W0 ?5 s6 G% V
/*
: \$ n# c! e! m: r/ {
* Check memory range for valid RAM. A simple memory test determines
$ p" l8 t4 W; r# F4 i
* the actually available RAM size between addresses `base' and
7 d6 T: f2 @1 }5 ]
* `base + maxsize'.
8 f7 O4 Y2 a6 z6 ?, p, ]+ e! ^
*/
0 G+ G' {$ t+ G/ p; O4 }# j
long get_ram_size(long *base, long maxsize)
" D& r; ?. n4 @& B% V* ]
{
. w# w# P- I' s2 A3 e- |0 K; t
volatile long *addr;
3 v" r( a+ A. a
long save[32];
7 z9 r( L( v; B/ y
long cnt;
& w1 i1 j, ]" \( j. Q3 v
long val;
! r/ V- ~/ @+ f: l! @+ K1 u3 H
long size;
% C6 E* f! V0 e! j1 W% n Y) t; `6 ]
int i = 0;
6 }1 u3 ~2 f: F2 G! i$ ~
- ~' ]/ y# ~0 j/ A5 Q$ s" i8 u
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 E3 O8 N0 K3 ]2 h1 W7 T
addr = base + cnt; /* pointer arith! */
! z8 V$ E: w; ]* Y K$ R- n; l: h
sync ();
3 I% R' j$ }0 |) f2 M' M: c0 y s
save[i++] = *addr;
& E1 n, T o3 X+ Q7 ^/ E
sync ();
' b5 F- K& A6 F3 s. @+ R( V0 \6 F$ V
*addr = ~cnt;
$ e4 y, W4 w' A3 M8 b S
}
X6 ?: q( `7 W' W' U
6 A( m# v" _, H
addr = base;
6 Y/ B9 K2 S% H
sync ();
F h/ r0 H p! D
save
= *addr;
: f6 O! L) T/ f+ D& F7 x$ a
sync ();
- u s5 M7 `! L, U2 R; B
*addr = 0;
4 }8 W" ^! s5 ]$ _( @# i2 K0 W
' g# r; I% |( t) Q
sync ();
! Y" b- g. ?+ _* m
if ((val = *addr) != 0) {
( @& O5 E! N2 K9 C; ]( c
/* Restore the original data before leaving the function.
( y" l* ]8 X/ j2 _+ u! \$ \ F
*/
/ v& k6 Q6 G) a+ _
sync ();
8 x+ D' _' F4 x# \* D8 j0 z Q
*addr = save
;
& u" \4 }, e, {: o
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
& G, `) G4 m- ]! o- k
addr = base + cnt;
# j1 z3 [$ \: p" U' A
sync ();
- W4 v8 u/ g- d3 p$ o Z! [6 v
*addr = save[--i];
" C: r0 K( B d+ m
}
( H1 F( ]" E9 k
return (0);
6 C) X& S* H# L1 j
}
2 Z3 X" Y6 e& n5 R7 l- t9 K
: u# y% h% ]8 H' g. n$ ?
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 F/ b8 D8 I! D; _; R( H8 B( T
addr = base + cnt; /* pointer arith! */
1 x5 |+ c( Q% ]* G
val = *addr;
9 k* b5 D( d0 v+ s) G0 _$ \
*addr = save[--i];
2 } N( y2 J, S8 f5 u
if (val != ~cnt) {
; Y- h2 J. L0 Y W
size = cnt * sizeof (long);
; `1 m& M/ N; T: F) Z8 A1 [
/* Restore the original data before leaving the function.
7 n1 F9 A1 Q* F/ f( B
*/
! j% v( u& t+ R8 G }( r2 R
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 Z! W" x" D1 n% @
addr = base + cnt;
5 W% w* A( C0 N ^
*addr = save[--i];
# m& U' u4 X# T7 ~' w2 q) ^+ `+ }
}
+ R/ p) Y1 R! D8 i# a" v) u
return (size);
5 a- C" j( X: X; r! ?
}
- \( h( i5 A+ l0 \) q8 X; ~
}
' q) i( `0 t* b7 M9 S" U
8 @4 x2 t% [3 w2 _$ D
return (maxsize);
9 D+ W E, x: O, X, {2 [
}
0 M+ S6 R i* p& `, @! b4 o. a
int dram_init(void)
* m1 L6 v& m3 Q! B
{
- J- Q+ F$ h& n
/* dram_init must store complete ramsize in gd->ram_size */
% H% O% \2 A! w* B3 N1 I
gd->ram_size = get_ram_size(
: P+ { G; _% Z3 K
(void *)CONFIG_SYS_SDRAM_BASE,
5 {, _# F, f# {" e8 B X9 _
CONFIG_MAX_RAM_BANK_SIZE);
3 {! n: h- x9 h2 I5 S
return 0;
* u* ]1 ^$ j. u. s: E: ^
}
4 v) {4 a8 x9 g7 [) ]
4 K( _: _" I0 G: ]9 u! j
; O( o4 b3 L' t7 ]5 |8 E- G {
1 l0 ~" F6 I8 O3 \
' w; T/ s: n8 x; B, Y3 P
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
6 V0 L& o0 r6 }1 H2 B" r
b" o% z w( M' u" ~" R. U
! y. }3 U9 X/ }9 H" K1 t0 N
8 g4 V& F W ~0 o) |' N4 f
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4