嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
& r7 }) d, l9 P( C9 j
核心板2:DDR2 256M Byte NAND FLASH 8G bit
% s( y. w/ }+ [
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 V- ^+ }3 q$ |5 f; g+ ]6 O; q
% T6 J Z" g2 M
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
; M$ S* |1 ^; o! F: Q, J
3 f$ t9 ^4 P! U" V; B5 h
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
: Z9 @ n$ ]* |; ]' U
/*
% x9 m5 _/ x1 ^9 d5 \. y
* Check memory range for valid RAM. A simple memory test determines
5 Z+ a- A/ D9 `; Z# m
* the actually available RAM size between addresses `base' and
2 @7 i8 N+ n2 w7 `, g1 Y8 C6 G
* `base + maxsize'.
+ k" n6 D/ b7 M+ u
*/
5 @5 i1 q. @6 w( G0 D I# k7 a
long get_ram_size(long *base, long maxsize)
1 L2 L8 M% l+ T/ i5 ~0 z" x" F2 l% Q- j
{
) p7 ]+ u1 r1 A' h
volatile long *addr;
8 E* R" u) ] M$ a* v+ w
long save[32];
# w$ @) a# `4 i$ [. o
long cnt;
4 P) \5 c9 w. N
long val;
$ c/ U/ Z% H8 f5 S- Y! f: C
long size;
; ^: n! [5 d& i# }- }
int i = 0;
, I8 F N% V3 `% }4 J [5 g
$ _0 _/ D- c1 t/ \
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
7 i6 G1 ?$ R: z& U& {, i3 d
addr = base + cnt; /* pointer arith! */
, v# b! a% B/ D, ?3 ^. M9 U
sync ();
1 T. x1 w& w& A5 C. b
save[i++] = *addr;
/ j) F- m4 B# _2 ^+ P f
sync ();
( y: `8 h- ?2 x0 q) [- q4 j
*addr = ~cnt;
" I8 }/ l: R/ }0 A8 m
}
8 _& n5 h7 m' d: k! {/ N
3 N1 A- `' i' `1 d" c9 ~4 s# H
addr = base;
6 Q6 G# `0 w5 @9 R: m: m4 t
sync ();
. w9 N: T" o+ r. ?5 @4 b+ _
save
= *addr;
0 e* y& @& h* y/ M' I$ v8 y! V7 z3 m l
sync ();
5 J0 p2 i; z {
*addr = 0;
' T+ X" J# m7 e) ?+ P
5 f% t" n* d2 ]) S% s w% L
sync ();
; I7 l/ q o* P5 d0 G7 d
if ((val = *addr) != 0) {
8 `6 X p1 G$ z9 N8 [' n
/* Restore the original data before leaving the function.
, |% j+ j& B/ m" @; x
*/
5 t" Z/ ^. S) \4 Y. m3 u8 w0 J
sync ();
3 S2 a/ u V( e; q( E4 G7 M. \
*addr = save
;
/ a0 g, s$ K4 w. g2 ~& } L
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
! h; q, ?/ O; O: D! L( v1 }
addr = base + cnt;
+ w; }1 Z- R7 b' d
sync ();
" q8 U( n3 t1 `6 B
*addr = save[--i];
, V' @/ z3 B- a* R' R+ m
}
m6 S2 u, \% v' m& t
return (0);
& X" H$ r% j n
}
/ u- x: F3 G- q, j# q$ T
% i1 D# I* G$ v6 r8 Q0 a
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
/ P" S+ d; l: |5 W
addr = base + cnt; /* pointer arith! */
' e! x2 r1 r: h2 S) ~
val = *addr;
% D- P+ x; V4 q7 A6 D5 \& N/ m
*addr = save[--i];
L' y6 Z3 ^& u1 o1 I, v
if (val != ~cnt) {
* M6 d, {" m% y5 P) _
size = cnt * sizeof (long);
Q8 K% I8 O. O$ h5 ?) r
/* Restore the original data before leaving the function.
4 X# D5 W o* h! E, u5 O3 z
*/
9 x6 y" C, }- G% I) Y
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; K: y) j# K E7 H3 M* r9 @
addr = base + cnt;
4 f9 Y) Z0 ?( b; P* ~4 U
*addr = save[--i];
8 R. S% @5 ~7 M7 b6 M% A9 N
}
# S1 ^% U7 n5 d6 A2 |/ K1 s
return (size);
5 _6 m( J* i, O8 J
}
! `" z- H/ d0 J) X
}
: d/ ~8 j a$ F/ C
8 F4 M4 J% o9 P$ K9 w# W; l; n8 D
return (maxsize);
% r, h: g* x+ W. Z% [) V
}
$ R; w; T0 W6 x1 B
int dram_init(void)
# z& Y" G" h" r: g8 W% |% `8 f3 v
{
4 O1 g" Q% b& O/ w& T! D) _
/* dram_init must store complete ramsize in gd->ram_size */
; C9 d, o7 @% K% v' h
gd->ram_size = get_ram_size(
; H4 a- E: X. d0 A1 e, b, j4 j
(void *)CONFIG_SYS_SDRAM_BASE,
3 k, \/ C `# G$ G+ o
CONFIG_MAX_RAM_BANK_SIZE);
, ] } T. m8 A" Z! Q4 X$ m3 `! [. w. k
return 0;
4 d2 S& S- U1 F0 u
}
! x% p) k$ y! j2 a, J
+ {/ }: [ k7 _" \: d4 \- s
. H) D- p7 f9 q5 K1 A9 Z
% _; q, s4 z- l, O2 p) Y
, d& Q) Z. T6 F' K& h# h' c Y( @$ [
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
" ?' d8 W$ p; T6 M: y# a) _( p
6 u7 r ], {# V0 m1 i% ^
/ g- ^3 t9 _& ^6 |8 N x
% }/ r G- N" ^ ~
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4