嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
) e. q' S3 P9 b7 M
核心板2:DDR2 256M Byte NAND FLASH 8G bit
6 j& l) [ x$ R" p
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
/ q8 R; i0 ]" s7 ^; Y3 r a
& s1 i8 a1 D7 C0 n! g" Y( O
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
2 W% q3 W3 N6 g1 z" `# Z
. e! M% ^0 R& B8 `+ j( o( V
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
5 i$ \4 J8 Q9 o2 A* ]& M6 K, P
/*
4 y p# X! b- b& s, G0 e/ i
* Check memory range for valid RAM. A simple memory test determines
6 U1 l% g6 F' G% R z
* the actually available RAM size between addresses `base' and
' o2 n# ]8 U: S( B% b: ?( t
* `base + maxsize'.
. I. a8 P# P, m1 C! }1 \* X
*/
) s c, B8 B% X- I( a
long get_ram_size(long *base, long maxsize)
: K6 g: h: }8 Z) v3 l
{
$ g2 i# b1 X# J+ J/ Z
volatile long *addr;
7 N& }, @5 d- f+ P! w' {
long save[32];
' B: p, M% c1 w+ ~* v% g8 n
long cnt;
: L# g. \, i0 r8 I
long val;
' H/ n* L8 H ?' W
long size;
( D- c# t( u: v8 P# M
int i = 0;
$ P3 A& W; C; F' ?
" O2 |1 N( o+ H5 A7 I5 A' T9 d0 {2 I
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
1 W/ t+ j; ^/ ?" P5 r+ ]5 c+ a/ E
addr = base + cnt; /* pointer arith! */
3 J4 a& j$ p, i3 k3 m
sync ();
; a3 M$ @0 i# O7 C4 Y
save[i++] = *addr;
: ^5 X4 n- z$ ?/ X0 A" b
sync ();
, s7 t% v* l5 y
*addr = ~cnt;
/ t3 E8 U9 f9 b- s- e! s
}
' K( m! L0 m0 [+ ?# P9 O, v
m& S# o% S6 C H6 a7 T
addr = base;
2 h. u6 Z2 H2 v* F4 i
sync ();
" o. n1 T9 k/ y. Z# |# F
save
= *addr;
1 o9 v$ t6 @/ _6 N( U8 i# y( Y' N
sync ();
; D, y2 E, h5 R* M @( m
*addr = 0;
2 j- J/ H9 A& `5 p7 V% R
, _6 U( @/ V4 j% l- Q
sync ();
' s, N: m# `) h/ @# P' A6 F& ]
if ((val = *addr) != 0) {
4 x/ s+ n/ B5 p/ `& @2 i! _2 Q
/* Restore the original data before leaving the function.
2 F0 P m6 R6 v1 o4 i% H5 U6 C
*/
" c4 E/ l9 Y. e* M% M
sync ();
8 i( r6 D+ `- j* K A o* d
*addr = save
;
- T( D" r' j$ e
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
5 U7 |3 c% t0 r+ }) l
addr = base + cnt;
4 k8 m) V* C% d0 `
sync ();
$ @/ V( f) d1 S. p, j w8 H9 {
*addr = save[--i];
2 \( O. F* I& G0 J3 V/ D, J6 R
}
' G M1 K" C4 r7 F
return (0);
, y3 g8 N; B: r/ C1 {
}
( m$ Z" R# T* Z
G" ]! t( s O8 k0 R. w
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- `8 Y' T9 W; U# p& I
addr = base + cnt; /* pointer arith! */
/ J4 T% w* j3 U! F. v9 s
val = *addr;
3 W% f I; U' A% ^4 l2 I% h
*addr = save[--i];
# m5 W4 p7 [0 |" v) h8 D
if (val != ~cnt) {
/ w" x7 j& ^1 B6 z
size = cnt * sizeof (long);
. Z$ y! Z w2 O6 ?! q1 t0 ~( M
/* Restore the original data before leaving the function.
0 J$ J8 S) B+ Y! ?% L7 U V/ w
*/
4 D" S5 Q. I1 w) {% a M# s
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. U0 V6 Q+ f; v, Q, p2 x5 R
addr = base + cnt;
5 |3 w$ _* D! w6 s
*addr = save[--i];
& ?# J- E7 J) y
}
5 v# c" i+ ~/ D2 n8 m
return (size);
/ k# m b, _+ n9 P
}
0 h1 F% E t- L
}
4 a5 I% h4 V5 Z) T Q: e5 u
' P* l. k8 f9 y1 P, o
return (maxsize);
9 h! I! E& n$ Q/ h: p
}
7 I% G9 w) l# ^) z+ F" w6 \
int dram_init(void)
3 Z* Q5 c( X. b/ a3 Y5 _" ]+ ^# A, q8 {# a
{
9 s# x3 i, m3 l: { z
/* dram_init must store complete ramsize in gd->ram_size */
2 p5 K& O% E4 |
gd->ram_size = get_ram_size(
+ r) _0 G, J! X! W! w6 g" i; w- w
(void *)CONFIG_SYS_SDRAM_BASE,
" Z, ]/ u4 G/ N8 Q3 Y8 [3 L' Y
CONFIG_MAX_RAM_BANK_SIZE);
6 Y8 o4 B. ^$ |7 m1 j
return 0;
. W& M7 S! A4 K
}
\ H- _2 s/ o
1 ^" a! }$ z6 M- I7 O! [
0 o3 e: a5 D. i
4 Z7 U' J* z$ m3 l; y; H; |
h& n4 m3 M B6 o0 t, ^
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
7 i2 p) m& g/ U- e
! {2 a1 J# L! t6 |; B& o$ F
4 l4 f4 ]7 e8 V
" @( M0 O' v9 P( y6 h# k
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4