嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
; o7 r' J$ E3 Q+ j
核心板2:DDR2 256M Byte NAND FLASH 8G bit
# i# F- h7 R7 g! `6 c2 W
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
8 P0 n" z, O |3 @/ Q; [
) v* n1 p* L6 z* @. O7 k
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
- T9 {. H3 e; Q4 F+ G- y* a
2 I' J; y4 [3 D! Y0 U5 h; s
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) y0 l$ V! w* F# |" H
/*
$ z# K0 c* s }' p
* Check memory range for valid RAM. A simple memory test determines
$ v1 @) ?9 p. j8 ~5 Z8 |8 G2 o& G# g
* the actually available RAM size between addresses `base' and
, s; ]7 q, Z0 V3 {, Y4 v
* `base + maxsize'.
' T; c) F& |6 y# f; G3 ~+ v/ q
*/
8 `% T$ K. ^( O, c- W& ?
long get_ram_size(long *base, long maxsize)
1 E+ P( b# r+ x/ b
{
2 }6 L, B7 f# U. l$ R# B
volatile long *addr;
, l. X1 N- s* v1 n7 [/ t/ h# \
long save[32];
" h; d3 |- q9 D+ i: _
long cnt;
6 M* j; L- p0 {* _
long val;
- g. I3 k8 u% j- c" S& @
long size;
+ a- R+ a2 ~ }# `* H
int i = 0;
6 |2 ~' q) A6 _+ ^8 G
! k6 o4 x+ T y( |& s l, A' |" l
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
' I$ n7 g% c; n5 L; b
addr = base + cnt; /* pointer arith! */
' }* ^: n5 A+ y' H
sync ();
# h% ^% [3 H$ c9 f: r) _
save[i++] = *addr;
- [5 q a8 |5 x+ d' K
sync ();
& l( o8 O6 O) Q' ?& w7 |
*addr = ~cnt;
3 V. Z2 L5 }3 y* u
}
) N0 B4 ^! c/ C K* S2 |
+ l( i( V* R. W5 L
addr = base;
- l4 a# o1 G7 k; j W! M
sync ();
' q8 Z- N5 G) Q0 Y+ s1 |
save
= *addr;
$ h9 r. o2 a0 T- o
sync ();
* K0 n' i3 K* Q5 M g! y
*addr = 0;
3 j. M' t, m; K2 }) t/ x7 a
- }+ ^4 m7 K: Y# A: ~
sync ();
% S4 ^. s; {, Y8 |) i
if ((val = *addr) != 0) {
" @3 t. L* v8 P. U, {% R
/* Restore the original data before leaving the function.
3 n$ X7 H% L* y- y8 B6 g
*/
* c% c! K: g, _/ I; D
sync ();
3 f7 [. Z, U9 D6 d e& r& [8 O: P
*addr = save
;
$ q' W. i! t, A6 T
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
0 j3 ]/ d9 i$ L" N6 n6 D8 S' {
addr = base + cnt;
( U8 O5 \1 S |9 k7 i2 @
sync ();
4 X/ k$ `) q/ E
*addr = save[--i];
3 {5 O+ o* d+ R Z
}
2 T0 y& C' q* P" L# ~& |7 d
return (0);
* W. ~2 Q s0 v% x/ h, z
}
+ g w3 d/ W/ ?! k! a! Z+ R1 A5 m
8 v; Y: K! X1 a9 O0 l
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' b; ?2 b" i; `+ X9 V
addr = base + cnt; /* pointer arith! */
X. C3 {& R# W
val = *addr;
& _# g. h) k d6 H. x
*addr = save[--i];
2 S/ m# ^# \; [+ @
if (val != ~cnt) {
, }, T% N% l, r* _
size = cnt * sizeof (long);
5 A/ p! I9 e% D
/* Restore the original data before leaving the function.
2 ]) {0 d. ^9 h* X4 \7 [
*/
3 `# ~% b0 n2 F* }
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( c7 `. X4 D: {& ~* V8 d. M
addr = base + cnt;
5 a. ?) Z, Q. R1 U
*addr = save[--i];
$ s5 ?' b }7 Y# y! v- ^4 ?# w
}
% L' w6 M+ K1 G( b6 P+ }8 C/ q
return (size);
: R9 `" p1 A( `( v5 s
}
( r2 o3 s3 c; v
}
8 c8 j0 L; m5 N: i% s+ u
- O: X9 H$ N7 B1 O4 L: {
return (maxsize);
% h, s1 G" w$ h7 C0 t! C% U
}
5 L9 t3 P8 a1 V/ l& x3 j
int dram_init(void)
7 @( E1 q, k+ r/ C: t
{
7 N4 \# E) Z4 N2 Z
/* dram_init must store complete ramsize in gd->ram_size */
7 e1 `& g; c R8 O2 p) a# }
gd->ram_size = get_ram_size(
b" Z/ N! U; ]: D* V
(void *)CONFIG_SYS_SDRAM_BASE,
0 ?0 O0 m: R5 {8 \& v
CONFIG_MAX_RAM_BANK_SIZE);
! R7 C) N$ j- h, x, F" M; r& F
return 0;
4 T1 x' k- U; F4 h/ z2 W
}
9 {8 z' U2 A" l" Y$ M5 c
$ N. O5 c/ b# d' F. d8 d3 w0 a
3 L4 p% S5 V5 n/ O# b5 t) C
( F4 d7 y9 u1 j. B# ^+ ~% l$ ]8 t' l
& s! o+ t0 o; G
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
! Y m4 ^* I# W3 i. u) M
; E! X" ~( `( t/ X& x9 a
/ {9 K7 J! d( y
2 j* t7 T: X( p8 G$ i2 h+ K6 W
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4