嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
9 ~, [% p5 P6 U6 I
核心板2:DDR2 256M Byte NAND FLASH 8G bit
5 F3 Y: l& m- w7 Z3 e3 V7 K
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
: z/ d6 d+ s7 Z# Y
* M) o2 h p) E5 p
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
$ l: a, t' H) |* S& p+ y, D" \
: Y5 Y. F! T+ z. z
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
6 u! {! N. R% P( l
/*
2 a5 { i) H* O$ Y
* Check memory range for valid RAM. A simple memory test determines
* [* w$ x! S% d4 V2 ^* p$ t
* the actually available RAM size between addresses `base' and
- y$ R( E* Y% ]+ p- ^
* `base + maxsize'.
; C$ u6 ^: G! q4 v2 e
*/
1 \1 j( h v% b8 B
long get_ram_size(long *base, long maxsize)
& x& X; S2 h2 g7 d1 o- u# c! j
{
( k3 C1 z; r* x
volatile long *addr;
+ @% a0 N! b* i# z8 N' B6 X
long save[32];
1 q2 D; N; C; S' }
long cnt;
0 i* E/ z* |* O) K; }
long val;
+ O% {9 j) ~" z
long size;
7 `7 l/ }' y' G' I) O3 q# x7 ?! ~7 D
int i = 0;
$ z/ e6 [: u9 U# W. G; `8 P0 n
6 O1 b4 I8 h+ ~. q/ q
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
4 ?) b+ z& d; Y. g9 N# x7 G
addr = base + cnt; /* pointer arith! */
6 Y+ e! ?, c6 ]$ d' G! ~, z
sync ();
$ q4 {. r7 p1 j$ H$ d
save[i++] = *addr;
% x& j& _* v* K
sync ();
3 r8 P3 J o9 _ N' r- l
*addr = ~cnt;
6 m6 P+ d& Q3 `" }$ l0 @, q) c7 P
}
, w6 ?8 I9 Y* u# f+ [3 _
$ k- Z. l4 X% J: W& _8 ?0 M
addr = base;
g& A- i2 q r* {; I
sync ();
/ t! j( T5 G1 Y% |4 I: _
save
= *addr;
0 ^& I! G# o/ X! O
sync ();
; ]0 R* H# Y- g. ] B
*addr = 0;
, F8 W: S+ t' o2 b; T- P! y
0 }1 A U# `6 R6 b. F# [
sync ();
. g9 @' B4 P9 Y' S2 }5 y, ?3 I
if ((val = *addr) != 0) {
: n9 R$ n3 j& N& ~6 T' }7 r
/* Restore the original data before leaving the function.
/ i3 l" i0 \# _3 E7 o/ J( N5 [
*/
3 u% m$ Y; r3 O
sync ();
7 r; S: V" `3 _! g( V% x
*addr = save
;
; |9 d% P. U1 T$ Z, K8 p* O) T
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
( \6 v* Q7 E0 O# j; Y
addr = base + cnt;
# d: M" Y7 t: J3 a, g
sync ();
. x+ H, a: C M& w8 k( d! R: b
*addr = save[--i];
7 M {! B9 Q) J) \) e# n5 ~
}
: ?" k6 d8 ?2 ~$ U% Y/ l
return (0);
8 l6 k+ _ \* |
}
6 y! P$ _6 w! F& z: M
; X; `# M8 Z( Z9 u( w! O
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. ~) }2 Y; G$ y& B
addr = base + cnt; /* pointer arith! */
7 i1 X8 _' {' D5 b B- ^$ j
val = *addr;
6 D `& P% f) W* p) d- b9 d
*addr = save[--i];
, ^, C8 N: M& r9 _6 c
if (val != ~cnt) {
7 c! d$ I1 D5 A# R& s& U
size = cnt * sizeof (long);
! Y- m, _0 {5 J/ v: i
/* Restore the original data before leaving the function.
- O0 P9 S) }6 n( W, ?( U) f
*/
& [7 q. W; D+ _+ n7 V2 P% [6 P& o, S
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 |7 A' g" J, a5 k/ G
addr = base + cnt;
: U) j v3 @1 t+ s
*addr = save[--i];
# J, c4 N- \5 F& P
}
* {$ m: Q# {1 |$ E9 c
return (size);
o$ ^; L! J! U+ k1 b
}
) Q3 W* G3 C7 C- f
}
B1 d1 [1 U" E0 h
; N" _$ Z$ K7 I" {/ f
return (maxsize);
% s. E8 l9 [3 O: x
}
( I( b+ Q" Q$ m' c
int dram_init(void)
- m: c$ F% |- o: }' O
{
7 Y# F% m! O$ H% l' g
/* dram_init must store complete ramsize in gd->ram_size */
2 d i% t" v. i$ T% _
gd->ram_size = get_ram_size(
5 @0 ^/ g# l4 |1 i
(void *)CONFIG_SYS_SDRAM_BASE,
. l# n5 S8 e0 {# A* G( A: ^2 J
CONFIG_MAX_RAM_BANK_SIZE);
4 ^, ~3 T j1 h0 f: b5 E
return 0;
2 B3 i! G7 F& X7 p% h* U* C
}
0 \6 y. ?! B% @7 M# V- j7 g
! S! ^1 H* [. d5 i$ O0 `
, b- f5 V4 i m# _) k+ U
: z1 t9 A* c; c! @# @9 E
0 H& E% g1 q" ^
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
, b- d8 x" W( r) \5 D0 p
. p+ i2 m* H+ U, z; A6 t& V
0 F6 D2 {. W3 F. A) u
& Q- _0 m- Q6 r. l$ ~, t1 l/ E% w! o
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4