嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
- g+ h ?7 P1 t: g
核心板2:DDR2 256M Byte NAND FLASH 8G bit
4 b5 |0 K: @$ h- d+ Y/ n
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
, t. W% T2 t, s. {$ c. P$ T
6 r" d( Q8 x* _
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 K/ j3 L6 L+ c/ S" R4 n) F
1 d' {& E8 [/ `- w/ ]8 N' k6 f
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
- N& \( v1 q: W
/*
$ B) g6 ~- S& ]8 @ U
* Check memory range for valid RAM. A simple memory test determines
1 o: M+ ?* W+ i2 W P
* the actually available RAM size between addresses `base' and
7 d5 w7 s( I+ T
* `base + maxsize'.
W, N2 A% |$ `2 j
*/
8 x- f# ^* N) W! `8 _1 ]$ J3 U
long get_ram_size(long *base, long maxsize)
. A, U- L" {. F& O% E
{
9 }+ ]8 ^; E- @& f
volatile long *addr;
8 E, S; j% K* \
long save[32];
2 T& B1 U, g9 P" ^* H, t0 D
long cnt;
; R) a0 E" T* ^* @0 C1 ~
long val;
& L* A9 v6 ]8 E8 p7 ~$ |: P
long size;
2 c4 a/ V" V, e' \3 O! h
int i = 0;
8 |9 H% `% W( Y# ]1 x$ F/ [; ^
3 j( }; @3 C( }9 V( C4 W
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
3 p5 U: F5 _9 [7 Z; I& m! c
addr = base + cnt; /* pointer arith! */
4 r. x1 W* E1 I1 Y7 U
sync ();
- M: {7 j1 C$ Q
save[i++] = *addr;
% ^( c% k, j$ G9 g. ?
sync ();
" {6 ~$ ^: J9 g% ~+ d0 i
*addr = ~cnt;
% \1 ^4 R+ \$ r9 f6 m' h
}
0 ~) v4 Y( y# W1 b
. w8 T8 W; k3 ^4 o
addr = base;
V4 |* m V! T& s/ o- s' k
sync ();
, T8 _; K/ m; c6 I5 t+ A
save
= *addr;
0 J- K! W* M' L8 |' W' P, o4 s
sync ();
! l Z# H& l* d; Y8 ~# N
*addr = 0;
& D7 h1 K ~3 X( g
4 a2 u6 _: h. D4 L/ [
sync ();
1 M3 [, P& N% W" A- P& `) O
if ((val = *addr) != 0) {
4 F5 o. w. X/ U' r4 p: ]
/* Restore the original data before leaving the function.
6 G% o# z# P* n; c! g) o
*/
" a2 K7 `! s) O/ E+ K
sync ();
- m, D! a1 P J l. h
*addr = save
;
6 T. I6 [0 ]6 l) w
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 }3 R1 q/ |' X
addr = base + cnt;
6 Y. G) H- h, |' C
sync ();
6 Z3 h) T. T% D3 p2 R( h
*addr = save[--i];
8 ~1 e O( O1 B8 w
}
, f v: ^4 q! f: z2 q# H9 l
return (0);
. }2 V: k3 C1 {8 K( c
}
8 g8 _% N" T5 h- v9 x
6 g2 ?/ ?% y5 Y5 _3 d
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) w) y$ D) y9 G
addr = base + cnt; /* pointer arith! */
3 J% t5 e& O& `# Y: e" X
val = *addr;
m; O3 T' |, }
*addr = save[--i];
- _9 _, R$ D! A
if (val != ~cnt) {
- y4 n" T9 ]8 p8 V/ x
size = cnt * sizeof (long);
8 j5 U! R& Y, v# k! m( O1 H
/* Restore the original data before leaving the function.
7 l# e- r$ F% ^! V, _ I5 O
*/
. B, Q: T* p' \/ ]: Y
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 n$ V7 P2 r% n4 v7 p
addr = base + cnt;
2 Y+ {$ h+ @' h, }2 |; {) k
*addr = save[--i];
1 \, y7 I, T0 {
}
9 ?+ H! e9 c9 P1 A/ u
return (size);
& _2 ~9 }; p* @6 z% v$ ?( u9 Q
}
* H' L2 ], h7 t) Z
}
0 w v+ c9 B/ C* A. ~
1 J' m" Y. D I# i3 t0 U( q
return (maxsize);
' G c2 ~6 P: F1 |
}
- R# r- h$ {0 _. z0 |% q: c. s
int dram_init(void)
: D' u* _( W0 k
{
C2 A7 Q5 C6 T/ I) y
/* dram_init must store complete ramsize in gd->ram_size */
/ S' d1 @- V5 T; m& j+ s
gd->ram_size = get_ram_size(
3 W* S8 g% M1 V5 m; T `
(void *)CONFIG_SYS_SDRAM_BASE,
9 d) z1 \" X1 S, d' Y: [, f0 y
CONFIG_MAX_RAM_BANK_SIZE);
4 R. N& {8 N9 s
return 0;
; ^7 v7 Y- y& Z& d, v3 B; W- A- u0 Z& _
}
4 ?; I( p9 m! L' o5 C- U4 B& _
/ A% T. @ U: o/ V
# z) G; u3 {5 r( x
" r1 T8 ]8 Z- B( Y, h3 c9 K
0 P3 H5 p! `3 c/ s7 ~" O
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
- L3 i6 w7 S2 i
- Z; R- W! w& X
D& P& P- E+ g. f
' E. {) W4 O7 ]4 {9 C: R# }
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4