嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
* n# e- s p" o+ J' f
核心板2:DDR2 256M Byte NAND FLASH 8G bit
. `+ l9 t) P- q% s0 V" `* F' q8 P
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
: I1 ^/ [! b% P
% x" e0 g5 H4 E7 C
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
" o+ |* |9 z( l( M
1 J$ T# V! l3 l
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
8 _; G- t$ m; N+ w
/*
; U/ R! l, n$ o. b( u
* Check memory range for valid RAM. A simple memory test determines
2 N+ N* `6 w4 d4 d
* the actually available RAM size between addresses `base' and
6 h' U' K9 u# J7 J6 K! o- d
* `base + maxsize'.
" d5 s" I9 I5 K; n! c8 S
*/
, a, G& J4 G& ]' P9 ~
long get_ram_size(long *base, long maxsize)
+ j" P0 v9 L! O% r$ ^; w* o& @& I* S
{
) a. A: F7 `9 v }
volatile long *addr;
% L$ A! y/ E8 b$ w' _
long save[32];
2 A& {1 U) |4 O2 W2 {
long cnt;
! d' C% d+ s7 n% ?3 \
long val;
9 k( U6 a4 Y5 Z: _1 n3 N3 M
long size;
1 x$ ^, a, o2 ]1 ^, } }
int i = 0;
, b/ e% p5 J$ T+ R
& s9 Q% Y8 b" L
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
2 ^+ P$ o7 Y: t( _% ?
addr = base + cnt; /* pointer arith! */
' K! J5 ?9 F7 D1 S* S
sync ();
: R4 G! ` T4 J2 J- T
save[i++] = *addr;
9 P! X O6 n9 s _; w. m
sync ();
% J/ s+ B. }3 f6 z s% U C
*addr = ~cnt;
4 n# N7 X$ @5 S) b4 q
}
( q) M( Q |1 k3 m, u- ?
+ z s& g+ ]5 r/ t
addr = base;
# [0 j& m0 H2 z3 z/ O+ |
sync ();
- m" q( i1 E* |: T T
save
= *addr;
6 T6 U* C/ ^( S' O' K) c; g8 n9 m
sync ();
$ |6 X. I6 V+ \5 f! \2 g7 [
*addr = 0;
, d7 u/ N, g" R G K$ o8 J1 \2 U
0 ? k: W5 E( q) K% \3 V- k0 z5 U
sync ();
3 N6 i6 c. l% F* J7 m
if ((val = *addr) != 0) {
: Z2 g! ^' m. G5 L" f
/* Restore the original data before leaving the function.
* }" J W. a0 r1 T6 T& t4 y2 E
*/
3 X5 K) \8 f) X- z
sync ();
( [, _+ r4 U' E f
*addr = save
;
7 C; J2 s+ n7 _' v: Q/ A
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
1 x; U, ` `0 p W1 W' P
addr = base + cnt;
0 r5 P1 T6 ] D2 i/ E- A# q0 `, Q
sync ();
! ~6 N1 m: D0 V/ d' o
*addr = save[--i];
; ~# F3 G2 ]4 y! d+ I
}
' ~; ?- A* ~0 [" ~
return (0);
9 r+ |4 J0 {: |8 ^) a8 z
}
6 |5 [7 J/ W4 ]% Z" G
y3 B+ b, A6 S" i' S: a0 a+ Q0 W" O' P0 W
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& K% S. O/ b9 q$ `; q
addr = base + cnt; /* pointer arith! */
3 j2 R8 ?2 W) ^4 }2 H) Y
val = *addr;
# p1 `4 K* x9 X) G
*addr = save[--i];
; M6 J) |8 o% S' P I$ d+ K9 A
if (val != ~cnt) {
8 @, O, M. ^/ }( x5 n5 Q( X
size = cnt * sizeof (long);
3 A8 W: c4 H( _
/* Restore the original data before leaving the function.
. z) X9 b* q1 f# G2 B$ n, Q" y
*/
7 N' Z8 W# ^! g0 X+ ~
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 `3 D% c8 _9 x- C
addr = base + cnt;
; ^( U- S5 j; V- J5 A
*addr = save[--i];
; t# k3 H* v/ n6 g& W
}
4 `3 {8 Q9 Q$ ?8 W7 p1 W
return (size);
) i1 `0 ~. s( n7 u
}
1 f; c% q& Y7 i
}
5 ]3 w5 T; j: S( ]
0 q/ f+ T* @, W, U5 \- [
return (maxsize);
/ }7 q9 H( ^" d; \$ K- e
}
7 k6 r# ?( E6 s5 _
int dram_init(void)
^* O0 w7 ]/ x% }+ ^
{
' \4 d% I+ R+ f' d+ W, g# ?: d- [8 C
/* dram_init must store complete ramsize in gd->ram_size */
; n) e; L/ U1 F' H
gd->ram_size = get_ram_size(
$ N0 y$ p# u2 S5 L" a2 F
(void *)CONFIG_SYS_SDRAM_BASE,
4 h% }) P% b u" J
CONFIG_MAX_RAM_BANK_SIZE);
% {' V) N0 ^, K
return 0;
5 Q( X5 e7 m% s8 J
}
& {) l. F5 G; Z& c1 Y# ?
3 j* [5 F( M& Z; j D1 m' ~
9 A9 z% ~. _, y# d0 m8 h$ a3 I! A
% o7 C# p- v! I+ z" h0 N* E# L) K% ~
+ e' B* H, G2 Z3 @2 |8 V
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
+ |* J; U6 o: Y: Y: d
- ?, p P z$ }1 f# i5 z- W. o
- s4 k% C: `/ t6 S. h
4 P( ~: ~1 B% s' i0 \9 D+ f
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4