嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
0 m) y+ b8 z0 ^+ k% ^6 u# r, c
核心板2:DDR2 256M Byte NAND FLASH 8G bit
6 h# m" \: h V) r
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 r. c1 o- E( r. I1 i8 l% ?
; `! u+ H% O; B2 Z- [6 @& F
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
( @) d& T1 [) N5 N/ p
, m1 o5 j7 T7 \' g9 I) s
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
$ l) z! A2 z: d$ W0 ~
/*
Q, Z \2 l1 b, n% K- ^% b- T
* Check memory range for valid RAM. A simple memory test determines
( y& }- t3 M& |( v
* the actually available RAM size between addresses `base' and
& H5 s6 u2 X' i
* `base + maxsize'.
( D; @3 e& o/ g& k) V( b
*/
, h' N) o/ o1 t+ ?( D
long get_ram_size(long *base, long maxsize)
* e( `, \6 g. r0 M; a1 ^# q, p
{
5 ~8 B$ l1 g/ U) S' u- H
volatile long *addr;
7 i \& b, D, p: |9 w
long save[32];
6 W; T+ L7 d9 R
long cnt;
# u1 O' A0 R/ F
long val;
( g+ |& j" C9 U1 A$ a
long size;
- [. k9 ^9 ]; `
int i = 0;
6 ?; f4 h; N- }* P9 t5 k
, D# |- B8 G- _* E, p! E
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
- p% Q! s( D3 x" e
addr = base + cnt; /* pointer arith! */
( f6 M$ S. \: a. h% i7 c7 ~* s( U
sync ();
! o3 `3 P- e1 k% M6 {
save[i++] = *addr;
/ Y/ U2 i9 c6 R% S( H- x+ c
sync ();
+ H' z3 J2 A3 m: G2 N
*addr = ~cnt;
. U! K+ q: t6 H1 M
}
& B' w* v b& D
' I1 e4 t, k' B# ]7 x1 ^) a
addr = base;
. E f( {; z9 F0 r7 S/ b
sync ();
' g* B; d$ w+ Z7 B; S
save
= *addr;
, l) ^) k, ?7 C1 n2 q( r' y
sync ();
/ C, |9 |' V9 Q. g
*addr = 0;
" y% D2 _( L( m6 g7 p
" m- }) Z: E& x( H( z5 K' O$ E* i- ^
sync ();
# o, f2 l; C4 p j) i4 w
if ((val = *addr) != 0) {
1 ~# i7 O6 k. W
/* Restore the original data before leaving the function.
2 M- W" |/ N2 A7 S0 q" {2 N m( s
*/
2 b4 ~# s) E6 \' M. o6 F8 C
sync ();
0 a" W8 `& h/ \2 c" L( V
*addr = save
;
3 i/ c- n$ Z3 a9 f, W, N
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, w! L- P/ D: e! M* R
addr = base + cnt;
$ o1 h" ?1 K7 q/ b% ?0 [0 m
sync ();
+ B \% A$ [5 A1 }6 e) b }5 }
*addr = save[--i];
: K5 G0 m9 ]7 U/ D
}
4 ]3 p* W5 s" [' M+ F
return (0);
3 O$ Z/ }0 F+ L1 R
}
5 _6 k- u% l; Z) N
2 b# S3 O# S- s0 `# U* x3 k
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, a9 r c2 p6 x& L/ e/ }
addr = base + cnt; /* pointer arith! */
$ |3 v. i( Z7 R7 U
val = *addr;
: F1 P* k6 ^( H# y& T M( i+ o
*addr = save[--i];
, ^# L. T, {% c) ^* y/ ^6 t
if (val != ~cnt) {
9 V8 a1 L9 ]) w6 Y) f
size = cnt * sizeof (long);
" N- _, b S' p9 Z- H! ]
/* Restore the original data before leaving the function.
* q1 Q% v1 t' t) r
*/
+ T7 \$ ^5 \" t1 j4 j. i, F
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 V. o. K" H/ t- X) K
addr = base + cnt;
. q& H5 }% Q3 d) }
*addr = save[--i];
' _) B: d& l) O0 G
}
) W9 F* g e) Z7 S; g
return (size);
: w: K. V9 u1 ~/ y" w' m x
}
9 ?. r _) i+ z! I6 x: B" p
}
( o9 A) e1 F5 t- c0 U; } ]) @1 U
2 [/ T" V- P) O0 _
return (maxsize);
7 x4 U% l) ]8 B7 g
}
3 f5 o6 k9 K, {+ g3 c
int dram_init(void)
' n+ f) ^$ G8 {
{
6 [3 t( H' e ]. M3 p
/* dram_init must store complete ramsize in gd->ram_size */
" J$ k9 m/ N8 k+ N) X
gd->ram_size = get_ram_size(
2 p- f4 {6 U+ a, Y
(void *)CONFIG_SYS_SDRAM_BASE,
! H, @% U6 c+ ]
CONFIG_MAX_RAM_BANK_SIZE);
' i" v7 b1 r/ R8 i( {
return 0;
$ g+ k1 b! P% i# u4 ]6 @
}
9 b0 V$ s s7 ^: |
2 |! Y! o, r1 i- Z: w1 @& y
' k3 u1 c6 p1 C& c! o; F
2 c- |% b; X1 R# p8 v
" F5 @/ j; ]' P$ s. r! c8 c8 u
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
/ X2 S3 ~$ P& I
' a+ @4 a& S( H% ?" B+ c. O8 g
7 o7 L: T, V/ T U1 H. \1 a. ^5 T
+ ]) @8 C; ?0 Q/ B" c$ a& O
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4