嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
' Y/ G/ m# ^) w/ A
核心板2:DDR2 256M Byte NAND FLASH 8G bit
' z. O! x+ @6 D% W# x1 w
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
" J, m7 F& ^& x! m
1 r+ @3 R- ~/ [- x, e& x
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
9 a# U6 }( p. C3 |4 Q
/ E1 {9 |# _' y, a5 x4 ^. p1 E% ?1 Z
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
9 p4 E$ C; t+ ^
/*
' D* R& P9 R0 G) H
* Check memory range for valid RAM. A simple memory test determines
" {" b N' I* b/ l
* the actually available RAM size between addresses `base' and
l: d+ |. {3 O
* `base + maxsize'.
' l- r7 l: A/ A( S
*/
* u0 C0 Z5 x) K; ?1 ^0 U
long get_ram_size(long *base, long maxsize)
" X0 q0 U8 {( J' o3 _, ~& y/ f% Y
{
/ u) S: j* t9 n2 O. o& Z
volatile long *addr;
c* p4 m) S( Y
long save[32];
4 e) S2 |7 w6 s% q# W0 a3 x& @
long cnt;
. o! B" H, e7 b* f3 H
long val;
8 T2 F, A+ q2 D l) I
long size;
* i! n4 Z6 Z! X
int i = 0;
6 ]0 w' X+ n5 M" V! z) \ B
# T7 _4 c* z& a: K- i
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
+ M" j3 s0 r/ B+ |: t0 P% k
addr = base + cnt; /* pointer arith! */
( G0 `( F' W! m& L1 b: q
sync ();
q+ v, S! `4 n7 A( w
save[i++] = *addr;
' ~7 c W) b& F1 I# ~
sync ();
7 m9 c' {5 L- P- H4 s
*addr = ~cnt;
% M; |0 D6 d0 ]* h( H
}
. ?( Y" e' N% U& Y' N
. M! A. w, E# l3 I; t: U& ~! N$ o+ F
addr = base;
+ l p6 U4 w3 y/ `! @& `8 P4 `
sync ();
4 A# f5 H) y' l, t: _) Z6 _) `2 I6 H5 e
save
= *addr;
+ C' G, a% E) z: x' B7 g: b8 j, B; {
sync ();
) w. E8 z- {- B9 s( X
*addr = 0;
7 N; Z$ B1 Z+ m1 h3 n2 S
, }$ C/ Z) V) D
sync ();
1 r! T. H3 F4 j f8 ]
if ((val = *addr) != 0) {
. \& M+ Q8 I, f+ ^% p4 \* p8 h
/* Restore the original data before leaving the function.
/ E) Z* f4 `. p! N9 O# {( I* u
*/
4 ?4 B* Z$ R- `6 m
sync ();
! t% Z+ X- F- F: D: b
*addr = save
;
( e9 @- g. }5 \' b
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
' {4 ] ?! y( \4 q. [
addr = base + cnt;
, m& O/ o Y2 @, r1 d& t
sync ();
! _5 k2 o+ O `) j$ a0 ~
*addr = save[--i];
. S5 f- s/ T0 P1 U5 j7 e* f
}
1 p" i/ O' i+ ?0 ]1 o% z
return (0);
& W6 q+ }* d5 N' u3 B
}
5 S, s1 y9 X$ V7 G* s6 a
9 a$ {2 n, R/ d9 ^
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' U. v2 D: E7 f2 ^) R& M5 u( I# ^
addr = base + cnt; /* pointer arith! */
' e% A1 C% h+ T
val = *addr;
, q0 L4 A+ s# ]3 _6 J+ _
*addr = save[--i];
8 C4 C# U- T0 g* B q; M+ V% v
if (val != ~cnt) {
% s3 w7 Z. a. E2 B- v/ g' M
size = cnt * sizeof (long);
, p* U% b2 N8 A5 g1 e! k
/* Restore the original data before leaving the function.
& K R s1 d U0 H) C- t+ n9 q% V
*/
( {, _5 x$ C$ c
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; b1 P' {5 r7 X- w& R
addr = base + cnt;
$ T# Y2 l% m- e# n* L' |
*addr = save[--i];
4 r( V7 l& v5 }( Z: \
}
: Y* k3 X e4 x% n! e) o4 T& r/ _6 R
return (size);
: g; a* C% E; X
}
) G! m6 p* r, M
}
5 M& ?5 g7 J. ]( g, Q8 I2 r G
4 r. n: f% J3 k7 |1 j
return (maxsize);
. }% f, M" E$ K, }, ~
}
8 z$ T$ h4 b$ e2 ]
int dram_init(void)
6 a* U5 p# s: x. I Q
{
- b8 J# a! \0 C: K
/* dram_init must store complete ramsize in gd->ram_size */
3 L! h/ _; h4 ]/ Z5 q1 d
gd->ram_size = get_ram_size(
( F0 }- b6 I: b: W6 x% W
(void *)CONFIG_SYS_SDRAM_BASE,
# U4 x) M0 t$ A0 r; w
CONFIG_MAX_RAM_BANK_SIZE);
: I- e; j/ P2 r: }: E) k
return 0;
! c6 J: M. j+ u) T1 @
}
9 ^+ H" V1 N0 k/ x
$ ~: {! `3 o; N5 Y7 |7 p% u
. Z+ R0 @8 e' L2 [$ R* i* i; Q$ {& m
! U# v% b5 B7 q, S
' Q3 C. Y! j5 v1 A
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
% d' F3 w# k" N' _
/ U+ M/ J! ]7 @3 A0 o; Y
, M' T9 v @ o5 n+ A$ F
/ [& q4 k; {6 U& H, f
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4