嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
8 _1 V4 g* j5 G* x) O" Y) D6 z
核心板2:DDR2 256M Byte NAND FLASH 8G bit
4 B$ `: z9 P+ |) G1 S* d
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 `% p5 T: o# d0 P4 W& b
; ?$ [% T+ R# D( ]9 h- P. [
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
( Z+ `" t: c0 s; o5 H$ l
7 B: H& e# R2 h0 m, h8 s
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
6 q( l6 l! E6 x9 c' h! M
/*
& P6 c: T: _( `6 n* R: R9 G7 h
* Check memory range for valid RAM. A simple memory test determines
2 x- z8 u9 ]/ c; E# ~* ]" c/ [; H. o
* the actually available RAM size between addresses `base' and
( W4 }% b- b0 g$ ^- B
* `base + maxsize'.
) t5 p/ Z+ c+ r5 L6 A1 m
*/
9 z. ^3 \4 L; n) z& I H3 O$ e4 B
long get_ram_size(long *base, long maxsize)
9 N* F& E0 h/ J$ _8 E
{
7 R: g% A; W( x& W
volatile long *addr;
* L6 D1 B4 p- _% w* j- A U* P
long save[32];
! |" F0 I7 n5 `
long cnt;
5 m1 m3 }& w5 N T- k
long val;
7 E7 N& \6 T2 u
long size;
$ x( E @. E& N$ ]7 i3 p8 c! x
int i = 0;
8 V+ |5 {. o0 J
: V7 l E4 j4 {! F9 z% d( [
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
1 u; H0 v3 ~+ d+ y# G
addr = base + cnt; /* pointer arith! */
; O7 G% H5 C8 ~: D; u1 A' h7 e; L
sync ();
. z7 \# M8 q: o2 S9 Q) M/ _
save[i++] = *addr;
+ H) v: I5 v0 i
sync ();
& I- f# b! E+ M
*addr = ~cnt;
! s: v$ p) O' R& _0 K
}
: g( {* t/ M* P! L6 B' h
+ ` j' ~; U$ L
addr = base;
5 O6 I9 S2 o: p
sync ();
$ G: r5 n' @4 S7 b T
save
= *addr;
1 A8 X# y+ G0 x% w1 E5 y) B! p H( h
sync ();
$ c6 Z% B1 }9 Q c0 h
*addr = 0;
# s* ^/ Y# T o q3 J
- E$ V# s1 u4 A1 G7 \% B. @
sync ();
) X2 m' L6 |4 i6 c/ ?9 Y( M
if ((val = *addr) != 0) {
. g% _* g9 C5 \3 G
/* Restore the original data before leaving the function.
" j* v9 s" y7 [3 u1 ?# u! I Y" P5 l
*/
% l; n8 A+ I. F! f) T0 N' i7 O
sync ();
- [ y! O) B0 a8 L
*addr = save
;
9 {+ R. ^( y* W
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
2 s# k: N9 L3 l; q s3 q
addr = base + cnt;
/ a- V, G( o+ U9 X, k; B# E2 y8 \
sync ();
4 M5 j- [ E0 d7 K* M
*addr = save[--i];
) P" h6 ^* {1 B/ x2 }) ]7 j! M
}
" d# T) K7 {* l/ ]8 ]/ s, F# a' y5 t, Y* n
return (0);
9 I% _8 }6 e. O- l" V$ D9 ?3 \
}
/ w* p+ ?& H+ g; O
* Q1 u/ Z+ w6 `
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; q6 s1 c; D# u5 Q7 [: g
addr = base + cnt; /* pointer arith! */
% K/ I8 M4 F( f! u( K. ? F# Z
val = *addr;
. ` q: o1 e( z! @2 J# Z
*addr = save[--i];
1 z7 ~6 m6 k4 H2 U
if (val != ~cnt) {
1 }+ h$ t! s, S; G! J3 O8 V
size = cnt * sizeof (long);
2 K' [& y, l9 L+ M5 v
/* Restore the original data before leaving the function.
! s9 K1 R i! l3 D6 a0 Q
*/
, `: ^/ o f" h# N) y5 Y
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) e7 g6 m7 { K; S- C; R
addr = base + cnt;
$ Y/ t. J1 P4 M
*addr = save[--i];
+ x7 Y1 k: q4 f, w+ V
}
2 a. n+ p" B& Y+ M: l" w$ m" p
return (size);
, k) D! N& v) `" Y$ D, P
}
: D% F, B$ ^. O# c5 U
}
4 X% R+ ~' ~; d
! _7 s! s% x( S4 u
return (maxsize);
8 `$ f- W, ]) A: i: H9 h2 K
}
: ^! [- x7 r7 \; Y8 N
int dram_init(void)
* K; J) R) I7 @: V+ E" e
{
! r) s r# ]- e
/* dram_init must store complete ramsize in gd->ram_size */
7 v+ X r' E" z+ j; g4 P6 Y
gd->ram_size = get_ram_size(
, C+ U8 H- j8 Q h( C5 N
(void *)CONFIG_SYS_SDRAM_BASE,
4 _0 E5 k5 q; K
CONFIG_MAX_RAM_BANK_SIZE);
& q/ m! T/ r/ S& y# u
return 0;
& s/ f$ I; i! V/ W
}
; e6 D" l9 D( C. _
( F: q& {$ i: T* p( ^0 D0 f/ A
, L, T' d/ u/ y( G+ O' M& h; d
" P$ i" R- e7 K# x- E$ E' G" O' i
: ^9 C1 `, _# P# _% y* S
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
! I$ k8 D7 a2 f) t5 A' Z
+ z. D; g4 o9 Q
4 B n2 `7 `+ b0 T5 l4 g
- R% g2 r$ j& [! y8 X( W
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4