嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
7 |3 Y2 g$ T- ~+ P
核心板2:DDR2 256M Byte NAND FLASH 8G bit
i" b. M1 f& A& F3 `/ A
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
( H4 y$ q: l4 x. |
% T6 D& o) d3 p! b: J- t1 l$ L5 v1 |( j
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
& J# a1 F, |3 {& u5 c8 L2 L/ h) B
, H! W$ `' Y# ~( @
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
# r2 P3 t7 V/ @% l" M" R- Y
/*
- B6 T# n' ?; o" z
* Check memory range for valid RAM. A simple memory test determines
1 l3 j8 V" Y( U2 i; f2 M; R" }
* the actually available RAM size between addresses `base' and
5 W9 }) y4 n: C3 y1 z* x
* `base + maxsize'.
2 S! H% q0 s* d1 `' D
*/
* Q! q+ A9 n' { l4 O$ u
long get_ram_size(long *base, long maxsize)
6 N0 _2 M$ O6 S4 B) g+ |# r
{
9 g5 U( O8 Z8 P% s& c
volatile long *addr;
r1 v/ Z2 \" r
long save[32];
; @' z2 x" L2 L0 Q, F; M) ^
long cnt;
) v: m8 w: G) G! J# ~" `6 X
long val;
4 G1 Y- Z0 { F- x B! U* \
long size;
4 l. O1 F! _! N# N4 T8 a: W
int i = 0;
" n+ m! P2 i u# t" S
) Y+ W2 I, k' G7 L) \) u2 C) R7 w
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
+ D) {* J2 s8 @% ~# a7 r: g
addr = base + cnt; /* pointer arith! */
! @0 I& Z9 l2 T! j g* f
sync ();
% a7 O l$ N% z: ^2 Y
save[i++] = *addr;
/ s) k4 A y1 m% M9 [* W/ N E* m
sync ();
& D! q: o+ f, z' U0 _
*addr = ~cnt;
4 o0 J9 ?- q2 p$ [' N. x
}
' _- ?7 o* Q. {. i1 }8 J
/ F9 \. T0 |5 I2 Z' U, _+ s
addr = base;
7 g$ C; w$ ]- c
sync ();
+ H) z8 a( {9 X0 O' C* g
save
= *addr;
' {7 {/ r4 W" c; a4 b; o6 L
sync ();
* i! h7 G7 z7 {3 q M
*addr = 0;
* u( J" I6 p7 i1 N. W
9 w% h. {0 K' j1 W7 }3 W; Z2 u
sync ();
) U. i! a" M" m) r" E
if ((val = *addr) != 0) {
# u% {0 F6 k$ F" o
/* Restore the original data before leaving the function.
$ ^; }. i. F: n; s: e( ?" _
*/
+ I, A. s7 Q0 c* s) n' X
sync ();
' c; H$ p: L+ B: S6 ?
*addr = save
;
0 {$ c6 v2 D. c- ^6 o6 }
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
' y, R+ y |+ [3 N' c, S$ \4 N
addr = base + cnt;
6 y3 P9 V9 y2 T6 q: }/ H" w; _
sync ();
/ a; ` o; R; N5 J+ t
*addr = save[--i];
) G; m" \' _/ R9 R# ^) Q
}
' h! l c/ N! V9 ?8 _3 T+ a" W+ L
return (0);
4 p9 I. q! U1 W. j+ q
}
. _+ v/ G$ H3 X9 n4 J
* c: ^/ S' H$ n* a. A
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 [5 H `3 M* P% |) t0 n
addr = base + cnt; /* pointer arith! */
4 m1 f, K& m9 [3 t) T8 \
val = *addr;
9 }* Y; {8 Z! r; l; W d- t
*addr = save[--i];
: w9 Z! P! L: Q# M+ i' m$ I& A% u0 t
if (val != ~cnt) {
6 \8 h0 X/ X( J' l$ V8 d) ~
size = cnt * sizeof (long);
6 ]0 n) F8 U2 Z7 | q" a+ Y
/* Restore the original data before leaving the function.
8 u$ ]( n* J! i. P; }, A9 Z3 V
*/
0 k( |: l& C2 I) t4 i
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 d0 R8 |- l9 {
addr = base + cnt;
; ^: V7 S% M: \4 Y! L2 ]) X
*addr = save[--i];
k+ M; ^! [ [3 S7 |) w$ J
}
" y4 U+ K0 }1 J- F- |
return (size);
: W" F/ G- }% Z! o8 x* \0 c) u Q
}
7 e2 N7 W1 B6 R+ T
}
1 P6 m ]$ _" u8 o, g
& F8 T1 o# a3 j
return (maxsize);
9 e+ x( I5 E, W, J! }* M8 M6 a
}
" c! i0 G" y. x; \
int dram_init(void)
& B* o! [6 N+ b
{
- Y7 A6 i: Y# u
/* dram_init must store complete ramsize in gd->ram_size */
' V3 C1 O& K9 F
gd->ram_size = get_ram_size(
9 Y' m# z3 d; K% O, M3 y7 c3 Y9 F
(void *)CONFIG_SYS_SDRAM_BASE,
$ F- w3 C7 _2 @, {. ?$ z
CONFIG_MAX_RAM_BANK_SIZE);
# v! S- c: u2 z
return 0;
& N9 u# D, t& G' X
}
* Z* [# N, R4 k' g. z
! V) ~+ O! z& o* g" r. H5 i5 F
8 _% `* L2 m' T6 L6 R' [
2 T; H) i% A8 U8 T" t$ O6 O
1 |, R1 |2 R1 {0 K
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
" M& h- `) U: v7 Z
: A# N7 ~; N' x' q t' h
) [7 v- S2 H) |
1 O% x# {+ X! J+ t/ V
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4