嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
" O, }6 ^% ?0 |5 G4 R
核心板2:DDR2 256M Byte NAND FLASH 8G bit
6 h8 w* u4 I0 A5 \! ~
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
( ~3 ?+ p: T2 E" h8 u. q
, t; F2 w$ }5 m2 i0 I3 | D
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
, c% |* U4 ~7 R' n+ V
$ V7 k- g! T/ B/ @
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
% I9 }8 I9 _: a6 y+ x6 G7 ~0 I
/*
0 h* P* H/ v5 z3 m( E2 S
* Check memory range for valid RAM. A simple memory test determines
7 ^4 u' z, a7 [7 r- d$ G" R
* the actually available RAM size between addresses `base' and
1 j, `- N J5 y) S' w% g
* `base + maxsize'.
! ~0 E6 @- k; B6 g) i8 n
*/
6 ]- \2 o6 D& z4 I
long get_ram_size(long *base, long maxsize)
* [: X4 h# a. b3 ^8 R& u8 [: B- e
{
! t6 t3 s# x' a4 h4 K6 E) y
volatile long *addr;
) K( Z0 A2 R. D3 q1 ~' X
long save[32];
% S+ V* E4 \5 e2 {$ J3 l. @, r
long cnt;
/ E* O' k; ^8 D' @+ k
long val;
$ P3 l5 z+ R3 M& K1 d
long size;
3 {- A% c. f2 u' f& s
int i = 0;
* f1 [( A: w Y) U
- f1 t% B2 R0 X& E, n
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
0 ]. _7 [2 P# w( @2 T( S5 t
addr = base + cnt; /* pointer arith! */
+ i9 S, }4 T: `1 d6 Q U
sync ();
+ e% G( ?/ X3 n6 _( R2 h
save[i++] = *addr;
! H* ]# V: g A
sync ();
^1 @. f6 l- \' `, d9 `" C
*addr = ~cnt;
$ ^' R. B2 f6 a' Y& _! v
}
* a8 i- n( V; G4 b( \# p4 z0 I0 v
4 R1 ` y5 D+ d9 n6 t. M/ o* I6 {9 s
addr = base;
- m5 t0 I8 [, C
sync ();
3 U$ a8 u2 q. h# M/ T0 M
save
= *addr;
* ?. Q% n) {/ \& d- `( v
sync ();
7 |+ X& B5 F$ l: W" p1 e
*addr = 0;
0 X: E$ b' O4 W
1 T q$ Q w' \5 `4 r* E& E+ ^
sync ();
5 r; G7 w9 i/ E& n( M, X) K
if ((val = *addr) != 0) {
: X0 Y( \2 O( j7 `# n" Q) ~! `
/* Restore the original data before leaving the function.
9 U, s1 b$ D& Z4 i7 R
*/
, O/ f! b, W! }" M. `
sync ();
" y' ^' E( {! d/ P
*addr = save
;
$ l+ H% B+ A$ i+ }
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
~ Y9 F$ |0 Q
addr = base + cnt;
7 ~+ S% A& D' H4 U) c' \' t' P
sync ();
0 ^% I( L# J) W9 ^- r
*addr = save[--i];
# }, U8 U9 k/ y
}
m' R& g) n1 S; l+ T8 d
return (0);
* C" T/ U" q" `2 Y0 L8 _* T
}
) }2 E1 b; Z( U2 p/ c
+ d. P4 @4 Z3 e" \7 e0 O4 x9 y! D
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, Y7 J7 U/ C7 m9 i' P0 i" ?# ?
addr = base + cnt; /* pointer arith! */
9 A4 @* Y. z, n H0 e
val = *addr;
. C# Y c# E5 X2 r5 Y# ]+ E6 f, r
*addr = save[--i];
: u' h+ v) Q1 V6 Q. g4 k& a
if (val != ~cnt) {
2 z: I& C: T/ @0 T
size = cnt * sizeof (long);
& P3 H, X1 |3 [, K, d @1 D% p- K
/* Restore the original data before leaving the function.
4 m+ v% D% W9 f& L
*/
% s" M2 G# ~1 y
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 a: s6 m$ U# o6 z' z
addr = base + cnt;
' K. ]3 T( w# c5 V
*addr = save[--i];
5 L2 s* r7 {7 j4 _, T. v+ K% \) \
}
i- a( h+ ?" F6 v9 I
return (size);
9 U4 h$ R5 U' H& a
}
9 Y- m% {3 | ^( W4 Q: s( h
}
9 A; w2 n+ w1 M8 Y/ |2 V
& t3 |0 _- w: S" P+ _' R- k( Z
return (maxsize);
3 e" N O w& ~/ \9 {
}
8 `( a4 F5 v6 j/ t6 V" w3 E7 `: P
int dram_init(void)
8 P1 v' S1 }3 |5 k7 r3 {+ j) b
{
5 k- M0 O! U: ?* {1 ]
/* dram_init must store complete ramsize in gd->ram_size */
9 q5 D6 c7 W! {% T/ z! F9 t
gd->ram_size = get_ram_size(
5 C: x: H) R# S
(void *)CONFIG_SYS_SDRAM_BASE,
2 Z; k" [5 V, w4 G6 \, C
CONFIG_MAX_RAM_BANK_SIZE);
3 M" c! Z( {* `# t4 L# V
return 0;
+ ~7 j' F2 K! x& }& O
}
% Z- h* ~+ V* Z! ?0 h
9 G+ A# P2 u a$ |3 R
! i R `8 f- ?& j% {
Z6 ]! w! W- T3 v1 n
) G/ L! b) k9 _4 O$ t( P, m
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
7 I! ?0 S8 P6 \
* I+ J+ N$ V" k
) O4 }2 T) w: N. V( {$ a8 n
* K, K" ~7 E2 d `4 @1 n ]( Z8 ~
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4