嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
+ b2 m5 w- `! P7 H! }$ V5 k
核心板2:DDR2 256M Byte NAND FLASH 8G bit
, i1 B4 @: i8 D f7 k$ T) m( w7 Q; [
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
. Q. s) G4 u; c% k& T
5 s" H& O- S" B7 P/ w9 g6 v! c; z
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
9 {4 y3 [8 y* b, I+ k1 G* V: e4 Q
' h4 _9 C* Z- C
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. V9 _1 }" Z. t' \/ C
/*
0 r3 F: M V+ G% p) n# Q# P4 B
* Check memory range for valid RAM. A simple memory test determines
4 X$ [, a9 |2 P) c
* the actually available RAM size between addresses `base' and
6 x \1 p$ j* Q! R& j5 \
* `base + maxsize'.
: _, F; U- F1 }9 S3 |
*/
/ {; v! i! h% d5 @# C
long get_ram_size(long *base, long maxsize)
( f& _# }; i2 g; R
{
" U6 m+ g! d5 X; m' i9 f+ i' m
volatile long *addr;
& T! P% ^/ Q) [ ^: y; P
long save[32];
) `# ~ X# x. C* r. \8 h
long cnt;
8 c3 b- O) J- |" L, ^
long val;
$ Q- M* A+ e( y8 C+ \
long size;
) e' I- s/ G N+ L
int i = 0;
( u: W3 Y0 G! }4 M {% v# K
. F i! U: e A5 g
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
4 s+ c: L2 V! Z( [. O$ O5 p9 L
addr = base + cnt; /* pointer arith! */
& }, i3 c* k# `* X9 x
sync ();
5 {7 Q3 A6 _" J( k+ m
save[i++] = *addr;
4 Z3 V7 I# H- U
sync ();
5 I$ X: F' g& @+ A6 A5 t: |7 N6 b
*addr = ~cnt;
O- F* p' ?$ q5 Z( h6 m2 E
}
. v6 W8 w. c- ?7 B
# r% T7 Y1 S' V* I+ }& x
addr = base;
2 G d8 L& L1 e) ]! ?" r
sync ();
& p3 @5 v9 C! w, q/ T
save
= *addr;
% ^7 G- q! J* C% T& J
sync ();
) R* ?1 Y8 _! M4 g, i2 g6 Y
*addr = 0;
2 c$ m4 ^, B* ]/ y! z
( t* o2 o; A, Z% e( r2 B5 F [
sync ();
5 |& C% U' u- S' K
if ((val = *addr) != 0) {
0 `$ |" s, z0 a! o& H, q+ X
/* Restore the original data before leaving the function.
. x" I3 B* Z# k0 c1 O. T7 S
*/
, C6 q- m& c n( m. w( Z+ }
sync ();
! y; a, q4 @' a$ b" Y
*addr = save
;
4 J7 L! q! W( v4 _8 o& x
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
1 K( w( b$ o6 D" l
addr = base + cnt;
* n/ o8 V1 ]% y9 P) {7 a8 n/ r
sync ();
z" n+ ~- T& Q/ @
*addr = save[--i];
$ i) c5 g, m6 k, r
}
* h3 U% b. a% O
return (0);
9 ?% E# X6 ~, [* t
}
1 h+ ^. d. }+ i3 o' s! T( r
! E1 F6 O, J+ n) a& m. T
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+ M! A7 o. M( }
addr = base + cnt; /* pointer arith! */
( W5 r- I' C. u. \) K
val = *addr;
% h6 d) {8 V2 C
*addr = save[--i];
) l- ]4 j3 A, n3 ^
if (val != ~cnt) {
* y3 b$ q5 n9 n; q% D5 o1 V8 `
size = cnt * sizeof (long);
: o9 ^& V- y; y/ ^1 A, i( n5 x* V
/* Restore the original data before leaving the function.
9 ?1 |/ C0 t8 l& U
*/
) u- j0 i- F3 u H1 f
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
/ W& ~- N$ C6 y1 }! ]
addr = base + cnt;
! q& w' ]3 c# a9 V/ S2 A
*addr = save[--i];
* n9 `% K- ?+ Z( y: E
}
5 X# o' x; [; @* M. U
return (size);
- `% k, e6 ]; V3 W
}
& [. S$ s+ r; A& ^1 J7 j. S
}
) B, `; Q2 a) o& E" S
0 S( f* F) P+ F9 V
return (maxsize);
2 b/ G# Q4 ]7 J& p6 N
}
% c5 c0 k0 N9 B- H" g8 o! t% g3 s
int dram_init(void)
) T4 [7 A0 K& @/ p, N
{
0 ] {3 t; J- V: @2 z2 i) W
/* dram_init must store complete ramsize in gd->ram_size */
3 P6 q5 H& e$ H7 z6 T
gd->ram_size = get_ram_size(
' P( ?2 k8 O' G5 }+ ]
(void *)CONFIG_SYS_SDRAM_BASE,
! F& H7 S# M& y$ M3 {+ J" V
CONFIG_MAX_RAM_BANK_SIZE);
1 M. g. a: x+ j2 y2 ^$ [. K& h7 N; O# e( |7 o
return 0;
; h- x0 ~& b l8 R5 y
}
0 m) {* W+ ?: C6 V
4 ~% I' U( M. K# m- ~( x) I1 F$ m
! g$ ]8 w. V" o1 Z; k% Z3 `
6 m4 Y8 n7 w" }4 q
( V0 e" H9 x/ x, s4 F1 S
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
# ^" f4 E: @) \: K
; q; w2 c" ]( R; Q
% i1 Q0 x. W4 U, X1 c* ^1 v
( R, M! C9 H$ X9 _! J
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4