嵌入式开发者社区

标题: TL138 uboot是怎么区分配置两款核心板的 [打印本页]

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
% t2 v- x' |* r5 m核心板2:DDR2 256M Byte   NAND FLASH 8G bit
& r- {5 p% o, {- V# N' `6 |0 T这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?9 J" Q; [  d& u+ k' ~4 B) B

, W1 q" ^/ \9 Y1 y: @是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
6 }9 t/ k! }0 _9 ^  i8 E2 @- N9 o

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:2 o+ V+ v0 ^! i  U. P) Q
/*
4 z# N: @; p. \* m; O* Check memory range for valid RAM. A simple memory test determines, i6 N3 k6 H' Y6 W3 M9 V1 q9 ^
* the actually available RAM size between addresses `base' and
. K0 D/ U. n* B( o! y+ y9 Y* `base + maxsize'.
  |( d: O3 e) L, ^; b% @) e6 L% [6 R*/# U" w9 P, b; }& \8 w
long get_ram_size(long *base, long maxsize)
8 p3 x" C; ^+ G1 {8 u! }{
6 v5 n0 |6 g) [  @! Y  ?        volatile long *addr;" w( e" ]1 ^. ]
        long           save[32];7 P7 V1 Q# K+ y- K# Z' D* n. ^
        long           cnt;
/ E! a' H* k, q/ ?1 \        long           val;% s2 s  L# u5 ?
        long           size;
6 p7 N" t* K: c+ _! B, V        int            i = 0;
5 k3 O4 p8 Y' I! M7 i" @, [5 [
4 F; A4 H( u* m" \# n        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
; n4 I* x  f. J, Z                addr = base + cnt;        /* pointer arith! */* S0 F' T" `4 X# l: h) m- \
                sync ();
+ @8 O$ _2 L7 E( e- t. f- }. m3 A% _                save[i++] = *addr;
  J2 C* l% ^/ T, {                sync ();
5 b( l! N0 j8 E6 }                *addr = ~cnt;, s$ }: t6 N, z' F; F2 {2 I
        }
$ O: d1 T, O1 `* `  P9 \* h8 @
8 W8 f! i, ~! j1 _0 U        addr = base;. f: R. ]1 O9 d) n3 {
        sync ();
$ R! \/ v% M. F6 L3 [1 Q        save = *addr;2 }4 Z( R9 M/ O0 F
        sync ();. `" e" _! Q* R7 G( H
        *addr = 0;
2 A) B5 i- r& n
. q/ ^" M3 O: [7 f        sync ();
8 ^# `( s$ Y: u. A1 G        if ((val = *addr) != 0) {$ S% X3 \/ O6 Q( x% l
                /* Restore the original data before leaving the function.( o: J% K! K7 E( }
                 */
+ T! X& ~- K, M3 t& u* }8 q, s' ~                sync ();
' v% H9 ?! h' x" P( C3 X/ e0 X( M                *addr = save;0 a  v+ g8 Z9 m- L' ^+ F$ ]
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
1 Z+ w: a2 U/ I* G; P8 V5 K                        addr  = base + cnt;
9 _- [: v3 [  B5 X) D$ Y                        sync ();0 C: R3 W- M+ o8 C* D
                        *addr = save[--i];, q0 i2 D* q! h3 I1 l3 B- |/ D
                }
/ }9 }* W" a# X; `( [$ a2 P                return (0);! [- y8 a" P$ H" x" O
        }
- P8 z; V4 Z8 W
& d! i8 \" U# y1 o        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ Z( e- |3 _9 }3 _& @3 s
                addr = base + cnt;        /* pointer arith! */6 ~+ O! ^6 V/ P- g* u, x3 J3 w
                val = *addr;, K3 Z" Z4 z; h5 D3 e6 [
                *addr = save[--i];2 }( T- S* g: `' `, F. g* ~
                if (val != ~cnt) {. `* J8 W# S: y# Q
                        size = cnt * sizeof (long);
0 Q5 J/ M0 ?# E! y' W& G                        /* Restore the original data before leaving the function.
7 Y+ m- J7 k- [/ e( f                         */4 U' ^+ ~/ b7 [; j/ j* ^# n
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {7 Y6 Y$ L# m% i
                                addr  = base + cnt;5 c7 L7 x( T7 N+ Z
                                *addr = save[--i];
$ d: c* _+ k$ Y                        }3 d7 x. B3 S5 j$ s: L! J
                        return (size);
- _& F0 P$ W7 ^/ K; S( A: K+ M                }
: I3 ^! R! Q; l6 T$ Z        }
, Z6 r" M0 ^, X! @, d- D6 r8 `# b0 C' U0 ?5 K9 W. u
        return (maxsize);9 \' ?- Y/ {- ?2 p% f
}' I/ r1 d, |$ l7 M
int dram_init(void)
0 I  ]. G' }- d4 d{
3 m9 q" G/ H; m9 a/ V        /* dram_init must store complete ramsize in gd->ram_size */8 w5 d/ s0 k5 M* G9 d
        gd->ram_size = get_ram_size(
! b* F( }2 \/ i2 ^2 \$ M                        (void *)CONFIG_SYS_SDRAM_BASE,3 Z1 z" u6 R! N- W( G
                        CONFIG_MAX_RAM_BANK_SIZE);
; G  J% u- m7 ~; V3 V, B        return 0;
! K4 Q) A* n4 K# U  b}( h) Q3 P: I/ @4 W  n) }

) _# r7 W  B1 j7 Y8 F7 J# d: M+ k" `* k) m
! b6 B4 D1 ~/ C( D$ ]9 m1 M0 g
' h0 A4 k$ U+ [; {% H0 X% Y
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!( \* J1 n4 {2 o3 r! W% S4 E" `8 C
, r: h; @0 F% X, D/ f1 S- {3 e

2 V% z* _# {9 e$ A" a: i6 t

1 e; A  T, M3 T




欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4