嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
- F/ ~7 c7 b0 f, v% l) R
核心板2:DDR2 256M Byte NAND FLASH 8G bit
$ s; Q$ F$ ~+ B! _9 a
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
/ z9 {6 }- f; q
0 }3 ~( o8 ?' C: z
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
8 ~$ f P E: g4 }8 \
, e; z4 k6 g. C6 K. M, ?
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
- V* Q) z9 G: j( N
/*
4 A& p$ b/ L3 B, T L
* Check memory range for valid RAM. A simple memory test determines
# N6 E/ n! U' W* o+ S& n# ~
* the actually available RAM size between addresses `base' and
, v$ H% h& @) e4 ?4 v$ S! p; y! v
* `base + maxsize'.
0 P1 E) d" e& s. M" u1 p) }: M
*/
; X' L4 P c% `! v y8 A9 T
long get_ram_size(long *base, long maxsize)
/ \. I% T0 [) H5 p+ v, z: O
{
1 n; n; a- B T1 ^5 R& B
volatile long *addr;
5 @7 _2 i) N! V
long save[32];
% N! j+ V& V( r
long cnt;
+ |: [2 b9 K( i. z' n
long val;
6 |- b. E7 W0 s9 _1 P# ^% D& D
long size;
" _% A# g: q$ F& n; C, u. O. l
int i = 0;
+ v: u7 F5 G/ a& }" y8 ^& u0 s4 Q
( C Z) o$ Z/ G3 k n6 C! g
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
* C' {3 y' r5 r+ [( g
addr = base + cnt; /* pointer arith! */
! L/ t" R; E4 H: R
sync ();
/ O* }6 r; e0 K* p% I9 J0 [+ n
save[i++] = *addr;
" j& P6 x5 {4 B1 f# J( i
sync ();
% X+ ~. H# n7 v
*addr = ~cnt;
! f- I( N6 u& T! s* E5 O3 s
}
' t0 T* S" ~; @% t6 \
. d4 |; ~' V% |+ U$ ^0 m
addr = base;
' b- a- h( O. h3 r, v3 q
sync ();
4 I9 M+ Y, Q* ?" n/ g9 a
save
= *addr;
9 @3 a' Y9 s! W0 l3 d
sync ();
5 L$ E# _7 L: Z. Y- f" o& |4 Z
*addr = 0;
5 d) a1 n: r( d9 G8 B! A2 T
r# M; F6 `$ u' R3 ?# M
sync ();
/ y) a1 ?& D7 k7 U# [7 s
if ((val = *addr) != 0) {
2 O3 v: W3 g; v1 M
/* Restore the original data before leaving the function.
1 A, V# {, O. x6 i" q
*/
h. o! R% K7 i* K! {, ?5 F
sync ();
: x. g7 i8 w9 ]* X3 j2 Z1 e z
*addr = save
;
& Z0 _9 N2 V/ \. e4 }
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
4 _& L* B5 l9 `$ e4 \
addr = base + cnt;
7 V; ~. Q/ A0 f8 `. l1 o ]
sync ();
4 `& d+ {1 L. z# f
*addr = save[--i];
t9 ~. ?1 @* O$ U
}
) J% H( V& i; x! w/ ^
return (0);
" ~7 D. y; v* U( o! Q
}
' t Z3 B2 `6 U8 J$ \; Y
0 n" t+ |9 T; o0 u4 K2 v9 x
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. m" E* B+ t2 v0 h( r1 Y( ]; f
addr = base + cnt; /* pointer arith! */
/ f- q2 Y& P$ z Z
val = *addr;
4 D7 z( V* _7 c& D, r2 K3 x
*addr = save[--i];
}; E: L" ?- \- }9 h" J
if (val != ~cnt) {
, i4 q' y0 \2 k
size = cnt * sizeof (long);
* g1 Q0 V9 ~! z; ]4 M( v
/* Restore the original data before leaving the function.
5 ^" e8 s7 c0 h6 P/ M
*/
0 S/ E* z: [& V% g% p; r5 b+ j
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 {9 r! K& k; P+ N
addr = base + cnt;
! [- y( U8 H C$ i0 c
*addr = save[--i];
7 o y% V6 K! `
}
7 x6 d2 z p8 q& [* s! \
return (size);
% k' V7 }8 I& r: ^4 c$ Y! K
}
! B$ |4 f, ~% j% F, a5 t
}
; @( k1 K; G0 H% m6 K# B
( J- e8 [& S- t" H R
return (maxsize);
! q6 d" o( ~) N" j/ W3 Y
}
2 J3 ~ ?7 [. q+ X7 a
int dram_init(void)
5 b% N, Y2 U$ [1 z. |( X V
{
- K* t$ R0 V# }7 \) G# N2 K
/* dram_init must store complete ramsize in gd->ram_size */
J! Y( N4 m/ n5 ]
gd->ram_size = get_ram_size(
) S% E2 l) Q) l3 _+ Q
(void *)CONFIG_SYS_SDRAM_BASE,
7 D U4 Y2 x0 H; g' |' S
CONFIG_MAX_RAM_BANK_SIZE);
1 x4 ]' X7 W+ C# z
return 0;
' U' G9 P/ @0 D' X4 ~. H: M- \
}
3 D' K1 i, e+ D7 s! I0 p }
) a: s3 V V2 a7 F$ W+ B/ [
5 T9 H; {+ r+ k2 j
# c& S, N7 U, M
& Y3 l3 Z: D+ D
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
$ K0 q/ ]/ b: b( ?
" I1 A7 O# Z5 z G
" ], d6 s$ s" Z0 m
9 S ^, p! \2 ~: d7 E0 O
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4