嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
5 I* w* t3 f6 r1 K& `: m1 d
核心板2:DDR2 256M Byte NAND FLASH 8G bit
# I1 T; H+ D. C( ^
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
n1 q4 Z& n' e a& r' a
# H# i& @* x8 Y: `% i0 d
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
) b p$ _. l' P; y
! z0 q) O% L" p1 k
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
0 }' i4 p( v: m) g6 g
/*
! ~% p7 o+ J6 e1 F# R9 c
* Check memory range for valid RAM. A simple memory test determines
4 M% O; W% N; G1 }5 w3 t
* the actually available RAM size between addresses `base' and
8 B( J1 g5 T6 T) d4 w
* `base + maxsize'.
- h$ A2 Z$ N, _2 n; p) i3 m
*/
" j) N |3 L; s) }9 W- k$ X; b. M9 ?6 [
long get_ram_size(long *base, long maxsize)
% k' A& s# Q3 W$ ~
{
; M1 E* _7 x# Y# `
volatile long *addr;
t, A) E# }4 b& n h3 P& ~- ]
long save[32];
7 e3 L g6 c( g1 j: R6 R
long cnt;
0 y& ^4 w' w# x7 r" g1 o$ C0 }4 W' L
long val;
6 m, H; H: c4 x% I/ S
long size;
6 P# g3 n, X8 m
int i = 0;
1 N' J+ j1 H ]4 ~ Y4 {/ P% r
3 R; z- g! o) b! H
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
, I$ |7 U4 m& R3 m3 s. L
addr = base + cnt; /* pointer arith! */
* {2 x% u6 V$ V% G, C! \) c
sync ();
' I0 C9 `$ F1 _" }& F
save[i++] = *addr;
; p! ^4 ^! [! k9 \5 ^
sync ();
! _4 z2 @: c: A% y+ E& l& |
*addr = ~cnt;
/ \/ M) n( n2 F8 r
}
$ C0 m9 _; }8 L2 \' N. L' n
X% t& e8 M/ _4 c$ ]
addr = base;
. _- A8 |3 Q6 n) `, |
sync ();
: [8 y. F* o' a
save
= *addr;
, P! @" u! h3 H* _# c8 ?$ `
sync ();
+ _# U& L# G8 K" Q5 K% I3 [
*addr = 0;
1 B9 i4 A" |$ u6 t' Y% _+ O f
: R" c8 ?- A3 Z
sync ();
- ~1 T% `$ l) H, L
if ((val = *addr) != 0) {
1 A! y% ^ c) S2 R2 f- K3 \# ^
/* Restore the original data before leaving the function.
% S8 P3 H/ j& X# F `8 M
*/
- F, L& r: R" Y, I9 @9 [
sync ();
0 x* r& S% ?! n1 H N" r! ~, @$ b& x
*addr = save
;
% r2 u z7 P7 r1 a' z" k9 X
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, j7 `+ J* I4 P9 ]/ [; K3 i! C
addr = base + cnt;
- q# h/ q4 L8 i( i
sync ();
& b! D( q( c6 K& O. b' E
*addr = save[--i];
! N ?2 B3 B7 b
}
/ ^2 ~& C2 N; p( |# h: \0 `
return (0);
+ P& T% |0 d' F# \, c
}
+ o9 E# K- f% G4 G; Q& [0 P; @
6 k& ], I: h5 i* X; `
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
! I# A, e* ~$ l% y. k. C; l
addr = base + cnt; /* pointer arith! */
# M9 P# R2 v% N8 e
val = *addr;
5 x2 s( _0 S3 G) c+ v+ N
*addr = save[--i];
2 `' h3 T6 P. V) @$ F
if (val != ~cnt) {
8 N2 Z' H8 l8 [5 ]$ }
size = cnt * sizeof (long);
' U8 a9 O" f W; Z; J5 c; ], T1 V
/* Restore the original data before leaving the function.
4 Q4 E) M" w- M* ?; \5 B) U0 g
*/
1 w7 J7 a' h( c: c
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, w4 Q; V; f, j1 c/ w: [' m
addr = base + cnt;
' L4 Y% x9 { T X$ Y T
*addr = save[--i];
) [/ x$ l6 x# G |5 ]3 c* d
}
" Z1 @4 h9 N5 b8 k9 ]" ?
return (size);
/ k( q1 h4 v( O" l" u
}
3 Z+ a& @1 N7 E! a7 Z1 A
}
* ~, a6 w( n0 Z7 ^
9 c+ F% D5 U9 Z7 h. ^( q; N
return (maxsize);
9 g( V- t: z( }7 E, u m7 y
}
+ q, _9 M4 T4 L* E; {9 _7 ^
int dram_init(void)
Y0 A6 Q, t2 x1 Q
{
4 C8 X0 g1 X M; x
/* dram_init must store complete ramsize in gd->ram_size */
+ @5 O. v- R" Z) \$ n$ p! Z
gd->ram_size = get_ram_size(
3 K1 i$ |0 w+ ^2 z
(void *)CONFIG_SYS_SDRAM_BASE,
( F1 c' Q0 E8 r
CONFIG_MAX_RAM_BANK_SIZE);
. g& y( [. Q+ R% f. m. _% {
return 0;
1 c c6 |- |) [$ r
}
+ n! K- u8 y4 U I0 n
- F. T# B, @1 s E
1 {4 i& p4 }3 K( W3 Q% j
" g. c8 [+ c( H$ E0 |/ q8 W+ x
0 u5 X5 V8 k; ?" q
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
: I. y4 }2 B1 A; ]! v
4 l- [: F8 m( ? `
4 R# N9 M+ r2 C& _
1 @9 g5 [$ R) z9 P9 X
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4