嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
7 J  W% {8 T: K核心板2:DDR2 256M Byte   NAND FLASH 8G bit
5 I* v! w4 j2 H这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?% A& D/ e4 s, V2 o8 C( g4 E1 I' y

/ s5 u4 Q& g& [8 S- i是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?' A+ S. F$ {: E3 Z3 g& E
1 @7 @: C2 i) T3 u7 Z( o

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
2 r1 K( o- |9 k; ~) y7 T/*1 e0 y5 q: a/ J, ~7 _- _1 r8 {% x/ N
* Check memory range for valid RAM. A simple memory test determines
, U; u3 V3 j; v2 V. v* the actually available RAM size between addresses `base' and
7 b1 q* I* h9 d1 k' s6 _* `base + maxsize'.- b1 Q) I7 }& {' h5 M
*/0 |% ^' t% s# i
long get_ram_size(long *base, long maxsize)
* f, U2 n, u, i) k, Q7 C{* q8 ?1 ~; g8 }( F( M1 L
        volatile long *addr;
3 r4 f0 h- ~* ^3 y; w        long           save[32];
, o. O* e& D$ }  s+ e        long           cnt;8 h9 q/ w9 S5 m. K- n& d+ G1 C
        long           val;
. u9 ^- r7 {* d0 @1 C        long           size;8 F9 y: X0 x. ~1 c' M$ [
        int            i = 0;
6 S- X* S& Q+ S' ?$ \8 C7 U' r2 u/ n  N- ]; D! E9 U% X
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
! z$ W% R4 k6 k5 z4 G$ N                addr = base + cnt;        /* pointer arith! */
& Y& h* |2 S+ b" A4 S2 w0 [                sync ();$ m9 U" y1 R; `
                save[i++] = *addr;
+ h' N- R" F; D, ]& ]                sync ();
) B/ m" d# j  W5 |' p# B& N                *addr = ~cnt;
8 F  S2 ?9 K4 ~( ~, B        }5 f0 M/ s; b/ b0 q- N

: q, k1 A) `3 e3 }5 R, U$ {8 e+ l        addr = base;8 k! j" t: o. `1 X  b7 A
        sync ();
6 C3 P7 X6 o8 Z        save = *addr;
* U* ]; `, V( i8 s        sync ();
& }- _7 h8 Z" v/ e& T, u# Y8 h        *addr = 0;# X6 t) J) ]8 I' ~( V' q

$ p- P( k1 D& f) `0 u        sync ();
& _; E- u+ U' q; i6 j        if ((val = *addr) != 0) {
/ I9 U( Y. f( A9 G* P                /* Restore the original data before leaving the function.
2 u0 _( P. v; G                 */
* p' Y- C; [+ }0 f                sync ();, R. c6 A1 E' A( y
                *addr = save;# P* e' m; }, `" c8 C
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
& J; Q0 P# ~4 {! d+ }. c% s                        addr  = base + cnt;
% ]+ M' Z( h% E' [5 a# x                        sync ();6 R/ @# C% s' d1 f7 @5 f. l
                        *addr = save[--i];
. a9 V7 v3 x& i1 O1 S6 u                }
/ x# d% V, }' m9 T$ T1 ]( m7 v                return (0);
" f, m; b5 Z4 q: X: p1 b        }' z' N9 k6 }* n* z: D3 E0 C# I

- U7 E# E. v6 D* ]- b( p3 x: X        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ L+ U' s3 @$ C% o1 w% j! m                addr = base + cnt;        /* pointer arith! */  l! y- ?& `) v; z! Q
                val = *addr;
9 X/ ^" `8 ?9 t, P                *addr = save[--i];# e: X* X0 f/ X5 q) m( D8 I! J
                if (val != ~cnt) {9 O  ^) W  o" J2 Z6 ~8 a8 x
                        size = cnt * sizeof (long);
. l4 \! Z$ n' ]( c/ [) p                        /* Restore the original data before leaving the function." M: q( x" ~5 ~9 N; Q2 E2 ]* \' \$ F
                         */# O% f$ w: O0 a- I& b
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {; m4 n* Z6 T) g1 k- K
                                addr  = base + cnt;6 {2 R) g  [! f: {
                                *addr = save[--i];* z) c  y$ Z( {& b
                        }
; t  g; `9 s, X, l                        return (size);
8 m# }+ {1 @9 y/ t3 n                }
+ h5 H2 ~1 H  u+ f9 Q6 X% r4 ~4 D        }# ^5 ~2 }2 g) x7 {% v

8 s4 t) n" f! Q% w! _) H+ |        return (maxsize);
% o# z- Y4 W9 @& s' _}
( k) ^# ^% k  T. Mint dram_init(void)1 X' P) j( R& ?) F8 C% h) F
{# d; q! q; y+ l- o$ r+ W- P
        /* dram_init must store complete ramsize in gd->ram_size */+ R3 I% `5 A/ @2 ?/ y
        gd->ram_size = get_ram_size(6 Q6 }8 G. v* C+ ]1 t
                        (void *)CONFIG_SYS_SDRAM_BASE,
6 \- J/ R4 _' U: @                        CONFIG_MAX_RAM_BANK_SIZE);
# Z, A0 o5 |' v7 n# i) M: ?/ ?3 K: i        return 0;
4 t. d/ T8 d0 u/ R}
' A# g- W; ]- V! a# n6 ?9 n( W0 A; O* ]" V
  X) \8 L, U+ n

3 Y3 I0 l0 A0 A, W5 m3 i; T
" @3 R7 V3 I# tFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
+ U& ]. I& h3 h1 t* n0 R- ^
  h& l% U" E% ]0 o/ R2 Z0 q) q. m7 q
3 t8 k) \* p2 K8 V1 ~1 ~" Q

3 S5 z$ U3 b# T6 i9 A, D9 [




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