嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
! A( a8 @# Y2 l: T
核心板2:DDR2 256M Byte NAND FLASH 8G bit
6 C% S' b2 B( S+ }% z* C
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
2 w: i, w8 s4 E/ D0 `, Q
; W9 x# w, i# h# i& p
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
, |6 T; |3 A J z* P
9 F. _, D* \6 l/ Z5 \# H
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
0 h: l& G+ R9 q7 V0 A) `- ?
/*
( m% D# j) D0 L
* Check memory range for valid RAM. A simple memory test determines
9 H0 X: M& o( l5 \1 P3 `
* the actually available RAM size between addresses `base' and
/ { V O4 [! \4 u% [8 g7 Q o! Z
* `base + maxsize'.
3 ]2 ]5 ]3 L5 N+ \8 i9 {
*/
5 C' M3 t. K8 J- V
long get_ram_size(long *base, long maxsize)
4 @, c$ f9 v' K: L) w) g* f6 |
{
5 M+ H$ `7 `7 \+ V# p
volatile long *addr;
- x7 }5 k+ j }) D4 d
long save[32];
2 }. e% k' R* p5 R
long cnt;
" z5 d% m( V' w. k; Q
long val;
! ^& ~1 o' g, t, j
long size;
8 j/ [! n4 |6 ]& M
int i = 0;
) w3 U. y3 C# J+ T* f8 w: D' j
/ |3 r4 {* c2 J8 Y0 B9 i! k
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
2 l0 Q6 e- O$ X# _9 D- P* \' Q
addr = base + cnt; /* pointer arith! */
# L( P* j. z: B ~( k: R7 x5 f
sync ();
& V. u X. @1 t2 ^4 ]
save[i++] = *addr;
7 d( h6 O3 a* x" R9 s
sync ();
1 E% ^8 E5 u) a \0 M+ O- T
*addr = ~cnt;
! U/ f& M( R: d
}
* d/ P- A% ?2 v: q! l* Y& ` T2 r+ y
. O- K1 P2 T0 R8 S, I8 [8 Q
addr = base;
9 h( c1 v4 @4 c+ G& U t
sync ();
8 U, i9 E) n+ V' x+ j ~
save
= *addr;
+ w- Z3 r6 V. Z. K/ C' |
sync ();
$ ^3 y! P3 r2 I1 G7 k9 x
*addr = 0;
6 [7 K [# D& s
# e( x' ]% d& c' u, n5 X5 _
sync ();
2 H3 n% q0 y: v- ~: a
if ((val = *addr) != 0) {
, {# u* i7 ^# v
/* Restore the original data before leaving the function.
' r2 m( |! a- N2 [. }' ~
*/
: v9 P# j8 {& W7 W0 p4 P' n
sync ();
) ^1 ]. m9 @8 C0 G
*addr = save
;
+ s7 s( I' g/ f" B3 C
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
" {# f* A" U" D! f5 d3 f5 U3 C
addr = base + cnt;
1 {; E' b i9 e) v6 a
sync ();
% P2 k! P' [. F, P/ C
*addr = save[--i];
+ m) a1 e+ o, i* v9 k1 Y* d/ Y
}
, W/ D2 d, F# i
return (0);
! s0 Q2 X: v t. Y7 M7 D8 S
}
6 x5 u0 C0 ^, s* E9 r0 i
9 j- o# r. D1 J3 h
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
8 j4 j. |+ |0 a% n, C
addr = base + cnt; /* pointer arith! */
+ X- W# V( _2 `1 l2 ~
val = *addr;
- P+ F" a/ n) ]* h: q: F
*addr = save[--i];
! H$ k/ a0 Q" ]0 \7 m2 t) C. i
if (val != ~cnt) {
0 f- }" C5 p% e
size = cnt * sizeof (long);
, }0 P7 N3 k" d f0 _, b
/* Restore the original data before leaving the function.
5 F; r( F, e* `6 c7 t: W
*/
7 h, D/ D2 b- L$ L c
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 J! s& Y* z+ V1 z a
addr = base + cnt;
4 G( X! v8 Y5 _. c7 U# d
*addr = save[--i];
+ u% f. L% O# b2 V1 |
}
' `# a+ s! H1 \
return (size);
/ P* n# A! r# `* r m: T( v+ u
}
3 D# b1 i' E! l
}
3 q2 W0 m# Y' \! K$ G' ^$ ^
2 z8 z# d8 C+ }1 q8 z) a
return (maxsize);
; b) B9 h5 k$ Y4 t" Y* ?
}
8 ]# C( `- \; f5 }; D1 T$ a& \
int dram_init(void)
: F5 L, B, Q' Y; Z" A: P, R4 t
{
( p( j9 g( Y$ Z/ j- [: {
/* dram_init must store complete ramsize in gd->ram_size */
# `+ `5 V$ C. p/ L9 A
gd->ram_size = get_ram_size(
+ t; U0 ?2 p6 ^0 c j
(void *)CONFIG_SYS_SDRAM_BASE,
/ _, D, u# }( r# K" c' q( r! k
CONFIG_MAX_RAM_BANK_SIZE);
% p0 q9 O2 b+ o
return 0;
5 j Y. Z1 B ^6 r [( G* c
}
0 ~3 U8 Z$ _* O" e
; C/ R, ~+ b* p' c! U: X; Y& ]
( Y$ s: e6 X5 d+ b2 ^% m
2 |6 O) q4 a( K1 ~' `1 R9 f0 [
! B) T9 K4 a" z U
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
! o- y. M+ G! {3 O. y z( ?+ I
( X. Y% B9 G. d" O6 \* b9 z
. }+ h8 B. H, O) O+ z L. K
0 ^) E1 B! \2 E) Q' ~" ^
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4