嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
B: B f! F/ I1 g' z) N0 [
核心板2:DDR2 256M Byte NAND FLASH 8G bit
! b! w0 z" J' E* [# l
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
% F/ m6 s$ D! C: j' q& r# L
& _2 I/ Y7 G! i4 V9 w% l: s) @
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
9 r e& a/ K( w- {& O7 x0 L
4 a, Y: e7 Q. R$ a/ R% [
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
4 K W" t' C* H0 ~% H( s
/*
5 g) x7 e) f3 k
* Check memory range for valid RAM. A simple memory test determines
L, @+ K; F$ }! h6 c
* the actually available RAM size between addresses `base' and
7 M8 a7 r3 h& r4 e' O h ` |
* `base + maxsize'.
1 p8 j6 S: O4 T
*/
; ?7 \" @ b* M& o4 i
long get_ram_size(long *base, long maxsize)
6 P& e; d8 c! w9 I O
{
! ~' |5 A2 c, ~
volatile long *addr;
, {: {( w5 O8 e% N0 x, S1 M5 J
long save[32];
* a' F; f$ a2 e
long cnt;
% P y6 f8 f1 b4 b& w @- ^
long val;
: Z& w/ X# w) D: I' t0 z( `% N
long size;
/ |9 w$ X+ k( V$ |3 [8 A/ ~) X4 y: v
int i = 0;
+ s7 @" \. _/ n/ X h; @
9 R+ P( B# C$ _7 ~' l
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
; s/ Y( l3 P2 h5 n
addr = base + cnt; /* pointer arith! */
/ \8 Y6 S: m2 T- F( {) Z/ u
sync ();
, i6 W/ `9 @+ W; ]) r6 F9 k+ q
save[i++] = *addr;
$ ?( W' l% ^8 p! i
sync ();
% i4 [, W# {2 @9 F1 h6 l
*addr = ~cnt;
. j! R0 M* U# g9 [3 Y; W% W7 v( t
}
5 e% \4 c8 ?+ V z! a8 I1 ^
) b9 }1 g! Q# }9 H
addr = base;
+ ?& h1 E# ], f# c1 O/ ^. H
sync ();
& [/ x: `# R: k+ h% Z A. z
save
= *addr;
* h- R& Y( w) M5 D: H$ T4 V
sync ();
$ ^6 e9 u% `, p7 s$ N! k5 s
*addr = 0;
) \8 y9 f3 A* j; ^4 J! n: T0 |+ h
% \3 @1 B2 V& H& V
sync ();
& m/ x' O4 P; ~$ l
if ((val = *addr) != 0) {
/ @6 Q! @# J1 c/ y7 u" T0 C; P$ D
/* Restore the original data before leaving the function.
, [7 w' {8 L1 C2 b# d# j' G- O
*/
, I! a/ g" B* ?. f# q- v# i
sync ();
& [' P1 `6 ]- j( f7 s' u8 C# b4 m9 t
*addr = save
;
/ e' Z; C- E% H/ b6 y- N# B
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
* {5 j6 e3 \& j' M1 t+ ~
addr = base + cnt;
. l5 ~" L4 a( q4 D1 O. c
sync ();
! w, d- i3 M, [4 A8 ~
*addr = save[--i];
, t- @8 M: i* }* A2 t
}
8 M. m L1 c9 J" o2 M1 w+ S9 P0 b
return (0);
2 I4 U* l: M2 H2 b
}
* ]. b9 ]& t1 O9 E& N
' L: t% ^* [# N# P4 s: x0 _3 ]0 f) K
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& K' G: |% w' { ?7 f, v5 A
addr = base + cnt; /* pointer arith! */
. x' M# {2 C! o, u. f
val = *addr;
7 k3 B* i9 K" h# o' I* X7 w K
*addr = save[--i];
3 Z+ v1 ]' Z3 T8 u
if (val != ~cnt) {
: w) n0 O! {. n
size = cnt * sizeof (long);
2 M" e% u3 r8 N1 l% A
/* Restore the original data before leaving the function.
, w+ l! r% `4 m2 {* X2 ]% M; C8 |" L
*/
- a/ u: |6 H7 m b
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
S+ X1 B# J1 X8 w& w4 T3 D/ v1 k
addr = base + cnt;
; H8 Z& J. [8 O) a
*addr = save[--i];
. @! d( Q& z8 s7 P, A
}
! U- [7 y9 v! d* b. d; Z% m9 }
return (size);
8 m- n! n4 v0 O/ i: [/ k# B
}
5 H1 g- f) a/ E7 Y6 B. a4 B
}
* l& a; t# x) ^: Q8 Q" m9 Z
3 P& _+ z3 L( Z! V# i. d; [
return (maxsize);
' t9 M- F! T9 i# z4 B; m0 H- S
}
8 h) i. h+ V& [* u* V+ @! t" o
int dram_init(void)
& E8 l7 ~4 g( m- t9 {% ^7 x
{
4 h" h! h6 g* G$ I* ~' c, b
/* dram_init must store complete ramsize in gd->ram_size */
% w, E, D0 q3 _9 r4 Q! q& h
gd->ram_size = get_ram_size(
' m% K$ N; K/ @: }. N+ {+ _
(void *)CONFIG_SYS_SDRAM_BASE,
! J0 e6 F: ~4 g( p
CONFIG_MAX_RAM_BANK_SIZE);
3 e( v- e( a& o
return 0;
/ S U- e+ E. o
}
/ [0 k- v+ J- q! x# o5 x! _& _% e
) m( i' e& {1 A5 A: h
$ T+ Q1 ?: r, M
' J c0 n( M$ b8 S
8 I, r _ r' r4 d- ~
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
2 g1 ?9 B" C# b' d H8 X
: _1 S v' f5 K/ N" }/ [. |$ Z/ s
1 t2 m7 Q# }0 W0 l; I/ }4 ^
2 M* N. [0 X# G4 x: C/ e& c# A
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4