嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
/ E* A' ~& n& O7 N
核心板2:DDR2 256M Byte NAND FLASH 8G bit
. O6 ^; D% V1 z' u
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 Q0 B2 H* j) ?3 }: K* b- X
% T4 @3 Q* L! _& J
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
* R/ j6 Q6 G( A" l+ D. P! _
: f2 M" e0 V: O% K' s, O8 I
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
' B5 j( l, ]0 D8 ^. h- g1 ^7 M
/*
; |0 v7 |& E; H+ J
* Check memory range for valid RAM. A simple memory test determines
. y: X0 s$ U+ ]" i6 F
* the actually available RAM size between addresses `base' and
/ B% J3 Q7 d+ c; N) y, a7 _3 B" b
* `base + maxsize'.
: f9 V2 V3 X0 G
*/
* P+ A' U: C Z* B1 y
long get_ram_size(long *base, long maxsize)
/ N* q# r* i6 L+ k
{
! @; j- i; k+ ]2 V; H
volatile long *addr;
7 g* \; V' g1 h. p R: N( O
long save[32];
9 a* C0 S5 L9 L$ Z% l- T4 j7 G
long cnt;
2 a/ F ^6 s4 A8 {' K2 K7 c
long val;
* u8 L/ m `; m5 m W8 _% s
long size;
; _, i6 x' u# z1 `
int i = 0;
& O3 d7 [0 T) s; V3 D: o" q
/ P* ^. V) s! ]: ?
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
- z4 e4 y" f, K6 M4 E! p, D
addr = base + cnt; /* pointer arith! */
- p7 T' h: n B$ V0 Y: M6 |+ F
sync ();
: ^7 i ]: f @7 B3 x4 t$ j
save[i++] = *addr;
1 ?, H. [& U8 o" e: p
sync ();
4 ~, d( B9 }$ U
*addr = ~cnt;
/ K+ E: T$ F' O1 K
}
2 H3 p0 ?$ e6 L6 V
# v. S# B1 r$ r' D
addr = base;
3 z" I+ j6 \8 G5 U& q+ R2 L
sync ();
# Q% K4 e' a8 J. {3 e8 q; S& f
save
= *addr;
3 `) D+ X9 c8 v
sync ();
S! m" M" z9 N
*addr = 0;
. I+ K5 o/ m, C( ^. N
) z2 P9 k; e/ W2 J, c
sync ();
1 X& V$ @- D7 ~' K
if ((val = *addr) != 0) {
& P) _% V2 v7 d+ ^) {4 \8 s
/* Restore the original data before leaving the function.
8 d6 @" K! b, X+ \, n
*/
* O9 @! S, p1 a/ |5 ?
sync ();
2 ]/ y, @4 f7 @2 A3 i
*addr = save
;
# T* `+ s+ Z7 v
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
Y1 N; g) V- I8 L
addr = base + cnt;
. V& r$ ?' W' t \2 ?, \3 O. r+ `3 S5 J3 g
sync ();
- @$ G h, ~& f( H6 K
*addr = save[--i];
# o! R. H6 X+ Q* U. _* p2 ^
}
+ ^( X9 A" A; O0 Z7 l
return (0);
) F! T7 y6 t- `. a9 g
}
' H# M$ {2 t4 Z. s; j
9 A0 e2 X8 f5 l# T2 n# b( g c
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" b+ h8 p- [3 ]' N# G) D
addr = base + cnt; /* pointer arith! */
9 `5 Z# [ f& w" y! |6 C& n* Z
val = *addr;
8 o9 \4 i. A1 z3 T/ ?. ?5 T) [; y
*addr = save[--i];
! h# @+ R; n1 [* _% Q. P/ Q
if (val != ~cnt) {
' o3 N) x6 u$ ]) g
size = cnt * sizeof (long);
- g: o/ @8 g& S2 p: J/ j# a
/* Restore the original data before leaving the function.
' U l5 ~5 m" ]! }# K6 X1 y H0 Y
*/
4 \" }) A5 U# ?/ s! s9 V p2 S) J
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
# O! N2 ]$ O8 x. v# e
addr = base + cnt;
$ g/ h' Y8 w; r& C
*addr = save[--i];
! }, G- m3 b' C
}
" J u) d- d" ?% w
return (size);
; q# E5 R: R* _6 T2 P4 G
}
0 V7 t& ` I5 l1 ]# k
}
( Z. r& B' E; R* s
( L) P4 v4 T D# k0 Y3 X) S9 W5 s( {- Q
return (maxsize);
) S9 |; q# d. b' B8 B5 ]6 H
}
: V! C% d# N5 D( }% J
int dram_init(void)
1 N9 j; b) h, {& ?$ r4 h7 W6 [7 b$ ]
{
9 ^- y' `1 i, ?: A. s# r
/* dram_init must store complete ramsize in gd->ram_size */
- [5 z0 T$ j' ~/ e4 [; [7 ]
gd->ram_size = get_ram_size(
0 }0 O4 L# w3 @- D4 R
(void *)CONFIG_SYS_SDRAM_BASE,
# o5 l D2 z+ \2 j$ P4 l% K$ z( b! G
CONFIG_MAX_RAM_BANK_SIZE);
. I" A; i( S0 I$ p6 `6 U
return 0;
# m" h4 o6 Q; `8 g
}
# P8 f% G( v* @0 B
; j& i6 P( C5 w
/ }* `! Q. Q+ M/ j) \
' H- G! k4 B. u7 i' {
% q* A& E8 J2 T1 y6 {; c
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
2 U, i7 L* z/ [- X& t; W
/ t' n6 [! c4 A, S/ t9 n, F5 T- B( h
. H: Z. o/ d$ m* _
4 B v7 n# M! ^- N( C
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4