嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
: W( o9 u9 M! T P& C
核心板2:DDR2 256M Byte NAND FLASH 8G bit
+ Q3 ^2 y; Q$ L- D/ O
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
, T7 K+ Y0 u& s
6 {) k9 j6 X* o# _3 w9 I% v% {, b7 U
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 i8 R! j7 E+ a0 E( S
$ T! |; A) W ?5 q( g2 D. Z7 P
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
0 W& @' d$ e4 T* B, u7 k
/*
7 @) M' y! T! R' T# \
* Check memory range for valid RAM. A simple memory test determines
6 R6 _! d4 v$ u8 X( v- [2 Y% [
* the actually available RAM size between addresses `base' and
* [9 s; ~2 B; s
* `base + maxsize'.
$ T6 ?) A+ L/ Q- ^) h5 w8 T
*/
. L" n: B' i2 A( o
long get_ram_size(long *base, long maxsize)
+ u$ Q6 ]' n! |9 x8 }
{
. `; |% P# q* V! a3 R& V
volatile long *addr;
% S# D! O' d0 J! ^ a, F
long save[32];
! E% h. F# s0 d: x ^1 I. I1 I+ b
long cnt;
6 v( L- k( L! a5 v9 T* }- R
long val;
- r, F' f1 J/ [) i" m& B
long size;
" _% ~4 d+ J, e) N; b
int i = 0;
$ b7 {% w8 A) ^8 ^
+ A; | {8 ~2 _! L3 Q4 @$ O4 {1 W
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
L/ a: ^ D, t% b: ~& h
addr = base + cnt; /* pointer arith! */
7 {7 V; j; j5 [, T5 A* I" l5 O/ f) ?
sync ();
8 Q/ {/ A4 w+ `9 l" z3 F0 l0 k: @, h
save[i++] = *addr;
# s7 ^% `6 y& i* z; Q7 [
sync ();
% n/ F' h- l& F m- C1 @4 F
*addr = ~cnt;
9 \' I. ]1 \+ N3 D5 }, @5 A6 K; z# R
}
; B7 V4 ^: N$ C0 i5 X5 c# }3 R
, u) r& ~. `7 d/ F7 b# V
addr = base;
: Z" m: I, l9 p8 D9 D d0 p% @
sync ();
6 ^ `( A0 H) Y( ~
save
= *addr;
. \/ ?" J( J3 |0 u9 z' ] w( S
sync ();
! L; k- p' e0 l% {- l5 F% ^
*addr = 0;
* M) p2 N, ^* \
- R; T/ J1 w8 Z- @, V3 C! W: K
sync ();
' ~$ K3 S9 |- s& {% z
if ((val = *addr) != 0) {
4 F' X% K0 K1 P" M6 Z+ D
/* Restore the original data before leaving the function.
0 {% s4 N9 B# s C
*/
: X! z! {3 b/ f
sync ();
6 I' y9 o" a: Y) Z* r! [1 N7 d) T
*addr = save
;
. Z$ J- x9 `0 \& K+ p
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
3 X9 j0 K- B4 D p; _
addr = base + cnt;
$ h# o% X+ p% L2 i- z: u5 f
sync ();
' Q5 {5 h9 N. K$ K7 \
*addr = save[--i];
, t2 j% z. m7 ?1 T8 j+ j2 I
}
$ z8 _4 b5 y& r, ~2 _6 [& }
return (0);
& B+ `, s# M8 d. [1 o
}
) w/ R! _' e1 I+ A
) Q3 o, K/ [! C
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, k6 y9 B! g$ | R7 s- }# A: h3 w
addr = base + cnt; /* pointer arith! */
% `5 d( i! ^1 A# p
val = *addr;
% C# r4 |6 |5 A1 i8 y' Q
*addr = save[--i];
; P( @* h7 V0 m9 V* y6 j9 d; ]
if (val != ~cnt) {
( y2 I: u/ P2 ?/ z* M7 i) i! p
size = cnt * sizeof (long);
- v* f$ {" D/ k- D
/* Restore the original data before leaving the function.
% G3 W6 V+ W7 L% G2 V
*/
5 N1 f- b% |9 G" _3 G
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- q- I& w" r! M
addr = base + cnt;
/ O; t" g5 g$ P5 |( m% J0 `
*addr = save[--i];
) h% y. T# q$ L1 [
}
! A; [( }( p: B& b8 J$ F& f7 {
return (size);
% z0 k {" h! d& B2 W: c
}
" } E- C& J: n9 |% Y7 B
}
$ W; w4 M3 [$ s$ H; j
7 w/ C: B/ w* z/ |0 Q [
return (maxsize);
. T5 W* d6 v V2 @; F, R
}
+ `5 X( c6 z W0 e- ] r( z( @1 d
int dram_init(void)
- Z8 n. l; Z e9 w5 E4 ?# t, M: G
{
) M L; B2 w3 m+ K) ^* S
/* dram_init must store complete ramsize in gd->ram_size */
$ ]" Y5 Q& e: x+ O" J; s
gd->ram_size = get_ram_size(
, C# V* T5 o- I/ r
(void *)CONFIG_SYS_SDRAM_BASE,
; V' G" ]6 M4 V9 g5 M. d
CONFIG_MAX_RAM_BANK_SIZE);
! E2 T x/ r! v
return 0;
! `) ?$ a- B9 \) O. @
}
0 Q/ K b7 ]4 l9 N
0 X6 _, n @* r& P0 u) G
3 _; r2 P& ]+ y. W) H! J
. F ^6 A$ b! ]) S2 |4 S1 j
( T T$ I& P1 Q$ q6 ?# D
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
2 f0 G5 `- c$ t! G* `
5 {+ S& ]2 Y/ {+ H5 `2 D
' L' W5 e9 {9 x* V( t1 K8 W6 i
4 q: X+ w! w; r% J
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4