嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
; \! S q( c: Q, q5 T7 g
核心板2:DDR2 256M Byte NAND FLASH 8G bit
6 m9 j& D2 T5 k0 H. @
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
* A) y3 `! ~7 l1 M- c7 z+ H& t
% ^. ^% B4 `7 V, U
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
' P9 m& ^2 A2 \4 J' o4 x
+ L7 I ~0 @! [5 o7 x Q
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
* z4 y) E2 B% J+ ~* I2 C2 c
/*
0 _3 [% W% P9 ^
* Check memory range for valid RAM. A simple memory test determines
1 h% P0 E9 u4 n& Q1 V% c
* the actually available RAM size between addresses `base' and
+ L$ j0 {9 F8 c- N0 M; Y9 Y: t
* `base + maxsize'.
2 {/ M" N m3 Q( {
*/
2 p* E! b7 I2 y. f6 r
long get_ram_size(long *base, long maxsize)
9 I7 A1 A4 N9 {# I6 @+ z& k
{
- w% \+ J! z9 X
volatile long *addr;
; Z! f6 P+ R% |" x2 ?" W0 |0 h+ U
long save[32];
$ i% l' P; \6 y+ S8 J. h( O' T
long cnt;
4 I2 f+ C2 Y: v% X A5 n
long val;
3 d) n3 p4 R- S/ y8 ]
long size;
N8 J; P& N. u" R$ A Y; U& I
int i = 0;
' `, g I: H- f
' j4 o) s, a$ \) B0 q- v
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
& T" `# k3 a: [2 C# o! A9 [4 x5 R5 X% ]
addr = base + cnt; /* pointer arith! */
& h/ F" g) H. h5 p; V% I, Z* [
sync ();
! u9 a: U; n6 A+ [3 _8 F
save[i++] = *addr;
3 R/ G1 \0 q9 J3 X
sync ();
& K L0 x/ H; s `7 J1 w
*addr = ~cnt;
- Q* N- C5 ^3 K/ p' t, d# \' ~ E
}
3 U& x0 c1 K( y: e% S$ K" X
4 F& D2 {, u3 t$ Q) w- x) D5 w
addr = base;
. m' p. @' Z2 a" ]8 O
sync ();
9 _- D% I% P* k; Q, c
save
= *addr;
1 V% N6 @ g9 h z( D; S
sync ();
4 v7 x: a* f% M6 X% C
*addr = 0;
a. L3 x8 C1 B! E, |/ r
8 O& Z$ K: S1 `& v1 D( ?; j
sync ();
7 g$ f" l' V( N
if ((val = *addr) != 0) {
" \; l8 @& `) [7 Q$ f) E' H+ r- V
/* Restore the original data before leaving the function.
& i9 [' E4 s( o' ~
*/
& u- ?: d! K! W- ^4 {
sync ();
+ P! i! J! G" e" k0 U3 h
*addr = save
;
+ _6 _/ H' B! Y4 l& h
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
2 w4 K+ O- L0 z9 U5 [
addr = base + cnt;
6 J2 y, U$ Z9 r# ?' t1 h
sync ();
( {2 H8 A) s y. ?: J9 Y
*addr = save[--i];
* j, |' p5 a/ p$ e; m, s
}
' p; M. K" o9 a
return (0);
3 a/ L/ d% e* s$ ]
}
0 z3 s5 m& V4 y
% w% G( m* ]4 ^ [" k
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
4 a1 _2 v! f- D6 }
addr = base + cnt; /* pointer arith! */
& Z- @: G# S, `$ N! I
val = *addr;
- M( R: l! A& S _: {& z
*addr = save[--i];
" x* j5 i5 n0 B
if (val != ~cnt) {
( n, m' [9 f" N* z8 e
size = cnt * sizeof (long);
0 d U4 g: p, P/ P1 G% c
/* Restore the original data before leaving the function.
0 X1 B8 T3 P8 r/ E" Y& b# r! m
*/
% A D, O) u3 x1 l# e `% h+ a+ G5 j; O
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; K6 Y0 B) g8 e; T. Q
addr = base + cnt;
; i5 H3 B. J$ O
*addr = save[--i];
" G# U; u; i9 [5 ~; [9 ?4 w+ W4 K
}
% T) |& P3 d7 R0 A
return (size);
! L; e# S) \. i4 \1 o
}
$ e: Y6 k* J8 |' t* G
}
_+ `; D: h; ?' L' C# b, d
. @: `0 P; A% P* L+ r9 K) l5 D$ M0 Q
return (maxsize);
3 w% E8 A0 H: _6 {2 R
}
( {. b3 }% m# S: j' ?! V1 `
int dram_init(void)
- O8 w# v4 U5 `. n
{
: h+ c+ h0 q: v, z2 o$ X; ]: U2 e
/* dram_init must store complete ramsize in gd->ram_size */
% g, o7 f* K( k/ K' n
gd->ram_size = get_ram_size(
7 L. N# i2 @7 J1 _! B1 A
(void *)CONFIG_SYS_SDRAM_BASE,
6 g6 k/ I% A9 M0 I
CONFIG_MAX_RAM_BANK_SIZE);
7 C- b- i2 K) \% @. H3 Q2 B/ j
return 0;
2 o. ?2 h$ n" F7 C+ a$ K' {
}
4 U J- h) H9 c+ q
; Z R3 k- O, t9 M/ A/ {. `# `
4 m. v2 @9 H8 y1 l" N l8 x
5 N6 M- D: z7 F; ] f8 W
+ z: t. R( S1 n. k2 X2 L- J; J
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
# s9 Q9 q, n# P9 G$ x2 o, z/ v
) w2 Y' Z/ ] \- J$ x
, ?2 \. D, k9 r' _
% E c2 r2 [$ \& G4 ~1 G" }7 p) K
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4