嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
2 u# |9 Z2 a7 }+ J" u
核心板2:DDR2 256M Byte NAND FLASH 8G bit
5 R) S4 @" ]5 e
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
, m+ E# i0 }: |! w+ P( [4 o1 C
% J4 w% ~5 J! l3 s# d/ V2 B
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
- w$ I# l9 X( B) W( e4 x* F# b- C
+ F0 U. ^& ?: c5 k5 k0 Y: v2 w; `
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
1 ^" Y: y6 {" h# i+ y/ b
/*
4 ]( O# c, p8 i
* Check memory range for valid RAM. A simple memory test determines
! g1 d$ v: d* y: x0 \
* the actually available RAM size between addresses `base' and
6 `& I* a7 w) v; k
* `base + maxsize'.
( i' r+ U# P# C9 C3 w; v
*/
+ @% w) u6 }* \5 Q) U6 g
long get_ram_size(long *base, long maxsize)
/ a; P4 H/ Q% u3 l" Z m0 D U( I
{
3 ~9 g5 _, e3 O/ M1 y
volatile long *addr;
I* Z7 B% Q% Z9 k. h
long save[32];
5 Z& L7 Q: g+ U
long cnt;
6 q. F3 e! m( x% s
long val;
* A7 {* W) g) c5 x ]
long size;
& n% h! n% L! S5 b: I, `9 o5 D
int i = 0;
5 i* \' G' D4 y9 ?7 s. v
/ h( H K7 q$ c7 R; o+ X
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
: y0 d5 {7 R% p5 k8 t. J- E1 N8 I
addr = base + cnt; /* pointer arith! */
: I9 W$ ], A+ y0 J( }% |
sync ();
3 A1 f, a; D; p u0 J
save[i++] = *addr;
+ q: `$ O3 B+ w& C( x& t' X
sync ();
/ u4 B# r* h/ |* |
*addr = ~cnt;
; g! G& N* j* P/ e! h) b8 V
}
! B0 A% n& l* P6 X
; r" g6 K1 [. o$ }
addr = base;
+ G( e; r8 A0 i$ U1 F
sync ();
/ V% `! i6 v) X, M* w$ j
save
= *addr;
* j: [' c+ X! N& ?) n! l2 L8 L
sync ();
! s6 d9 B! J' [- F0 o* e2 O
*addr = 0;
. W2 c' h+ z1 W
5 t G4 F4 U5 K |! z
sync ();
; o3 e0 _. a( k& i' d& Q; r
if ((val = *addr) != 0) {
& q( m6 i) ^$ C
/* Restore the original data before leaving the function.
& R) j% i6 S- x6 i% r5 @* ]
*/
' L( m- u4 ~7 G4 H
sync ();
/ P' @; Q8 c! j/ \6 G
*addr = save
;
0 H2 e- O& Q# b8 }/ @5 T5 E9 L
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
+ { x9 P# D7 u8 y5 k
addr = base + cnt;
. a1 e% N: L$ O1 C6 r( V* Z- [
sync ();
2 s" i8 r- b. c: Y# ]
*addr = save[--i];
4 [3 X: U; q) F# G
}
- Y0 `- N5 i6 e X
return (0);
! Z* q" {% ~) f/ J) f0 j8 a% y* ]) w
}
6 B" t5 V" g+ H' x/ y
f9 ?) n( ~( O& I D
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 R: E4 D& [# [9 o: r
addr = base + cnt; /* pointer arith! */
$ X/ y t0 L+ x- q" }' A% I
val = *addr;
8 a9 c( F$ ?5 v0 B7 Y
*addr = save[--i];
! [% G+ I, c+ p, E7 i# P
if (val != ~cnt) {
: \ I% v6 H: C$ H2 F; L8 a, S' F
size = cnt * sizeof (long);
" ~. u! g0 r+ W$ O5 @% ?
/* Restore the original data before leaving the function.
$ [+ W( x3 K u& [+ k- A
*/
& Z& n# I- |+ ^( i0 _
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
/ f, h9 f9 X8 B" | e9 M
addr = base + cnt;
7 s' c7 U1 f& q' W# ]; J
*addr = save[--i];
8 D5 k; c7 l3 L ^9 h8 K: B
}
8 r2 T4 B* w* i. E
return (size);
1 a' w" p9 M" i2 \) }' g! s
}
2 |* E1 B ^( K" i& S6 m
}
8 S( ~$ T2 I/ \# I) L% h3 v
( B0 B$ @+ I) ^/ U
return (maxsize);
3 V I( u% T# j& Q' j% |& D! @
}
* ^3 Q* ?3 Z+ ]1 Q
int dram_init(void)
3 z3 l5 E- ?$ a7 P0 N+ d9 s/ |
{
: a* Q; R: _2 d$ H/ O
/* dram_init must store complete ramsize in gd->ram_size */
9 T) {5 C8 ~ I# a
gd->ram_size = get_ram_size(
- h, u1 x' s2 @& a6 z# |2 ]
(void *)CONFIG_SYS_SDRAM_BASE,
, y, W6 B- ]9 S
CONFIG_MAX_RAM_BANK_SIZE);
5 v! Y; Q1 J q0 d2 X7 n5 F3 g B
return 0;
4 m: `7 j$ a% F$ E( ?
}
$ p8 K# z" H0 N3 u. T% [
/ O* k& T* D" Y- B: a, ]5 n6 h
4 X; s( X* A6 ^8 R3 f! q
) w: W! z; z# f7 H \( n3 r
5 T8 O2 [7 Z3 H2 f5 O
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
% H# p% Q0 E% }" S
- \1 s; q0 F" D9 ^( X$ }" \' b4 Q4 z
; w4 R7 P+ w* V% A( o: {5 [
~1 ?7 \' _- Z2 H* t! ^1 g9 _
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4