嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
$ J! M Z& s6 s6 Z1 W( ]" [5 k( X
核心板2:DDR2 256M Byte NAND FLASH 8G bit
( ]+ d2 @6 B8 i
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
* R" V! b% H! p8 L- F3 n
+ X* g) {5 A4 u2 L1 ]3 Q
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
8 o/ P) x' |( E3 _
+ t' U; K: N+ g, L/ C+ e7 U
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
, j( x% c; t+ ~& Y5 d
/*
' F( W, i; q X, O0 @6 F: q
* Check memory range for valid RAM. A simple memory test determines
- v [$ Z% M, }" x! O, M7 C
* the actually available RAM size between addresses `base' and
6 B' `) L' y% g, M+ P4 s
* `base + maxsize'.
, l) }; |, @+ j+ {
*/
T5 ~4 n/ t% q5 J5 J" m
long get_ram_size(long *base, long maxsize)
1 e6 }3 j; G; |$ x* S! ]9 T
{
3 U; c+ g- H) H' f) n0 W
volatile long *addr;
5 X+ r) {% T+ M" t2 @* @
long save[32];
" }4 \7 Q, `* T
long cnt;
; T2 g# U; ?; l1 w$ A9 g
long val;
' ]' [: R4 y W. M
long size;
0 _2 u: {6 N! Z4 ~( ?* E
int i = 0;
# I8 s9 J7 m' o
4 [, `9 |2 {6 e) D0 N- ]
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
% j& r- L. i0 [+ q' d* f
addr = base + cnt; /* pointer arith! */
4 Q( S5 C- y+ A$ V2 G! R$ n4 K6 N
sync ();
3 `4 d9 Y/ L' ?3 h' j7 |
save[i++] = *addr;
1 v' l# r3 J# s4 s* c
sync ();
9 q! D' s% Y* T
*addr = ~cnt;
d1 H2 V& H) E9 h
}
9 d1 M* O; ~2 ]. P' ]) @( q u B1 Q7 F
g. |: \' ]- Z" C
addr = base;
8 }2 |& m$ V1 E
sync ();
$ U% R: W" K' U) d
save
= *addr;
; v! m/ f5 @! \( W" p' N% e
sync ();
2 d" }7 f, j+ ^# C8 g; ]8 o
*addr = 0;
+ k8 V v I! s* X d9 L3 a
- q0 S- `% D# p$ C2 c3 m2 ^
sync ();
# j! i W% w/ G; i, u. R
if ((val = *addr) != 0) {
/ L {% N9 ?; @6 H( m S
/* Restore the original data before leaving the function.
9 P0 S2 j- W- Z# m5 h$ \
*/
. ^/ h, ] i( `8 Y5 b3 n& J
sync ();
& c8 S8 `/ N( p% Q$ t- v
*addr = save
;
) k: e* B' O" A0 M
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
' g6 z! y v, Q( A# L
addr = base + cnt;
6 Q1 Z! k0 ^3 x: w* X0 z! f& |
sync ();
9 K1 p; j8 i# {4 Z$ x1 `( w
*addr = save[--i];
i) U3 Y8 I7 @! c2 _8 j
}
$ t8 Z$ B) Z8 O
return (0);
- W, J, L6 h2 c1 n$ U2 n0 A/ c2 v9 ~
}
: J* j7 |$ r$ k9 l! N* g- c& v9 r
% h! g/ W: z- }# [" ]+ J
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
9 U. G3 S3 _# l3 s! ?5 B2 D
addr = base + cnt; /* pointer arith! */
+ E4 n6 ?$ B, o. [+ {- Q
val = *addr;
7 q1 M+ o# Y7 E1 l0 G9 ^
*addr = save[--i];
- \ w- T6 a8 f" t! A* }% f( ~
if (val != ~cnt) {
; f! O8 [, C, _" ~ u
size = cnt * sizeof (long);
6 t" M8 v" ~) {$ P
/* Restore the original data before leaving the function.
3 U8 D$ [& M* M9 s" I0 s9 @. O
*/
1 J9 b. b5 Y( Y5 e: i% m9 I
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; [1 j6 h6 M( I4 o( q, F) c$ U
addr = base + cnt;
) ?0 l8 F. g3 F5 Z" M1 X
*addr = save[--i];
0 q1 t* |1 i6 C* l& K" L1 x8 H
}
/ Y( y1 ]6 p4 m1 V! I
return (size);
" \) e+ N4 b# {- A/ ~& D
}
6 s8 E. y Q& E- p9 h Y) W5 h
}
* O7 A D9 D; x1 E5 u
# J/ ]# S& t- f( d
return (maxsize);
9 t9 Z+ T5 n; n
}
1 k/ M' W. N9 y
int dram_init(void)
7 P5 y, I7 @$ e
{
& ^& o$ `2 T1 |
/* dram_init must store complete ramsize in gd->ram_size */
2 O, Q6 D8 f! P
gd->ram_size = get_ram_size(
) h. Q: {1 w) T; ~1 |" ?7 T
(void *)CONFIG_SYS_SDRAM_BASE,
, e$ p; p8 S4 V) J7 T8 s
CONFIG_MAX_RAM_BANK_SIZE);
/ U4 \ {* y. V
return 0;
! i2 h: ?# C5 ?! x5 g6 @7 |
}
' A" ^2 t, y+ l5 Q( x+ ^4 n% W4 e4 j
( O5 g1 H7 H; ^
4 K' E# [4 Q$ @* h8 k+ M
$ d- y8 R) G1 D5 S3 w; d h
. Z( C6 F. t8 x6 E1 ^: O# R6 M
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
: r2 |- `+ H' n6 z; B( l W+ Z+ I' T
) M' y0 r6 Y# G& ~- e, r
P% E q3 k$ A# R* d& z5 [
2 Y9 l* W6 y% X# X3 L8 G
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4