嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
2 i& q6 [, t4 K3 G. a4 A
核心板2:DDR2 256M Byte NAND FLASH 8G bit
4 k, D. _- q( z4 D
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
' a; j4 d5 ^) } P7 @
0 _* X- H7 M9 R) K; ^. w s
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
" v, d0 p+ [( j
" T5 K' Q, g2 q0 n. h' a" Q+ h
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
* M+ E2 q4 N( B) Z) l
/*
0 F7 l4 d6 a/ ~. P& \ _
* Check memory range for valid RAM. A simple memory test determines
% }. O* |# _2 P0 @' B' [; Y
* the actually available RAM size between addresses `base' and
/ W/ y3 B! u6 f+ d
* `base + maxsize'.
- u; b1 w0 w& H: ?. d! i% H- t
*/
3 ?3 I* y+ y; K0 B" p9 D
long get_ram_size(long *base, long maxsize)
% h* S, b v3 d# F. L$ \
{
) J h) ~" F1 ~: T; }# u
volatile long *addr;
& ]% w8 s0 E7 N! C k
long save[32];
9 X2 {0 H. r/ P# q
long cnt;
' @ M7 E( o4 ~6 c+ G7 L5 G
long val;
( \ y( y3 Z9 A+ ?, a
long size;
, s, v0 k1 A2 u* |( u) K+ @5 j
int i = 0;
) K/ f! p1 V# ], ~0 Z
1 p2 w( x. H8 q( l1 c
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
?& k, ~( [ ~. y& i# D6 ?2 Z$ I- a
addr = base + cnt; /* pointer arith! */
( {) c E+ m; H2 q0 X! r, x
sync ();
8 D3 x, b0 t/ H) T5 m6 p E
save[i++] = *addr;
7 e, P, |' s, [; x1 o e" x' _) Y
sync ();
, V& v5 n1 v$ i" N3 q# c; @
*addr = ~cnt;
3 c9 z* ]# L7 w2 {2 f0 H8 `0 Y4 B
}
/ ]9 A% ? s* Q0 w+ P' ]
! U. ~& v3 ] N3 M" A
addr = base;
2 w* [4 C) s& W7 E% }( j
sync ();
7 o) ^. J: u) e8 `
save
= *addr;
& j" Y, N# q" i5 Q5 `; \% o c
sync ();
1 B) a8 Z( m3 a* V3 N2 i% f9 t$ Z
*addr = 0;
( X1 u, T' S8 s, \
# `; q/ D. W, t( h; K! K$ q' w
sync ();
s2 B3 u4 v3 r# L, o$ ~# i
if ((val = *addr) != 0) {
* ? A( q0 S+ @, E: T1 |- M
/* Restore the original data before leaving the function.
; s: r- @! T8 A3 v- [! Y5 B
*/
% u ]$ Q" T( G1 ^6 s# `
sync ();
- Z! D8 I8 J4 E
*addr = save
;
# A7 y4 U# s$ a2 v
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
2 f4 t! t0 l; T* a( {( v
addr = base + cnt;
5 E' r' e! S/ h. a& d: `" q
sync ();
" G2 P7 S6 x x8 r5 e' ^" I# \
*addr = save[--i];
! T* ]4 y+ n. O) f1 |& u% k
}
' O6 n4 J, k) B4 ~. n0 P
return (0);
- U7 L* t9 z& V- ^+ t
}
- l& Z ~7 q3 o9 C9 g: E ]
6 s1 y9 {/ g: B! e1 _) K
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
/ ~7 k* S" {0 q5 o+ L
addr = base + cnt; /* pointer arith! */
; f- j, g; ^3 q3 g
val = *addr;
8 n7 c# n# c3 G- W# i ^0 W
*addr = save[--i];
" m; n( W9 j. Z: z6 A
if (val != ~cnt) {
7 z* L5 ?! A& Y5 c) P
size = cnt * sizeof (long);
S' j$ Q9 }: Z# J# G# e7 j; K
/* Restore the original data before leaving the function.
% X% `3 V1 y" {% \
*/
2 h- X ~1 o3 e% Q/ O& u
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 o/ ~ X2 ~8 ? {! d6 n2 \
addr = base + cnt;
0 g8 o1 ]9 v3 ~: Q" i g
*addr = save[--i];
. t* T. W3 v# w* c# N- I- [! ?
}
1 c: k5 o# o& b' Q2 j% U
return (size);
% x: E6 x( O/ H/ n
}
+ [ g) T0 @4 i O$ }/ Y" u
}
$ l* o* Q. r1 P z! a5 _$ K% I
" m0 A7 e- b7 |! }* u& I1 d4 v
return (maxsize);
# d- ~( o7 S: }- }
}
. O q$ d$ H! B; l9 {) }5 N
int dram_init(void)
' j& `9 H1 J; |6 \2 y
{
0 e: {! O! s _; V! E$ c5 o
/* dram_init must store complete ramsize in gd->ram_size */
8 o8 g8 N4 j. j% s+ K8 [
gd->ram_size = get_ram_size(
0 ]! w- ^. b$ f9 \6 s
(void *)CONFIG_SYS_SDRAM_BASE,
! g" M# w% g: i& Z, w
CONFIG_MAX_RAM_BANK_SIZE);
Z9 S. D" F% O3 D
return 0;
4 E: a5 I# Z1 T: c9 V+ D- _& O. x
}
9 O' L; Z% k% |$ J3 \
/ Q+ f" l; i3 D% k% h% X5 V
7 b5 m) u% C; k) z
& v& x* A" B0 {9 v$ \) J1 _
$ ]( u+ K. u8 T# L8 f" ^5 y0 p- o
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
5 S6 [) o* T0 t. Y1 T
( ?* G1 ~( m/ N }+ V: Y3 X1 ?
0 P9 q! a9 ]+ o& @% O6 w" D$ ]
q* H6 S$ w5 A' m" M
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4