嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
0 X, ] u7 G- b) Q7 l
核心板2:DDR2 256M Byte NAND FLASH 8G bit
9 x. i) A: H4 x: t
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
4 N A4 A0 m, u F+ ^) f
9 B$ S9 U! t& W8 @* Z( l7 J
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
& ~3 Z5 q; h! D) N) K9 o
2 T5 Y1 I% o5 S
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. b) ~# p w# M! q9 ~! n
/*
b, G5 t6 ]$ q8 N% m" u, D
* Check memory range for valid RAM. A simple memory test determines
3 t" V$ i3 |- M3 f- D. s/ P
* the actually available RAM size between addresses `base' and
* B% x# P7 @$ M" N( A( S6 \; x
* `base + maxsize'.
U0 \1 G. V; E
*/
. o3 H, J# h, `. ?& ~+ p
long get_ram_size(long *base, long maxsize)
& L' A; L" ^9 Y# }* j& k
{
# l$ }6 T) c: p& ~: F$ T: ~: q
volatile long *addr;
6 j2 |! z+ x) S9 p2 O" O E# [% p
long save[32];
7 Y) D" h4 i3 c! ^8 h& t
long cnt;
, ?: P2 t7 _$ [) k+ h
long val;
3 o; M, q- f& x; p
long size;
7 X# N, u) _3 [8 k& m) Q1 M1 b* k, o
int i = 0;
( n m7 P# `, B. X0 r# f; T: g
( \( p' E D4 m# d2 h, j
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
* ~* j$ k6 t. \) u$ s
addr = base + cnt; /* pointer arith! */
) N0 ^! B2 D* [* K% i
sync ();
( N" r$ y5 v/ R
save[i++] = *addr;
$ b) |) q, q1 c3 W
sync ();
1 c- c- N- w% u
*addr = ~cnt;
" X# v" d. P1 ~5 G2 h- H: n$ K
}
% u2 u" ?, {# u) G& e8 c
; D1 f5 O2 R: z! x
addr = base;
/ E& V8 ~5 y- M* [8 e6 ], F4 I
sync ();
4 u' s" _; e* L& j6 `2 t+ [9 ~
save
= *addr;
3 ~/ T4 ^1 U- J9 U: R @
sync ();
7 g' r# n7 I; V! T
*addr = 0;
" t: t! o8 O: V1 C s1 ?2 H
$ ? T* _/ b6 P$ U5 n+ z
sync ();
$ [3 q" }& ^8 p) N! Y! j
if ((val = *addr) != 0) {
! v: v- D7 e ^) `6 m: _, i2 M
/* Restore the original data before leaving the function.
9 S& P3 h4 x0 C
*/
" K2 f: o) @7 ]
sync ();
& }0 v# J$ u; Z! w" z
*addr = save
;
8 N7 w; J2 \& r# ^) s! l9 L
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
3 \( Z3 G0 h( U% J7 \; \
addr = base + cnt;
8 H- {# j! t" K
sync ();
* c# G+ \; |0 X+ T; V
*addr = save[--i];
, B2 [3 o8 x) g( X: @ A M# b
}
) `0 C' j7 G* K) T* o! `: C
return (0);
$ [# B% Q& e# k
}
! H6 }0 ~4 [# d2 F
3 V& k) N& d1 s# d9 f4 i
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
9 Z. B! @) F4 M( M, H! v
addr = base + cnt; /* pointer arith! */
# i5 `& m4 l2 S7 M) T9 N! S6 ~2 L
val = *addr;
+ {# g0 G( H* l1 g7 L
*addr = save[--i];
* z# b5 t" l3 O: [
if (val != ~cnt) {
: v; c/ m" ]9 Y, T
size = cnt * sizeof (long);
' w$ _" C4 P3 K) b- }) o e7 J
/* Restore the original data before leaving the function.
' J. E) V: A2 ]# x2 A' N
*/
; s- r3 c. @+ I
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; v5 h$ ^9 h3 W1 Z1 G7 Y3 }
addr = base + cnt;
, W7 \. a/ Y1 R3 j0 N
*addr = save[--i];
$ J7 [3 d3 u! m
}
" |. V6 I1 d" D% r& D: Q
return (size);
' z( O! u8 y: U* Y; b
}
$ V/ K0 N1 S6 ?, K$ b; b7 t) h
}
7 v7 Y0 t& n* f' ^1 \% e. R! B
( A$ u8 c/ R# ~0 |3 }. `
return (maxsize);
( L+ ~% I9 x0 p3 W/ z
}
. U5 w% ~4 {/ x: v' l- t
int dram_init(void)
) L8 s" y* p1 A" J* K
{
( T$ E$ w# c% l' D- H! A
/* dram_init must store complete ramsize in gd->ram_size */
' H0 a- i' e$ Q$ M9 `* p
gd->ram_size = get_ram_size(
" y7 j/ N* L! f( m$ q. ~0 }+ r
(void *)CONFIG_SYS_SDRAM_BASE,
, D( i3 M* D# J1 J2 e
CONFIG_MAX_RAM_BANK_SIZE);
+ u7 S; d: X/ Y5 c' w- @
return 0;
4 m) _; q/ I1 r: ~
}
P+ [$ n, X/ D& G$ Q
0 y+ D* _, D: r3 s" e6 t2 @
" t; i T' q# [# T1 d! z
. Q- h* `( H/ L6 |2 L' ?
8 `( v! v3 J7 e7 L
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
$ O! d8 i% t! T
$ R3 K. P; g$ j- {: }7 y; r. j1 b h: m
; X/ e; A6 j4 p2 ?& |# d
6 k g/ J t# ]: C9 V
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4