嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
6 @: `, l/ R3 X
核心板2:DDR2 256M Byte NAND FLASH 8G bit
! X* ~ s5 j- O9 p
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
) _" k8 X8 [& ?% y' y
! R* B8 Z; j" a) d
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
5 l# f* b% w4 x8 o6 `: S9 l8 P+ f
# P( Q- d9 j6 b' e* D& Z. U+ D
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
" [5 h1 o( y, }* R1 [
/*
% @3 N3 {# P" h
* Check memory range for valid RAM. A simple memory test determines
- |* v; F8 v! d$ d0 o
* the actually available RAM size between addresses `base' and
7 z: `3 B7 i6 |( Q
* `base + maxsize'.
9 Z+ q& F4 R, r2 J
*/
- X( T8 y5 l8 x1 ?3 p2 z
long get_ram_size(long *base, long maxsize)
6 j* }- k3 z/ q; T* i8 L
{
4 M* b& q. N4 M0 {$ j/ s
volatile long *addr;
$ w" y0 ]: I7 M1 {
long save[32];
* T1 I* g# m$ L% i6 {
long cnt;
2 f9 F+ k0 j/ {, l& L! x
long val;
+ l9 W b7 |5 n# Q
long size;
- ]" T/ k* |9 c* @9 L' Z' d2 C
int i = 0;
& |2 W9 o& U! Q: C- w
' b# Z6 A& r; o+ p- o# j' B' Y
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
) I% E0 ?7 ~; E: ^9 b
addr = base + cnt; /* pointer arith! */
3 o: L6 a% a; n+ D4 Q8 n5 e
sync ();
; G) b# A2 N- b: Z
save[i++] = *addr;
2 U* G1 K; o6 d' Z# A
sync ();
6 k+ `5 N: _: a3 v, ~, w
*addr = ~cnt;
$ K+ Z G: R, @& V8 ~8 N, N( P
}
7 x' J# l! G3 e: ^/ Z3 D" L
- P/ f4 `7 c9 v/ A3 y( \9 E2 Q. X
addr = base;
' ?2 u$ }! }$ j7 q1 @6 y0 h, w
sync ();
5 g/ q) i. p2 S/ M% z7 W
save
= *addr;
7 c* i8 |+ ]3 M" P
sync ();
" A. }* ~" @1 V$ z9 V
*addr = 0;
' o" o7 h# `! V& Z+ A) R6 t
) r2 `8 Z/ ^0 e: ^9 L N
sync ();
$ U3 l- i( r1 @5 l. V9 F" l
if ((val = *addr) != 0) {
d; g; M8 d8 o1 u6 R! R" v; z
/* Restore the original data before leaving the function.
* D1 l( o# h/ k7 b+ e2 ?7 l l) g
*/
+ H! @# ^, }4 ~/ u' s" i. p
sync ();
8 |- x+ L+ @! r- \& [
*addr = save
;
1 y8 `3 t4 ?" V" P# h
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
; V1 x8 R4 h. ]1 r
addr = base + cnt;
9 d" R- _2 G7 {4 N
sync ();
- n4 k: O& Y' f' C) a7 R! b0 f* G
*addr = save[--i];
) Q, [3 |) _3 W0 v& a- r
}
* L. w: F% v4 Z& X
return (0);
2 d8 [0 k7 M) F1 W; M/ ~' M* Z
}
5 q7 H0 E$ N: }
8 B5 e% @# \1 A# }& z% g
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- z+ n5 j/ y5 A% a& g
addr = base + cnt; /* pointer arith! */
5 q* ?2 C3 E6 M$ _' v9 m
val = *addr;
1 X9 W( p1 r) R+ b
*addr = save[--i];
( C# z; a( Q/ x6 p W
if (val != ~cnt) {
- {( Q: a3 m$ q3 `% o) f, ~
size = cnt * sizeof (long);
; C4 f- Q! y' g; T4 j2 D
/* Restore the original data before leaving the function.
8 K- K7 Q2 w4 P" z4 o
*/
% E4 \$ S( m |2 E
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 p4 K4 u& z/ |. `8 }5 E
addr = base + cnt;
- m+ a# `) Y1 z% Z G1 z' f/ Y# O6 {
*addr = save[--i];
4 R" P3 {7 z+ g: w% ?/ T6 V
}
2 x& l7 z7 D0 t8 k! P1 A
return (size);
0 N; A! ]6 y. B/ ~
}
% C) R8 j; w3 d
}
; ?1 t' J0 x/ ~/ B! j
s; P7 \$ x% J8 \0 W6 N
return (maxsize);
) d4 o/ E% e S0 Z2 L8 A
}
3 j7 o: ]) r2 c! V4 c
int dram_init(void)
& g7 G8 ~2 Q5 }
{
: u) t& t/ p! H/ [3 o
/* dram_init must store complete ramsize in gd->ram_size */
4 e: U$ d0 @/ g
gd->ram_size = get_ram_size(
2 q( A6 ^! |# I1 e/ J2 q
(void *)CONFIG_SYS_SDRAM_BASE,
% M3 j- u( ~9 m h% f L* }
CONFIG_MAX_RAM_BANK_SIZE);
0 J0 d5 X; ^: b% \- S) P
return 0;
; D: T9 z( a/ r8 S# f ?
}
. o) a8 y" W* P$ E8 Y; Q
% p- h0 G% o$ u
2 L: j- V: @! m: [# G
0 C$ S5 P4 E- K8 M5 N# Y
7 J: E, H. J( j1 ?5 u7 m
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
( |# R* r, D: e% I$ R& z W
- m* `9 u! I" z! ` m- d
: a" U+ G. l6 R6 r6 x6 W, ?: O4 g! Z6 {
' @9 W- q$ P/ d5 |, J# R
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4