嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
4 A1 E" P S* S0 k3 _% |, n
核心板2:DDR2 256M Byte NAND FLASH 8G bit
8 d4 ~5 F. }$ a; A/ m9 C3 l! P& F
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
" p6 J+ B% g. G
* G% S9 S2 Z) A
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
! G" J: q: k5 l& ]
" O& {0 ^! e8 v& I0 O
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
5 |- D2 W( C: E% R
/*
1 y& {* l& H- h
* Check memory range for valid RAM. A simple memory test determines
0 y: {' Y' i9 g
* the actually available RAM size between addresses `base' and
6 R6 F+ W' A) h. t3 f# Q
* `base + maxsize'.
& e+ c" v' k+ t9 }- }
*/
- ^5 Y: K6 V% e0 c, c- f) [
long get_ram_size(long *base, long maxsize)
2 C+ ^: f2 U6 `4 `7 [# a$ B% p
{
# t+ V+ q F' ?3 }
volatile long *addr;
+ @8 N3 b" o) e) c( P
long save[32];
3 f+ @" p+ R' [) R, |
long cnt;
4 @- e$ B3 W: K0 q8 x% F/ }1 D
long val;
6 k0 \- r: x! e. t
long size;
8 D4 u9 n4 w: y6 N! r* q
int i = 0;
3 E5 E2 r8 W, C2 N/ D
/ V( O' T( A' Q+ \- ?) P1 k6 L
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
, m, @* Z0 X9 ^1 d; g$ m% {+ {2 S
addr = base + cnt; /* pointer arith! */
9 c* E: z& p8 y+ E# t: r2 {
sync ();
$ r( \0 I, K3 @1 ?9 w- P
save[i++] = *addr;
9 w( s2 ~* L; g9 x. a5 R- ?
sync ();
2 z5 M3 c+ E1 k$ r, e+ [
*addr = ~cnt;
( u! P" ? p5 X' r4 R/ O
}
, j' f/ v/ q i! t. Y1 R/ U' C1 L
' w" m% Q) G, m7 h2 H; O
addr = base;
0 Q$ U6 V/ n2 P1 M" a) N( N
sync ();
& u2 Z8 ?/ H2 U0 N3 @' n
save
= *addr;
$ @% S7 d% F. ~
sync ();
% r, A8 A; K' i5 N. w1 \
*addr = 0;
& X) e* c; J6 Q6 d& p
3 T1 C8 D1 Z8 t. @; [
sync ();
+ F% ]6 i9 n5 E0 N* T( ~
if ((val = *addr) != 0) {
- \7 Q1 L# |2 [+ `0 U1 _
/* Restore the original data before leaving the function.
. V8 Z. W1 T. b- u. h! l; r
*/
( I* E' V: |- f7 t. p
sync ();
% N; n/ Z1 Y' q) o. R
*addr = save
;
# E' G% B Y$ V9 \
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
) f8 Y5 S8 k$ Z1 o4 p! V
addr = base + cnt;
* }! q" N6 D4 e1 O$ j
sync ();
$ l9 o- R: G' S, p- ~# @. _5 H/ ^
*addr = save[--i];
7 u: l, E" c R
}
$ @4 h# e4 z) X/ G+ u
return (0);
, v' A& V8 J- n
}
& t! w! @) P0 n) {
4 K& K/ r8 ^7 T8 q
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- Y) V2 h! h4 i& o
addr = base + cnt; /* pointer arith! */
$ T5 Q/ d: c3 v: y1 g* F O
val = *addr;
& u5 d7 y. \; z) d6 c
*addr = save[--i];
p/ d3 p7 H) @6 m# f4 |
if (val != ~cnt) {
2 |& |$ w" ^0 J0 V H7 d5 Z" K3 w
size = cnt * sizeof (long);
4 j; N- s) p, O$ X
/* Restore the original data before leaving the function.
) I: H3 T7 K h6 ~8 U v& F
*/
+ G* F; }$ w: b. f% l0 l3 S
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( N3 k9 N) ]! M" a- b
addr = base + cnt;
- `4 i$ p4 i0 G7 i
*addr = save[--i];
5 G0 }# b" O# J. x1 f
}
$ ]+ z' h; N9 V/ s) V) W
return (size);
& Y4 _. y, u8 q: @* a5 q$ s% z
}
: C- L. X4 m0 T- x
}
% B0 G0 U; w; ^) k* i
" y i5 r& ~( g
return (maxsize);
- a/ Z9 T h/ ]" B' z. B
}
* E2 b" x# ~1 s* ^$ D3 w1 x9 D
int dram_init(void)
+ J: m! D0 m" Z
{
4 y# L, s5 c# Q4 p9 U
/* dram_init must store complete ramsize in gd->ram_size */
8 v1 R1 \( S w7 ^# Q; k+ I
gd->ram_size = get_ram_size(
2 w, w. j. U' [
(void *)CONFIG_SYS_SDRAM_BASE,
0 F, C3 d {$ l
CONFIG_MAX_RAM_BANK_SIZE);
2 ?& s" A O L2 p0 a+ |
return 0;
6 R3 i9 ^; Y' Q+ X1 T
}
' K) G8 ^! W6 e9 \6 n9 N' n
* ~6 Z1 a3 K) E: z. e
' F9 V- r5 S( u) ~
/ d% k( n- h- o g
& G& i& Q: f( Q6 T
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
* e# M c i4 q1 }5 j; U' g, H
$ n1 V0 }0 d& P* J
. J. Q9 W G6 j9 c9 t
- ?: F% C1 J4 |) d7 I2 s, P
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4