嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
g8 d1 z0 w0 t9 m6 F$ y
核心板2:DDR2 256M Byte NAND FLASH 8G bit
; p. W" s' c3 v. a) z
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
+ V3 h9 U# i' D+ O% z
/ u6 o. Z' q& b3 t- | V
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
2 W' F: [4 q8 j0 M* X) k2 w
% z, {2 F% {6 S. t" B- ]! a+ h
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) D; C5 @: X j# H. {. p, @. Q
/*
: ]9 q% x- D _7 [2 _
* Check memory range for valid RAM. A simple memory test determines
5 a' ^4 E- @% i. @
* the actually available RAM size between addresses `base' and
% ?, j9 p+ i" ?, f5 P
* `base + maxsize'.
1 Y3 _# J& G5 O7 I0 ~
*/
, t: ?' Y; I4 {6 n+ R
long get_ram_size(long *base, long maxsize)
, R& ]! S/ r! W' H" g. A
{
' t, Q% T6 a" U* R% K9 `: V7 j
volatile long *addr;
! c0 t: D) W# a0 K( ?' {
long save[32];
9 e$ }) @5 o" Z
long cnt;
% x7 O7 _6 j1 W
long val;
' D; l/ Y, l# f* F9 ]/ a1 p
long size;
0 C9 [ _7 l; T z) O
int i = 0;
' J! ]+ v @% W* j1 E6 _7 I
6 B% R0 ]+ j7 n) N7 Y
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
p9 m7 j" r' Z |
addr = base + cnt; /* pointer arith! */
2 p' o' l3 N9 m
sync ();
" u( B' ]5 ^1 y3 z4 Z8 P M
save[i++] = *addr;
# B# n9 J2 U: k8 l ~" o% E
sync ();
7 h6 E0 i+ O6 B/ H; ]! g
*addr = ~cnt;
% J }8 t& Z7 @4 I8 o: P
}
9 E R3 l1 t# _$ A! @- V
- J/ V5 K) T& J o9 q0 y% N
addr = base;
* ^9 q$ T, ]1 v; S4 F
sync ();
/ k6 q4 \6 D) V$ Q) k" ^
save
= *addr;
. \$ g6 e: v* V$ Z$ C# |
sync ();
0 D* @& ^8 E3 U9 j, _
*addr = 0;
9 P0 ]7 w5 l/ I6 q' K
, A( c' b0 M3 s3 d4 p
sync ();
$ M: U# G/ R' h, M' G
if ((val = *addr) != 0) {
9 Y1 i4 l1 C% E3 j: n7 V
/* Restore the original data before leaving the function.
; h6 ^) q! A! ?* L" c$ |
*/
: ~4 [% G; `- f5 T4 U0 G+ z
sync ();
* D$ U6 t, q6 f& |
*addr = save
;
. i8 X$ z$ w1 ^2 \: ]/ m
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
: u0 b- q; S, P0 Q
addr = base + cnt;
% j3 G2 v. i' q8 {8 u/ ]% v9 ^
sync ();
0 {0 H0 c# ]) \. g( ?2 u
*addr = save[--i];
4 P G2 s( W" L$ r! |- ?6 L9 n
}
- _. A7 i0 i( O- v/ E
return (0);
0 q( S: h+ e6 s8 G) V* y- x* m. ?
}
* n% G) p; O$ g7 m4 K
; Z5 k% w* `! z$ |
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ K) s% f7 g# f, F P: x1 J
addr = base + cnt; /* pointer arith! */
: s, T9 N( V6 N; j7 i+ |$ j9 ]
val = *addr;
3 |* C7 |, x* Z/ l
*addr = save[--i];
. o3 Y' L$ p9 H9 ~
if (val != ~cnt) {
/ j" n5 B; P2 U D; W2 w6 y& G
size = cnt * sizeof (long);
! \1 L% [. P" q. b$ y
/* Restore the original data before leaving the function.
' S) v" K \3 u4 ]8 n, r
*/
- y! N8 _1 Z4 m5 n
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 ~+ G# P) q$ f8 W% E6 L
addr = base + cnt;
* V# V6 J/ b0 v1 h
*addr = save[--i];
# k, a* Q5 _1 l! S4 R$ ^& J" \
}
0 l4 M7 d! V+ H& @/ D z! w: y
return (size);
9 M) ?! m8 P; M5 k, e0 z
}
" f: @2 h k% a2 |
}
) [5 o) S, O' |; P; W5 f) p
k7 o% w B3 Y% }# U: Y
return (maxsize);
" A" ^/ g- G1 X! B# s+ Z8 H
}
& U) U( j) S3 J( M8 z2 \8 h
int dram_init(void)
4 Z4 s7 V' c; A7 t1 d; y5 _
{
, Q- i% {& m- E- M) G, |
/* dram_init must store complete ramsize in gd->ram_size */
; x h5 F1 n8 `2 \
gd->ram_size = get_ram_size(
2 L+ u4 t8 K% Z. o
(void *)CONFIG_SYS_SDRAM_BASE,
2 @; G1 E- I9 z) x9 k4 u
CONFIG_MAX_RAM_BANK_SIZE);
( ^5 ?9 i- `2 j9 q: j5 J
return 0;
1 t) [8 F4 l, }
}
$ n9 ]! Y! c6 o! h
( P1 F$ ~, c7 \' s7 Q4 ~8 Y, `' g
; e" M- C) B7 V; [# V
8 I& W8 v6 |, D/ X2 X! P4 k( z# f
3 S) X! d/ H/ [# ^
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
( O9 ~! v: f- k7 B( @
4 y: o# W/ \& i8 {$ v7 h
" e0 H, H1 P$ o; G3 ^# h+ T
: p3 i2 |1 {) R* m/ L/ u
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4