嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
H3 [$ ^! S! o t! D
核心板2:DDR2 256M Byte NAND FLASH 8G bit
3 _. p" B9 F! Z. Q2 x% v
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
1 K8 B& T1 R4 H7 n1 Z# ^3 u, q
" \6 t; o7 E3 M U/ ^
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
' ^8 U5 \2 S8 {/ d: ]
- t: I3 h) [/ s+ i' x0 l
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
; ]* R6 q/ ]' {+ M
/*
8 ]! L) q- r6 u# f, A/ F
* Check memory range for valid RAM. A simple memory test determines
9 l3 \2 r* [1 S! w) A5 S
* the actually available RAM size between addresses `base' and
8 w$ B4 U1 A( s& p- l
* `base + maxsize'.
# y. q1 [' C" h( R' T, k4 m- n8 z
*/
" `' E5 i# Y' y6 K/ b0 J- i9 c
long get_ram_size(long *base, long maxsize)
6 Y5 a2 G9 _, e' M9 L& T
{
6 s+ w$ h( ?0 J
volatile long *addr;
6 w) A1 m( U. i. o& L, t
long save[32];
& e; ^4 W, L( ?9 ]3 [" m
long cnt;
# O% a+ Y& H. R
long val;
/ r6 D) c2 S, B6 X6 Z) k
long size;
6 s) k6 ~1 e& X3 U/ u) s
int i = 0;
" R) O; B7 L- s( ~
. t5 @4 L4 S; u* H e$ i. v& {/ G
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
) C! `4 S: d" ?' z% y0 H: j$ |
addr = base + cnt; /* pointer arith! */
. Y x* Q, k4 j6 v2 |/ d: b
sync ();
; T2 c! {+ u! T1 }% t
save[i++] = *addr;
2 d" u! @9 V% c) a) S3 V& {
sync ();
+ d- d6 e7 E4 u# ^+ C3 ^1 d
*addr = ~cnt;
$ b9 \ j3 N' F5 X
}
7 b" O% C4 L9 Z( @
% _4 ^5 f, q4 D. Z, `
addr = base;
5 ^0 ^" p2 o0 O$ N
sync ();
2 v+ P& x, B* ^+ e- [' i, _
save
= *addr;
$ r$ O1 e0 R& x8 ~- i% c6 c
sync ();
- O* S. j& n r$ ` {( U
*addr = 0;
3 E) C: e, M0 R8 r
7 l3 L3 i7 R, G0 Q0 k; w: r$ U
sync ();
- P( ? S& n* L, I$ t% H
if ((val = *addr) != 0) {
0 E( G- x @2 q8 V! m5 @6 B
/* Restore the original data before leaving the function.
2 h# z$ k4 A, R2 M# c
*/
: B# Z# [. ?# i4 o
sync ();
% a6 J0 t; ]- i* B) x: P; I
*addr = save
;
( } H5 K$ m4 s% X1 [
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- x) l- j2 Z8 }; \
addr = base + cnt;
) B% u/ N" t( Y) f, G7 `
sync ();
) p- Q# K9 X$ k6 T4 ]. n& M# B
*addr = save[--i];
) X9 t* x& c5 A
}
1 E) o: x; M& V9 C; C- y5 i
return (0);
6 Z# D0 D* x7 R4 B
}
, F/ C; o& T5 S2 z: g$ P) e
# F+ G' F# u5 I7 ` }% i! X% ]
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 `* Z$ j# ^- E1 U9 N+ d+ n
addr = base + cnt; /* pointer arith! */
* c& F y9 j- A( P
val = *addr;
: z/ {& Q; z7 g; H+ @4 y" u
*addr = save[--i];
2 q; N+ g$ F b2 q6 w7 W) n
if (val != ~cnt) {
: [+ d( N9 ` E
size = cnt * sizeof (long);
* ?4 u& q4 E" B9 V
/* Restore the original data before leaving the function.
; g; T' G. g$ `; @5 g6 H
*/
! h/ C9 T! y% Z8 z4 |$ d' i
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- y8 `1 Z; b! v
addr = base + cnt;
; X; E( h! r9 e8 h
*addr = save[--i];
; p5 W# p5 h, b5 _) g2 u5 J
}
$ n! v1 ?0 J1 M+ z6 V/ N6 t
return (size);
5 N( w. {, { X/ R% l. C
}
; O4 B, G: V# e& C; H
}
6 Y% [. e; {6 [* j
. q0 Y5 E3 M7 i' L
return (maxsize);
6 O: B* S' L( q, [. X5 M
}
8 S3 O% U. r6 x: I( b' T
int dram_init(void)
M5 _9 p1 k5 T
{
7 N9 | I7 O6 B5 o" N
/* dram_init must store complete ramsize in gd->ram_size */
' H( H1 I9 m) G: V+ A, w* u
gd->ram_size = get_ram_size(
, @+ A5 |* r4 y, [: \" b. N
(void *)CONFIG_SYS_SDRAM_BASE,
+ e9 s# J; ]9 ^; \
CONFIG_MAX_RAM_BANK_SIZE);
% J( S. ~" V7 B5 H& _: a
return 0;
9 _* [+ h& Z9 h' v$ b- x
}
) D2 U/ ]) `; T1 B/ T5 ?
$ Y/ @( r: k1 C( \9 T
# C& ^) l1 q6 i/ I6 ~4 k. j' h
7 G" h& g% N! V/ N, S
3 n0 u7 w2 x; ~. i
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
0 c, }* l! Q2 M( X0 e# X
- o- u' I) N0 q n+ U- M
5 V+ S$ k4 b7 M! y% s
: q& ?. ^) R: R* V) O
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4