嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
& Q, t6 u* n# q& d6 T
核心板2:DDR2 256M Byte NAND FLASH 8G bit
. J ]; F5 L% K% w- |, q: {5 B
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 V v; k) _0 _% s8 B
$ H& _7 j. r$ L- j3 R8 q
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
( D) {: b) \1 c# D2 G% ]" A* o
1 f7 C8 x9 _9 q4 {3 \8 [
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
2 k9 }: r7 s2 l/ k$ A- q/ I
/*
# ]& [- y3 w, N& B# V: O- H, s
* Check memory range for valid RAM. A simple memory test determines
5 M1 S' L# b% A, C! {& j3 A9 H
* the actually available RAM size between addresses `base' and
' m2 }7 C2 A1 G+ W6 u
* `base + maxsize'.
/ k5 H7 H4 z* J; e$ }
*/
- Z( c8 ~( R! {9 R. R, |
long get_ram_size(long *base, long maxsize)
# M( f! w h$ ~2 j+ b: C# e
{
7 ~* B7 j- S' K/ j
volatile long *addr;
$ D. V/ z5 C. g) X% ?
long save[32];
2 `+ m: e% i5 i% s
long cnt;
2 n7 l" W6 S, l+ F
long val;
8 t/ d3 S2 Z$ F" c
long size;
5 o# ~, p( @: y* R% O
int i = 0;
6 v2 h+ C; I2 z) t0 I: f
! t1 ]% L3 n! ?& P3 B4 g
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
0 i" ~$ L; {7 V
addr = base + cnt; /* pointer arith! */
* U" s" |0 t( U. E# n" X6 R
sync ();
) b6 a7 T* q0 C7 A
save[i++] = *addr;
- @ F& C2 s" X0 A2 j4 S/ X c
sync ();
% \$ e) [, Q+ h/ v, K& r
*addr = ~cnt;
6 S4 P# [0 N7 P6 }
}
3 x4 e2 s' Y; F2 Q, Y/ c/ m) a
8 J" f9 w3 n+ G' @
addr = base;
) S* L# Q( [3 s9 [! ^
sync ();
+ [( F# R/ C( I1 {% o7 C* V# m
save
= *addr;
& w. Q; ?2 J+ v2 O& s# s
sync ();
: B" d7 U! y5 |' h% R. @* K
*addr = 0;
4 i% p) V' K* e: q- u8 E
2 P1 b2 L3 g- I' i' x
sync ();
2 ?3 R* T, E! x% b1 p _( T1 O
if ((val = *addr) != 0) {
3 A" m0 E! _9 ?
/* Restore the original data before leaving the function.
& x, M2 o; U- w; \
*/
3 V% ^: l& P4 z; p' e# a1 E0 n8 s
sync ();
; _, A+ [9 F4 |' G+ n- u4 C9 l' z
*addr = save
;
- C& H$ S! F' I2 ~$ X
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 a* W+ b- R, |. N- i
addr = base + cnt;
( v, @% d- Z; l) a
sync ();
, ?# g j& R. z1 j n
*addr = save[--i];
a7 Q. D' A9 u O: p7 z
}
; N) Y+ _' e+ \0 j
return (0);
( g7 \1 H( \0 o& @, n* S
}
5 {* y# X3 O% |7 q& A4 g
/ N5 R% N6 i9 ?, x2 j8 |1 Q
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+ l+ }. s, x$ ^: y! _% ]
addr = base + cnt; /* pointer arith! */
$ Q' F$ z' N; r- K7 ^
val = *addr;
2 ~. g+ w6 ?! H3 R* K; f
*addr = save[--i];
, S- Z8 U8 W4 v: n+ \$ d
if (val != ~cnt) {
$ h, G4 M! A+ L( E5 O
size = cnt * sizeof (long);
4 [" _. _6 c/ G4 V/ h
/* Restore the original data before leaving the function.
9 \ _& [, J& ~$ R/ \( ?: D2 G
*/
. S$ |( ?7 S3 C r+ c- r6 e0 m
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( D$ U% N( l0 B( D% D6 _ E
addr = base + cnt;
0 l# n6 }0 F! G! r& x `
*addr = save[--i];
0 j9 U/ r% N- O+ |) E
}
& h% I4 ?( B; A
return (size);
& m! \9 k7 x% a2 e
}
+ Z- w% t, z% G5 c; w
}
" }' O& w8 p7 @7 d' O
# [/ I" {0 x' j+ N
return (maxsize);
* P' F) I0 y5 W' p6 s \
}
3 A: {; a, `. Z
int dram_init(void)
8 C8 E& U/ C8 ]0 S
{
; A3 R" {" S+ T- y( |3 J" Z) T/ O
/* dram_init must store complete ramsize in gd->ram_size */
' k N+ P2 e7 d, n" K+ E* a
gd->ram_size = get_ram_size(
3 r# x+ o) x9 M- c4 |9 C
(void *)CONFIG_SYS_SDRAM_BASE,
$ k( D! [# h$ y4 ~
CONFIG_MAX_RAM_BANK_SIZE);
0 f# [, f }* ^5 Q9 I3 @
return 0;
: r9 Z) h& I8 j/ l: H
}
; P X. z# h' |# Y- u7 h3 J+ [
8 g( x: |1 E) i9 u% |
3 n% S2 c6 W$ G+ H
5 W z. e8 ]6 _4 k0 w
0 C* T' L# h$ j- m5 ]. E- V* t( P
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
5 ]" W5 P# B4 \2 o% M
" M% k$ p' s m% Q8 B6 n( `
9 i" d* i' t1 i/ M8 v" W* \+ Q
; F- c$ G* A$ _; G" z2 f5 P
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4