嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
4 t: j" A5 z+ J/ d1 p3 a& T3 h
核心板2:DDR2 256M Byte NAND FLASH 8G bit
: o* h( f5 L, \' f- O% n
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
# r% O% a1 T. J6 a4 @6 t. U1 p a2 L
- y3 n) D+ P( q4 x1 A: m2 \
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
- H8 c8 ^( O) d' y, ~2 i& V
; q: I! h, g0 t% f
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
! v+ t- a' Q4 D2 u$ L$ M
/*
$ K: ?! h% E+ M9 B
* Check memory range for valid RAM. A simple memory test determines
+ R4 F( U3 u* L: z9 G1 Q
* the actually available RAM size between addresses `base' and
8 d& i q, `. d3 c
* `base + maxsize'.
# e1 G7 w k$ G. @ f1 o( }
*/
% t+ `" j6 N/ ~5 o
long get_ram_size(long *base, long maxsize)
& ~0 D0 N" n' }/ X7 I% n
{
1 g5 F8 }+ v, @0 u7 Y i8 q
volatile long *addr;
0 J" a; Q- ?1 c& u. \9 d4 J9 U
long save[32];
7 i6 \( t/ F$ ^7 f2 l; v* i2 u% _
long cnt;
8 O& b( f3 j0 |4 I% Z: U
long val;
' n- ]: W+ z& g- I/ W9 O3 T! o! Q
long size;
3 F" W, f6 D! }6 N$ R& [: P
int i = 0;
+ o2 H0 n, t h6 E6 x3 ~: M
% `" P* ]! c" g$ |% Y) s3 n6 @ |# p
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
8 B: q c" E: [: y
addr = base + cnt; /* pointer arith! */
" a5 t" H& x& ~6 M8 B5 t6 ?
sync ();
: c, X8 B. h. V- K: s
save[i++] = *addr;
) F( H) b/ a8 K, Y
sync ();
) k% u9 O% k3 n1 d8 T
*addr = ~cnt;
; w: x1 [; Y0 P" O9 T: [: n- O3 H
}
n% |2 o1 \7 ?# y
# W- v5 V1 [& l+ j+ s- U1 ?; D
addr = base;
' F! D1 u. G! n7 @9 V
sync ();
, \4 w. M- d$ B0 d& k9 M K- o
save
= *addr;
) M7 t+ q3 i" F6 \. R: R
sync ();
7 }2 }1 c% ?/ @- o* I
*addr = 0;
% f' X8 D& n1 S& m7 l: T
+ E6 F+ A5 Y% c$ {) X, m1 l
sync ();
; {% t+ X4 X9 q2 }
if ((val = *addr) != 0) {
9 I9 C2 h) u9 ]" m! q0 W7 e
/* Restore the original data before leaving the function.
0 M5 _8 G8 \; ^* k6 _) E1 P
*/
/ f: X0 Y" `& E9 U |1 p* W
sync ();
6 r. C# ]1 H/ c6 o$ H0 F: i
*addr = save
;
' g5 v5 H5 c" q5 `8 L2 p
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
# S, L# T0 L h2 ~4 H! g3 X Z
addr = base + cnt;
8 I% |6 [0 Z. U7 t2 P0 m
sync ();
* h0 @1 q( v# P
*addr = save[--i];
2 `( Z3 w& ?7 I( c
}
2 N. j4 g3 V8 I* O3 @ G! ?
return (0);
; R2 j* [$ }1 M) P
}
( h3 M* F! r3 G: c
$ B! q. @5 s2 ~: x% T2 K
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, E, U+ N M+ |9 \9 A- G, I
addr = base + cnt; /* pointer arith! */
$ Y' y5 ]* k# x0 O/ ]
val = *addr;
5 [3 X h7 b. e8 k; T p7 B6 g
*addr = save[--i];
0 D# R8 ?. _. r# W& z+ A# \
if (val != ~cnt) {
9 o( G$ y4 f: N3 Y# k( \1 ^
size = cnt * sizeof (long);
8 l5 v3 l: R2 k) K( k
/* Restore the original data before leaving the function.
+ R M+ y1 s9 b/ D
*/
# F P9 w+ g* ]6 ]* J8 \' e9 q
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' e0 t y2 m1 L, T9 W
addr = base + cnt;
4 x* e7 d1 M j; N; |" `: A+ B" S
*addr = save[--i];
! r8 u; s1 y- ~8 b. F: X
}
% L; H; v; v- }* y
return (size);
7 @: C' @# z. b
}
- v' r! p9 E( h7 N2 Y
}
# @4 z b1 R6 c* H( m' ?$ t
% o; H. O1 L4 m7 O9 L* } i
return (maxsize);
( A V; r: E& W! v$ i) B
}
, [, W% I- D, X r# J
int dram_init(void)
6 s' \$ D/ l0 N" u& x# ]
{
' ?1 w4 u. Q$ `2 z6 B
/* dram_init must store complete ramsize in gd->ram_size */
4 T& Y; R5 c5 |
gd->ram_size = get_ram_size(
3 \$ @" m, n5 Y I- p
(void *)CONFIG_SYS_SDRAM_BASE,
}. o$ |' ?0 i& Z/ @
CONFIG_MAX_RAM_BANK_SIZE);
6 R$ C( b) Z( q# D/ `3 O7 g
return 0;
0 y# Z8 w0 b; C% r5 x7 ]' r
}
* n" M* w3 C5 ]. }! J
/ h* g5 y2 h5 l6 |
2 @3 [- B5 `) t2 N' X
' z7 T8 J5 Y( o4 M- I4 ]
8 s: B0 x9 l7 x0 J! B4 E
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
! i6 h4 }; i5 T) b+ r
X3 m7 p1 F6 o* T& L: ?8 S
; o& E" O! Y# a, q% ^, f
; F- f) y! Y: }3 j9 k' O
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4