嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
7 ?: h" f# {2 h; J0 V- L
核心板2:DDR2 256M Byte NAND FLASH 8G bit
8 s# ^% M3 B6 i5 M4 @
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- C8 w( @, [2 D. U( L" M, u
; o8 a$ ]& l) m/ I1 D
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
% O l2 |3 w$ v' x2 W; C
9 o6 n: K; Z& E. E8 R
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
2 i2 y, C: d' p. S
/*
5 k! G# B; z1 P# B: u5 p
* Check memory range for valid RAM. A simple memory test determines
0 n% E: l) P% ?+ h
* the actually available RAM size between addresses `base' and
8 L. r* N/ B7 b p' Q$ L' D* n
* `base + maxsize'.
& P' s. w x& x* p( ^8 @$ Q
*/
3 ^' v. K0 e/ Z
long get_ram_size(long *base, long maxsize)
" {+ z3 [% ?2 _, v! c2 C% N
{
1 d0 O- U+ W: [9 g
volatile long *addr;
! O/ B( z3 z5 h7 V' a* r
long save[32];
z5 o- j( y2 z# W/ }: [
long cnt;
+ t9 k5 E) _4 Z
long val;
; w, ]( d. j5 r$ d" d$ z( G
long size;
; [6 _% ^ h# @: s) ?8 }5 z
int i = 0;
8 I& Y# [. j5 Y
5 c3 J! c# I4 i" h! ^
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
% a; L( I- D/ B( f* k& v- ~
addr = base + cnt; /* pointer arith! */
( \% X3 o& m0 _4 n
sync ();
6 }% ]. j$ Y: U: m6 h
save[i++] = *addr;
( R9 n0 s. X1 X2 }! N! f: R, G4 L
sync ();
+ d7 U' K* ~: `1 o4 S4 _
*addr = ~cnt;
1 a% @" W) P8 c
}
6 c7 L5 b$ s5 {3 W
, m# Z r, z* j$ s* G
addr = base;
3 Z4 M1 Y! R% {5 I
sync ();
# R- k u; `( f. @0 x* v7 T4 I
save
= *addr;
; l2 r6 x- c0 t5 M% d
sync ();
b* K7 Y$ ]' ]# i0 m
*addr = 0;
' T+ u# l1 v. _5 b3 Y; s5 H
/ s' T' Y/ G6 v5 B, I% ?; F/ G
sync ();
$ V0 I) H; z5 M
if ((val = *addr) != 0) {
% W7 i9 ]/ H8 @8 c. h
/* Restore the original data before leaving the function.
$ x* i- c# N' G9 H6 U. s$ F, @! T
*/
$ }# q& w. C; [! m
sync ();
4 q& Y( B! k8 ]) `2 f
*addr = save
;
5 n8 s, [9 E8 h7 I$ k% u& q
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
' u+ x. _) l7 R' \! D3 \# y# b: w
addr = base + cnt;
! O S' L5 t6 i' r2 `" A, b* ~3 O' S
sync ();
' S# H1 S% J$ s. X
*addr = save[--i];
! S ?. L! j) V3 ]
}
) a% m- R: t1 J# w, e
return (0);
$ _0 a0 }/ ]; d* I8 B8 H6 s" _
}
$ F/ p/ U& l1 s$ Y- r+ l
: k# h# X4 T# C/ ~- l
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ x4 h+ P% W) Y4 P* ]! }
addr = base + cnt; /* pointer arith! */
: Z {" l7 u$ |9 j/ g3 r* P
val = *addr;
$ _, ~6 l, F: L/ o* s5 k
*addr = save[--i];
# x7 O, c/ `( D& C9 J; M
if (val != ~cnt) {
/ { k$ [6 g5 b, K
size = cnt * sizeof (long);
1 l# G5 q( t; h B# g. z4 v; F
/* Restore the original data before leaving the function.
) s9 w& D% Y) j, e! A
*/
" V. d5 C5 V, m7 v% P) `( C
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 p7 {! N; Q) o! J! S- ~7 O
addr = base + cnt;
5 e( A( r: d1 j" y2 b) H
*addr = save[--i];
% t& m' X$ f K1 ~4 g: o! M
}
+ }; \0 R0 }; t0 ~
return (size);
\; R* l- N" c" {% Q2 F* A
}
) y' d( ~: w/ }7 q
}
8 m* Y9 v4 g! z G
5 Y, ~6 G9 L! B" o& f
return (maxsize);
9 Q2 k6 \ }' G' R6 C+ v- L
}
' ^9 u8 t. m, }
int dram_init(void)
/ ]! w4 O% E2 N r: t, B
{
& ?; A8 @3 U8 c/ L# s/ ^: E
/* dram_init must store complete ramsize in gd->ram_size */
% q' l4 E! x# B ^
gd->ram_size = get_ram_size(
2 k% b! S0 |. ~; M
(void *)CONFIG_SYS_SDRAM_BASE,
; a h9 U7 ^( g7 @
CONFIG_MAX_RAM_BANK_SIZE);
0 V) f" U% l6 L+ ^2 |
return 0;
4 Q& |, w5 D; l+ S
}
, M! f1 _, j, g/ e X3 d! C, B5 @
/ X1 N9 [# @, X: `9 l2 y" a/ i4 m" O
6 ?0 ?# w. Z$ ?3 c7 M
! A( z; s% d+ ?; s1 m! D3 q" A
8 n) M; h9 F4 A" _
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
; d% s9 l+ z) M0 \# K8 p; y+ ?
9 y! `! D7 o* b" ~3 G5 s( S
3 P6 k* X4 C1 p3 A! Z9 G+ M
" v/ r- C; a. ]7 r9 J
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4