嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
6 \7 z7 l5 A5 |+ Q4 _
核心板2:DDR2 256M Byte NAND FLASH 8G bit
! j0 y5 n$ y$ a5 F: E$ T* b
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
6 w% r/ D, c {) D& C! I
- y8 V8 W3 ~3 F0 R+ f0 g, c
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
; }5 M, W, [7 x1 c# W) ]4 A
* C. e% o$ u, T7 [2 O
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
9 o. d a% Z- \
/*
" g) d( ]) F( C& F, R0 ~
* Check memory range for valid RAM. A simple memory test determines
9 z G0 J% V$ G7 f; s# f9 [( d
* the actually available RAM size between addresses `base' and
( l( V' e6 i7 {$ M# F
* `base + maxsize'.
( [8 O% a6 D3 h
*/
& S/ m3 v3 | W/ X' x6 z
long get_ram_size(long *base, long maxsize)
0 {2 x4 F! e+ ]
{
4 d" m/ W+ a" ]. r# w
volatile long *addr;
9 i2 t' D$ B# U9 b
long save[32];
9 Z# D; r; q1 j# l5 D2 y# ?
long cnt;
) e' t7 b3 ?6 Y8 |
long val;
5 t4 G( U' r7 ]+ a9 x Q! B
long size;
6 N; y4 b! F, Q* C* I
int i = 0;
7 @9 M) e0 ]2 \* ?, m2 q9 ~* h
0 B# e b9 i( }' m& L7 [5 X9 y
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
9 {+ c. |, h) @ J
addr = base + cnt; /* pointer arith! */
+ G2 t6 M7 G2 U
sync ();
0 E0 l4 E% Z4 p. M- p+ X5 ?
save[i++] = *addr;
$ m* ?0 d, K# x* d O
sync ();
# \& v, a+ k8 r, b7 L
*addr = ~cnt;
! y$ n$ X5 ]4 N, E Q# P( H) `& r
}
: P% j. c) V# ^/ x
2 j0 q% ^2 W* G! V6 K% s3 Y( b/ V
addr = base;
# k5 G# }% K% h2 S% M
sync ();
7 C4 F% |$ {3 @
save
= *addr;
+ m. K6 F2 s6 g* T
sync ();
) s/ ]( I7 l& B6 e1 o( ]0 m0 L
*addr = 0;
M: j- }. n: b: \5 Y$ M
) r& ]! l, S4 N* @6 h: R a+ T
sync ();
. |1 Z& M+ U4 [0 V/ a/ d$ w
if ((val = *addr) != 0) {
. ?/ D" Z* T( }
/* Restore the original data before leaving the function.
2 i* z: J- Y; y4 ~, X
*/
; [& L( ~& F0 l2 A0 i
sync ();
& N. p9 g; b: l W4 i
*addr = save
;
, t* M" \; R3 v/ G1 e
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 i4 G, Q) i, w; V1 \. D, R5 c
addr = base + cnt;
0 [0 a( F0 y, D+ Q5 y! N5 I# K
sync ();
5 w6 Y# H+ }. v( w% m% |
*addr = save[--i];
% W% ^% V* O" C
}
* b* _' e# ]( n% s: t
return (0);
$ u( N/ ]& i8 q ~; i
}
: B* \' }+ n" M. t5 P4 f
3 F$ {9 p+ c0 @0 Y9 C: L
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 G$ d" J- i' P. Q3 `! f
addr = base + cnt; /* pointer arith! */
2 m2 c ~% m( [$ ]) f
val = *addr;
$ W7 K( ^* D" v6 h
*addr = save[--i];
' d s, o S; C( s" ?7 z
if (val != ~cnt) {
6 [1 q$ o& k3 j a2 r" v5 I
size = cnt * sizeof (long);
5 }4 s/ `. [/ I+ o) u! h3 A
/* Restore the original data before leaving the function.
# m4 G+ Y3 t: V2 V+ W @$ ~1 n* M
*/
# H8 n8 V! h \! i n, q- v
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( M U" `& t/ m
addr = base + cnt;
4 w/ L- l/ D! a8 v/ M ]
*addr = save[--i];
- I! r7 ^ F6 k: n* P
}
% Z! P" X$ r8 v p: W3 L2 i
return (size);
+ @6 \/ B; v2 S* K2 R) u
}
4 M- t) v; v6 b ^8 B% |7 X, h
}
- g( U1 @1 z" {, N8 }/ a1 M
( X# Q+ a5 j5 v) ]" _1 R
return (maxsize);
5 S/ r9 I2 @. B$ ^
}
4 e3 h9 F6 v7 ~. o' k
int dram_init(void)
* `' D" N/ Y+ A9 F
{
0 e* l0 [, M6 c' K" l
/* dram_init must store complete ramsize in gd->ram_size */
) q7 M* l. D. a6 C
gd->ram_size = get_ram_size(
4 `. [4 S; B, A4 Y+ ]0 p5 X
(void *)CONFIG_SYS_SDRAM_BASE,
5 B0 K2 E& U6 |6 A" p1 l" u8 r
CONFIG_MAX_RAM_BANK_SIZE);
% U/ N; j# Z5 G3 g' L' o" k4 Y3 C2 K
return 0;
8 E D( K% z9 A
}
* ^! O/ G: d8 M; Z V
2 M- m: L7 {) A" a+ v! o1 P
/ |1 l, }6 E5 F5 ]6 H I) C
! M5 g) }7 O' m# i; a; d
' N; o/ Q! e) g7 d' `( }1 z9 J
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
9 P" p3 ^! w1 B3 G. X4 x5 s, r4 e
4 A- I9 k9 O# j5 E
" D7 u1 p6 [+ Z6 y' ^% [
; r7 W1 T. b$ a) w; E D# a
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4