嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
# `) k1 r& n, a G
核心板2:DDR2 256M Byte NAND FLASH 8G bit
4 P, _0 f- g$ k& j
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
7 O) n" k# x# `% R( d0 R6 @
# l+ d7 f* D/ K; {" d
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
# I7 S- o) e4 H' H- U& L
( W) D. \/ s0 @: t: ?) ~& J
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
" h! y( m# @+ O5 N* n: G
/*
/ ]5 y# ^$ C- K. e1 j- m" w
* Check memory range for valid RAM. A simple memory test determines
6 s% q5 ]1 U6 y- C
* the actually available RAM size between addresses `base' and
0 E! F; P0 d) W# I) W9 \9 `
* `base + maxsize'.
- ` C$ d9 j& B8 C
*/
4 Y7 ~% N! S7 J. S; h; S
long get_ram_size(long *base, long maxsize)
0 A+ [. `% z3 y4 x8 q7 C
{
, J" t# E* x* ]( ^
volatile long *addr;
$ g' ]$ a" m4 V* C
long save[32];
* B! k% |* A8 ]% C
long cnt;
# [- q7 J8 j+ ]0 p9 O8 m
long val;
* p( v- k7 u) x8 S) ] M; a
long size;
3 R. P: f. D8 q
int i = 0;
* p* w5 G& c" {: O) u. D9 Y
) p, L/ {; q! r3 ^" b
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
3 r1 I2 D, j- u& P, E$ m
addr = base + cnt; /* pointer arith! */
2 M6 ` m* E( p& S
sync ();
- ]" T ~# g$ P. e+ l" U4 l( K+ s
save[i++] = *addr;
% d/ I* Z# g$ k& N7 r7 K$ H
sync ();
+ h I+ ~2 y3 f) \" W
*addr = ~cnt;
1 b% m8 C5 v, ?1 x7 W
}
1 V* O' [7 X$ q( U9 N
r8 [! F4 ^' q: r
addr = base;
) R) ~) w5 @1 W# b, a
sync ();
) A$ B8 k# Y1 }. b5 f U5 {4 X. C- d
save
= *addr;
" D& _4 G' U# g8 ~, z* K/ B
sync ();
1 `, R% v. N3 d
*addr = 0;
6 ^, m% M2 @$ ^! Z0 c; d4 y
, R; Z2 g2 R# e3 @* G# W
sync ();
: \ T! W5 }% g/ V8 d
if ((val = *addr) != 0) {
$ _+ c2 h0 `) }0 s0 F0 f! m
/* Restore the original data before leaving the function.
$ ?( D! n. j" _9 @5 J- _1 V* D2 a
*/
0 Q. B: B; n) G* x Z
sync ();
" t3 t- W/ C2 F* n! U+ Z0 Q) z
*addr = save
;
8 A0 J7 M, C! _8 j( R( w
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
b9 J0 r- e5 Z3 Z6 S: c
addr = base + cnt;
' R; @0 s( _+ d G: u6 B
sync ();
7 `) t1 J! e7 m& O; Z7 E( L/ b; ?
*addr = save[--i];
; P+ z2 D& H5 _ [8 @4 _. B `
}
/ V% h3 L- f* u: z/ u V" k! d
return (0);
7 M5 W* r) S# a, C
}
( U/ [( U9 w1 o; A* u2 `
: N0 c& h& f" e- g- x* a' Y
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 W" f5 o7 y8 x% d2 V
addr = base + cnt; /* pointer arith! */
! s5 s# n) p8 q2 h
val = *addr;
$ C3 F1 @1 e f
*addr = save[--i];
" k! w5 N: O# X* B! k3 t) A
if (val != ~cnt) {
' C I5 ~% C( O) c2 [3 |
size = cnt * sizeof (long);
7 `' A* t2 Y. b8 V- a- D
/* Restore the original data before leaving the function.
. I( b3 F! j, P& }1 U1 w
*/
q: S2 N1 d8 u& T7 F: B; W9 \
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
# ^* r- h5 g" v. U0 y* m( H, k( E
addr = base + cnt;
( a3 Z( y$ E6 J# F+ @+ T
*addr = save[--i];
1 Y* T5 l2 t( m/ \) `
}
) {+ B: H; p, d; `9 H( |' i; N
return (size);
# r% |' P4 V! I w W
}
$ _& \0 w' K8 f" t" y# E$ V) x# V; [
}
" c% ]$ k' D9 A4 i i
/ }+ C; y. k2 y, L% p/ t
return (maxsize);
$ k6 b- C9 D! j, V
}
6 i' |' i- B2 @7 Z
int dram_init(void)
8 r5 A! _1 p( P* P
{
( ?2 w' z/ r% U
/* dram_init must store complete ramsize in gd->ram_size */
h8 x) l0 q! j9 o/ `2 k
gd->ram_size = get_ram_size(
) J ?9 n% B( [ p3 i
(void *)CONFIG_SYS_SDRAM_BASE,
4 S- U4 Z Z# W
CONFIG_MAX_RAM_BANK_SIZE);
; y# f3 {8 Q6 r, r; b" W+ I1 o
return 0;
5 z* f( W5 f. D) g7 U
}
9 j3 V. h- g" M3 g
; e" Z- H$ [& L' A# X: q
, j* y* N) e$ p8 f
- l/ h5 ?1 j# u. w, ?4 j) N3 `
3 p( P$ Q" ^' }4 d
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
* [. \) p, j6 O! G9 o
9 n8 e- W6 G" z3 p
* r" ~9 J7 Z; R/ d4 C. M* r& V# }5 i
, Z& F( b. ^, `3 z
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4