嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
+ d0 J1 j" l6 j/ d& ^- a f
核心板2:DDR2 256M Byte NAND FLASH 8G bit
9 c4 s" h0 w$ d! i. O( S( |. v
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
1 H2 x Q) u- C# J) G# Q
, o( @# {" `( s1 t% _5 z
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
$ r; M; P d# ?/ v2 d7 e# i; d8 O
% r2 r9 ^) L& |$ L" A K8 T. a) L
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
4 B) E3 k Z2 p8 h8 k7 r
/*
7 q/ U' y* s4 p5 K9 ]8 G
* Check memory range for valid RAM. A simple memory test determines
3 ]1 t# W4 S4 N: p4 y! R
* the actually available RAM size between addresses `base' and
% O0 x! ^ a$ S, b, H
* `base + maxsize'.
: J. @0 z2 l9 K2 V
*/
: s8 a$ H' t# m$ ~- Y& |
long get_ram_size(long *base, long maxsize)
0 R, s5 a9 I) _5 A8 \( u
{
7 W0 T8 Y1 s+ ?
volatile long *addr;
% T/ L) D1 u( Z& F+ R
long save[32];
7 Y6 ^9 d4 U: P4 I9 S* e Z
long cnt;
" b$ q5 ~* }$ A( b( c5 K. W
long val;
/ y$ z: @6 j" s) n$ s
long size;
f) c4 A! M( N; J, C. A4 z
int i = 0;
4 \6 Q; l5 z5 t
D" u" y" b. ~$ Z l, |0 p. T
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
' k- X2 s) Q) L1 ]! i* \! ]& M/ ^
addr = base + cnt; /* pointer arith! */
9 _8 s6 a* D9 T. O& a) Z N8 H* k( ^& k
sync ();
0 C, | O4 H9 w! m0 w& s
save[i++] = *addr;
3 y7 L* A8 g, a/ H$ t" R
sync ();
z. C% X; D: I3 u Q! [% J5 d
*addr = ~cnt;
3 W2 H; I6 d9 w$ s% V5 E) W; N) ~# e
}
8 c! R7 \* [8 H
) a& p: ]0 u) u9 U1 O$ Z
addr = base;
: D8 T8 |7 `- u" |) {1 C1 B
sync ();
1 g5 `( [/ I) E5 X$ w. x4 h
save
= *addr;
3 w: |: @9 M5 _# K
sync ();
+ D, U, I% u4 z, y* F% Q, y3 H! y _
*addr = 0;
/ d0 i8 a5 l2 q# h; x
. e) p p1 ?! ]
sync ();
: H/ z) e3 @- ]7 D( a7 w
if ((val = *addr) != 0) {
# ~+ v5 Q4 |. V* f: b8 ^
/* Restore the original data before leaving the function.
" e) k# u( J% j% q" G E
*/
0 `) G; x: w: Q" h5 _
sync ();
# Y* C* \5 n; S) s5 w: I
*addr = save
;
/ i& S3 a$ K7 e% n
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
$ U& C4 D* n1 y2 ^0 {* ~
addr = base + cnt;
1 n/ \0 g5 D; f! @( E N# b
sync ();
: B* H, m5 n. g: n% O& Q0 O
*addr = save[--i];
/ \: }9 O( `5 |8 \# |, l
}
4 l" v" C) t+ D R; W/ F7 z2 f
return (0);
/ s2 G f0 U$ v- C" d# I+ a
}
z+ P2 l0 }* \; g6 a. Y
! Z, @% b6 v7 g- A8 |
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" B% p* C3 W- ]- n
addr = base + cnt; /* pointer arith! */
( P8 f4 w. _6 K3 F
val = *addr;
( ^' T6 n- @ I. ]* k1 c0 Z. R" ?; ?
*addr = save[--i];
( l( O, V R# g
if (val != ~cnt) {
: O6 u1 r3 l1 w9 `. }7 [! Y8 ~
size = cnt * sizeof (long);
! Z/ Q$ u1 F: t+ l4 ~' [
/* Restore the original data before leaving the function.
, G, V/ K2 J6 B9 t8 s
*/
W5 @( @1 B. x7 f* G
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, Q8 @/ D1 i4 o
addr = base + cnt;
* M3 x- I0 O0 B
*addr = save[--i];
! z. n$ s3 x, Y1 n, J0 D
}
# b( P; x3 O6 K# d; h- r! x5 t
return (size);
0 C+ s/ ^# D- }3 @8 a
}
. V" G) v; \' |# K$ U+ v
}
5 o9 @( E* f) V, M
% W. o, ~& j% I6 }
return (maxsize);
, m. b3 Z; S* G M. \( s
}
8 U$ w4 Z; w" N( R% W* b1 g
int dram_init(void)
. n' a* a( r6 _1 H- I2 a
{
% A" b5 f8 f# j
/* dram_init must store complete ramsize in gd->ram_size */
: z! I$ T. B+ S8 w x
gd->ram_size = get_ram_size(
" p/ s9 K# i2 s) W. b
(void *)CONFIG_SYS_SDRAM_BASE,
& p) e. U3 A# m% P
CONFIG_MAX_RAM_BANK_SIZE);
# K9 j+ [1 p6 Q: R; V9 }
return 0;
; ], F: J4 ?# U$ s6 ]8 B- x
}
9 n" u! c7 B+ z$ W# |
8 G o) m; O# b9 H) n9 q3 s) I5 ?
8 z( G6 \' Y1 ~4 x# A" d
@+ O$ q, d/ l5 D- J" r9 ]4 R
" n7 T$ }3 E. W
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
9 f5 S- a8 d" \. h- e8 g) q+ g
' v# N+ E( i8 A- [8 u& T" N% H
- e X! u* v4 L+ }* i" H; U$ X
, s6 J! F- z' i' e
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4