嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
0 `% u/ Y, m9 b; s* h0 p
核心板2:DDR2 256M Byte NAND FLASH 8G bit
$ e8 \2 _7 W0 l
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
& k# L& c7 U$ N
8 H& w& X+ k; m9 n/ \
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
: Z7 Q$ Z \7 V
" c6 N8 w) S8 S
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
5 A( ^ m+ i' l
/*
; z M b) C# E
* Check memory range for valid RAM. A simple memory test determines
6 c& j* p' v" R: j+ A) p
* the actually available RAM size between addresses `base' and
$ ?5 c4 I$ h) h t
* `base + maxsize'.
( ]: A3 C3 x5 ^" F" D
*/
! d1 t8 C0 j4 q# X0 h4 Z1 X
long get_ram_size(long *base, long maxsize)
0 a( a& o- f: p( C4 w' X
{
& N# d9 P, ^! S$ n9 u. r
volatile long *addr;
; t! q7 X" V& ~* U* U1 j" s' V) l
long save[32];
( }9 H9 `3 f" ^
long cnt;
: u+ m: J7 ~9 q3 B9 p$ Q
long val;
+ x2 m) {/ r) F5 b
long size;
$ X4 S0 f* Q' j0 w+ p
int i = 0;
, |) u! N7 y4 t2 _+ p$ Z8 S& j
% q4 m$ \; H5 ?3 A$ h
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
, X) v2 \ J% e9 X
addr = base + cnt; /* pointer arith! */
( G; {( q+ L/ H
sync ();
4 h. s: N# {4 g! `
save[i++] = *addr;
8 h% h+ ?6 o; r! B4 k% h3 z
sync ();
( {0 f2 U+ X7 o8 O' R
*addr = ~cnt;
0 i; M- Y* V: I9 U
}
( C/ A3 {$ e4 s( M9 s
9 P) I/ I6 e3 u
addr = base;
U# ?5 |0 K# m9 A6 P7 H3 x4 w
sync ();
7 t0 B7 h' }% E, t
save
= *addr;
' Y7 \" E1 d6 g5 d( m5 q. p6 Q1 k
sync ();
w) h/ ~* T1 u! s9 w+ o$ q
*addr = 0;
" J+ I- k; Z2 R
' Q A1 {$ C- X8 b. i5 u
sync ();
4 T) |. Y$ [: W
if ((val = *addr) != 0) {
. X: q( R; [2 \1 p9 V
/* Restore the original data before leaving the function.
4 a1 d* @- Y, V5 P( {
*/
" Y" X3 O6 G O
sync ();
0 n* l+ U7 J6 T7 K; w5 V$ K$ J3 L3 F
*addr = save
;
& A; D" B! `. _6 {5 j+ f
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
5 ^2 T7 I1 X6 D- f/ k! j1 l0 h
addr = base + cnt;
0 {/ e/ u' C4 R. k. G
sync ();
6 c& Q( a& e$ G% S% K
*addr = save[--i];
' a# H ~) _1 X& P
}
! O1 b( @" d7 c- c2 |; S7 \! x4 @) ^
return (0);
' {, X- K: t' L! ?$ O& t
}
# p5 C: {! r# W8 G/ |# V7 J* F
5 o C8 x- }8 _8 f
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 H" R" c9 a$ U
addr = base + cnt; /* pointer arith! */
8 {: r3 W: ~$ _3 f) i
val = *addr;
8 e8 S6 r3 Z0 t7 d0 i
*addr = save[--i];
3 C' f7 C% n) X8 k9 P4 W9 p
if (val != ~cnt) {
: V1 m8 k" m. [7 m4 D/ E- j8 s
size = cnt * sizeof (long);
2 e; [4 `% n3 T" t
/* Restore the original data before leaving the function.
/ l7 P& r+ h9 |- ~+ R, ^+ t
*/
" {+ C$ B1 X6 I0 L" P3 r* l1 L
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
! y8 \9 r$ b1 O; z6 V
addr = base + cnt;
' U5 [3 V' T+ p, G
*addr = save[--i];
& a( n1 c+ Z$ u1 Q g
}
) j, Z/ q9 T1 L ?0 t4 s
return (size);
h& B& Z% y. |8 y9 E$ _# q5 n6 H
}
9 z' }. C" v s, R/ M" D/ E* }6 H: O
}
; d% W0 P" X/ F; f, s
: a8 [& T& ^ g( B7 y
return (maxsize);
) @( \8 S3 j/ ~, q' T0 }
}
. u( f/ m8 ^. P' J0 A8 }6 q1 D% I3 b3 j
int dram_init(void)
+ T$ g% T) r6 }; d. A
{
t, F: R! e5 V* x- B( f3 \
/* dram_init must store complete ramsize in gd->ram_size */
* z. a0 z7 p" L8 ~+ R2 c* V
gd->ram_size = get_ram_size(
1 h" [1 a& m2 |7 G4 U2 D
(void *)CONFIG_SYS_SDRAM_BASE,
" x! O @, s, z2 |# [$ c6 I
CONFIG_MAX_RAM_BANK_SIZE);
* C* Q, V |4 D2 ?$ T5 |3 z
return 0;
5 N* f8 h, d1 B5 p. g
}
) i4 B! m1 _ E
2 \$ p$ @% f' u; q3 i' ]
: i( z! B' I/ X; W3 [$ b% G5 n
) O1 I) e9 ^% Q; z/ C1 h
0 f$ a2 E4 @# t4 K: m
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
. f6 E. p$ b) v) @4 r( h
5 `- R, [! \$ w
& ], C( [" I8 ], _* z; p* c
: X/ F6 a( I7 i" I$ Q
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4