嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
" g0 r6 _+ i) \( M
核心板2:DDR2 256M Byte NAND FLASH 8G bit
) q6 s. @* i( i R8 l
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- X6 {2 W% ]7 L& t3 B9 x
5 @; \6 ^* J3 J( O: J
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
+ \5 X. j/ r4 |& m- o( E* ?4 q8 {
1 @ d- U4 C0 U3 W* [# g
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
& K) P2 K" _$ Y# U
/*
4 B) V/ g5 _9 X
* Check memory range for valid RAM. A simple memory test determines
: s6 n- P- E2 p8 u3 T2 {" S
* the actually available RAM size between addresses `base' and
4 I1 j; d7 `" ]. z* C
* `base + maxsize'.
% t2 h. A" x% m9 U4 q1 @1 T
*/
, N) ]+ F, T0 m8 i
long get_ram_size(long *base, long maxsize)
4 R; k6 V$ ^0 h# j' P
{
9 f' U9 E4 r+ _# R- U& v$ v
volatile long *addr;
) I" d; x2 T- a/ N% [' K$ U# s$ e
long save[32];
& h$ B h% ^1 q& Z
long cnt;
5 A( d2 d3 w- ^6 ?
long val;
- S, L6 w& ^1 J1 |! F! s# S% I
long size;
, ?7 t7 A" z: d2 [
int i = 0;
: n- C; R w4 \- w
& t. Y) _% Y" b+ ~) n; b: m! g8 U
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
: m$ s/ x' h |6 s
addr = base + cnt; /* pointer arith! */
9 T( {! E$ V. E% | A6 @
sync ();
" z* Q, o' s6 x0 d0 P& T* Y
save[i++] = *addr;
7 O5 v8 U* `4 m# v0 e
sync ();
' O/ Q0 |# L* F# u2 B0 q+ [
*addr = ~cnt;
6 l0 `( A" S, i& R2 G
}
, r7 a7 b& Y6 q8 G
; c8 X6 m- Z: P
addr = base;
5 w. f. l4 ^* H* N& Y
sync ();
( {+ `+ n/ T) a. } F
save
= *addr;
7 @+ ~6 x* F3 ~9 `8 }
sync ();
& N5 D8 k# x9 V, q% K
*addr = 0;
" g$ C( ^0 n+ s. A: C, S& i
# L: g' t( Z* b1 R6 i8 U# E2 S
sync ();
: ^9 z6 p" s4 D3 H4 G
if ((val = *addr) != 0) {
, s" A) @5 N d. w$ Z' ]( a
/* Restore the original data before leaving the function.
g, M$ V! w1 ]: R' ?2 e
*/
& O5 \8 |- [: `- w7 ?9 l, }
sync ();
# M% V2 ]- \* {7 k) X
*addr = save
;
4 J& Y- O- y i1 Y$ m
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 O7 w. N8 I( L1 j& \
addr = base + cnt;
4 B' h6 l% ?% m3 `+ `! m( S
sync ();
% R7 g* Y5 w/ ^4 |; h& v
*addr = save[--i];
3 |. U7 O! j" b* X0 w1 @) K
}
1 E* t. J2 N4 l+ w; h i- a' ~
return (0);
/ d9 `! z+ t5 M. [9 Q1 q
}
7 \; M7 T( J5 a2 c
% F2 _! ^& U N$ l. N/ Y+ ~
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
d9 B# {% d- S2 O& y
addr = base + cnt; /* pointer arith! */
8 O" V" V- d) k: C
val = *addr;
2 {8 b/ ^5 j( Y
*addr = save[--i];
4 C% W! e! ^5 A7 Y
if (val != ~cnt) {
3 g5 u P9 I+ M. l0 }
size = cnt * sizeof (long);
' D4 }, r. \/ d" a4 |3 j X$ A" i
/* Restore the original data before leaving the function.
2 g1 b0 A2 r( [8 c5 x
*/
0 E5 j; l: p3 q# y* `+ E& ^. |
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
# U* p. F$ ]! u5 V2 r$ R
addr = base + cnt;
, r( q: \# E& D+ @
*addr = save[--i];
' j! g0 \% R* j, o2 |6 A" O
}
) {8 x3 N' M; V& _( J5 t4 Q" `
return (size);
3 b$ u: T% G9 F$ r
}
$ G7 l* n0 V; A+ a& ]$ \
}
+ n: h7 M* @) J
2 E: C# T |8 F
return (maxsize);
" p. W. U& w# Z, {3 M
}
6 J# x4 V* S/ N+ p0 L. j
int dram_init(void)
/ N! g4 X1 |! |
{
{" L% k/ b \0 k' }
/* dram_init must store complete ramsize in gd->ram_size */
) s) z0 O x+ W5 V- S. f7 g
gd->ram_size = get_ram_size(
z, b r+ o8 x: v* D
(void *)CONFIG_SYS_SDRAM_BASE,
% O; c1 \$ I/ e- y0 ^4 v; ]
CONFIG_MAX_RAM_BANK_SIZE);
9 E: E) M" R% l) N! @
return 0;
6 v1 h& _: e8 ]. l# L; a$ m
}
( l1 }) S# U4 l% i3 q# S
) g2 k1 G3 D z& B) Q" P
" d: U: v6 J/ d- f; {7 i {, {4 ~
5 B/ k8 Z: Y# X+ h
& {; r$ y( Y% W3 S: C
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
" w5 D& q! d9 g9 ^2 `9 d* X% T/ n. ]
- Y' J7 z" G" k. H, M$ J
+ \4 z& S6 V" A3 o- x4 l
9 l5 w6 o6 p% Z
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4