嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
7 |! r, ?3 j0 U8 H5 z2 r
核心板2:DDR2 256M Byte NAND FLASH 8G bit
. n3 b% O3 W# p3 @+ u
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
5 d f4 c+ Q7 d1 _) Z& c* V8 ?
3 o3 ^; x3 r1 m& ?
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
; ^" I) x6 V, Z9 K0 L
, ]1 A4 y* {4 S) x5 l+ ~& K
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
: s& m0 w' a( H7 T
/*
) u! y* K1 Q* f- U, U/ @3 d6 F
* Check memory range for valid RAM. A simple memory test determines
; P# f" ]7 j7 I+ \8 m
* the actually available RAM size between addresses `base' and
D: c4 P% [7 }$ B' {3 i
* `base + maxsize'.
& ^# |( D/ c2 w c3 h
*/
* ?+ t+ }2 B) V8 a% o+ e* Y
long get_ram_size(long *base, long maxsize)
( D# S+ C2 H; f
{
7 q8 z8 O, E9 `8 k
volatile long *addr;
' i) i+ `$ S/ c8 i. L5 q+ ^2 Z- E- Z
long save[32];
9 c& f0 @- J- u: e; ~" w2 N' p
long cnt;
( h% ^4 \) Y6 y
long val;
$ g/ X" @# r2 J$ `
long size;
5 G& j5 G: M( B: d/ `4 N3 |; ]' N
int i = 0;
- Q) ]; V& F1 ~$ W2 g
2 {, f$ {2 O! a' H% o# B
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
' W. ~0 y" z3 D
addr = base + cnt; /* pointer arith! */
7 b) q/ \: s* `: h0 Q3 Y
sync ();
5 V4 x) E* s6 O: _: P* i& a
save[i++] = *addr;
$ ?+ `9 H8 S: B
sync ();
4 v& [! i) s- C, L6 d
*addr = ~cnt;
- l0 W! y7 a1 A# n) a/ z8 |
}
" H% }9 x# d' J5 Z2 m: D
$ c- ^; P& G- U6 f" n
addr = base;
& f" @2 ~, |( n; X. z
sync ();
6 X( I8 H3 w. y3 W3 }
save
= *addr;
/ b- O2 \' _. h7 z/ Z- `" o
sync ();
( P% b* \; U; l Y% t3 O
*addr = 0;
0 Z" W* d: _2 P6 a- ^7 M
9 R9 D; Q' T9 k
sync ();
" X9 W' L7 g) \$ ?4 n$ u# C
if ((val = *addr) != 0) {
T2 [* @; d4 G. ^% D
/* Restore the original data before leaving the function.
+ S( p& [! U. j8 t2 _, [7 D0 T
*/
: A2 {! L' Z( u/ I0 v
sync ();
6 P9 I+ P$ E1 ^+ P8 I
*addr = save
;
/ F5 _) H( q: E/ { Y4 h9 W
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 Z' B3 ?: t5 }: g# C. M
addr = base + cnt;
. N! `' E3 b3 d2 k$ x% x
sync ();
* G! X1 ?0 j5 h7 C, i
*addr = save[--i];
. d% s# w7 _% ~/ j/ C
}
+ V, R) m# R. i( i4 _4 D; _2 g& P7 ]
return (0);
7 n/ B3 U2 {. o# C; S
}
6 I. H7 q3 J8 w0 Z9 ?& {' `: ?
, u1 u" c; j8 b, [% A
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% T' X7 D1 h: T+ I
addr = base + cnt; /* pointer arith! */
; D$ |3 I5 A \+ H) d
val = *addr;
! ?! A6 y6 H: w9 |8 O
*addr = save[--i];
0 ]0 W5 s$ i( h3 b* m% x
if (val != ~cnt) {
# e {# R* R" V7 A# v% B( _- U
size = cnt * sizeof (long);
2 G. h9 C, Q9 v7 @8 J
/* Restore the original data before leaving the function.
! h% o& L/ z# p3 \
*/
# i' D& O k' |9 `8 |4 j) c4 Y3 \
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+ E6 w, U y6 l$ K0 |/ K# O
addr = base + cnt;
6 G: B. p" i/ A, f3 G
*addr = save[--i];
' n3 g$ P- B7 g' T
}
3 E8 c6 j& c/ @* ^# L8 e
return (size);
) P0 ]3 c* G+ P
}
+ f; U9 q% }& r- g7 L3 w. l5 F
}
" L; h! N1 T9 v0 r
- ~, {# U7 `) w. d2 I" P% P
return (maxsize);
. e# g0 a* M; w+ N2 ]$ x0 z- t
}
, @2 n. \2 R/ f: G+ l/ ^* ]' Z9 }7 O
int dram_init(void)
( V5 {- R r/ f( M, O% Z: S, X% l3 f
{
w8 W) @3 A( p
/* dram_init must store complete ramsize in gd->ram_size */
% O0 } _1 n' G
gd->ram_size = get_ram_size(
: @9 E, O; x5 j5 k/ ?
(void *)CONFIG_SYS_SDRAM_BASE,
2 c/ h' h% F+ C! ?; r/ c
CONFIG_MAX_RAM_BANK_SIZE);
, V% y3 O+ c# ^* k' E
return 0;
f; @1 s7 [0 y4 N
}
) G3 \0 d# \. b. h4 @
* J3 z& Y: W3 O6 R
- T' w& M3 m0 I8 @8 m) R
- m4 }4 E5 |% E
$ g7 q7 x# m0 X. E% y- h4 P6 j3 s
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
" @5 Y# g( g1 V3 r$ t7 {8 M4 m1 ~
( d7 |& J3 }' o" i2 s# b/ _
) X) T( ~/ j* a r" `6 i# n, G
; K& V* ]" \1 Z: d7 M8 H
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4