嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
1 n6 p6 g: T$ _+ l( d
核心板2:DDR2 256M Byte NAND FLASH 8G bit
% C0 u, e2 F/ e
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- M6 W+ o; f, Y, R& y- Y0 S; I1 E6 {
( L; z* N$ P" z
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 U, P z" }* o
, G8 U, C8 _1 s! |
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. U8 ~- g$ }' @
/*
V9 x+ i( {9 `
* Check memory range for valid RAM. A simple memory test determines
% }- ?9 {. M7 U4 ]
* the actually available RAM size between addresses `base' and
. x. L! \% A1 \9 }& e
* `base + maxsize'.
( i" T$ C* m' l8 ?, v7 Z4 J
*/
! a' m9 E9 L& O$ h! B
long get_ram_size(long *base, long maxsize)
3 D1 D; S6 {1 J# j2 K7 B+ n6 j' `
{
% @7 |0 z6 W: ~" v, w
volatile long *addr;
2 N5 l0 v( q, k
long save[32];
& r: Z5 U8 r0 e0 K9 H8 y
long cnt;
7 T, ^2 J' r+ G9 X
long val;
. k6 v) T: a1 R) |8 e% g: ^' I4 K
long size;
- _ E+ x% ~ U! _
int i = 0;
' z. P2 H& k5 Z* J; h& F6 b
: h& z5 ^% }+ d& g( w
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
& Z5 {$ a! Z4 w# t
addr = base + cnt; /* pointer arith! */
- ]1 V* N# i7 `8 c$ s& i2 X6 _0 l
sync ();
# t+ A- g, ^. e. c- I0 D
save[i++] = *addr;
7 S6 u% t2 M5 p" b# h
sync ();
: h* P, X3 V3 ]+ I; {) m# e: [
*addr = ~cnt;
5 [4 r6 u9 A) Y/ J) O
}
/ s& V' ^# V" {- q- y
, y7 g v: u T- U; N& C
addr = base;
, c, j$ E1 i7 H0 d! M) T9 d: J
sync ();
& B0 |) m) l: ]5 j: I" @
save
= *addr;
' w. o5 I# R% i) H8 @/ _/ |; t1 q% U' z
sync ();
2 Q+ W) v4 \ Z4 a, {
*addr = 0;
2 s# T# H8 g( a0 M
3 R3 W! l9 ~& X
sync ();
+ i5 U2 \; Z0 u- E( T
if ((val = *addr) != 0) {
& T9 @) i1 Y3 V) M# R5 {0 c' c8 V
/* Restore the original data before leaving the function.
! T# p# R; [, w, t$ x0 N4 |1 g y
*/
/ J. b3 o w( v' d& |
sync ();
# d: _3 J) S" R! F0 q
*addr = save
;
' x# D0 r* ~: f+ b3 C
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
2 k! T. m+ L3 ?/ V. f7 f2 {
addr = base + cnt;
8 L/ D2 P! D x- ^
sync ();
8 t b+ e/ o) p
*addr = save[--i];
' H& u3 H+ J, \9 ~+ V
}
+ I. v8 a! B' b* v
return (0);
9 [& u# C+ I$ x B0 K( W
}
. Z A: S( h+ l! ?/ Z
. f2 K4 i5 z- o+ B/ B
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
# l1 H y) Z7 N. g7 a
addr = base + cnt; /* pointer arith! */
6 G; T' g5 t0 y
val = *addr;
$ E4 G$ s, F+ u0 x* q. M' V& N
*addr = save[--i];
, C7 J, d4 t9 |
if (val != ~cnt) {
3 G, o0 u5 U( l8 [7 X
size = cnt * sizeof (long);
1 J# J. F. s# R% O# `- N
/* Restore the original data before leaving the function.
3 @' }9 h: s. g0 u! y
*/
% A; h( j9 A# a. M
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- H# Z& F$ f2 D6 \* c7 }$ i; ^
addr = base + cnt;
4 V7 U9 h1 j% [
*addr = save[--i];
c" |4 Q+ z( y5 h" ]( p2 J
}
8 {# ?" J6 m M: a9 e
return (size);
8 f% k+ W& L( G6 f& a
}
, {! U0 h |4 h# ^" ]
}
( E. {7 R; L* e( |% u
9 L2 Y0 W3 l u Z. @5 H+ B
return (maxsize);
9 X0 X% J6 h; l8 v; o' y+ H
}
4 `3 l* D8 x' t! s2 H! w
int dram_init(void)
4 s, w9 N3 a/ x3 W7 J4 _1 W
{
) D) m- I$ e2 J8 T
/* dram_init must store complete ramsize in gd->ram_size */
8 Z4 u- ]' F" N( F1 b+ c3 Y- k
gd->ram_size = get_ram_size(
' _7 d8 V5 Y+ S' S# I' A. M
(void *)CONFIG_SYS_SDRAM_BASE,
6 |$ \, b- l! ? c9 ]( P
CONFIG_MAX_RAM_BANK_SIZE);
! |! V9 V' c0 d: B- @! C
return 0;
6 z- e0 j8 C6 R- j+ I9 d9 d
}
; e0 g U4 K3 V" H1 c) A, v
9 A# z! o, l7 _& U9 w# s) m* U
1 R+ o! ?+ o5 t; d- j
* N8 z6 \) n+ b1 g' k5 U4 R' D
`5 [+ I8 s9 k0 I& F k9 H
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
0 E6 L7 E1 _. E2 n j
0 q5 d3 T0 v$ U6 t: y% h# c+ ?/ l
7 H% e5 }% v' \1 ?
/ p5 b; Q, `, r; f- I
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4