嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
: C5 Z% {6 ]4 P* s% E
核心板2:DDR2 256M Byte NAND FLASH 8G bit
+ h/ }0 [3 |& Q
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
# U+ f' Q& a+ \3 F7 k
- q9 _; O# {3 H; d
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
8 Y/ y8 c& g _
% k# q* i1 F# T! P _- l" Q
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
6 n/ _/ Y4 b# h4 o/ M
/*
' n' V0 j, L8 E# Z. @8 Y4 M4 {
* Check memory range for valid RAM. A simple memory test determines
5 g" J3 J Q5 T. o z0 {
* the actually available RAM size between addresses `base' and
# r+ [2 n: P5 v: R
* `base + maxsize'.
. h9 q! e1 U" q' Q" |& e
*/
+ E' W2 o( r. O
long get_ram_size(long *base, long maxsize)
0 Y% ^0 `# k& i% [* T1 e
{
' m! w/ g3 \: Q* f( W
volatile long *addr;
# \ i: Q$ i1 W8 M) \0 @# S4 ?
long save[32];
5 c$ @0 l9 j/ C/ ^- D0 |
long cnt;
. f+ R/ m+ U$ Q. o! A# `
long val;
( S, P1 K3 x1 n) F; a& w* _/ i
long size;
7 B& e. x. F: z/ o
int i = 0;
' m6 |/ [2 Y& D3 K! Y% y& k0 e
! v' F; _) p, Q4 `
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
$ I* Z! [# d8 a/ @2 G
addr = base + cnt; /* pointer arith! */
, v( l* @/ }" u
sync ();
+ q) u. o8 ^' A, y! x
save[i++] = *addr;
8 x; n, u, L: k0 S- k7 Q" a
sync ();
5 Q6 ]1 o2 f3 f# q P3 [. K1 T# G
*addr = ~cnt;
+ Q' r4 d' i" F' d
}
5 Y) a0 H6 ?: N4 L
; C* [# T; \6 j) y* S$ Q6 q& T! Q
addr = base;
# ?3 M4 H$ G% ~4 Y! Z! X6 K' t
sync ();
2 P/ U9 V8 \: j0 c5 {
save
= *addr;
& ?& d" G# {, q' v: `; c
sync ();
( n2 }# \3 t$ g/ k; n
*addr = 0;
9 K5 }. S. \) W$ m2 K- }/ C K
6 d% R/ @+ ?9 D8 ^1 S
sync ();
$ x, C g2 q9 i' |% a' j: l
if ((val = *addr) != 0) {
, |- ]8 P+ U2 D) O
/* Restore the original data before leaving the function.
' T7 h6 _. J7 s. O' c' V
*/
6 ~8 J& S! ^2 K4 X1 t2 f e: S/ A
sync ();
: T( e2 y) e1 e
*addr = save
;
) w/ d0 z' J0 d5 }8 B( |( c- \
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- [8 V2 I( Z7 L$ v! h
addr = base + cnt;
5 |7 d" V/ `1 ]: @* _& |
sync ();
z2 ]# l; |) P- N: F9 p
*addr = save[--i];
+ k* m9 d8 n( n& k
}
& ~( P1 S3 R2 |
return (0);
5 o( u/ \8 V, W1 {) ~' D
}
$ F* H4 z- F% r# l: u3 U, f+ B
1 E2 C; w3 y6 Q$ o/ t8 h, @7 x
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
/ O' J V3 `* v6 D" D% B+ f2 x l
addr = base + cnt; /* pointer arith! */
. b% x: b$ ^8 J' b
val = *addr;
; h: w( F% B/ H6 `" \
*addr = save[--i];
9 x7 G' E" d9 k2 C" K- g; w
if (val != ~cnt) {
- x9 R' b9 \( o
size = cnt * sizeof (long);
@. y; j x6 ?
/* Restore the original data before leaving the function.
6 H- B, X, y7 X9 i& U2 D! b! F
*/
" a V3 L# \/ c) S% u* j
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) [1 ~; h; Q) g! R9 S- N) `
addr = base + cnt;
j* K" m* I) P- A- W9 g4 ?. D5 Z
*addr = save[--i];
) m3 p2 f4 M1 R: I4 x
}
) j2 B- o: G/ S* A/ ~: j
return (size);
0 t- f. Z- g f2 s1 K# n( p+ Q+ w% K" x
}
" t- J5 d9 G9 j$ k
}
1 x- I6 ]1 R: F5 D( E9 C, ^
& d% Z$ H' K/ x" w$ b2 K4 I+ u9 P
return (maxsize);
' D" J6 h9 R" Y$ b- o$ W) s
}
. i5 T$ X1 ?; X; V5 `
int dram_init(void)
! k+ y" t; B0 a E
{
+ w0 w1 B) L5 a' [4 K! S' N/ o1 z' N. s
/* dram_init must store complete ramsize in gd->ram_size */
. P# `' ^- x& D+ |7 A2 x& }8 s4 B
gd->ram_size = get_ram_size(
8 r# v& I1 O. A
(void *)CONFIG_SYS_SDRAM_BASE,
: ^* ~8 ]; d* v
CONFIG_MAX_RAM_BANK_SIZE);
$ m7 `, ^( _$ m6 `5 S( ]
return 0;
3 ?# j; o: J. q4 t& X4 r W8 I A
}
: \9 v% i. m4 W2 `9 y
5 ?+ g# c/ `% {2 d
0 _: c$ ?: r2 `- k* H8 D2 }
( g+ C# ~. w9 v& \5 _
, L" N! I( H9 g) a5 x( Q
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
& g+ R8 N: N8 h/ ~5 k9 m
2 o/ _7 P1 F, R" g: t
4 [* h8 @4 a5 v( s
# |. L1 X$ P& ~. O" V# v5 p( _
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4