嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
' M1 h. [/ B+ K; L8 p0 J# z
核心板2:DDR2 256M Byte NAND FLASH 8G bit
( e- r1 W- `6 K& s
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
0 F9 s- f7 L) [, A8 p
: R8 [5 Y. o3 I7 S
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
9 z& W1 p# r, m$ E- l7 D! B9 w
% `0 G J0 f2 e* |
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
: }7 T$ e# d8 B& J6 u$ k
/*
* C( u" W0 ^& S! M$ t% B$ e. O
* Check memory range for valid RAM. A simple memory test determines
, l- I: ~4 T) q5 l9 y. ~" X
* the actually available RAM size between addresses `base' and
9 ]5 g# |2 N' }* e J# q, T
* `base + maxsize'.
1 ]0 n% J% B0 H2 H$ c8 |
*/
+ y' j d: H3 q! `
long get_ram_size(long *base, long maxsize)
8 i0 K9 ~$ c2 F' v! B* H# x/ w- h
{
: u7 u: F0 P% {% m+ S6 b; n$ Q
volatile long *addr;
3 Q, s2 n' y& ~, g
long save[32];
3 F8 S l% F: z) A+ n
long cnt;
( }2 `9 q: Z; L1 A; o
long val;
( f) |9 N; b7 t
long size;
( O# Q. c6 } e- W* I- H
int i = 0;
2 h6 a+ q, I% B; O; ^- \
g f$ ~( \6 F2 |8 O# f& G
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
0 Q+ ~% e7 [' c( v$ r# v
addr = base + cnt; /* pointer arith! */
8 I: j/ N0 l5 ^# m7 t
sync ();
) B5 f. G6 I, Z" l; `
save[i++] = *addr;
/ ^/ {" k! @" U+ d8 ]2 d
sync ();
- V' |& ~" L O2 z0 J ^
*addr = ~cnt;
, N- Y$ h5 F4 I {+ b' z1 ^: r# M
}
5 J9 e$ h' Z# K( k# A' T& |
% W/ t7 `. f( H8 X
addr = base;
* t: d+ x& y0 f2 g u# ~ ]
sync ();
: K9 K1 U+ o+ W8 [+ c1 o
save
= *addr;
+ T6 H) z# }$ w* E' a. f
sync ();
9 J0 M7 @0 P9 j& g/ c2 G$ Q
*addr = 0;
, C! L+ @& D0 q& i- W+ j
6 D4 Z0 D! t" C9 W6 G* c
sync ();
; f, l4 u; s$ w+ o- `
if ((val = *addr) != 0) {
1 |- T2 ]3 Y, s1 ?- H
/* Restore the original data before leaving the function.
. q& R4 D% J" `: X
*/
. U8 k7 s. ~. b$ }' I% Z1 ?
sync ();
% o# t3 B7 u/ G2 S/ U' F; J
*addr = save
;
+ a5 {; d4 Z6 a: F3 e4 L7 p1 J8 H. O
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
0 y7 ]) _; P) ~8 W$ `) j6 U
addr = base + cnt;
4 C" z& A6 u2 e# ?( `- q: b* P. x* b
sync ();
: b( s1 x- u* C0 o0 f
*addr = save[--i];
& U: ^) R9 ~4 y: \) k
}
; {. O( X; s: Y8 K
return (0);
: }; @; |$ q# ?; \" m
}
8 B1 X! s3 X& Q; v
9 O$ n6 @+ G( m4 N' O, t8 K
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ q t) U7 s- O
addr = base + cnt; /* pointer arith! */
9 j( f6 R7 l# q- K
val = *addr;
2 o5 b" i& r% T7 s
*addr = save[--i];
" p3 M5 _- ]4 P0 v7 B/ h9 }
if (val != ~cnt) {
5 r. v* y# k% W S' ]+ d
size = cnt * sizeof (long);
1 }- K$ z: ^/ s1 B3 _" E+ p
/* Restore the original data before leaving the function.
+ S* d% K* V) l: E- W" |: T1 A
*/
, Z. k8 U! m3 i y
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 G6 v6 }6 _4 i# I7 C& E3 ] u& P4 v
addr = base + cnt;
5 j3 R( c8 `6 _2 f/ v* ]
*addr = save[--i];
6 d% l: X6 z# b. g, n. e" L
}
+ X$ q @+ J3 u! X
return (size);
' M% l) O0 g" J& I* a; E7 `! G4 K
}
5 s. G0 H! F c- q
}
9 t# @. `( B" k$ {/ _6 L, h* A8 Q6 P7 g
" H3 X, H5 ~5 r. q
return (maxsize);
, Z( I: ~' r- M& A# V
}
. E `' M4 a8 M. U2 j; _8 G
int dram_init(void)
) Q& l5 j. W3 X1 p2 _- d
{
& i+ H7 v5 G. ?
/* dram_init must store complete ramsize in gd->ram_size */
: @* Z9 ^0 W* Y9 [/ o! T
gd->ram_size = get_ram_size(
8 V# ]* v- P9 n
(void *)CONFIG_SYS_SDRAM_BASE,
& M2 W! ~; c$ c0 g- d! z" C
CONFIG_MAX_RAM_BANK_SIZE);
5 Y+ q: e8 O" k6 K
return 0;
6 u8 l6 }- o8 T
}
8 l6 t6 R- J7 b$ `
8 C# x. r9 B, |: F
- }* G+ E; [6 u; S' @$ \
# Z3 i# G8 Q+ J$ i' f
$ w& _/ k/ m: q& C
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
( r' |: Z9 m, t4 c$ S
3 N4 l5 Z; [) x3 h& O
) ]* O/ Y4 @ u! ]2 b5 J3 h
h# c) s& C5 J, c' J) o1 v7 m
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4