嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
K9 s, L/ l& W* R6 Q. e! c
核心板2:DDR2 256M Byte NAND FLASH 8G bit
7 a$ Y4 R3 S4 t0 n4 Y6 }
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
( J. m- U) G7 m; _9 k
& Y& f& h( R6 v- E% [& x
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
1 H$ n( i% j% }7 D4 t
' t" e, Q( g: ?+ W
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
2 [" u( z! U; h+ F6 _5 w* \
/*
4 |0 E2 p' F7 Y8 e2 _
* Check memory range for valid RAM. A simple memory test determines
F$ q# Y( d' z1 p) X* t9 m+ T
* the actually available RAM size between addresses `base' and
, i# @# A" P H! \/ Z4 `$ C$ e0 R& I
* `base + maxsize'.
* G1 B! u4 q- @, T
*/
, O n& t& E3 \4 |5 ~, g
long get_ram_size(long *base, long maxsize)
* s6 p5 M* ?7 l7 F% R" X) ^; `
{
# U* H. _' d1 }- ]/ J) U+ @
volatile long *addr;
2 w, r' t( c1 k' P! P' O
long save[32];
5 N3 |. t4 b( V4 Q. z% i
long cnt;
) n2 M% f* ~* t0 n* X4 r
long val;
/ M) A4 N F% s6 m- t6 b
long size;
1 T V3 T/ ?. n" }7 m0 L7 x
int i = 0;
8 ?$ Q5 {" i! d$ g" u) x
& Y- w; J8 \+ ?) x/ O9 |
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
: _- a2 F$ b- [
addr = base + cnt; /* pointer arith! */
8 X$ } f; w# X; v9 _( n# |
sync ();
: m1 j; c+ ~5 l$ k& V
save[i++] = *addr;
1 O3 C6 c/ ^1 Z" {* M
sync ();
' I6 ]4 D/ a# u. t
*addr = ~cnt;
( M' A. T0 E B2 `8 H ?# @
}
+ H- |( M0 ]" Y4 U( }
$ W- S5 J* o$ j4 J/ y1 x
addr = base;
, R# a [- z' H" `' Y& J
sync ();
3 V1 ]; u1 u) X8 T9 k0 [3 e" Z
save
= *addr;
4 T% d( {& ]5 S5 s9 @% P7 m
sync ();
5 g, S+ x0 V2 l( u }& E- @' }
*addr = 0;
5 a7 V1 X6 ?: R
; g3 p* K" w' ]. O
sync ();
# y( c; A/ Q" t
if ((val = *addr) != 0) {
4 t5 P9 G" q. E& h; \3 W: r6 k
/* Restore the original data before leaving the function.
, b v' w1 b x: Q- M5 q3 ~3 R d/ B7 P
*/
# q8 ^' k0 m* A2 ]; i, [4 @
sync ();
/ P, Y8 l: I: u- {0 Q0 E3 t
*addr = save
;
, `, u' q5 i0 g9 ?. w
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
5 |/ v% m; k& [1 b; V& F& G* N. _
addr = base + cnt;
+ k, O5 `9 g' Z% u _: H
sync ();
6 d/ `) `6 \# q* S
*addr = save[--i];
2 i2 o8 B: q; U2 z, K- A) w2 c9 B
}
+ u, I; `) ?9 X9 s- r& k4 ?3 q5 z
return (0);
# {' P% n! i- E1 D' f
}
" |5 [5 o d# {# h8 M; H5 r
- q1 s2 J/ `& ` n$ N/ L
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' ^* ?) t8 d I0 I7 W' g3 P
addr = base + cnt; /* pointer arith! */
4 r6 I+ m8 L5 }$ \% r% U
val = *addr;
; A. _- ]7 `% [) q3 x
*addr = save[--i];
1 U" I+ @1 b6 I! t6 X. @& b
if (val != ~cnt) {
" o: Y1 Q: v: f
size = cnt * sizeof (long);
! C9 N2 h: V7 N4 f) ]8 S: M
/* Restore the original data before leaving the function.
# \: i0 f. s" y1 f- a! {. ~: z# N
*/
& X+ l" S9 \- S7 u: M
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; O* D1 I2 `; m9 c) T
addr = base + cnt;
% y) H0 e3 K* y/ M
*addr = save[--i];
. c4 `, C7 F6 x! r
}
+ K% }/ e- }( ?
return (size);
- R: }/ d7 F: Y3 [: o: m
}
' s. I. L, s' \8 U/ J1 `/ u
}
9 c$ V- l% V" R) v w( k
3 V+ _( U& u, `/ q
return (maxsize);
2 W6 u! H% B" c
}
0 a u* ]" m/ e1 X% a) s
int dram_init(void)
, ]7 \- [4 c4 V- v h9 c) I
{
$ D" T3 |+ }; o4 W; e7 m9 K
/* dram_init must store complete ramsize in gd->ram_size */
8 u' K6 O/ K% [! W x- i7 P2 H! C
gd->ram_size = get_ram_size(
. d) h% q2 K# T, Q4 j
(void *)CONFIG_SYS_SDRAM_BASE,
y' [1 N1 s$ Y# |9 @% J6 N
CONFIG_MAX_RAM_BANK_SIZE);
1 H! t, l9 H: c/ n) \
return 0;
$ r; p' E5 @6 Y1 _
}
& E5 _: G/ B+ u# a0 ]
4 x+ | X' k N
* |; T9 n' ^$ c5 ~
7 K N) w# ^7 i4 `. S4 D! @: K
3 L8 `9 I/ U4 A D+ l+ k
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
: w: b6 V4 i/ q3 j6 p
0 z5 U: A. J# _8 Y
4 h2 i% G0 L- y- a# M
* A2 b! L$ @' I8 S" L
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4