嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
* q$ Q: z2 }3 \
核心板2:DDR2 256M Byte NAND FLASH 8G bit
- g$ J) W9 j9 Z4 w
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
; C8 a, R# k9 w$ C/ e7 K
/ F% X, {$ z+ Q6 `4 p
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
. r! Q) M8 Q/ s5 q* r
7 I2 P9 |% h" g8 L6 f4 W- H4 g2 ~- ^
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
( k' s. A& J0 B9 [: e! C% j
/*
; H6 }, A/ t3 M# N& n
* Check memory range for valid RAM. A simple memory test determines
O) Q. O5 o. }% o b) m. L3 u' o* z
* the actually available RAM size between addresses `base' and
; F; q/ A0 b" u& R3 R
* `base + maxsize'.
; B, b! l. @" O* W
*/
; {* E/ g, r* ^+ X; ~
long get_ram_size(long *base, long maxsize)
1 ^/ d) V3 {3 b1 y; \5 e2 v
{
& M) h2 r" |# E0 k5 J
volatile long *addr;
$ R& \- [( z5 o5 w$ }
long save[32];
. }1 \" h* g6 G0 ^) B" i+ ?! N
long cnt;
) L+ F. `3 @0 k' M
long val;
% t" B9 }! P9 X+ k5 K/ z" h6 l6 N; U7 v' I
long size;
! |# ?) E' M1 v1 T5 e6 r( i. `$ k3 z
int i = 0;
8 W( @! W' d, D6 ~
8 D+ |5 k6 w. f& r5 ]0 ?
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
% c8 ~' ~5 ~9 ?5 m
addr = base + cnt; /* pointer arith! */
! k; c7 \$ ?2 `* u' n
sync ();
9 _/ a+ T+ `3 r5 |7 h9 {! l; v
save[i++] = *addr;
* j7 y/ R" l; r$ g7 f
sync ();
. } ?% W0 e) d. d: D
*addr = ~cnt;
1 k# n, L: [- J9 T. n4 _) Y( a
}
4 ~& p9 b" x( ^6 b, [: D
6 s1 I; h; e6 F. W% Y
addr = base;
( ]# t7 B. |+ W+ W
sync ();
; h& P/ \( [' ]+ X$ U+ ]( q
save
= *addr;
$ C1 y) V$ j0 K" f8 B- O& _' @
sync ();
; Y& a& K H/ s) d$ H2 z' [1 P
*addr = 0;
2 ^1 s! y. K! G7 t4 J8 C8 V
5 H+ e$ G" J( u
sync ();
& F" j L# b% e) E0 c7 {" L
if ((val = *addr) != 0) {
$ C. |( Q% `! A9 c1 X/ Q. I
/* Restore the original data before leaving the function.
. D* {0 Q* f, {6 ?+ R: E$ X
*/
1 c$ R% y* S8 Z- t3 y9 F+ M
sync ();
" V+ q3 _6 D0 B3 g- L' V& L' I& p& t
*addr = save
;
9 q. \, g; T3 B# L% h
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
. }- [8 [) P. N. P
addr = base + cnt;
- S: a, u# b, o- U+ d" S
sync ();
/ `3 M) `. d' n2 I, g. N0 [6 N
*addr = save[--i];
: G% Y0 d/ m, d4 L
}
8 _! q) P1 \& y# `, z
return (0);
6 ?4 i$ G2 r" F( Z/ g
}
% [# ~9 h( z, h
9 W3 |7 ^# K# l- T
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ a3 V1 K& ]' K9 R
addr = base + cnt; /* pointer arith! */
# @! P5 w$ n1 r" c1 X
val = *addr;
( N- n+ \6 p) ~ K9 k
*addr = save[--i];
8 x0 L$ ]( O h7 s1 S6 n
if (val != ~cnt) {
6 ~- s5 @& `( `0 q# t+ H) d/ \
size = cnt * sizeof (long);
+ k+ I$ h2 [# q
/* Restore the original data before leaving the function.
* D) s# i* g0 Y
*/
* ^/ C- }4 i4 v& D* J
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 z$ ~/ P6 H# a$ s7 j
addr = base + cnt;
& `& @, d. L4 }: b0 C' v
*addr = save[--i];
" M& q5 q& X3 w# R. z9 X1 f$ J
}
/ [5 W9 a7 @3 {3 D: \
return (size);
2 }' N% u9 F! n; _
}
2 ~# f4 W9 C* _8 c
}
. {+ N: R" H& R
& ]) h* |9 r2 U1 | S; s! ^
return (maxsize);
2 C! f' D: x9 E5 K, e
}
$ R, j- d" V1 u1 a
int dram_init(void)
# w. U$ l, C9 D# l- J/ B) I% j
{
- s" A+ }. w' \2 i* x& Y) F3 d
/* dram_init must store complete ramsize in gd->ram_size */
T6 r- C6 `+ U
gd->ram_size = get_ram_size(
+ P& u& x! O/ z1 i; o- g
(void *)CONFIG_SYS_SDRAM_BASE,
' O4 j1 t( m, q# {
CONFIG_MAX_RAM_BANK_SIZE);
: }8 v+ T/ K# G7 x b, ~
return 0;
, q3 N6 ~! I* L7 `0 Q7 Q* K
}
, }& y( ?6 l" u' b
7 n/ B8 K, A: n, `: A
7 y. u; ?. a+ r
3 i7 ?6 S6 p$ c
- U3 Y9 ]3 L2 x# [- q, G, x
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
4 {$ W* W1 I% Q* R" `, ~" a
2 g; x+ r" F0 A0 Q# `: I
% S( E* k% {. h" S7 A
$ Y3 |# x5 C, n* A
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4