嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
. b1 i7 F! D% T- [8 U) T
核心板2:DDR2 256M Byte NAND FLASH 8G bit
+ m3 y2 Y9 H, T6 m0 s7 o
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
+ I& M* V/ a. N7 p( @' V* F2 {& d
: m& C/ T. ~. |' E+ G1 X
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
O- r3 J) S. \3 B" y9 B
`4 Q9 {& A/ ?( k, k
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. C* h# `8 x( o- j7 ^
/*
. b+ i0 Y) g$ ~; L% V+ }
* Check memory range for valid RAM. A simple memory test determines
$ h" k* `6 l) J$ a
* the actually available RAM size between addresses `base' and
% m# X$ t @ Q6 f/ Y
* `base + maxsize'.
. e% ^) [3 F3 n' \& l c8 O' h+ v
*/
5 W" X: d& {: z9 \
long get_ram_size(long *base, long maxsize)
# |/ ~' r- R( g7 @
{
0 l, u6 ?' p ^' n, g0 W
volatile long *addr;
" N: m# u( G2 X; n, I" h* v
long save[32];
( N( J3 n9 f. k3 K- U) i% N: e
long cnt;
1 q$ f9 {' Z {* v4 O# W
long val;
( U4 V1 ^7 b, g: j1 C7 G
long size;
# h1 q0 p. t* a$ H# m/ J6 g% |
int i = 0;
- Y- n4 P% l# t/ g9 D
6 {. A C: u$ L+ n# z/ q" L4 q1 K
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
% v, O8 v h# M# ~8 c! ^* j! K
addr = base + cnt; /* pointer arith! */
/ r$ i4 L9 [) i4 N2 V: @
sync ();
5 j; j" `5 C" F+ b
save[i++] = *addr;
# k0 M, c, x) x1 s7 y
sync ();
, j* m; c* K* K" J) h
*addr = ~cnt;
) q! a; b8 K6 D' ^* m8 J( W: R
}
' l" ]2 U d7 r$ r( d
9 Z5 ^% S3 _0 v Z* x
addr = base;
1 j& _* O& F/ ]2 s/ Y6 {1 D8 V
sync ();
5 u' t* h: s3 f F9 u6 ^% ^! f) @
save
= *addr;
: G. L t5 U* t/ w; G
sync ();
) P, D1 Q3 T F( X+ T- [
*addr = 0;
7 l- v% w" c7 O3 [4 P3 c
& R4 p* x$ p0 l# O4 y8 n0 C( o1 R& y; `
sync ();
& [! n" Q S4 U0 e
if ((val = *addr) != 0) {
- f/ g+ u1 Z& [) [$ S
/* Restore the original data before leaving the function.
4 N" o7 t0 z4 `
*/
0 I* p2 i/ i# }- E
sync ();
7 Z# Z$ U0 s0 d
*addr = save
;
- u) M. s) z/ [
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
$ j8 N0 K4 K Z' l, v; D1 q3 y8 Q
addr = base + cnt;
" i% \& I) }$ a8 _, z" X
sync ();
3 K1 {6 Z" y2 ]! h! L
*addr = save[--i];
% e& P0 K" } f2 Z/ ]! d
}
5 I, C) e4 }' U
return (0);
/ Z& S3 m) t- o4 S4 e9 K* a' G7 I
}
/ j/ l3 R4 z+ K5 e( }
; C$ @( p$ {$ B9 {2 n
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; ^' ~3 \* P2 X H+ O9 E N6 T
addr = base + cnt; /* pointer arith! */
1 B3 @6 ^, {4 m# \
val = *addr;
- a A D+ u7 u9 |* n2 x
*addr = save[--i];
- B( q0 d& T+ {# M3 ^
if (val != ~cnt) {
1 ~" \& T( O$ j' i
size = cnt * sizeof (long);
# u7 P2 Y+ Q: |) J$ v" D
/* Restore the original data before leaving the function.
" z# E! N! T& G' E/ }
*/
5 N+ I0 D |% f* j/ T' v
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, ^- E. y' J: v% [- [
addr = base + cnt;
2 i) g0 \0 L; a! C0 s
*addr = save[--i];
. X3 F0 e( x9 F& g" J+ U' f; B
}
- f& s& W' F' F( \
return (size);
5 ~1 x0 W1 \. K& K/ E# J4 r6 \
}
5 `6 r) l% N! ^. y" f: E& V
}
7 d% g. K' E) @
! T+ s8 G2 b o2 t- ~6 a) F
return (maxsize);
: U- N$ A3 c% a) S' ]
}
5 \- M8 Y" q8 t7 U n7 A
int dram_init(void)
+ T; S; \* N9 J2 I% L
{
. v9 H/ u+ r& U, y
/* dram_init must store complete ramsize in gd->ram_size */
' @' \$ ~, ?4 p& D
gd->ram_size = get_ram_size(
% J/ u. \/ @0 } G# ]" B6 }
(void *)CONFIG_SYS_SDRAM_BASE,
! s' j( H4 C# i4 f! ]0 e9 s6 W" @
CONFIG_MAX_RAM_BANK_SIZE);
0 j5 ~$ f9 o) f9 ~9 W# J
return 0;
$ d6 w* D$ a8 S$ k( r7 o
}
( R$ I# l5 L% u0 T' u
1 Q) \* H1 W2 e. a$ L
0 }, ?( q' ^, g
1 ] a0 `( }" {
5 V! }$ F) r( c! |0 c
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
/ D; T6 b- o2 x
! Y' X/ i3 M* L& ?, |3 e F
4 ~' h5 w! `/ U% U4 B* M8 K
# n3 Q1 c6 J$ X
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4