嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
$ {* M. w" m! {& q5 F
核心板2:DDR2 256M Byte NAND FLASH 8G bit
4 n; I5 {- b" {4 N, P+ s6 {
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
. ?+ n; `' F" @. a7 j0 F* v
, L5 \5 K: m+ H+ r" W' G
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
Z& t9 L& w# `5 B9 d
, {; Q5 w6 U# n
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
4 L) l3 P" \! i2 C( s
/*
- k, ]4 x& U, r4 ~# F* R4 V
* Check memory range for valid RAM. A simple memory test determines
7 U7 l9 w1 h) Z6 X0 D
* the actually available RAM size between addresses `base' and
2 c+ V k, I" T5 Z% f+ a4 s! V
* `base + maxsize'.
& k; _3 D* p3 E- f- S* \
*/
. {0 A1 h4 u. M' ~) v1 ~# J4 r- z
long get_ram_size(long *base, long maxsize)
1 T; Z; `8 C+ H* ?
{
" O/ }; b; Y& W" r) }& \3 K
volatile long *addr;
' u+ X' B# r/ S7 E A7 I# ?- u
long save[32];
0 e" M! K/ {- o- i8 N
long cnt;
g9 H! q I% Z9 `; K+ t
long val;
9 F: p- A3 R( [# H8 i' ?* y0 O6 Z
long size;
i. p# c) s7 V0 s, ~* j4 Q
int i = 0;
D0 {" D" S* f9 Y
# p$ e/ ^" h& H" ]0 I# ]
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
+ t" ~ H& J. a% f! P
addr = base + cnt; /* pointer arith! */
z) [. y. F' h" C2 n
sync ();
7 D" e7 Z8 m& U" L1 Y+ {% z
save[i++] = *addr;
/ ^+ X7 L8 N) |- r( L7 J0 Q
sync ();
9 G- T3 m8 a4 R0 N
*addr = ~cnt;
0 V1 B# d6 A( K8 Z+ L1 e( M, F% b
}
" {- H7 |, e8 J6 q7 n$ O5 f) M+ B9 M7 i
4 v2 d( C8 X/ J8 w
addr = base;
; B) W: {2 }2 d% v8 T
sync ();
, s4 G+ o) t6 @0 d! [! e
save
= *addr;
) b4 @. P/ G4 n) N: ?
sync ();
. s9 S& G1 q# ?) W* Z
*addr = 0;
V1 I5 y! a j
) s' B; j Q$ I9 w7 D
sync ();
% U. F& z9 ~5 Z+ J
if ((val = *addr) != 0) {
. c [: r4 l9 i
/* Restore the original data before leaving the function.
' R k) T6 _) n9 h5 i3 s
*/
# i- X' Z( j* c; @4 ~$ \( S
sync ();
0 p- \ t6 r7 Z. g0 ]
*addr = save
;
; g# |8 O2 c6 V6 Y* e
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
" R% G; h4 A0 l' D/ k; ] ]( Q
addr = base + cnt;
9 g" ?0 V9 }9 d) d- s
sync ();
5 \8 R8 I4 W3 V; `7 y2 H1 N
*addr = save[--i];
/ j6 e: k# ^0 |$ g5 `; w V# Z2 S
}
]" X5 K( t2 E. y
return (0);
2 W( v) R; h1 L# ?/ _
}
& l3 Y1 `2 U$ g, }7 B: N9 A1 x
) s, H, ~) M f' I, F
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ L0 D( F1 K+ b% P$ k O y8 u
addr = base + cnt; /* pointer arith! */
6 | K. ^0 Q- N7 n e
val = *addr;
+ P# Q, N0 j n K) Y& }
*addr = save[--i];
3 @! s' K9 s0 K& ]! \% j! h( i2 v2 g
if (val != ~cnt) {
3 K) m2 q) Z, }0 L; {. K2 e6 U
size = cnt * sizeof (long);
5 y/ v. K2 `& a) |
/* Restore the original data before leaving the function.
2 E6 x+ F3 U# Z0 H; J
*/
% f9 U+ e1 b+ I6 ~/ |' p i) ^$ `
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 o9 A# f7 H, m- c. J$ Y) B
addr = base + cnt;
. n% c+ n' `; t" V& U
*addr = save[--i];
" T X; s4 s) i; A1 i2 m: v
}
) Y5 K( G' f0 K1 G
return (size);
- }3 X" }' t f0 L3 C3 M4 S
}
1 w' L0 D5 k3 V: w4 Z2 s5 p; e
}
1 }! n4 H8 t) H \2 f- l! D
. L6 b6 f) u4 O% W \
return (maxsize);
7 @& W! b: ]- Z$ c& V
}
o: a9 V8 g4 {' R: Z" ?* |
int dram_init(void)
0 E6 a( r7 _ O) o! j* d6 F. w
{
( L* L1 D& T( Y5 c
/* dram_init must store complete ramsize in gd->ram_size */
& o( H" d6 d5 d( Z9 N/ o% D3 B' l
gd->ram_size = get_ram_size(
; ~+ q5 b- {. {; ?! O
(void *)CONFIG_SYS_SDRAM_BASE,
: M1 l. \" F m& `4 y" ]" f
CONFIG_MAX_RAM_BANK_SIZE);
, {( u( Q& D( a( ~; n. n
return 0;
- D- \% q9 p+ p8 z* X# W% u; D+ ~% K
}
4 k8 {3 L, U& f; B! j, ?
+ Y0 ^$ L% D& H2 m
$ n( J% g: m: h! W% x1 \% n7 a
- u, ~' t+ n/ | f* L; _! X2 a
" `2 ~- k! y0 Z5 y6 M0 t6 M
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
& m4 S4 E. a( B; z) k$ b6 W
$ C }0 }8 l8 a& p D
& i, m& o: l% W! ?' ]6 D
+ m# F# \ ?, u1 ~* S# J
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4