嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
9 D2 L: a- W, e1 P
核心板2:DDR2 256M Byte NAND FLASH 8G bit
$ o T! [& A( y8 q0 {+ p* f4 Z
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
/ ^" C1 K+ [& V: G7 V' ~+ J# }
9 }+ Z4 P; {2 V" A2 L# g
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
6 I$ g5 h9 m4 A# k
8 h6 g: E4 h4 m& N* w K6 _
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
: E y1 L0 U* f7 P
/*
# { F* H; Z+ c+ W+ v9 K( W. d! E
* Check memory range for valid RAM. A simple memory test determines
1 T4 t" b+ i& l$ }# v
* the actually available RAM size between addresses `base' and
; `: \' p/ S0 z: r# q' I4 @
* `base + maxsize'.
4 @6 U+ @* S0 }4 c
*/
' E t' ]! T: a. j% T
long get_ram_size(long *base, long maxsize)
/ H% Y9 V+ H$ i/ g) b, |# p
{
% o: V4 @# Y& u; S
volatile long *addr;
8 a; O" r2 {: g+ m
long save[32];
6 N: O1 M( V, C W0 { O- M
long cnt;
8 x3 c3 p2 f0 m: Y7 C+ M# Q* i7 J7 _
long val;
9 l8 Q0 [! m7 |/ o7 d( |2 r
long size;
. m5 n; b& r5 i' @' w# y- W3 b
int i = 0;
8 W# s# _/ c. H( G% j" `
& R/ r+ C$ C% v& m U0 h
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
& j Y( k& V' {* |: r
addr = base + cnt; /* pointer arith! */
- F. ?# @1 e' Z$ D, s2 x, c
sync ();
' j _+ @8 [% n1 z
save[i++] = *addr;
4 J* F0 ?5 Z/ H: j ?. H
sync ();
. p" c y: l( a0 N: W, H
*addr = ~cnt;
( Z9 [- y" v( t% v, A
}
5 u- O2 v' n/ j" {
& q, x* Y _0 c, x8 c& z
addr = base;
+ _% K( |6 E9 D1 l
sync ();
, W5 g o# ?5 n4 n& o
save
= *addr;
( r9 o! b- ^) X: M: L# [
sync ();
+ H* r( M( a+ w9 {# V9 ~5 _# s
*addr = 0;
: n6 S/ _2 N3 V. u
' m. h5 @$ j z! p, l5 t. l
sync ();
Y( T& J" D% |, d! A! G
if ((val = *addr) != 0) {
8 C# Q1 }8 _% D J4 r( c% Y1 |8 |
/* Restore the original data before leaving the function.
* ]/ V: w% z0 W- |
*/
+ q4 N' }6 d; B! f6 v6 a
sync ();
5 c7 v0 K5 q" m% r6 J" V2 n
*addr = save
;
& m+ I0 K5 E5 l: G2 A5 C0 R
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 \* t% `0 [* ~
addr = base + cnt;
* K" |" d( d( `* i! M9 C( i* C
sync ();
" I* {' V" W' L4 h( H
*addr = save[--i];
- D' I2 ~& e1 S1 u7 A
}
4 \) a% ~6 w- P" U i
return (0);
! r, ?( v' W/ o- W2 }
}
! a Z- ]0 B0 @8 c9 Q
, {4 p" ?" L/ ]* ]' r3 `3 ]+ W
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 N7 R! k. E8 A# a/ H& d
addr = base + cnt; /* pointer arith! */
& D0 h0 C1 v7 y0 L f+ W
val = *addr;
3 d% a2 r# k% N( a6 }0 t
*addr = save[--i];
0 Y1 X8 L7 c. t( G
if (val != ~cnt) {
3 I( [4 j2 |4 M# u
size = cnt * sizeof (long);
: y5 D* ]) U Y3 a2 o$ U4 @
/* Restore the original data before leaving the function.
: V6 V* B* E! M2 f! w
*/
( n9 E9 w* _1 T- ~' x4 [, X; n5 z9 R% o
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" t0 |: I9 I$ ]8 | n
addr = base + cnt;
: G8 J- t1 w5 S- I
*addr = save[--i];
& ?1 V; R7 m7 n) `
}
4 t2 z- R/ s1 G4 f% R. B; Z
return (size);
" B9 w8 q7 }. M; V+ R( O8 H% @
}
) I4 g" I* z9 P- T! S4 v
}
; V9 _; W4 `' z8 T6 n& v" ?
0 j6 {4 W" N. Y( w
return (maxsize);
3 \1 l" E2 L4 Z0 p; h4 Y9 e8 N
}
0 z; w/ G. f0 S3 ^- s+ x8 ?
int dram_init(void)
4 I: S9 s4 a1 N) S5 f8 L
{
' d) x) Z- u, l1 K, E) h
/* dram_init must store complete ramsize in gd->ram_size */
* b' ?: S1 }5 X$ N+ ]' B8 v
gd->ram_size = get_ram_size(
: ^! t" t: n8 L0 \
(void *)CONFIG_SYS_SDRAM_BASE,
0 f. M: `+ G9 n2 E. k$ m: c. V3 M
CONFIG_MAX_RAM_BANK_SIZE);
0 [5 Z1 S" S9 p4 B* U. ~; c
return 0;
- t! n. m! q1 |2 i
}
2 H( H* s5 z( P! I! [7 D( D. U
6 W& i' N3 N+ [
) |- G; i, T2 c: s) n. s
3 K" g0 g7 F/ ^
' N7 r* p8 u: Q! U. W9 }$ G5 B
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
2 p4 J6 |8 ^* G4 ?1 n
' {! }& w1 j ^, M" Z, p
% D- _! ^# k( b3 @6 P8 N# C
) ~' _" E! J) d* m6 x
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4