嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
2 [1 U8 B p1 A5 z' x% s
核心板2:DDR2 256M Byte NAND FLASH 8G bit
: b a/ j" b J( n6 U# Q9 T
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
& U5 @+ g' r8 X5 @/ J* r1 K
( u% r" U$ v! S# b/ W u. @$ l3 \% K
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
1 y* I }; d8 h0 N
" L0 |, h2 a% s4 X2 F% W: w
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
, }5 ]! x( i& V; f
/*
, Q- Z5 P7 p# \: f% M" ?. Y
* Check memory range for valid RAM. A simple memory test determines
& {* O5 Y# j4 c; z9 \
* the actually available RAM size between addresses `base' and
' k& H. f& l! V( [1 s8 c5 L1 R
* `base + maxsize'.
0 Q1 f- L+ H7 A: n0 L E: P& ~% c8 Q
*/
) c8 g7 G5 S; E b
long get_ram_size(long *base, long maxsize)
& t% w& K: T9 n2 O8 `. @. R1 f
{
) z6 I4 ]& P0 W% C) g; K
volatile long *addr;
V/ S) C$ f& ?9 u; I
long save[32];
7 h' M+ }$ c6 ]. p
long cnt;
$ y U* g! `: c6 t3 B0 K9 J6 R
long val;
4 y! M% Y8 |( |9 w$ [; a
long size;
8 G3 Z6 `0 ^) A0 ]& i. ?
int i = 0;
# r: ]* U* W( p0 e5 f" z
9 f$ b* k0 c3 ` |2 E8 b0 n
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
. f# O3 [$ x* n- f
addr = base + cnt; /* pointer arith! */
& J5 z9 {7 A) Z2 ^; J/ Z7 s
sync ();
0 l3 ~ x- P$ n) l
save[i++] = *addr;
; g( W1 T% d1 s$ |
sync ();
6 l7 Y/ l) X- u. X- o7 y5 Z
*addr = ~cnt;
6 @7 S4 g! j+ `' ^8 C: ^# h
}
' Z4 K5 d4 S% \% e
( z+ {; V9 o# J: p4 G: n2 P
addr = base;
( O. n* e! n, q! j( Z. s
sync ();
3 S0 n1 t9 U# t. V# \
save
= *addr;
8 Q3 @ R9 c0 I
sync ();
; R7 v9 q( c4 G* V0 }
*addr = 0;
; J; ^/ M; I1 {
& A7 ]. A# r$ P( B5 O6 h p
sync ();
- ?9 I u* Z( g) v2 x8 g
if ((val = *addr) != 0) {
) V n7 M* a$ e
/* Restore the original data before leaving the function.
. j& z& Q6 t$ s1 m6 [$ q' o
*/
, }) i# v: v8 G$ M) h
sync ();
, K. l& |# A7 K
*addr = save
;
% o4 e# a& m# P% K9 w- Z6 k) O
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
5 j# Q* C' p. J( v/ k
addr = base + cnt;
5 Z* B" U) n5 a, G b) X
sync ();
! R8 L. F& o7 P8 ^! ]$ i' z
*addr = save[--i];
3 R, H3 h4 R& t$ b' N2 F$ z* L
}
/ J% D0 K6 q( F& U9 U5 _4 n9 |
return (0);
. q! T7 W/ U) g5 H
}
3 A8 q1 o4 B2 ~( K' ]9 c: Y" W
. u* c, G d/ N! y, }) `
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
9 C( U3 P7 `4 ?8 Z2 t1 t6 R# z: o* p* q
addr = base + cnt; /* pointer arith! */
- s+ v1 k( V. I+ m( h! F
val = *addr;
; k. j: N; e3 _* Y1 K0 d
*addr = save[--i];
" q1 q) s' A/ N* q1 \) j/ x
if (val != ~cnt) {
+ \2 T, z" y c4 o1 U- |
size = cnt * sizeof (long);
( h6 E5 e4 Q& ], P! K, ?
/* Restore the original data before leaving the function.
7 J$ V5 n/ L" _6 s
*/
C1 z q, X1 Y$ p
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
: @% h% s Y* m6 g: U
addr = base + cnt;
+ F$ V8 C+ C9 d5 W. ` H @
*addr = save[--i];
' X A, ]0 J$ z" N5 i
}
* r$ E( ^& Y! N$ ?, t
return (size);
' B+ p! B' j; s& a/ s
}
' i1 z- I; m- E" f
}
; x0 p9 [" f5 a! X
~* z" |5 d; S, C/ _
return (maxsize);
7 Q7 A( u. d2 R. G2 l4 H
}
8 c' G8 |4 \7 }3 O
int dram_init(void)
9 M1 J% l+ c, t) |
{
( b1 z1 D. s# B# }
/* dram_init must store complete ramsize in gd->ram_size */
. D7 U5 P) f) b9 @! M' u
gd->ram_size = get_ram_size(
! `& d7 E6 @% f! Z$ p* a) q8 |5 u
(void *)CONFIG_SYS_SDRAM_BASE,
0 M$ s' G# e- S) i" X
CONFIG_MAX_RAM_BANK_SIZE);
! B! Q: R4 e* g) o9 [4 S3 ^
return 0;
4 m0 t1 q" V, O' p% i) @/ g& _; L
}
% U' ^' K1 y4 t
; R( U G$ ^8 p$ Q5 u8 N/ ~% d
7 U. Y" H! q8 _7 B P3 \: B
4 v) R1 G9 O) A, L, M
D: p+ L# V* H
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
: v2 t% a. S6 B8 g! w) z3 u1 ]
& q) K5 }" Y7 k/ G' g+ r
) ]9 Q, q* o1 J& f6 T) R
0 a! R7 Q0 a- i3 O) J6 _) @+ B
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4