嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
9 ^5 Z4 [) g; H3 L8 x- ^" M% f
核心板2:DDR2 256M Byte NAND FLASH 8G bit
8 V; D' F9 {! U
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
6 ~6 j! @$ ~' Y! Q4 b0 d% w
9 a( S" y. H( i, E) A% c
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
1 s/ y$ \( j6 E# |" P
! h. j, c6 S. b0 ~; Z& z+ h
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
3 W; _/ J; l1 h
/*
* N: [. X( O6 o5 w% @% j
* Check memory range for valid RAM. A simple memory test determines
: F+ \2 h9 |& R0 D2 s- r
* the actually available RAM size between addresses `base' and
" ]+ d3 p: r% M9 L; V
* `base + maxsize'.
, j( M* z" D$ S
*/
- y5 u$ j% n: Z) v: _# F1 E9 m3 |0 V
long get_ram_size(long *base, long maxsize)
; I6 e: H/ X1 F' h3 h$ ~
{
5 { m9 N' G2 A5 p2 `
volatile long *addr;
! j. M: ]3 T* \ ?4 C# @$ x4 r3 I
long save[32];
! L* S; N" w( [: C2 N
long cnt;
3 t+ P, x; r5 h& |) W; h: D" l
long val;
* H5 e5 H7 h% [; J
long size;
3 R. F* |, f' x. h1 T1 @) P
int i = 0;
) E0 W& i0 j) H
, V6 u0 L! I) j3 ]/ o) Y# I% ?/ q
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
# p, G+ F/ m; y! b9 M G
addr = base + cnt; /* pointer arith! */
, C" s0 b: h8 Z) y3 r8 b, w
sync ();
, R" l8 f; j- U: O) P% j/ X: W
save[i++] = *addr;
4 M9 Y" R N8 a" y _
sync ();
- M2 v3 `+ [2 A: |9 U8 W+ I( d+ F9 S
*addr = ~cnt;
1 i3 ]& I' r6 d3 N9 b7 K
}
. [* s o5 Q/ ]* l4 _. r* x
0 C' C: }: j3 h" Q( }! w3 @% U8 @0 d
addr = base;
# \, q; X I! z7 P# |
sync ();
3 n3 n/ d) ?3 }. U
save
= *addr;
1 H8 v i0 M D& P; ^9 Q. e
sync ();
. l& L8 U7 T1 Y" }6 \
*addr = 0;
+ S$ ]# Q2 |) `7 Y
, p" T+ S! f& t4 K
sync ();
8 E Q! ?' \$ S- v6 I5 E
if ((val = *addr) != 0) {
( h$ v$ U! Z0 `, E
/* Restore the original data before leaving the function.
! o+ t9 Q* K7 k) P ~
*/
! m$ j- P# o& F& [ m8 e! h
sync ();
2 b+ [, y1 l+ R' f
*addr = save
;
7 \$ U% _% \$ l
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, w2 E e; G# A9 z% S$ f5 {
addr = base + cnt;
+ F7 ]9 M5 }# p
sync ();
4 Q# T6 h1 S( l( F9 u
*addr = save[--i];
- s/ F% ^ U X; y# Q8 P
}
4 ]5 D) T, [. U0 Z7 C \
return (0);
7 D& u: L. s& K! b% q! y) q
}
% J7 y5 b+ N9 i; a! t* ~ n; q) j
" V5 V& _4 y1 {$ J
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ N/ T( |, b! e! l6 H- L
addr = base + cnt; /* pointer arith! */
1 I6 t3 R4 r: c! K' H, b
val = *addr;
: N! I) z+ ^. ], m5 q
*addr = save[--i];
2 k+ X- m9 E" R2 r r) }5 |
if (val != ~cnt) {
; p% a# l) U8 b/ m, `
size = cnt * sizeof (long);
+ G @+ g6 A! c% p/ u! ?/ w
/* Restore the original data before leaving the function.
- _4 r9 Y4 n5 ?' K
*/
3 a5 o6 U1 |) x5 @
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% [; C, ]& Z% b! Y' L
addr = base + cnt;
) s* F+ ]7 i |- l. O! \
*addr = save[--i];
& k2 W, e$ l0 h
}
& d/ |' v! z8 e4 ~3 h5 L
return (size);
1 u7 D! `" z* G
}
, @# ?3 I* v" ?9 G0 V; m
}
) f0 B, R) \; j
5 \9 X4 Y+ R6 D9 |4 w3 q7 Z
return (maxsize);
- t. `! Z" ~4 q! L) Y
}
8 z. B- H+ V- E5 U
int dram_init(void)
) a* x' J6 n) @
{
7 {% _" I, B9 |( e+ ]
/* dram_init must store complete ramsize in gd->ram_size */
0 n' N. _5 J }: A1 o
gd->ram_size = get_ram_size(
2 w' H* X' C# f4 ]# a% l
(void *)CONFIG_SYS_SDRAM_BASE,
+ i9 L5 f/ l/ [4 F
CONFIG_MAX_RAM_BANK_SIZE);
6 G6 ]% W9 A" E2 | [8 ~- G
return 0;
) U# Y( W5 z- Z2 f7 m2 X# E
}
3 n/ a; B& I- A ?/ r: N/ `4 {, n
1 F) n n2 J! P( z8 i+ g5 m: h
5 ~) C" _5 ~2 V4 U
' O1 `3 f6 n9 o. s7 V1 s# R# S
5 X& D8 n. M1 i8 X# t. f. D0 X, J. H; p
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
4 y7 f% D3 a* E f7 v) Q$ ?% x% j
( W$ D3 }0 p8 Y7 [& U. x7 n5 b+ w
1 ^" V, B6 f# I0 t
$ b* R @) p& y Z- @+ d
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4