嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
$ s, A g2 G; r6 u, Z
核心板2:DDR2 256M Byte NAND FLASH 8G bit
6 M% }9 P4 d) I# p! ?
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
1 H) H& Y. V% m& M" }- b8 m8 F
, Y, v. q8 u: p+ z1 S
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
9 R1 ^- a- f9 a* H
' n/ ^* c5 U/ o) X. |
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
# W- E; J# v4 `4 h$ c' z* ~
/*
$ x6 m$ I, |" C& F
* Check memory range for valid RAM. A simple memory test determines
4 J' F# \% y Q0 t2 @- C4 A
* the actually available RAM size between addresses `base' and
8 w' N+ X! J: S
* `base + maxsize'.
2 @6 A$ J! o6 J2 U
*/
/ D7 z3 u& U1 G$ J
long get_ram_size(long *base, long maxsize)
# w# h/ z. D5 _* v9 w
{
' e! N( d( A% b
volatile long *addr;
/ h9 S4 r) P4 k6 \; a
long save[32];
% e2 x! Q6 p# R; F/ w
long cnt;
3 f7 u& q1 x$ P+ k! t' `6 h
long val;
8 m3 G) W( v2 ]3 _0 |. \1 x2 G
long size;
+ B, A: ]' d; A
int i = 0;
/ A ~2 @; J; o9 o2 p5 i3 G* Y# O
3 ^# F2 c4 A+ A# z
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
9 o. A: e% I7 s0 l6 H9 U
addr = base + cnt; /* pointer arith! */
$ _4 Z% ~" D" ^ W0 ~
sync ();
# R" b$ P/ I4 K9 f0 @1 @
save[i++] = *addr;
2 o# {8 Z8 X1 R3 _& \
sync ();
4 j- ?2 e8 D6 Q4 Y1 U) o9 f
*addr = ~cnt;
+ Y; M ?' d$ p( x3 w
}
1 B( f# p5 v4 G! B6 e
6 V7 F S. i4 H4 g
addr = base;
- ?: p- Y- W: {, K+ k8 _
sync ();
, [7 U/ h( F* y# Y' I
save
= *addr;
3 M6 `' }8 M* R4 X# ? _
sync ();
: n( J- ]0 k! J% C
*addr = 0;
, l& u: H* z" q# d$ w
; n- D. _3 K5 { x1 @
sync ();
) p* N+ x) k7 v
if ((val = *addr) != 0) {
8 X" Z, D9 i7 L" U) j1 L
/* Restore the original data before leaving the function.
' N) P+ n: V3 t& _' J5 ]2 C
*/
- f4 ~7 F0 ]$ r" D9 G5 U0 k$ x
sync ();
% \3 ]( H4 T2 m( K, K4 g
*addr = save
;
$ S5 L7 n F% G- ^
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
1 g( o h' n1 |8 g! V( p! x1 h
addr = base + cnt;
$ |! ^( }1 ^: I5 v/ Q
sync ();
k3 n: y% b' C$ D( g
*addr = save[--i];
1 m) p' u, P$ o% _3 | H2 V
}
: _+ I5 I3 B- S
return (0);
" B4 f1 @4 Y9 h- [; Z6 t }' _
}
* {/ a4 C i. c, ~) \' b6 r
. \/ ]) Y, h K- z7 u2 D' q
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' l6 ^' P! n! q* g I* V2 f) {
addr = base + cnt; /* pointer arith! */
+ g$ P1 U w$ F8 X) Q7 Q
val = *addr;
! R$ Y7 t1 d- ?
*addr = save[--i];
0 f) C A% t2 a# H3 X
if (val != ~cnt) {
6 _! l+ ^: n+ x" u ?3 m. {
size = cnt * sizeof (long);
( P) s, x2 }" }: }/ z8 P/ V
/* Restore the original data before leaving the function.
: F0 v; y5 K! H [ t+ |
*/
4 ~8 f5 M/ e/ Q' ^' J* t$ p1 Q
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 W! y' h( o2 D- V& n
addr = base + cnt;
% \. i: l6 I/ }/ n% u+ L, v( V( A
*addr = save[--i];
0 [* P8 n0 X0 L/ q3 l2 V: P
}
+ d/ ?' s, q6 a3 F
return (size);
' l, {! P3 A* Z& y% ^% U
}
1 \6 |6 Z7 n/ P7 }- \% [
}
}* ?4 e% T7 T
4 O" |6 A" h- L; k' h1 t2 i
return (maxsize);
# i' P$ x: W* ^
}
' ?$ T# [2 L* O
int dram_init(void)
$ h. q' T; o, ]* G2 ? D8 e$ Y
{
8 G% `: I2 D$ I
/* dram_init must store complete ramsize in gd->ram_size */
5 y" F* F9 f- M9 V
gd->ram_size = get_ram_size(
3 f3 _0 O" n" D8 T* l' K X
(void *)CONFIG_SYS_SDRAM_BASE,
* Z) Y" [2 u+ d& l9 N
CONFIG_MAX_RAM_BANK_SIZE);
8 x4 i, E$ Y# |0 T, [
return 0;
8 |) D# i3 n- r/ h% d( Q
}
2 N9 ?: l( Y4 X% P2 ], h/ s9 G' d
$ C W1 Z! n7 y/ T4 b
4 \9 F0 c2 D0 a6 z
6 u, S! _ X; m, J; s7 z
1 }) M; h d8 C2 h! A
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
/ {6 t, q+ y/ G3 V0 p
# z$ R' y$ B' Z
- p6 g; F: S8 N
3 d/ E) o$ O% C* ^9 x
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4