嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
% e* S+ w U" I/ _; R% f
核心板2:DDR2 256M Byte NAND FLASH 8G bit
) ^7 p7 p8 s* g+ x
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
: J$ C p4 j3 Q" T9 v& \
( Z- j, V0 p1 x
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
0 v) j6 M3 ]8 R0 m
6 B+ a2 P. e* X0 h# t% w
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
$ ~$ K( M s) ?; D( k
/*
, t7 g8 U3 s9 c$ ]" I0 U0 p3 B
* Check memory range for valid RAM. A simple memory test determines
" T$ a2 J# @( P i& q3 _
* the actually available RAM size between addresses `base' and
" }6 `! c/ B1 [8 s1 T' c- m2 g
* `base + maxsize'.
1 {+ `( k2 y6 Z1 E3 d
*/
$ v4 A5 O% O" Y2 W! a
long get_ram_size(long *base, long maxsize)
: l- l8 e% |) x+ j2 B8 j
{
# R8 B" w3 q% {9 m' y
volatile long *addr;
0 D. c. S- i& c3 A2 k3 Z
long save[32];
- ]; n- J9 e: [6 i" c4 Y& a' O
long cnt;
2 v8 B! y% U. E6 g* H |
long val;
6 y5 X b, d4 |
long size;
, B h5 ? O( I
int i = 0;
4 F8 e/ T2 \6 f+ C/ G
* U) X* ?/ K' H1 p0 x _8 @/ s( G
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 g2 j4 F+ o5 r
addr = base + cnt; /* pointer arith! */
8 f4 I% |( H, {+ c& R
sync ();
+ G' d+ d' M2 Y
save[i++] = *addr;
$ n2 F9 z6 ]8 B$ \$ L5 |
sync ();
5 j. G; ~ Y% ?$ Y1 Q3 C
*addr = ~cnt;
( A5 N0 m& E$ G6 s2 D0 z/ C8 u* L
}
7 z1 ]- ^# k4 ?3 y
0 p; s4 N6 A; b. f7 f( Z
addr = base;
) A, V$ }" g1 f" _. `
sync ();
) s: t! ?7 O; e* `4 C4 B+ E
save
= *addr;
; _( h5 u, T( M0 k
sync ();
" [' b) o, h6 x) `# {8 F
*addr = 0;
4 v6 W' |2 G2 m& A0 V0 w
$ \, a- N; o: O* X
sync ();
0 g0 d& C; h" s! f" w
if ((val = *addr) != 0) {
* e6 y2 u N0 |% C
/* Restore the original data before leaving the function.
- }" ^9 m J5 t, H9 p" W! e4 h
*/
! a5 ?, E8 p: f
sync ();
+ o/ ]( B7 |* I
*addr = save
;
0 [! g, E9 p, z5 N1 j9 E3 n
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
c6 J' _9 n# y; o% q
addr = base + cnt;
+ x6 E- R) }3 T9 E) ^9 ?
sync ();
* L$ K. I$ m! }3 u* i
*addr = save[--i];
1 X# w8 u/ y& M: p3 y
}
$ V9 B m: H& R! b/ m+ C/ d( c8 E+ |
return (0);
) [7 T( z9 M& K e8 q. H
}
3 w+ d) t6 G \1 z& E
+ m* I$ }' }$ n1 x+ j
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
4 Y" D7 g2 J2 [' q9 V R) M
addr = base + cnt; /* pointer arith! */
/ `, D0 j2 p1 X N7 f7 L& Z
val = *addr;
) K$ _* j( l5 A% h$ N& E8 U
*addr = save[--i];
0 C5 ] T ]/ i* r
if (val != ~cnt) {
, k$ t9 d @- M6 ` G( v( C
size = cnt * sizeof (long);
* u: F0 S& |. L- p9 k
/* Restore the original data before leaving the function.
! F1 D. C7 @& S; d% R
*/
$ y% Q" d0 t& e! Z K
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
?2 ], R' p& e" v
addr = base + cnt;
0 L j9 h5 d+ s' f2 s* k4 C _
*addr = save[--i];
' v) N1 l! p+ K6 E% K
}
% U% r N2 z) _' n9 `; y9 N) U. n
return (size);
$ n& b, h" s) x) p, Z- J3 B* ]& c, X
}
; a! p+ z' E" o! i
}
' p& b0 ~5 I b9 Z
5 U$ ]6 y2 B- w5 r2 K, Q/ L
return (maxsize);
, D5 S5 A8 G5 X% P, {1 x
}
3 l/ h; h* f8 g5 l, D
int dram_init(void)
/ U7 l& w8 o6 [
{
7 A# P5 v/ P; I3 K7 Z. L) a' B
/* dram_init must store complete ramsize in gd->ram_size */
9 g4 N# B ~4 n l" p+ y0 h$ G2 @
gd->ram_size = get_ram_size(
+ H9 k% p) |+ i
(void *)CONFIG_SYS_SDRAM_BASE,
- G- ^; N \$ v7 D5 x
CONFIG_MAX_RAM_BANK_SIZE);
: \1 g, E) ^- N/ @
return 0;
+ E1 H# |0 b- _' x9 {: c& Z
}
+ ]+ Q l5 {$ Z) s/ X
8 U( ]6 N+ U1 N
- \0 U6 p% B8 n. p) @
& f7 _/ c$ {3 F: f
3 O: L6 j- C- o0 Y) `+ i9 n' d0 A
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
6 |& d8 K. z6 a. X Y9 }3 [4 `, N+ ^
# n4 z& l: t& _ `7 A9 |& T$ C
. n* z9 Z$ s. P: @6 E
4 A- [9 f% p( H) C: f4 }% G$ h
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4