嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
! n: H% ~# T! e9 R
核心板2:DDR2 256M Byte NAND FLASH 8G bit
4 k! Z6 D" `$ l6 [& ?
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
! a$ |3 Q: U' S7 p
+ N* z* i' u$ q& U
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
4 @) M% i5 y& S: P5 a7 n4 D
' w% |1 W* o* T! z- O
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) [/ \+ I3 s- d" o3 a* O
/*
# X, R# r2 J* y0 P) ^. x
* Check memory range for valid RAM. A simple memory test determines
' L) J; i" u# C0 q$ g9 c4 a
* the actually available RAM size between addresses `base' and
: l8 j6 ~% f- D
* `base + maxsize'.
) D5 X, H. T+ q0 u5 B; g
*/
" \9 n) G4 i# W& v
long get_ram_size(long *base, long maxsize)
9 f* n0 a7 R6 N4 G
{
- G1 k- R% U7 R- r2 [3 ?
volatile long *addr;
: ?( l, X/ x; R6 d) K1 Q. I9 G ^
long save[32];
0 {6 |. ~ y0 |. j( E$ m
long cnt;
" X! f. \7 u; S% |% @
long val;
, X% r; ?& b4 n' x% y2 z0 v% R
long size;
" Z2 M2 Y& l& C8 `' F/ `1 c
int i = 0;
" K0 p: e$ e- U- l
3 `3 O% B* X# V9 v& A" S
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 G( P1 Y) _0 i; \2 M8 A4 b& @! \
addr = base + cnt; /* pointer arith! */
2 e& A7 f" X9 F4 H5 f H
sync ();
1 v* ?2 K( ?) d# r6 z
save[i++] = *addr;
2 Y+ J1 F4 g$ {' y/ C) T7 Z
sync ();
3 ?6 R; O% D9 j' Q: ]; i2 |
*addr = ~cnt;
. K" Q% z( {1 S( G Y2 Z
}
7 G& ?' b6 x$ |* p# D3 H
5 s8 D' U$ C0 g& f
addr = base;
# n4 b6 }" V; m' O" a- s2 J
sync ();
* @% t: @2 p" W. y/ N3 [' ?
save
= *addr;
& F) P5 R# \, d3 D, P9 N: |& G) N
sync ();
# Q1 a& y5 @) Q5 u c4 ~! O$ l& F
*addr = 0;
! U: X8 k5 Q: X. y& H
8 S) L4 b1 Z P7 V( O! t s
sync ();
" s Q# B9 f* {; @ K
if ((val = *addr) != 0) {
/ C$ T& q$ L7 T! x
/* Restore the original data before leaving the function.
' P- R) \) C4 z% N7 G6 m
*/
8 v9 f0 f! \3 u) ?! P" j. e: ? ]
sync ();
( F: Z3 ?$ o+ z! |; Y
*addr = save
;
( l0 H" d1 U {# r9 s4 O
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
! \2 c: \6 n m! J5 V3 x
addr = base + cnt;
" [/ B' @9 y; Y! v8 b! a
sync ();
8 |% i: t+ q6 U* w8 c
*addr = save[--i];
2 f, C9 _- O' n
}
/ i7 q6 B( Y; C; y' \
return (0);
$ l: w% H4 `" M9 [% z4 W9 A2 i' Z
}
* H2 r. I/ i# {5 b2 Y8 j
9 `7 ~! x' u% f* h; X
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 C: W4 B% _# n3 H8 q: W, T$ X" z+ c; J
addr = base + cnt; /* pointer arith! */
; h, a8 y6 Z8 U9 K; Z6 a
val = *addr;
! ~( _) X) l6 x, i8 w
*addr = save[--i];
! _& v# i/ h+ ]3 Q& f: u
if (val != ~cnt) {
/ A7 u5 n3 G" e9 b0 _# H
size = cnt * sizeof (long);
e, j! `: G; i
/* Restore the original data before leaving the function.
6 D1 u9 _! e8 `7 r" V$ k [
*/
P2 f7 Y8 x0 H5 T O5 r, g* r* r
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) C/ D x6 j: e" T. M$ w8 l M
addr = base + cnt;
( ~0 w. c6 c2 g: Z
*addr = save[--i];
. h+ x- H; s- T. h/ P, \* U
}
+ d" v* W& S: T$ ^
return (size);
" K) l8 X) g$ i0 s
}
' u7 V9 k" ]9 A8 @* @: H- p& d7 t
}
$ b& R" q8 s) M8 n+ G
. M2 F; e8 n0 q0 p, ^) P! A8 z
return (maxsize);
; V; b/ x3 n3 F* `. {6 d
}
- ^% Y3 S3 H) I# z5 t+ R
int dram_init(void)
0 J4 P9 Q+ p6 _5 U3 ?5 [
{
: R+ L0 N, U6 m: D
/* dram_init must store complete ramsize in gd->ram_size */
, M; }! @7 p9 W6 N( H" n
gd->ram_size = get_ram_size(
( \% U6 `+ z- P: a4 ~4 U" o
(void *)CONFIG_SYS_SDRAM_BASE,
. J; {0 ~8 N6 M8 u. `3 H
CONFIG_MAX_RAM_BANK_SIZE);
[* c1 \! V/ h, V3 |4 Y
return 0;
9 b( y" X1 ]8 m& V" g: n
}
: I5 G% Z a2 ^9 d; k& u, P
) K9 |# }+ e/ ~$ l$ F- m
: B8 |. V( a) E S
+ C. p% H, \$ r0 E; b/ _) Q! `
% p/ ?1 K4 ~8 w& ^3 x" {% X7 }' q1 d
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
, N' X+ W2 D5 P8 X
" O. `% L& D& R1 l( \+ I& @
; u( j$ h) k5 S* I' G4 s/ a( n# W1 C
6 \; u: H7 @6 |) c4 g9 f# Z6 _
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4