嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
# ]$ B+ D. q9 e3 W+ N" U
核心板2:DDR2 256M Byte NAND FLASH 8G bit
- x( A9 B/ D$ d
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- a p' e* ~$ C% V
6 n6 s/ r6 c( L- x; o0 d
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 v) A! J( L7 k! Q
, M; m: |) ]; R% ?! B
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
5 ~- r X; T9 g' g. F4 G
/*
( ?# i1 k. G% ?8 e/ V; G1 F& D
* Check memory range for valid RAM. A simple memory test determines
) G- b8 y l$ Y5 U/ b; J
* the actually available RAM size between addresses `base' and
' ?5 `, r3 |3 u
* `base + maxsize'.
0 O) p/ ?+ v3 S7 r; E0 f4 k$ I$ b
*/
/ Z- H4 _" Z6 x; C u* v
long get_ram_size(long *base, long maxsize)
5 q8 K6 {/ H. |4 {# {* {
{
# k" n$ A/ i4 k$ \0 I
volatile long *addr;
: b7 a+ z" i' b/ ]: l2 k R
long save[32];
: h& }) d' `# C+ B
long cnt;
: G+ `% ?; z4 _2 J! }$ |2 t- E% X: s
long val;
( E4 ^, P: Z x) f" }, x+ l
long size;
9 _- N/ R3 O' o/ P; _! E+ m6 T" V
int i = 0;
; p) y* L7 Q8 X: `( t
+ |2 {/ p; i$ I
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
) G' F* {1 U4 B* |7 P" t( t1 p3 U
addr = base + cnt; /* pointer arith! */
/ P% n) X( {- E' D9 i
sync ();
. Z! Z4 N! R& Q0 ?( s; ^; t
save[i++] = *addr;
o! y0 O2 {, \" Y! K* y4 b
sync ();
' u, P* o, \ F; [4 ~0 I% g
*addr = ~cnt;
, N& I1 ]5 O& W6 Z6 J
}
. l# d* j: e/ Y9 H2 q+ i
" c+ s! L2 L" P: q* U3 @
addr = base;
& e, m/ I y- ?
sync ();
6 j: W: i" M: g6 T% [
save
= *addr;
! a3 |: H& \/ q) p' C7 U D Z5 U
sync ();
$ L4 @; F* u+ ` t
*addr = 0;
% g. \3 _: c$ A+ i/ m- x0 n
9 l) F5 @5 J: n" _3 Z4 H
sync ();
& d% w, D$ B9 @7 k" I- {5 S0 e
if ((val = *addr) != 0) {
o! _+ ?' A1 R. d4 j; ?5 ^
/* Restore the original data before leaving the function.
9 ~1 u+ X7 R' }" l% o4 D! n+ ~
*/
- z+ G) P+ W5 A5 V& e
sync ();
, t: O9 l" M) a+ A) \0 l
*addr = save
;
$ K$ k: N: T2 B* Q' A+ R- B: T
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
# T# D7 e4 u8 B Z
addr = base + cnt;
$ ~" S$ ?' Y8 j( q" K2 f2 [+ e
sync ();
3 R7 P* U/ K3 P$ X
*addr = save[--i];
1 d5 N3 S6 X9 x0 G
}
# P+ ^$ H2 L) }7 v0 N4 H0 A" k& N! C8 t
return (0);
8 \. ~" [) h/ u/ E
}
/ u5 F0 l+ O3 x5 s( }7 x
. F8 h* B9 ^1 I. m* }
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" t4 a' Q1 i' z& c9 B- ]$ c
addr = base + cnt; /* pointer arith! */
1 c+ e$ N) _) V$ g M
val = *addr;
/ `) g: g+ J z! i$ p
*addr = save[--i];
- T; }4 T, f3 G$ {
if (val != ~cnt) {
" j; y9 M4 t' U a+ ]
size = cnt * sizeof (long);
2 }! Q8 { Q* t5 ] W. b* @
/* Restore the original data before leaving the function.
) }5 _ E# @9 e
*/
/ a; [3 k! V8 N L
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 d" Y4 ^# U# q$ R0 S5 Y
addr = base + cnt;
' h, ~0 @" V) Q* f+ W" z; `) n
*addr = save[--i];
6 ~# z! L; l' c, L5 y
}
7 @, P1 p' R# Z7 S" W$ @) @
return (size);
; r; o% b2 B% }/ i& z; ]
}
4 i1 P/ q! w" E3 v( x2 d+ n
}
4 `) i+ ^7 M- g+ M* S
, f: C: L4 | |5 Y9 }! B
return (maxsize);
$ _& D0 l# \ ]' M- |8 |
}
; J+ `3 z) Q' T( C
int dram_init(void)
! Q) P @) _$ u6 U+ N
{
) k# I6 v8 b* M2 g4 u
/* dram_init must store complete ramsize in gd->ram_size */
4 p; |. M- x) a
gd->ram_size = get_ram_size(
0 `5 p, v% y( z7 q0 @
(void *)CONFIG_SYS_SDRAM_BASE,
1 Y# n8 I2 @2 y) k3 {
CONFIG_MAX_RAM_BANK_SIZE);
5 X0 K4 w" I- s' t
return 0;
% r) a, N8 G& i# H8 d
}
I; r+ @, ^: k. k
7 n4 U; [4 S" P; j4 d9 w, i! K0 `* K
9 T- B% C3 _, d* h+ X b4 |
$ f& h0 V) J" ^1 u! E
* A5 G# `. L$ _
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
1 R0 x3 h( ~" ]* ^2 e& z
8 m8 j6 I' [- |
5 a p5 N1 k [7 v" ?5 ^
( b4 v$ K' \4 g
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4