嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
* ]8 |! p0 e& L
核心板2:DDR2 256M Byte NAND FLASH 8G bit
/ O+ a: U; o( a( D! C
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
A6 ]3 Y: M5 k
: W0 k+ _3 r4 M' V0 i
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
( H% n9 I# O+ j1 a1 e5 n/ t
v5 ~9 t" e" E) u( r3 |( F' |
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
1 A8 s4 n2 ~ y2 e2 a3 _! e
/*
- H: E' W, s" ?, p } L, T6 i
* Check memory range for valid RAM. A simple memory test determines
. O( @/ f2 b8 {8 `! V
* the actually available RAM size between addresses `base' and
/ l/ f9 V4 J c" P5 s8 W
* `base + maxsize'.
# j: j) W& R/ }1 G
*/
' Q- V, F V' C! F0 f' e5 O
long get_ram_size(long *base, long maxsize)
2 ~3 n: G2 e& P' y; N t: w; p
{
! P2 p0 p. l, J/ z0 ?, z- v
volatile long *addr;
' w! N8 w; Q7 R
long save[32];
; [8 {5 J0 m8 v) f. q, A4 X7 S
long cnt;
" e* Y( |' d8 B) f4 ]
long val;
% `. T# v9 u K; z
long size;
9 w4 x$ V* ` I* g, ^
int i = 0;
6 V) G! W- k" k4 @) B6 V/ \
$ @. d; U3 d8 @/ @. v+ E5 {
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
- x( j% V, |! `
addr = base + cnt; /* pointer arith! */
+ p; @# E( z2 ]8 x
sync ();
" X% E( }$ Q* e& {
save[i++] = *addr;
, [' d1 g7 k: y' C+ g
sync ();
" [$ f6 c( V8 r
*addr = ~cnt;
1 {. [$ A! ^$ H* `" o9 g1 U5 [
}
- A. ], m. n" P5 ~7 k( t
2 U+ y5 R5 w2 p$ X4 F8 P
addr = base;
0 S P) Q; P+ E3 _) S' q
sync ();
8 x& h$ a' g0 X
save
= *addr;
: A% O. H6 i$ X9 n3 |8 @& Y
sync ();
+ b& B& O8 w8 U
*addr = 0;
1 C% o- z) U6 |# ^+ A5 N3 G, k8 U9 @
5 Z2 E0 A* P9 z+ y4 `, \# _
sync ();
; H: g8 U$ H) Z, M( r: Y: F& J# }, o- D
if ((val = *addr) != 0) {
1 w+ c, x! j+ Z3 ]# \5 a# i
/* Restore the original data before leaving the function.
& c2 S8 }& Z1 G/ [$ u% Q- V
*/
* g$ L6 Q- P+ Q3 c, V3 o+ p) n
sync ();
: D% u+ l+ P& ^8 \+ c6 M- d9 m: F) K
*addr = save
;
: E2 q: ] J0 C0 K
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
% q" l+ g. ~; ~2 ~7 ]' `% ^
addr = base + cnt;
0 m, V9 X" l" \: V% J
sync ();
6 N5 G8 \( D# \ `
*addr = save[--i];
. {' e6 F0 P4 k; r
}
. _0 m* u; b0 S/ ]. `7 K. `3 `
return (0);
2 @5 \: [9 E' k; G! C/ L3 m
}
. R: r: \+ q. N- a
/ [- K/ u5 o) T7 v ]8 C" _3 k7 M
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 r5 P) `& U7 l7 i9 B9 F7 A
addr = base + cnt; /* pointer arith! */
9 B* b7 ^2 U. n/ ^+ ~) C, c7 j( J
val = *addr;
: O5 w8 H# N. i; U- H0 a; Q, G4 d
*addr = save[--i];
p4 ^+ z$ P* n
if (val != ~cnt) {
R: f+ r" f6 I. G2 \1 B2 Y
size = cnt * sizeof (long);
% `. ^: K6 R; U. ~4 @2 {; u
/* Restore the original data before leaving the function.
$ L- m7 V' [* j
*/
) a8 J. b9 n- i* v3 ~/ g
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" j* z4 l) g% b0 C" ~/ T
addr = base + cnt;
% x3 e1 j% u! j$ `% v
*addr = save[--i];
& s! x1 p3 T+ l. M7 K- g
}
* [# g# j, v0 C- @: `
return (size);
* C( q1 e- p3 }! R- e! t
}
! H7 W5 B9 z6 k7 }* U7 _
}
, ~" w% Q/ B: h* M$ L
5 W. D: q8 E( H4 X+ P0 T/ B
return (maxsize);
- ^. A9 |# ?1 l6 _' X5 i
}
' T1 R+ [! s9 |# G! w
int dram_init(void)
* N* B3 }9 l: E7 @6 _
{
! J+ D4 G, i6 M+ i
/* dram_init must store complete ramsize in gd->ram_size */
( e' F# d8 d% ^9 h0 h) J2 {
gd->ram_size = get_ram_size(
3 Z; T( s4 Q, L. k
(void *)CONFIG_SYS_SDRAM_BASE,
1 f+ Q& c, I; O0 Y7 Y
CONFIG_MAX_RAM_BANK_SIZE);
* c% p/ U/ W+ u
return 0;
. N X" |( U4 P, k4 h; w6 b% G" k
}
5 O/ r7 `, H! S5 {! F0 w! J5 D
; y5 T( A7 b/ E( a f
9 N5 e+ m( s% r/ y+ ]6 s; x
6 R) ~' G. C9 W- B5 s
+ T' x; y4 I1 t1 u N7 M5 U! Y4 B4 ?
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
' H5 L j8 [5 S* s& q
6 Z( l: k$ @3 |* p
0 y- [& q2 m" V( ` S
( [- E- n+ c1 s1 U/ ]; ^
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4