嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
' p |6 G8 U' t6 A2 h9 y
核心板2:DDR2 256M Byte NAND FLASH 8G bit
, M; }. }- z* n" W1 Q; D; u H; R' M
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
) z8 Q& b! _( k: J/ N
$ u1 b" |: S! ]
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
: }! P! Q& w. R3 C; u% m
' N: W6 Z) K7 H
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
6 i+ [0 U, T2 P% J6 V6 U
/*
$ o# W1 }1 u0 \
* Check memory range for valid RAM. A simple memory test determines
/ h4 q& g( x) M! H! \5 U
* the actually available RAM size between addresses `base' and
2 m9 h9 c, w/ |. H
* `base + maxsize'.
2 t9 d- y! b, o9 I4 Z
*/
4 R* n( N5 { i. s P
long get_ram_size(long *base, long maxsize)
& @2 \' R& e0 X1 w$ @
{
# a. L/ p$ V2 r
volatile long *addr;
) ?1 u4 k8 ]' I6 R& P
long save[32];
. E/ [0 N# [. M% _" h# s
long cnt;
X; e4 n6 l7 C7 Q
long val;
3 ~7 k# K% [- M1 D: P
long size;
' Y) p( B) R/ a3 R! c1 B7 f
int i = 0;
, h3 o; ?, `) ? h, c: T3 M" f
! k0 P2 l* ]3 I
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
+ {; k( J1 c9 _
addr = base + cnt; /* pointer arith! */
" J; l0 {4 K! ?2 Y+ C
sync ();
) y; @3 _# J }( p6 s5 l; n7 w
save[i++] = *addr;
' B2 J+ q0 m" ~$ V: j) f. D2 Y
sync ();
+ \, v$ F9 e9 ?
*addr = ~cnt;
7 p/ d- o4 D$ Q5 Z' R
}
; a0 [* |* ^1 E
: i( j: B* V2 T1 r, s2 n! M+ o
addr = base;
1 s' N- R) l7 ?" O$ @
sync ();
1 w2 y- ~% l }7 k( |2 O
save
= *addr;
. `: B7 f( K. f( d5 k6 n4 [
sync ();
0 Z% |5 q6 {! g
*addr = 0;
) d0 W5 E. q; [ P: Q
% |: P$ m6 w! x5 Z6 [& n- W
sync ();
5 T. D) [! `7 i2 G3 O; v
if ((val = *addr) != 0) {
8 [& R/ D4 H# w. x$ m0 t
/* Restore the original data before leaving the function.
. c# B1 w5 e; @# X K5 A' T
*/
. L* T! K) H0 F" o( R
sync ();
5 b* j+ A, n$ M7 p; A5 p! y- ]6 ?8 |
*addr = save
;
. x) w- T, ~ ~1 I) J
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
* h- a+ Q3 l# j2 T1 f* c
addr = base + cnt;
% S4 o/ Y& e* u* f' `( ^
sync ();
8 L7 H8 R; R5 }5 w L& s. N: ]
*addr = save[--i];
0 |5 Z, k0 @) ^' l7 d) p* J1 s& ~
}
7 P4 x) j) C4 d( E3 T$ `" p# p8 T
return (0);
* `, K$ a* s, ~
}
# P; f2 q: i" A& C) V
0 ?8 d& m% N& }9 z4 d
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 s$ i2 ]0 H4 o1 J% t% V
addr = base + cnt; /* pointer arith! */
( ^5 e$ a+ s- ^
val = *addr;
! m/ p% a0 I8 G+ d! Y2 o8 a
*addr = save[--i];
$ i" J( F. P4 k- `5 E7 D
if (val != ~cnt) {
, M, x5 `0 ~% O9 y
size = cnt * sizeof (long);
s6 q9 C' n" O" L
/* Restore the original data before leaving the function.
6 [9 h( x' ^8 p7 N5 W
*/
5 |( p' c: p: i
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
! I* c5 o. C0 k6 E7 L" z
addr = base + cnt;
7 e- U6 l" |) b3 I
*addr = save[--i];
2 n [- J2 w9 J: c% u
}
# \% G4 }; r2 E( ?# u
return (size);
5 F w7 D* [8 Z. R; u% U
}
1 N3 n# P0 P. ? {+ Y
}
: e! e' Y5 m1 w4 t0 w: b! y1 A
" c$ U! p6 n( |* J
return (maxsize);
/ X) c1 F! B, X% \9 H" j1 O
}
& J0 K' l+ Q' U3 n0 U: Z
int dram_init(void)
$ e0 |+ r$ n m. q5 c- C6 }
{
7 E' J. L" h4 H5 A
/* dram_init must store complete ramsize in gd->ram_size */
' ], r& B+ T/ j6 ? V. T- O/ }
gd->ram_size = get_ram_size(
# }: {: Z. M+ N( \4 N1 E" n, M% s
(void *)CONFIG_SYS_SDRAM_BASE,
% |( R. s ]$ k4 @: Q
CONFIG_MAX_RAM_BANK_SIZE);
3 u# a( q- M7 Q5 `8 c
return 0;
3 \5 p2 U2 ^* J+ e
}
3 F7 c% a: C! u+ a7 o0 `& L, N
2 w( h: I1 V; p! D0 j
) k: W# p7 K/ {4 v9 u
8 n1 _8 k& x% ?6 z0 @% Y/ c7 M
& V( j9 V: d% ^% i8 x9 p w
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
; Z2 @7 H9 A' j7 B0 p* [% y
* V5 a9 `1 v* N7 P
. g2 c: f O6 }1 x C0 F: I
3 |9 g# v' B- O1 W2 J2 X
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4