嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
8 r, ~( [7 Y3 h. x
核心板2:DDR2 256M Byte NAND FLASH 8G bit
1 f4 L* [4 c; H# B
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
1 R, p; F& {! H* z5 u, t' w
: O/ I! A3 o+ r k( Q+ ^
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
4 K- V) G2 j8 e. ?/ O; m
. D0 F1 X4 D8 L' s
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
/ D) q6 g4 \3 T. h+ q+ X
/*
: I# A/ }* s! f/ [: U0 w, E
* Check memory range for valid RAM. A simple memory test determines
* V4 D3 Z$ `, r& M" V4 j
* the actually available RAM size between addresses `base' and
A" [5 w+ h2 J$ ?5 o) D" [6 q- ^
* `base + maxsize'.
$ K. h; l8 z/ d
*/
4 x" R- `( ~/ G- g1 P
long get_ram_size(long *base, long maxsize)
( Q6 Y) A3 j- K, m/ k" T7 Y. M" F
{
) u8 |8 x9 [ h3 h: z
volatile long *addr;
4 V) i. Z+ R% n2 F. f
long save[32];
) k/ r8 B9 v% b! q' g) _
long cnt;
! ~8 K7 b1 T, L/ q$ l
long val;
4 n; Z, ]1 ] C% B% o
long size;
( h0 @/ t% q0 [6 L# Q' ?
int i = 0;
: {, |$ Y0 @9 j @1 k6 p( _
8 n1 D: S# f" Q6 z
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
4 M# q# g4 }, U+ P' ^1 D
addr = base + cnt; /* pointer arith! */
I% T( A5 {. H5 S
sync ();
- }7 ?) `/ m! u5 o0 _
save[i++] = *addr;
$ w1 ^6 H; {! m
sync ();
& {- }% ~) `6 |: Y5 ]
*addr = ~cnt;
" J3 ]: e2 t5 }7 P) B, f+ R( G, ?
}
' V$ g7 y! a" M
) R7 r( x) ^5 m" y
addr = base;
1 E4 l2 j" T3 g8 x: }. C
sync ();
" K, P6 C% ]2 t! B5 v
save
= *addr;
! X6 y2 w8 ^$ T" F
sync ();
: P9 e w3 l, z' C* ~2 p
*addr = 0;
i( h1 M6 j% V% _
5 u! p' d; ]$ l/ W) K& x
sync ();
+ F. f$ ]5 W1 \. P& g4 W
if ((val = *addr) != 0) {
) v- p- n) g$ q p9 h6 j2 _
/* Restore the original data before leaving the function.
- p" b' U1 o6 t6 B
*/
. w8 ]3 [/ [3 k' G
sync ();
2 q& E# G N" A2 B) }. Z
*addr = save
;
# x: m/ S" E# G4 V4 U
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
" C1 i Y7 ]' C1 H3 G
addr = base + cnt;
( E) G0 l$ k& U' @: h
sync ();
1 m. [: x+ h. j1 ~9 \7 x
*addr = save[--i];
% T" L( @0 S7 N' {
}
0 j8 e4 J8 x2 X7 i+ f+ X6 i
return (0);
) [: \$ j: ^* J0 m6 y( o4 ?
}
5 \/ S/ X1 E7 [& \$ |- q) |
) j2 F5 ?2 A7 t! e. r- a3 v
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
|2 C* O Q5 ^! g$ u
addr = base + cnt; /* pointer arith! */
9 |2 ?8 G# L1 C0 ^' u G2 X b
val = *addr;
) d1 L* p' A1 D0 s2 n3 w8 o# C
*addr = save[--i];
]# A( x# c2 ]( k* d4 s$ `: U
if (val != ~cnt) {
. I0 |& @# |7 R F% k& ?! C' R
size = cnt * sizeof (long);
) ^! D$ P6 W! E4 X6 v
/* Restore the original data before leaving the function.
/ H4 z7 f% ?" t2 m/ p
*/
, v7 [ G; y' X* S+ }! }5 u
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 q0 j( @' d s% J3 d% Q
addr = base + cnt;
0 [% z$ v* s; a+ Z" t
*addr = save[--i];
o) A: p' u4 k1 i" L0 E% i$ @
}
p8 c! o* q$ R8 {/ a
return (size);
) i8 J4 G' n3 v, b/ Q5 s
}
& p0 R! n; \) g# v9 |, q: @, g
}
" S! ^+ E% s& x/ E3 X. v0 q& A4 A
) l+ K) S0 ^2 u$ s; r" S$ P' Q; Q
return (maxsize);
: o' b% |1 o/ B+ R9 k! B
}
7 U; d% q* a B7 u/ q6 \; h
int dram_init(void)
* V6 P3 O6 m. k5 g. T5 V3 J
{
% \8 [& }, l! W# X
/* dram_init must store complete ramsize in gd->ram_size */
$ c, u& u) i# J3 o; W& s- h
gd->ram_size = get_ram_size(
7 g* s1 v ?" Z' U4 T+ o0 Y
(void *)CONFIG_SYS_SDRAM_BASE,
; h$ v. j {$ Z6 l% ?/ @2 v1 J
CONFIG_MAX_RAM_BANK_SIZE);
4 M. i+ e1 y. L V
return 0;
/ }! J: |3 d' \6 C. k
}
1 r. g4 a7 Q! r& }, E0 q
9 v9 ?6 u% w- ^/ I, }
1 Z3 V8 d( S2 s: l: `
* Q2 l2 ^* U+ d" v+ o0 L3 |
& n; W9 O# j7 _
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
" O ^' c6 _$ k3 T
& J! e" e# H$ n0 f, a% z5 u
# {* `" L8 z" d# l: ~5 i( G0 j8 c
d5 V. v3 W/ k
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4