嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
1 X4 b3 W, C; K
核心板2:DDR2 256M Byte NAND FLASH 8G bit
- J* T5 A9 S: E: i& ^
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
( |0 O3 E$ F5 O" c6 m0 q
* f) v: ^# i% m- Y5 b0 J
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
' d- @% S2 Q( m E& q# \
5 B; P& s: I0 R* t7 j) c
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
7 ` S4 i2 O6 R- X% b
/*
3 |$ m$ s Y4 k7 Y3 m
* Check memory range for valid RAM. A simple memory test determines
\2 V6 S& y) I5 e. O( I" K8 \. e
* the actually available RAM size between addresses `base' and
; z1 y7 ]1 f) W( w
* `base + maxsize'.
/ f# W8 @. q' f$ o7 \' A
*/
) b s+ ^$ g8 d9 L# G4 \4 i
long get_ram_size(long *base, long maxsize)
5 Z8 b4 d, W) K5 w# T+ E
{
' z1 V! e% G9 q
volatile long *addr;
) d7 q( _9 v8 W; }# e7 m
long save[32];
$ _9 {5 O0 ]* E8 p( f5 x
long cnt;
+ D2 _% O [+ e1 m4 u4 z. z* @# l( f7 d
long val;
# x. T1 I e1 |$ W6 t2 i
long size;
( J- G4 A) g0 H
int i = 0;
$ y6 {! f$ |+ _$ m3 o
* d# e, J" m0 ^. P
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
, z; ]- G3 d6 V
addr = base + cnt; /* pointer arith! */
, D: [8 u6 q* L% F; s
sync ();
' \5 Y, i' S+ Q; {; N
save[i++] = *addr;
: A1 h: c$ o( w8 {3 _: S7 Z
sync ();
9 }- i/ g4 E! \* {% K9 {
*addr = ~cnt;
; i7 ?4 r: Q7 P
}
6 M" R# X7 K8 o' B" L! r
4 Y0 k M: b6 P0 ~/ e
addr = base;
2 c8 |6 }2 f1 q& o
sync ();
; f; A4 i' g% J' x$ b
save
= *addr;
3 H8 e, s3 h) ^0 ?( v, w, z5 {( E
sync ();
1 P# s% b* [6 q8 H n
*addr = 0;
5 C5 H. z3 E4 K3 @. W: `# K6 G
& w" o5 s( p7 n9 n
sync ();
1 k1 ?( C/ H+ C# y: s$ \
if ((val = *addr) != 0) {
# Y1 y2 A% s0 c4 Y
/* Restore the original data before leaving the function.
1 T D9 _. D, K* B) ~) l& B
*/
9 M0 l; A5 j w/ J# B# H u. Y
sync ();
* n7 P6 Z1 `7 M; K$ p6 H3 P& u7 L
*addr = save
;
) U( d; G( a" S) Y3 o0 J6 ]: W3 w. F- y3 a
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 |" x C$ Z! F; P9 R
addr = base + cnt;
/ V& C# D a; Y; q* F0 x i
sync ();
# v1 ] p1 h# J" ~4 x4 M9 V
*addr = save[--i];
* R/ r! I, {# y3 i
}
) o% G) J$ y) d' D
return (0);
# L2 m. U. o3 V+ O) x+ J- s
}
# F" K, o! a& D2 p
3 \6 R9 r- X t* G" P4 W2 H
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 c; `4 N4 P: c" y- V1 P# m+ s
addr = base + cnt; /* pointer arith! */
% @: L1 {% S& L* G W5 u. v* K
val = *addr;
& X" v8 [5 A9 D$ i) Y+ r) l
*addr = save[--i];
/ P! U' U/ {0 X4 n! a! i) b
if (val != ~cnt) {
5 x- Y2 f) c( ]+ R, T, }9 j
size = cnt * sizeof (long);
# I) F; E4 x" h2 H$ q- C2 ^ {
/* Restore the original data before leaving the function.
) d2 ? z8 K/ J% j9 n
*/
j s' m6 `- Z7 g- K$ t
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
8 r- B, w( G x; d& v
addr = base + cnt;
* c' V# H& w) l' K
*addr = save[--i];
0 F0 E% T- \5 Q# _
}
$ x8 Z c0 F5 ^7 o& P8 A# j$ A
return (size);
- k* X3 |/ j) L n
}
, a* l, r% \* l$ B1 Q+ d
}
2 v" l* y: A9 a: D7 ?
. E3 L5 T. i( Q) P6 N0 r# y# x% Z
return (maxsize);
& O1 X5 a# L. u( _
}
" j/ {# R1 l' t5 Z
int dram_init(void)
. p. ]4 `* ~' O# `
{
2 h |4 H z; O, ]* r
/* dram_init must store complete ramsize in gd->ram_size */
: b0 v. L/ Y" X( R" h3 Q# `8 r4 h
gd->ram_size = get_ram_size(
$ S3 E& Q9 J. |( ?( `9 L6 `
(void *)CONFIG_SYS_SDRAM_BASE,
5 }( R7 U8 g/ b- Z) f0 m9 h
CONFIG_MAX_RAM_BANK_SIZE);
# H! q5 s$ ~- q/ @
return 0;
: v: g. r# ~; G' _0 R. E; d
}
4 C* M1 M6 U( b: A
) L: `7 Q5 ?0 \
b2 ?9 ^3 i# N) M* G* O/ R
4 P- \4 w# ?) j- S b
1 Y6 U L' X$ c3 p* u
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
- H$ b0 W4 Z, }: O2 j
5 D- T9 b* {. o7 j% u7 @+ J- ^' P
$ H! e- T" `9 S
* o) f3 S6 Z& Z8 w) [8 G7 A G a
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4