嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
0 }3 J" _4 E/ Z# ]3 C, x0 F
核心板2:DDR2 256M Byte NAND FLASH 8G bit
' \' h' l7 C! D) U
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
8 U" p+ O, E: m8 c; [, U2 N
" w" W/ u a( X4 \4 S K' `
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
- U3 F( t( g" Z, C" W
A& \7 O% b7 A3 p4 i. D
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
3 \6 A8 a. l+ Q; i: J t
/*
$ J. _0 G" U: D: l
* Check memory range for valid RAM. A simple memory test determines
, ^- H, q' `1 }( g* r
* the actually available RAM size between addresses `base' and
9 }7 B% h( ^6 ]1 e+ g% x
* `base + maxsize'.
6 o. ]! c, W. Q0 ?. d9 Z8 G i
*/
5 ^( _; a# o2 O% U) O y
long get_ram_size(long *base, long maxsize)
; \* D7 b% R% f4 W8 ]
{
, R5 V8 \9 F5 C; s) n: D
volatile long *addr;
6 l [- ]7 F1 y3 x) V% j
long save[32];
% ?4 R4 t! ?! p' I
long cnt;
7 x4 K1 s8 |8 N
long val;
3 U! M& i, S) u8 ^ O4 x1 s @
long size;
8 e; x' c! f& U3 e% A
int i = 0;
& o2 f; s* T* j* J( ?
6 c j6 W: r7 ]- _* v: k$ }
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
4 U B2 H/ H$ Y( b# @
addr = base + cnt; /* pointer arith! */
% h8 }! V$ r' r; i9 P6 h* V `
sync ();
4 q! D# D- q& i! q* x3 a
save[i++] = *addr;
; G1 m c! Y: x" ]$ \/ P
sync ();
+ J9 w7 k5 H8 r) u
*addr = ~cnt;
" d$ m g) G) k
}
' c# F) @. W7 v9 B/ T4 A
* e' p d4 I- S- c9 H
addr = base;
* E) r- I6 [* n# c3 c' r0 B' K+ G
sync ();
8 N+ V# m, w& o) g; t
save
= *addr;
% j Q2 j8 E+ w2 k" R/ m
sync ();
6 g5 P1 ?$ e5 w( r. ?9 r* V! x% b
*addr = 0;
8 ~! O5 w2 z2 @, E! i
2 _6 a" ?$ D! Z& U4 l8 f' j
sync ();
0 Z2 o+ e) n! F9 z/ a ?- C
if ((val = *addr) != 0) {
# G, g2 c7 m* o# d
/* Restore the original data before leaving the function.
# H$ y8 ? T2 U. q9 k+ n' t0 s
*/
% x" f( q! E: F$ I' N) O0 s1 c$ O
sync ();
3 F* g7 d) n+ M$ u# U
*addr = save
;
0 x+ Y* W/ }# [, |1 l8 J/ \
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
5 P( q4 \+ m/ s' t! o: a7 T; z" \
addr = base + cnt;
3 l) `# {, @$ {: z$ T
sync ();
^1 }8 a! ^ v [
*addr = save[--i];
# Z8 \/ r- u: Y
}
. e: q3 G+ ?" o3 V: x- t0 j H
return (0);
* r3 Y2 O q1 l
}
' j0 ` Q5 R) G0 _ N
$ m1 P+ i9 [: F# P3 s" _3 I
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 W" J6 V. I" b+ X v
addr = base + cnt; /* pointer arith! */
! @$ k. R1 m2 g- ^
val = *addr;
9 ]9 N# X! C( Q. Y$ K! t; h2 U
*addr = save[--i];
) f, l0 w) U! f
if (val != ~cnt) {
6 C+ `; Y6 V# \7 d; e5 b: c) z
size = cnt * sizeof (long);
. B! O2 R3 h* \. ~) W3 @: I9 p% D
/* Restore the original data before leaving the function.
% E* O/ B) k {! g% y3 s3 b; p
*/
0 @* u% G4 T4 z5 i) }
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. N6 K3 M, T8 A
addr = base + cnt;
/ w; A$ ~# S% M) t& D/ i% b
*addr = save[--i];
/ e/ G$ J- h. V4 g) j& q
}
. _7 A8 c# u3 T2 C& K$ J2 D0 ]
return (size);
, o; `0 L+ o; g, [: z+ ~
}
, t& [0 e- }# a% L
}
* W2 o# n7 o' J# a
7 r3 ?3 l0 r6 Q' v% O+ |+ j% r
return (maxsize);
" x0 u1 P. l* r+ S3 n" d/ X
}
$ P5 m3 L7 g# |: B9 O1 I
int dram_init(void)
& e. N% M$ q7 { }0 g3 ^1 J
{
9 }$ B! `3 l) M4 B* Y
/* dram_init must store complete ramsize in gd->ram_size */
) E/ {- X( h! {/ o
gd->ram_size = get_ram_size(
u! P4 C! i6 t* ~5 [
(void *)CONFIG_SYS_SDRAM_BASE,
' M2 U3 Q. ]( E& z( _* ^
CONFIG_MAX_RAM_BANK_SIZE);
N5 I# J6 a" i
return 0;
' ^- ?2 y+ B% Y1 Z
}
) y2 b% @+ k9 f1 A' a
0 G6 N v E- i2 d0 I
6 h7 x$ ?9 |. o* W" p# X9 r: T
9 a) d$ D$ Q0 `7 o
" g( [% @$ t* N% C8 m
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
4 R/ c j$ K: T! v2 S3 N
- \5 K1 T& }5 _
% A8 f+ F) S7 A( E+ \4 e/ k9 \% r& \
5 U" S. r8 k1 }; R
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4