嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
8 z! r- y0 Z* k2 Y
核心板2:DDR2 256M Byte NAND FLASH 8G bit
" c, z$ o$ T/ {8 H
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
; I1 R# K; ?) d* m1 H {
* ^2 ?4 ~. O( Y8 t4 [" y6 v, m
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
5 n* T! c! q4 K
+ D# n9 K* x& C0 t$ O; m E
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
- j# `7 w( [1 y# x
/*
4 Y2 e# @: [ o3 J6 l- l7 C# a2 _
* Check memory range for valid RAM. A simple memory test determines
' ?2 {2 T3 e0 f+ e8 W
* the actually available RAM size between addresses `base' and
7 l% m! y; x" u) ^+ r
* `base + maxsize'.
8 C5 j/ M& m; ]' x* [1 z
*/
1 H! M. v& w. T0 P# G
long get_ram_size(long *base, long maxsize)
5 Z+ D k$ V' R! I, a: K
{
4 x ^/ p3 p3 r5 f3 m0 c+ \& ]( g9 H+ L
volatile long *addr;
/ A# O& R. N( G6 K/ [6 |
long save[32];
! Y/ Q. t! W6 Q# q2 f: c5 e/ l6 c
long cnt;
9 y- w4 i$ B6 r1 m3 M4 P
long val;
, V8 {5 O, D+ Y3 M
long size;
: C y, F- _; T! v! p$ K3 M
int i = 0;
( j) G6 O# z% L) d
- N& W5 u& z0 `1 S! `) z
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
4 `0 A/ q2 J8 ^2 I) E
addr = base + cnt; /* pointer arith! */
; A! Y- x. y3 @ i
sync ();
! i# t% Z6 _7 Q6 d: c
save[i++] = *addr;
1 P9 d: y9 |( }# P
sync ();
- Z& @' C8 v) Q, ^, b+ @
*addr = ~cnt;
. ~5 H" m9 ?, c
}
h6 D3 _1 s! I$ W
k: ]- G0 C( z0 n3 S# X
addr = base;
7 S: D. ^6 v3 G/ n' f; o
sync ();
2 v1 d0 q2 H9 T% u
save
= *addr;
& R8 o1 [1 D( c" {! D4 i
sync ();
* m5 I: b+ \5 D- y. ^
*addr = 0;
+ b- |, M% p0 l2 O6 u& J$ S! `
, j- O' a+ Y: y, O. }1 r
sync ();
8 W& f; }. r: ?% }( S
if ((val = *addr) != 0) {
: }3 r. W* A! p
/* Restore the original data before leaving the function.
+ @3 t, W4 a4 @1 L1 T
*/
! l/ L* _; _5 z# X. Y/ D# u4 [
sync ();
) i% E$ H# C7 M% J) [. s
*addr = save
;
# B: q* n' {) }, Y7 K: h
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
& c- E7 y4 f/ D/ y: `
addr = base + cnt;
( l( q* {, \; a) _
sync ();
* V" C. _, T2 `* o
*addr = save[--i];
1 F# ?9 P) p8 T: b! z9 f
}
7 e+ [8 S, U$ A7 @% ]4 F' l
return (0);
; N+ ]. p. u& u; \2 T# G: W
}
" \8 w0 W8 l8 N% k
+ i; g- u9 \; T: ?5 p0 b$ s
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 l/ l# Q, e( y& \+ L0 t; v
addr = base + cnt; /* pointer arith! */
0 i. I3 d5 H2 q S! y" b
val = *addr;
) G2 K' A7 p# V& S/ ?1 `: T- Q
*addr = save[--i];
% C: x) u& r! z2 \" B' U* c/ A
if (val != ~cnt) {
% l5 K& k6 `% ]& F
size = cnt * sizeof (long);
2 Z% q5 K5 V0 h c ?$ T
/* Restore the original data before leaving the function.
" F4 R0 `4 \* V2 N
*/
% j9 F; R# N+ d- X1 T& c7 O% g
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. C5 a) K; u- {+ s1 r2 r+ c
addr = base + cnt;
( V% \, U2 Z- {! ~6 U
*addr = save[--i];
+ u! U4 i, |, L( S+ d
}
% \* m2 r) w7 q% R
return (size);
$ w8 s+ V9 A/ Z
}
' _! E& X/ j& s; s3 ]
}
4 ^' U8 n2 J: o
4 m: P' l$ k) c0 r$ l# K
return (maxsize);
- J% H4 R+ _; e% i0 _
}
8 J3 U( f# w/ K# N) i
int dram_init(void)
" O6 ?0 U5 G5 ~0 F& F/ z, D
{
2 Z4 g( ?# o' d) ]: e
/* dram_init must store complete ramsize in gd->ram_size */
/ p& ~+ w+ w3 ~8 Z3 L7 @/ E: U
gd->ram_size = get_ram_size(
! v6 |- P' O1 O7 ^
(void *)CONFIG_SYS_SDRAM_BASE,
" m2 X9 k! ~, n: g8 X6 t2 [& S* U" f
CONFIG_MAX_RAM_BANK_SIZE);
8 N* L+ v8 F) D$ v
return 0;
. q: F2 Q8 R/ v: [+ h! j7 Z
}
M* I8 C) {& I, `5 e. Y
1 |$ ^2 t8 [4 u, O S9 A$ f
9 u! H! B. o( T: |
: g% S4 G7 ~) C) s6 g
- K1 b) d1 c, g: N! ?
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
( N$ A, P2 ^0 B. X' k7 t) N6 j
% S1 b6 S: X. e, F2 q
& ^6 T, @* c" S- D9 ^1 t; d
) U3 @! x+ u( H4 A6 X
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4