嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
- N0 C" ^+ L8 j
核心板2:DDR2 256M Byte NAND FLASH 8G bit
7 }5 O" Q5 z3 z# C
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
4 l: ~/ r1 G. F) y# _" _/ b
% T S) ]* P4 ]* f1 E3 C
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
6 C! ~5 O& O/ T# G2 h( t; b$ F
% I# Z0 c* k+ [" c( H* f9 E
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
; h4 \( Y) K; o& \9 L* U* K* E, K+ m4 Y
/*
- N! k, K7 @0 d9 j' d
* Check memory range for valid RAM. A simple memory test determines
0 B, y7 U: a4 o5 n7 e+ w9 o
* the actually available RAM size between addresses `base' and
( m$ h+ x1 d, j6 D& W
* `base + maxsize'.
1 w, \; S8 m; e Z H% V
*/
' N- y$ {& h7 w+ _" q/ l$ J
long get_ram_size(long *base, long maxsize)
7 o) o1 o9 B6 y: {2 c
{
3 \2 B/ g# N6 x+ ~0 ~
volatile long *addr;
2 i( ?, q5 _# p' F
long save[32];
# Q% Z5 ?* O3 [6 m
long cnt;
2 p* F8 q. @7 u! p. B
long val;
4 B+ ~" f' K+ W- b
long size;
R. R$ C1 Z; u0 P7 y+ k/ U* y2 }
int i = 0;
* V3 ^8 U1 x. @# l1 n* n4 W, a
' Z; l6 O- I. T. P; V/ R* E8 o0 G
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
' h7 Y) A: w$ s s
addr = base + cnt; /* pointer arith! */
. C+ i. @$ r9 H7 k- G, A/ ]6 L
sync ();
|7 T3 J; v0 R+ V) r* F& V
save[i++] = *addr;
& F' o9 r3 e% _' _8 d8 U
sync ();
; y! k7 p+ Y1 w$ i8 P! a( F* R, i
*addr = ~cnt;
$ @4 q1 Y7 w8 c: b
}
7 O& ?$ p" N/ j% G! a" j' w, W' u
4 {" ?: z' V5 Z3 k
addr = base;
/ G8 i7 x$ B& J: \0 A
sync ();
) j3 `5 F4 y, A; u$ ^: H
save
= *addr;
. m9 B; E9 \. g
sync ();
; M# \- n* I/ B" l( B" q6 p
*addr = 0;
- a9 y4 ], }! _& _ Q
+ C, ], N1 M' |0 d0 M
sync ();
6 m( @- E* k6 m* u
if ((val = *addr) != 0) {
4 V3 I1 c8 @" |
/* Restore the original data before leaving the function.
$ j5 ]3 Z; d6 X
*/
1 v+ P/ ?1 r, }& e
sync ();
: P5 n4 |2 @5 g/ s) J, |* X* o; p
*addr = save
;
. ~' c, L% L; u; U; G+ h( N
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
; Y5 U ^( |9 J; {; [ l
addr = base + cnt;
0 A- O+ ^+ |* W2 m
sync ();
" Y! R' \+ d* U8 d* `: W
*addr = save[--i];
2 z! Z C% i4 f
}
C7 |) g2 j: N* F9 T3 o
return (0);
1 B4 k: G; u; r& j6 ?; P
}
3 i9 S* @6 d; v: E
% W: l# e/ w9 a' f" U
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
4 q9 v8 B4 [! i/ _+ I+ R; f
addr = base + cnt; /* pointer arith! */
2 ~0 j0 u8 G. s* ~
val = *addr;
% c7 d& k2 l4 b
*addr = save[--i];
7 e3 K9 f% p/ V3 `5 S$ b6 @
if (val != ~cnt) {
9 ^& o+ L( X; r$ r$ l9 d( `
size = cnt * sizeof (long);
/ I L8 k. h n: i
/* Restore the original data before leaving the function.
5 [( c8 s7 K. ?6 S; C
*/
! c$ @7 k0 K e
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& p0 v9 M. J" K
addr = base + cnt;
9 E' u: E5 i3 O5 f3 F; B, w
*addr = save[--i];
, D2 q; ~+ U6 c+ _& h5 s' b" ]
}
5 y, B8 Z& C( W9 k5 q. K( W+ J6 f
return (size);
' `6 M) g9 H5 G/ s5 c4 W6 t* b
}
4 z" ~" n0 k, A. w3 C( A
}
( j6 u1 `: ^" V# n4 V% l
7 l1 w1 z( w% ^' P% J
return (maxsize);
! G( H, o' i! x/ K
}
0 R4 b& ^" D6 e% _. L$ U
int dram_init(void)
; I- r0 T! D, f' x' e
{
# T& U8 q8 D7 h( [4 q
/* dram_init must store complete ramsize in gd->ram_size */
4 R$ o: P' V& J8 l. L4 K7 P
gd->ram_size = get_ram_size(
; Z0 q$ _/ m8 ?) N4 i# I7 p
(void *)CONFIG_SYS_SDRAM_BASE,
, N2 v. E- j% l& w0 l
CONFIG_MAX_RAM_BANK_SIZE);
2 K5 D+ o+ D; @9 R$ q% G
return 0;
/ k, X ~$ M% j# @4 B, C
}
) s( ]% k5 B+ J9 z J8 ^
X( f; C+ f2 |
* d( ]& Z. ]- j9 {) Q
- _1 A% | P* X
* A3 f' e3 w* P$ b# z
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
( @. w& ^$ \2 P. @9 _
5 t! z$ t+ d- R, G7 S& `* P
; s6 [, o& [8 G. m& A" E
# H- s: z" j7 W% s2 F5 q0 M7 S
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4