嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
6 J) s0 H% U; J4 ? ~
核心板2:DDR2 256M Byte NAND FLASH 8G bit
, q' E9 L/ F/ Y6 R+ j, ~
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
+ g( V8 b3 [$ d1 j6 e
* z+ Z6 R8 ~$ G; C/ {2 g1 p* \- k3 R
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
" w8 w8 c8 a8 g- v) O
' N. D* N' J! }& ^# _" z: ?
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
# w, q6 G/ o' f. S( g# L
/*
8 p) e3 b2 \; Z
* Check memory range for valid RAM. A simple memory test determines
! q5 U7 }% [! S! h* ~
* the actually available RAM size between addresses `base' and
& n3 l4 D1 B7 d- q2 Q
* `base + maxsize'.
" W N9 u( A. K T9 g% t+ \' g
*/
: [) d' x- |$ l2 a
long get_ram_size(long *base, long maxsize)
, e3 ~( w, D- i% T- a2 ^' } ?2 f
{
1 {( z8 A% e9 E
volatile long *addr;
% T" ~& @( x$ I/ R" @
long save[32];
! {. O2 _( @/ `& O2 r1 h9 m% ~
long cnt;
1 A8 {$ H8 ~. Z* x
long val;
3 R1 G* V6 E# J5 y. H' e$ ^" B
long size;
! f j% G+ u$ H+ o- X4 J2 P
int i = 0;
6 I5 R3 Y! v2 L7 f& A, n4 r
/ g* D' f0 ^* n4 Y9 {
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
# R) o: W. `3 ~& ~0 U+ D
addr = base + cnt; /* pointer arith! */
& q" |* f8 q J2 _' @$ n3 x. @7 s; e
sync ();
; ], S$ X& n( m( P
save[i++] = *addr;
# ?/ S$ S) T9 X% n
sync ();
5 K0 T$ `# G/ U0 q
*addr = ~cnt;
# n8 L, Y2 B! S* w- z
}
$ g1 Z5 I' ^; a+ f
9 g' V" N/ C! M+ L" Y# H! l
addr = base;
$ Z6 D6 h: b/ i5 P+ B+ F9 z
sync ();
3 {2 F2 ?+ v6 u0 v& z
save
= *addr;
7 }: M& ~' {3 p
sync ();
7 e$ F) e! W+ h* k- ^6 S& K
*addr = 0;
. x' a7 ~2 v. b
, O) f& S* M' v- E5 A! o S3 ~7 s
sync ();
! M* ~$ {0 K3 k7 ]9 W( E6 D
if ((val = *addr) != 0) {
+ H4 J7 w3 m6 s) V/ n( Y- c5 @
/* Restore the original data before leaving the function.
4 ~" O+ L) e+ ?) B) `% o! J% `+ _
*/
0 Y4 x' x! E2 e6 Y& G" H
sync ();
; }: W1 `4 D0 n! x* q
*addr = save
;
# Q2 {7 Z" q* i+ \
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, C0 w; x% C: q9 f6 A. d
addr = base + cnt;
) c9 G: H5 e: g {/ j; I/ R
sync ();
$ Z6 L1 h& l0 w. _
*addr = save[--i];
6 _; M1 Z; e$ Q
}
; \7 c5 {. i! A) ^4 {% e) l1 F y
return (0);
/ ^1 P+ Y3 l3 x* F
}
9 D! a* `) g# ^! Q A9 a) `- H6 l6 }
& C- G% T; q f3 D
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
* O4 R a8 u! x! G, J! f: z( T0 p
addr = base + cnt; /* pointer arith! */
7 x0 {) N! b0 [9 G: k
val = *addr;
: b& y- j3 S: f
*addr = save[--i];
- Z1 z K% I/ S3 ^% [
if (val != ~cnt) {
/ q: i# d) r2 ~' G6 O4 R: |
size = cnt * sizeof (long);
N/ E" l( X% K) N" H( ]
/* Restore the original data before leaving the function.
) _* n" e* [( i; o* |( M6 D, k
*/
0 r# y; V# a+ P! F0 V5 x$ i
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
8 }- |& M+ p8 `6 k
addr = base + cnt;
; Q+ [2 u6 ~0 C7 ?( [
*addr = save[--i];
: i: Z# y% V3 C) }
}
; ?! c& f- D( @ a( S/ A' l
return (size);
8 {" A* N9 y3 i6 {
}
( v8 U {7 e, G8 ` b0 a$ g! l
}
+ P8 U# z3 v& z5 H) D9 A( L
( `- K+ t0 q1 e5 j e* r) u; Z0 k
return (maxsize);
3 Z: |$ Z3 ] K+ y
}
3 p/ G2 k8 S" I4 o
int dram_init(void)
* Y& Z9 i7 W% k9 J" k/ \
{
) C0 ~2 \& R& K$ \/ y% a# p
/* dram_init must store complete ramsize in gd->ram_size */
. D0 r5 G, S; i- h- u
gd->ram_size = get_ram_size(
0 U) p8 ?: E5 a: |# ^, c- m
(void *)CONFIG_SYS_SDRAM_BASE,
# ~8 z9 w4 W8 f! w O
CONFIG_MAX_RAM_BANK_SIZE);
) T, z3 P6 T8 ~9 l+ l
return 0;
' n' ^3 g9 n) r
}
% A4 [+ e, i5 w3 X N$ D
$ F$ |# Z4 j8 z& R1 z
3 \- w* M9 W6 C6 Q0 |/ _, {4 H
4 }+ r& j4 V# U- t/ W
9 ]4 c6 h, L! k! |4 J7 X
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
; O/ T2 ]' E# d1 a$ q6 a" t) j% x
/ ?& K2 Z: x2 M9 S6 s# s
5 @5 j$ y/ s( U a8 @$ G( I
+ E) f T& ` }( @
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4