嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
/ P6 r0 B0 T3 ]% Q8 q! s
核心板2:DDR2 256M Byte NAND FLASH 8G bit
9 n2 J/ t. e1 [4 o9 S
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
# ], m1 M7 l. }8 F% Y" J* e
5 u, p+ y- o5 V3 [
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
l. {9 e0 d- U7 l7 H( R! {5 ]
) N3 n" Z4 n3 E" e* p
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
7 z7 K. ^9 k: L" h8 t# l
/*
3 E) _4 W. I" T
* Check memory range for valid RAM. A simple memory test determines
# I0 T7 O2 d6 C7 c" T; v0 n8 i6 D
* the actually available RAM size between addresses `base' and
& g2 M' I' B) \6 \1 _1 k) C2 @
* `base + maxsize'.
k2 {* O, x* K1 y$ a) {# |3 I
*/
2 H9 a0 j9 t+ u: A( R+ \- t- Q
long get_ram_size(long *base, long maxsize)
u4 i1 P8 W' Z1 c3 H
{
0 y0 i+ p. v7 G4 S+ ^ p$ E
volatile long *addr;
2 d7 M# `! Q) {; _
long save[32];
- V6 B+ O1 f# z: \6 p" h
long cnt;
* \. s4 I/ C% `; z5 X. [' Z
long val;
- A8 x8 G: `- d1 j
long size;
; e" i8 E- B$ Q6 p
int i = 0;
# x* R2 `9 K! @& c+ V
4 c/ k! F$ [$ F. \; K( ^
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
/ ?2 G1 l# {: _0 @* h
addr = base + cnt; /* pointer arith! */
3 X x2 M0 q+ F- S* x! u4 T3 w' a
sync ();
4 @9 Z( u* t8 P! X+ Q, U
save[i++] = *addr;
* ~- w/ Q, e* g$ ^4 R
sync ();
. v+ t/ i1 D9 R/ s0 K! {) ?9 s
*addr = ~cnt;
7 W/ B' W5 W3 @
}
4 z1 K: Z6 f( }( F
* k6 [9 f3 o0 E- \0 s( Q X* w
addr = base;
/ S4 o/ f9 {- h& H' E# n: e
sync ();
0 V% D! K* t) A7 P
save
= *addr;
$ U3 ? r) m2 ]
sync ();
% R J% S" ]: R$ t, u5 @
*addr = 0;
; f, g7 v5 l, n9 s+ f
; p4 y6 B- {6 t% l, w! g
sync ();
9 ]1 p ]/ k/ Z# c0 U) i" P# S9 D
if ((val = *addr) != 0) {
# [! C1 p' W! B2 {7 p. j& }5 {
/* Restore the original data before leaving the function.
9 M6 ?/ k7 @1 n2 O7 b
*/
/ J( U; {# |2 L# Z/ X% E/ V
sync ();
% G3 b; P9 S; N! `3 f
*addr = save
;
7 F( ~7 C: s& f2 f4 v
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
. s" l" f8 h$ a+ Z2 e; K4 N2 Z7 u4 h
addr = base + cnt;
0 o: l6 e( Y8 E6 x5 i
sync ();
3 m4 m7 h N+ ~9 @: c( b g
*addr = save[--i];
4 m& P$ y# L6 d8 J6 c% h8 I. p
}
, `6 P/ f9 h; C, S7 L+ o1 o+ J
return (0);
! e; j3 p. j4 C& y
}
# p! C% \2 G1 X; W: B& J, h; U: U
3 h/ P3 |( Z; v8 H! O* D: j4 l' r
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- X' o, i: s1 {1 f, f( h$ q5 \
addr = base + cnt; /* pointer arith! */
" X/ p& u/ g' @$ e! p& k4 u" p
val = *addr;
& X, V: D. h$ K v
*addr = save[--i];
0 H5 L3 U6 g" q6 i( r' f. H
if (val != ~cnt) {
* f! i+ B9 W) K- G" p! y
size = cnt * sizeof (long);
( W. Z5 Z4 H) t. E0 ]
/* Restore the original data before leaving the function.
% z$ d: r1 }! R) |
*/
1 d7 o7 a5 @* C. O
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
! L3 H0 u& \" v& c) T! S/ `3 T; | S
addr = base + cnt;
$ ]. \% ]- \+ o" i( U( e# G1 d
*addr = save[--i];
2 n$ `6 T2 h3 ~5 Z3 I3 ^" E5 B& ^& P w
}
8 l; D- A7 U' {5 z$ ]
return (size);
: @# s& {3 q; e1 P
}
$ N% u2 ~& {0 w1 ?4 q2 \
}
- d; k, o. Z8 q6 A$ g2 E6 S6 ?
' `2 R( s; p" f' ]" f; W
return (maxsize);
" {/ \; w! Y2 D1 ?. W5 S- Z3 B
}
3 o4 X$ B. D- T! B" ]1 X; B1 Q
int dram_init(void)
2 I$ u8 q+ G$ }3 i8 v, N
{
2 E- B9 T6 {( E0 b0 U' T
/* dram_init must store complete ramsize in gd->ram_size */
. u, D4 L" `5 g
gd->ram_size = get_ram_size(
- E" `( T2 t! ~# m
(void *)CONFIG_SYS_SDRAM_BASE,
' D' R9 D5 X3 B
CONFIG_MAX_RAM_BANK_SIZE);
- S9 l- ^2 g7 T" F6 A& [
return 0;
7 l0 p. h& L4 g/ G% r3 P% ~" O
}
P, x. F% ]1 a5 k# g, k. B
) Q9 | s8 b& k
2 G) M1 ] ?; R4 a2 M# @ u# U
; Z; B' G; V) W
2 g: o j/ ?" w4 }" O- U6 ]9 C/ I
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
$ d/ k& x6 J6 l3 n0 ^, d; |% g! {
- A |+ Y% I1 k' I) ~/ p# d( e
' E0 n6 r) D4 [9 B: E
+ A) A: z, Q) Y3 d. X$ ` R1 v: u8 G
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4