嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
" K0 S- \ Y2 H" X- q$ }1 ^
核心板2:DDR2 256M Byte NAND FLASH 8G bit
5 d, _# A+ g8 [" d
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- d- ^: p4 Z. n E3 ]
7 u4 u! K) m% c
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
; ?" A1 a, s. R
: _8 A7 C' x3 B: L, q
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
3 ]0 {3 c+ f# p1 S# f; ?
/*
: f0 h1 W5 q" o$ X4 C. n
* Check memory range for valid RAM. A simple memory test determines
2 U S8 \+ F: D! M
* the actually available RAM size between addresses `base' and
8 j5 A, J$ ^# [0 `
* `base + maxsize'.
% s5 V' D0 ^4 m3 k9 A5 K/ Z" ]
*/
6 @* |3 _1 o7 b ?
long get_ram_size(long *base, long maxsize)
! H% M- L; z* O! [, P8 F
{
' j0 p# ?& k$ F) s# g
volatile long *addr;
' W0 w& B/ o! D/ M6 ^
long save[32];
( a0 B: ?6 Z" N) a+ Y. T
long cnt;
$ `4 q2 X5 b3 b: k" t* {2 y* O* _
long val;
( L: K+ B+ k' d+ P$ D
long size;
6 \% `2 k3 m' D1 t5 L
int i = 0;
' p$ L( @0 E- U% O3 ~( P5 X! {
* g2 A6 }7 I/ w( a' k" B
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 @; Z% p8 d1 c! _ L
addr = base + cnt; /* pointer arith! */
0 Z2 o. K8 U9 t& }7 P s) C
sync ();
5 |5 e+ ?% U C/ P3 Y
save[i++] = *addr;
- F$ Z. _& ^( H/ @
sync ();
, y: [! P& i# l# o# o9 p* e# y
*addr = ~cnt;
3 }) \/ r" Q3 |+ L1 {
}
, K) U, e5 @7 K# u9 g# l
9 r# O) q% x& \, E
addr = base;
/ Z! M! c' b3 w' V. C
sync ();
( f/ L3 h$ N1 O
save
= *addr;
$ ?6 j1 A: _( @2 |+ l$ o4 c
sync ();
! O0 h' y. t7 l4 U& P! S k, @
*addr = 0;
9 G- A5 l; u( s. Z$ l7 }% n3 [3 I
3 Q0 A) X5 I) b& a( y
sync ();
& t ]8 K5 _1 J2 o \
if ((val = *addr) != 0) {
, C% c9 C; d" g
/* Restore the original data before leaving the function.
0 l3 j, b& c+ c* _- k. c' p$ e
*/
" [4 [2 S0 g1 q2 I) Z5 u
sync ();
0 a W% ?2 Z- n' i" C
*addr = save
;
& w+ J" w# e+ |4 A
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
8 j3 C s ^, k: ^
addr = base + cnt;
2 f& e7 L+ p% ]! X; R
sync ();
1 x; d) @: R( E _
*addr = save[--i];
, D, Y7 z' o( M3 [) D" i! F
}
O6 O* ], D6 o- a
return (0);
+ c8 W B$ n$ s: e4 x6 I3 {2 _
}
3 g1 {) N7 w5 Y) ?' B2 V, |
1 l, Q; K) ], p) q4 Q
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
! G4 I1 j0 m# U- r7 C7 \% Q
addr = base + cnt; /* pointer arith! */
( m' c# ^6 S& Z
val = *addr;
: P0 j1 U2 E4 ?) i
*addr = save[--i];
& z Y4 \7 b v" Y6 m2 I
if (val != ~cnt) {
, n8 a; l0 w" m5 T9 N
size = cnt * sizeof (long);
0 k5 A" {6 N! ~. ?6 D% o$ j) N
/* Restore the original data before leaving the function.
1 W' W* D8 w3 e6 g) l+ l* q( y
*/
$ R# [; a8 m& H
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; \" ~7 k. {8 G; }2 N* n) X
addr = base + cnt;
. [/ _. o. L5 H! V9 |/ x
*addr = save[--i];
C* R. e2 m. B; Z# R
}
9 m) G; H/ T- l. \) C2 N5 Z
return (size);
4 l: }, B( H: B. F4 _
}
( h/ S+ W( p! U- r: q: r
}
7 Y0 j0 h- S# V8 c% ?$ F( w
4 Y0 V7 |# V6 o3 n' j4 g- e
return (maxsize);
5 s0 S3 ]: l9 n
}
1 a! r" f" ~5 r1 c. o
int dram_init(void)
# e! k: c& w* L
{
( h9 k+ n. L9 u d) ?
/* dram_init must store complete ramsize in gd->ram_size */
) j, N! J/ Z7 w0 T' S
gd->ram_size = get_ram_size(
" R8 Q) r8 X1 q3 N0 J. C l2 t X
(void *)CONFIG_SYS_SDRAM_BASE,
5 ]% b2 R6 b: ]
CONFIG_MAX_RAM_BANK_SIZE);
# }% f1 E! i0 k, \. E. C! c
return 0;
# q' B/ q5 I& O8 `
}
( C5 x. ?0 T' b3 V; A, E- i% H
! f; \ J& E& f
5 y9 K! X a. T- D( S3 S
0 P' R, t/ z$ f# n+ V3 k
4 u* G b, W! k; [- N
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
$ b: e: B9 |- u
- f; b* N2 _2 N6 |7 S5 r0 P* N
7 W0 N& V4 @; Z L; [: s
, Y* U. r" ]' t4 b5 y5 a2 t
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4