嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
' q; J. b, T \, t& x) H
核心板2:DDR2 256M Byte NAND FLASH 8G bit
% O/ \) S5 ]9 U% |% i
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
' y' I+ j5 P& N+ `2 ^ A7 V5 z
, S4 \& ]( m+ P. J( n1 l
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
, s/ j; y1 M' D4 e( r/ z
( M# C4 I; f! D9 D, O# t1 U8 \
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
" S' H) ?" K4 P/ J+ x! @* q8 L# n& y
/*
% @0 y% d) x: ~( ^
* Check memory range for valid RAM. A simple memory test determines
/ T: f/ _8 Q" V, V
* the actually available RAM size between addresses `base' and
4 b2 t. C! x1 Z4 m+ p' {$ w
* `base + maxsize'.
m L% ?) A) Q, v. L7 }4 ^6 k
*/
% V1 P9 W6 J3 S
long get_ram_size(long *base, long maxsize)
; H2 A8 Z! o* e7 z
{
/ I0 `! `+ A$ X1 `3 R, {9 v
volatile long *addr;
6 x, b0 g% q* |) ^0 T* B
long save[32];
: Y% d5 E3 S0 M3 ]
long cnt;
3 j1 H8 f. J' y# J9 W
long val;
$ x S$ j0 M* s" S4 ^4 I) w4 `3 ?
long size;
' |" a8 ~, Z3 i! X( Q
int i = 0;
( \; P" u5 o y9 J! I2 Q0 R
: g; o1 P" ], V
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
d( n ^. V5 Z8 Z3 p9 i- g
addr = base + cnt; /* pointer arith! */
1 {# [4 X6 L+ \0 ~0 g" h
sync ();
* g" G: o4 Z1 |9 g& }
save[i++] = *addr;
9 G5 I3 I* Q7 b; q* N( Y) u; D
sync ();
8 q3 E y2 }+ z6 P F( l
*addr = ~cnt;
' t- [' ~# A& s# T @, n7 B& z
}
4 ~4 k3 ~; J( D6 F" {# D
2 W/ V! E+ e' H1 h9 T+ D
addr = base;
; |# ^' K: |5 C/ q# s
sync ();
; U/ g5 c" A a: K; h
save
= *addr;
# a' @/ b' z" G- w4 b- U
sync ();
$ A {1 V [# g( V" f& T
*addr = 0;
: {+ A6 E7 X/ d7 J2 T0 o5 @ C
/ ?* S: X! b. J7 H
sync ();
! u2 o+ l: |* N0 i3 G5 l& b) V
if ((val = *addr) != 0) {
- c$ C0 Z% I" y) k" L9 @1 M: o
/* Restore the original data before leaving the function.
) D g$ N3 O" i3 ~& \: } X
*/
' V. p1 u D2 P5 C' z: f( N' m
sync ();
+ q& Y- Q$ n% q4 X1 D
*addr = save
;
7 M9 ~: w2 y {+ f
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- w9 P2 W* }9 |7 c: |; E
addr = base + cnt;
# q1 E- @1 ?8 d p
sync ();
; k+ |+ V* z2 J# i8 Q9 r3 n. a6 U
*addr = save[--i];
9 d7 b: ?! F& g, U# ^3 @
}
: s x' B+ C1 O5 i4 V
return (0);
|. S( P/ _9 A1 x; J# r
}
: g( j2 N" v d" ^& Z
7 v/ ^ l3 W" `' G
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 C) {8 i1 h0 c8 w7 e$ j$ D+ s8 {) g) k
addr = base + cnt; /* pointer arith! */
$ g5 `( S7 w3 F/ O8 q
val = *addr;
6 B( k( p( T0 V' M8 Q- v+ J
*addr = save[--i];
Z5 {8 g' _4 n% p9 V+ I' L: N
if (val != ~cnt) {
9 ]7 E+ }4 m' t
size = cnt * sizeof (long);
- S5 D8 d3 W4 |1 e2 ^& `
/* Restore the original data before leaving the function.
+ u4 a4 ?' G+ z ~' |+ h; n
*/
8 G4 Q1 W3 P* l9 y7 |, @
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% G- {4 H6 K! U0 `
addr = base + cnt;
% M9 G' M$ l- |1 i7 _
*addr = save[--i];
5 i: G& r* g9 p2 J5 R
}
' i/ q* ~( c: }5 r3 [
return (size);
6 y l6 E$ d+ U8 T s! F
}
5 ~( p: l3 ] r/ O. f. @. v4 K3 D
}
" G% g& D+ d" M) J3 F
9 @2 \. W# F5 y" S0 L& @
return (maxsize);
2 ?5 J5 r9 V W
}
1 K) j. t7 }2 k( e: q8 c
int dram_init(void)
2 z+ ~1 C/ N2 a+ w( o
{
1 R4 m2 i, n/ P" r7 p
/* dram_init must store complete ramsize in gd->ram_size */
8 [1 s: j, ?& F# ?$ X5 W
gd->ram_size = get_ram_size(
& N* a4 v! T! A7 Q$ K
(void *)CONFIG_SYS_SDRAM_BASE,
$ ?7 s) F/ h) K! W5 I2 a; z& @
CONFIG_MAX_RAM_BANK_SIZE);
& A: ^" q# |. o$ B: O4 ?
return 0;
2 X" E; @ L$ R; J" M) {) \
}
/ q, `. O7 C5 u, G3 `. a% H
8 \, Y* B( K1 _( t) ?) f
* |* C& F8 [+ ?4 D+ o
$ R5 [' d0 B8 a3 x2 n1 d
* @1 L: _) l! f+ B2 W0 ~, ?/ |& C- n
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
1 O& k+ E3 ]1 }0 A+ S
4 ]9 ~/ a9 g- i( p# X/ M
4 _: O% a% r$ K$ q( a8 Z
* l2 w) I6 P" G( ?1 t
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4