嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
' V( z. `6 f; I( r' W
核心板2:DDR2 256M Byte NAND FLASH 8G bit
3 ^+ U# \# }9 d: s3 n
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
. {3 \, R: z: r! t. J0 K5 O3 T
. S3 }% N w+ T& G# N8 ?+ z( B
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
# o7 v+ j# |2 I9 F$ p
" Z2 B' E9 t3 a2 l( V$ v. g
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
4 X- ^7 m( H9 R$ B
/*
8 b+ y8 h% G$ w5 F" \6 ~
* Check memory range for valid RAM. A simple memory test determines
* D5 B6 M) f2 [; i: P! x
* the actually available RAM size between addresses `base' and
3 T3 K" R" i! M0 e" T( |
* `base + maxsize'.
5 G; b. j5 Q; Y' G+ h) r
*/
8 t$ W4 r/ [) l/ ], u
long get_ram_size(long *base, long maxsize)
" P4 v% a* \: s# W
{
- i$ @1 v' A2 @1 F
volatile long *addr;
* _& V+ `. j" n
long save[32];
; x% _& `# p" V }
long cnt;
^# V: P5 \6 R) i0 F
long val;
( T5 _4 {9 t8 `% ?
long size;
7 ?; ]7 c/ h1 z
int i = 0;
4 m3 Y$ ^9 D- ~: h/ f' [
" U/ _/ t: F: t5 V
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
n6 n2 o6 o7 t, e
addr = base + cnt; /* pointer arith! */
8 c- I* q! R7 G+ p
sync ();
4 |4 \% h: m6 V" X2 ~+ L
save[i++] = *addr;
4 c W* L0 u; ?' @, w' A
sync ();
% h! Y( _+ c4 V( f3 Q5 d/ ]
*addr = ~cnt;
0 G1 |1 H! Z9 M
}
' n" _5 X$ J l
% G4 `9 \! f; K% M+ l1 F* c
addr = base;
( ~: G& ~4 Q3 j3 I( i- R# _* E
sync ();
; v) _" k) J* h8 b0 `1 R6 ?( E
save
= *addr;
9 [/ o" A8 K" u5 L- _6 ^ A/ q
sync ();
. z* R: v! g' @4 ~4 b5 b5 [% }
*addr = 0;
8 L, m: l5 y* E2 E2 r- F
. d+ e1 ?" L8 p, f0 J- c
sync ();
- H3 g) Z* ^ s* r
if ((val = *addr) != 0) {
- O( p. T+ K( U5 S8 d0 l# x
/* Restore the original data before leaving the function.
2 N5 s9 j( u* m& x1 U8 l
*/
* c7 e" d! L& P# G: s6 V' n( F( h
sync ();
Q1 L2 B! g3 L/ l2 c* [
*addr = save
;
& l1 u( j- N+ F
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
/ R4 b0 T! n& F' \, N! h4 l; L
addr = base + cnt;
/ V' K# y9 _& z; L3 r) P
sync ();
" n9 A/ U% z1 w% w# l8 u5 e
*addr = save[--i];
4 [1 D! k1 L* S- o! A
}
* N" b0 \/ F; P8 l7 r; j* o
return (0);
$ m. T1 J4 l% R4 M: y' ~
}
4 a3 A5 |5 O5 p# ~
' w. z1 F- D' ]3 R G! |/ P
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' F) c% X$ O% [# }( T% @
addr = base + cnt; /* pointer arith! */
$ c3 @" s! Y6 d; _" ]( S) A
val = *addr;
5 x i8 l* X+ D1 m
*addr = save[--i];
) n8 @) M+ M" O8 @/ a) G
if (val != ~cnt) {
' V; C9 R$ @) h
size = cnt * sizeof (long);
3 z$ U2 U! u, F0 Q, u
/* Restore the original data before leaving the function.
: i3 A' k7 S: L% S/ p1 Z$ D7 f
*/
! D3 g' j8 I/ e4 N" d+ `
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, ^+ J5 x* [/ q) J
addr = base + cnt;
2 |( _$ f0 n/ m, @; X$ k
*addr = save[--i];
' N8 g) ]6 l1 w! N0 e+ I2 h
}
3 U& y5 S& c1 z8 J& H" ?# f8 F% s
return (size);
" i8 I& `) S2 M0 b* _8 O
}
/ _% T' T' E1 \: m# T
}
; ^4 S& z6 i3 u
; E+ s. S+ W/ l1 @6 j
return (maxsize);
5 a4 S# ]6 C! ], h: E
}
$ Q: M* N$ \& {. f2 ^/ ^9 y
int dram_init(void)
7 T% y! U/ R. b: }& `3 w
{
; m1 {" Q5 Q. _2 H: c
/* dram_init must store complete ramsize in gd->ram_size */
9 ]- G5 `3 C1 s/ E& O' s% F& f
gd->ram_size = get_ram_size(
2 ^3 g7 v% l% t2 f$ C* |
(void *)CONFIG_SYS_SDRAM_BASE,
0 Q% A( R- z1 k/ k; w
CONFIG_MAX_RAM_BANK_SIZE);
9 _; D6 S2 t. c' g
return 0;
$ N0 t+ b: H2 ^
}
% r9 s6 Y, c2 [9 x7 c1 [- i7 O2 b
7 Q5 X4 ] ^% p& X/ N! L
2 E1 ~" n8 k6 D# E+ D3 U
7 v2 J1 B( l" X, c! H w2 w
, M0 ?1 ~2 k: i( i
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
1 Z& G: [ i- i
8 b! z; r* ]! z- P7 t
' [1 v5 M& M! j6 y3 m9 k( L1 Z
6 I: p3 k6 ?( x6 \& E) w
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4