嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
2 \ r& v0 v0 v/ h7 o
核心板2:DDR2 256M Byte NAND FLASH 8G bit
+ Z5 r6 o/ i# ?* s. u6 H. X3 K! I
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
+ A; |3 A( A3 U6 r1 |
; ]) e+ H: s( U' Y( Q) g0 B0 d
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
* J% ~$ v/ Q4 @* y
+ i+ E7 ^0 i8 A4 _5 W
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
# r; P9 X& w9 U P+ Q
/*
0 {1 |" P) y- C! ~1 M) C$ @/ J: B, P
* Check memory range for valid RAM. A simple memory test determines
0 D% E9 ?" L x' D$ G1 {
* the actually available RAM size between addresses `base' and
c$ E9 _8 `6 q0 S `4 C- j
* `base + maxsize'.
1 ]* [9 U6 I) I' C$ I$ y
*/
+ v7 J6 P9 h1 J7 Z' A1 `$ `
long get_ram_size(long *base, long maxsize)
5 X" @4 | V0 I& o! D' t+ H
{
) V9 g& h' a: R2 z' |
volatile long *addr;
- d, S, x2 w5 e1 K( o) @
long save[32];
1 D! }2 @+ r% D) q, t3 n
long cnt;
$ Y# T. k. o7 c5 K
long val;
4 F: @/ s5 R N( b1 A
long size;
% v1 t7 Z, |- O
int i = 0;
6 D: a% q* y: h6 g- u& @( ^
C1 v: c+ w: o! n- B3 v4 P3 L
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
9 p, [& X4 }/ i- }4 B5 R* W! |8 i; R
addr = base + cnt; /* pointer arith! */
! n; q& l% M3 x$ C- D4 a
sync ();
, @5 [) Z* Q: W2 ]2 n* q. |$ u
save[i++] = *addr;
: B" E( w$ ^) T, p
sync ();
! I1 L; l/ n- s
*addr = ~cnt;
0 o! ]4 g& M! h5 O& F* `, ]
}
6 @+ e0 ^" J$ ~- ~
& F6 o( L1 ^) n* U7 k
addr = base;
0 x/ n' \; d$ v8 G1 v0 P
sync ();
! } W$ \5 w9 g( S6 W% e4 r( L, d
save
= *addr;
1 k1 \. w$ C9 b1 X8 N& |
sync ();
3 j# N$ p6 i3 s5 c0 r
*addr = 0;
' J) {. T! P" c' ?
, a9 u; S# ?6 z7 K! H, X
sync ();
! k4 S. h8 g+ r S/ T, b9 Y
if ((val = *addr) != 0) {
5 y0 `' J& w: o W$ h( z
/* Restore the original data before leaving the function.
5 Z$ V/ g. s+ n* P J
*/
( j4 k; A9 S" p. z4 ^% |6 d
sync ();
3 Q% q" A' D8 P+ d
*addr = save
;
- n# u4 S5 b9 _/ U, [/ [
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 w$ a1 f0 @7 Y% O, K
addr = base + cnt;
1 u$ c; `5 Q+ `& F
sync ();
8 e( U. o) J. K% M% p' @& A
*addr = save[--i];
" n" J( T& [. l4 o6 F
}
- R5 g% a5 H2 H$ n' {( I8 A
return (0);
. [. T/ t5 S: Y0 K0 m' t
}
! \; i0 N# A0 @5 t7 l p
$ P3 T2 i1 W% Y
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( |! Q6 v5 Q6 ?& _3 X
addr = base + cnt; /* pointer arith! */
0 v' ]) y* F- _" P8 h" `
val = *addr;
/ t/ B! O0 r8 {3 |' i' [5 J9 x
*addr = save[--i];
/ y- Y8 A2 D$ l P8 P B
if (val != ~cnt) {
& }4 g9 w; g5 C+ }: ?
size = cnt * sizeof (long);
1 r$ p$ n- |& y
/* Restore the original data before leaving the function.
& |' ^9 K9 r5 ^$ }4 i
*/
' v! p# {( q9 U! p( Y3 S7 M( c8 [( ]
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 S' ~$ i; h! n( X5 L6 A( x8 B
addr = base + cnt;
& P2 O0 o- c2 g
*addr = save[--i];
9 E+ R* t& \ v$ C
}
% u4 _# Z8 P3 s& C1 A/ q
return (size);
4 J, X. i+ O! H6 T; ]2 d- p
}
) d8 o' P7 Y$ [2 {
}
+ c# H- U6 e. {! I5 y- E/ T6 Q
* W% P9 r8 l- I4 R, x1 R Q
return (maxsize);
9 P9 ?3 _. k. @7 a' l1 d
}
, m* V) |' c4 u% h1 C
int dram_init(void)
* o6 A; `1 j% M h$ {0 ^
{
7 U* H: G" w8 I' T- G5 w* Y) ~% m
/* dram_init must store complete ramsize in gd->ram_size */
% n4 J. \ z' A* \9 \
gd->ram_size = get_ram_size(
& }1 H: A `7 ?( K) T$ v
(void *)CONFIG_SYS_SDRAM_BASE,
7 J$ `5 C! F7 A E
CONFIG_MAX_RAM_BANK_SIZE);
5 M G$ n z$ K. P
return 0;
: A& C2 y( @% h6 d/ E3 y
}
0 X, U! |: d: ?, P
+ s( n+ E. J! Y/ ]$ |/ [
* c- z/ \( p% P& G- q
: ?' O( y! v2 c
* x, ^, u! E, p" z8 F
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
0 f- b5 F) R' l$ f! {9 A) B
2 o4 ]) L: R' \' b/ l
) p9 E0 t9 l, B6 H
1 g, g1 H/ Z7 Z! T; v& r% t
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4