嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit6 H# N0 g1 ]% I4 ~) W( Y4 J! a
核心板2:DDR2 256M Byte   NAND FLASH 8G bit# n$ u0 D3 M% B2 b1 d
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?1 b* M, F8 g  |

  b8 R; y% E2 w# b4 p) a2 {" A是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?+ Y+ @+ c; j* w* A" G
& J$ k$ n( _. K: q/ L- `6 ?/ i

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:8 `# t$ S2 M0 _+ M' e
/*! {: z& k! i# O* ~& c$ Q
* Check memory range for valid RAM. A simple memory test determines
6 s2 T  B9 [5 k* the actually available RAM size between addresses `base' and
, p' n6 [/ `3 k* `base + maxsize'.6 Z# v& D- _# w) l6 o; W
*/
1 }$ [( A( ]* c" U8 Hlong get_ram_size(long *base, long maxsize)- I- K& p" b* A
{$ P1 \# f7 n  ?" e& s
        volatile long *addr;
# T1 K; W4 A7 ?1 z5 I        long           save[32];. f' d9 d: ?/ M+ u6 P& _. `/ z
        long           cnt;! y  J7 {( e& M1 E' |+ s4 ^  `
        long           val;* `( W! I3 O9 B2 \3 q" |/ F3 h
        long           size;- w5 a- w. G% U* F  Y# ?$ Q2 o- J
        int            i = 0;2 h2 s/ p# P" p* G) j
5 r" _' ?+ |& U" G5 y7 E4 l9 r
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
) I# D9 V) l2 H& A2 V                addr = base + cnt;        /* pointer arith! */
6 h1 H( y1 V1 S$ ]  z4 T, G                sync ();
' }$ F4 x% @6 [- S7 ~1 g( V( M  c                save[i++] = *addr;
/ @! r1 ^+ e& n; R8 _" Q, i                sync ();
) _: k9 ^( G' r5 l$ ^                *addr = ~cnt;" c% c2 r- p- _8 g( w$ i' @
        }
( l4 c2 f/ A( G6 z" X' W& d  z% f2 F
        addr = base;
( w% |/ M( Z0 G# k9 a        sync ();
; y6 {: M1 n( |7 V! R5 ]8 O, c        save = *addr;! D) U& t  D/ V; q
        sync ();- K) d5 b1 L, n: y5 J' y
        *addr = 0;- o2 w7 M7 ?7 i

5 b4 u  d8 L/ k, b+ i        sync ();  H0 c) M5 a  J3 W4 K4 t( j
        if ((val = *addr) != 0) {
* w" w# H- Y& l+ h" r) t                /* Restore the original data before leaving the function.
  }* H/ j8 a+ B9 G2 d+ i% A                 */( }: }( F% Y5 f& |
                sync ();8 o* b9 e5 g1 l2 F* I
                *addr = save;6 I$ D' ?7 |- T. ]1 ?
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- O7 s' \. }  U3 ^$ Q                        addr  = base + cnt;" J9 ^- r1 z' Y7 Q
                        sync ();0 H( D" ?% b& d* V3 |, |
                        *addr = save[--i];
5 p2 `3 K( Z% C7 S& ?: L8 a                }
5 [8 x! G1 a( K7 ?& ~+ _4 {                return (0);4 c+ j4 \( S% ?. n
        }5 s3 ^$ c/ e/ S# A  U$ L

+ o* S" W& ?  a        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) N) n# I% c) I) _- Z5 A2 @% x                addr = base + cnt;        /* pointer arith! */
, e- U, x6 b! T- z, q( f* k                val = *addr;
+ c, f3 b, a: s" |9 z2 K* C                *addr = save[--i];8 z% B+ h4 z/ G4 t) A" v8 _  v
                if (val != ~cnt) {; s4 ^! {" R5 c+ ~7 w
                        size = cnt * sizeof (long);( g! w6 ]& T& C5 ^
                        /* Restore the original data before leaving the function.. h, J# Z( ~2 `9 l' ]6 {/ I
                         */9 ]* {1 l* h- r
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {  F  p9 v, i2 D& n- G6 x
                                addr  = base + cnt;
$ k0 i* Q0 i8 X* g( `                                *addr = save[--i];8 V3 h' ^9 T5 R7 G: H8 D( J
                        }& g; Z- z& z9 ^: C- u" b9 n
                        return (size);
1 W/ C8 a# V" Y: ]4 m$ S% j                }
7 ?4 F! J0 g, N        }
7 ]$ _* z  c7 A: w
0 ^- a; @; `5 k, I# m+ |9 Q- B        return (maxsize);
6 |2 r, W8 L" D}
6 S- G" E% p6 e4 ^% K+ @: ^int dram_init(void)% k+ O4 p3 z3 u* Z7 ^; W, H
{! J. e/ h7 N" c. _7 {3 g
        /* dram_init must store complete ramsize in gd->ram_size */1 V4 Z( ~! q7 a, }8 R
        gd->ram_size = get_ram_size(( d1 m9 y% N; D4 \' D
                        (void *)CONFIG_SYS_SDRAM_BASE,/ A* t% v( X2 x0 |2 [. z- h
                        CONFIG_MAX_RAM_BANK_SIZE);
5 x) I% n9 q" l        return 0;
7 D  c! c/ |# N% @}  t! `; g0 A8 ^: b" Y: p
! Y9 @& ^' u4 F1 k1 m

' R6 \& ?. `, Y- b7 t
9 _7 T1 Z. S. i% d# g
: ]' l, z4 H. T- g5 _! bFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!% [. |0 X5 e  x5 p! R1 H! M

# g& s  K9 L- K! D
: f, K# q! a0 x$ F' f3 @0 I# Y7 ]( a
* g/ b  }3 w' C; i& [/ k6 M





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