嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
+ h5 @3 J5 J' ]9 s
核心板2:DDR2 256M Byte NAND FLASH 8G bit
7 d: R. ^8 |% q' B' w
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
% }% M6 g8 R9 S# I( f! p
! C. t/ u6 l$ Q" B" |, g% e
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
8 B w$ ]7 a* P
# m5 k3 r4 X- m
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
2 O( j8 {, f3 J
/*
) U/ M5 u8 S5 B
* Check memory range for valid RAM. A simple memory test determines
* r- K5 l5 k/ m
* the actually available RAM size between addresses `base' and
+ y" w4 c+ ]: l0 V7 Z, |
* `base + maxsize'.
1 l8 g* e, o* a
*/
. p, u9 c5 ?2 C: U% O1 @5 G& g. b# r7 M
long get_ram_size(long *base, long maxsize)
8 S( [& c' A! e7 N. |0 y
{
7 l$ V. ]- h! ]. Z1 `
volatile long *addr;
3 Z4 H* p/ V* [6 e3 D+ f7 b8 b" s
long save[32];
9 M8 F6 H& b8 N3 l4 {
long cnt;
0 E/ r9 d7 Z4 S! Y
long val;
. \2 P- z3 C# ]9 j/ R9 g: d
long size;
8 S# y. l* I2 J2 x
int i = 0;
0 }" \4 j6 t+ `" f; D2 w
, r8 J* e( I/ [( @/ J5 b4 T" D0 A
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
0 |8 K3 M T* w: F# R% ]3 O
addr = base + cnt; /* pointer arith! */
2 ~% g- \5 B1 H. n# p9 H' H t9 t6 T
sync ();
: Q U, Y: E; G+ W" ~2 ?, ]
save[i++] = *addr;
! n) q2 r$ Z% V/ {+ P" p
sync ();
8 a4 k' ^% S! f" {! R
*addr = ~cnt;
8 ]6 i7 f. T. D& @
}
% N2 U @; P( p' r$ ~
: _ M3 m1 s3 g& R+ J+ Z" q
addr = base;
+ g; Q& _" F1 z0 Q0 _7 \
sync ();
% ^7 W2 P/ o6 W8 p% J* G
save
= *addr;
" q/ F* q' w1 s4 @
sync ();
d1 Y* W2 K0 p% u+ ?2 W
*addr = 0;
) d/ W5 m/ e" K
: X! I& f' m {! [+ b
sync ();
% W. N6 `3 q& `+ V/ K
if ((val = *addr) != 0) {
! I8 d6 c, V7 ]' j4 V) @& `
/* Restore the original data before leaving the function.
$ d! Z; U# Z1 A9 Z8 o
*/
2 W/ U# q, q5 _$ f, ~
sync ();
: W4 b" C: V+ i2 J @
*addr = save
;
$ n: Q, b1 z$ e6 d$ ]+ X( D0 F" j
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
# o6 ~6 V7 I, O" _
addr = base + cnt;
& J; P' B. G- e- Z( f- C! J
sync ();
- J! @* w6 u: |% v
*addr = save[--i];
' n% S. v; h" S/ y) C
}
1 A" l( n/ W' @- j+ P8 e4 S# ^
return (0);
. \+ S* E H& r; d& L! ^
}
5 u# z* D$ K& ^9 c% |
* R9 r7 U! |! X# J6 ^) `
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& \$ |6 o7 i. ~1 t i9 a' ~
addr = base + cnt; /* pointer arith! */
3 Z; S1 E1 X4 |
val = *addr;
3 l9 t; Y# w4 ~
*addr = save[--i];
) B- w% m* A' `( X9 e) T4 V9 E
if (val != ~cnt) {
2 W/ f5 F8 s* J: {6 e2 \( S( h
size = cnt * sizeof (long);
! l3 M( F ~1 o0 x& o/ t
/* Restore the original data before leaving the function.
( p b7 J& m4 P" H- C0 c" I; I5 M0 y5 N
*/
- A* s; Z E+ v: O Q1 I h
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ H* B6 M- t* A/ n/ a/ }6 o% E
addr = base + cnt;
% B) P' Z. w7 E% A: M2 B
*addr = save[--i];
! v9 U! J" ]" r
}
+ c9 M+ ?0 W* Q5 z
return (size);
7 V2 r, t( G$ G3 L! c8 B: b
}
* z* h. G0 l2 y3 p) d
}
. F" Q2 l' |+ `0 _' [- Z9 Q4 C7 e
, x% J! f% p) _8 j$ @
return (maxsize);
/ q: P8 y! {2 Y0 ^
}
5 C+ D% D3 y' W P4 v) Y5 d
int dram_init(void)
9 ^, R: g6 @$ E' e& p- j$ E+ p
{
D. V, I/ J) g9 n" F6 Z6 A
/* dram_init must store complete ramsize in gd->ram_size */
. d9 v: R! }( _+ _/ @6 E" Z/ [
gd->ram_size = get_ram_size(
% q, J2 q7 N4 `! R/ A& h
(void *)CONFIG_SYS_SDRAM_BASE,
! N# Q1 n+ V0 W% m _ I, J
CONFIG_MAX_RAM_BANK_SIZE);
0 h# H, N7 ^0 R7 M! v, x( Z2 R, o
return 0;
( r' ]% e. Y, |1 A, A0 {
}
/ s e& Z9 {9 q+ N9 `
% X- T8 }4 q; l3 g6 y
3 w/ N8 D0 `/ ]% B4 ~/ g; E% r
2 O% Z) k8 o k" ^# W
5 B/ h" d8 X3 d
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
g: F% F$ X1 I i
8 }5 a% [# E' o$ o- _
! n6 I: L- C+ U
' h8 S: v7 ~1 A8 N# g: {
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4