嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
! ~- p# x: ~) ^! V核心板2:DDR2 256M Byte   NAND FLASH 8G bit' s2 B4 K& P; G, A8 Z  A: ^
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
' R5 V. c& H1 T' r; @' j0 {
7 T& Y: E1 F+ @+ S9 `8 f/ g; H. `是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
( y" e; i  P# A3 ~( m; q) X; Q1 i" ^: u2 \( _

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:7 n! r- T7 E, u! o$ g5 ?
/*
  S) q9 E& |" }5 x5 J2 n" H7 D* Check memory range for valid RAM. A simple memory test determines+ T, R* d( s9 g5 P( F. C( O
* the actually available RAM size between addresses `base' and" {; d/ {% q" n: Q
* `base + maxsize'.
5 ?, }, M$ z6 m3 z% \) W# R9 J*/
( H2 @' M9 _  y6 ^* H/ p. Z* flong get_ram_size(long *base, long maxsize)
; b: _: y. T* j{
4 s$ k" ^8 t3 `3 R: z+ q        volatile long *addr;0 p$ }# b; y/ E- V+ H. F
        long           save[32];
# O0 q' \8 Y7 O( y6 Q# C% S" s        long           cnt;" R0 F* ?% d; h
        long           val;! ^& w% J- [8 _) A( K
        long           size;
( i9 Y5 Y. ?" [! B8 |        int            i = 0;. E2 |& R9 v( b
, x, e6 V# v  N( V: O
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
  p  |  S( [( Y9 W- q                addr = base + cnt;        /* pointer arith! */0 j3 U& Y2 n& j; `% q# S4 }
                sync ();% |1 o0 H8 d" a% g6 j  T
                save[i++] = *addr;
! X+ F( Z7 z9 g! T# ?                sync ();
3 N! m3 P- g/ y7 |1 u" G                *addr = ~cnt;
- ?( H  p! k: }$ K        }
3 H0 ?& _9 v% z& M* t0 L" w$ a0 o+ B" z, K( l4 n- _+ u
        addr = base;
) v( H4 u: l  C) _# |        sync ();
3 {! r: h/ P- ]1 F: p        save = *addr;
8 @, g) b- k2 A4 w# o6 l/ ^& o* \        sync ();
$ O* }4 j" Y7 K        *addr = 0;$ f+ q' e/ C9 [: n& j+ ~8 _

$ e5 X' L3 @6 Y& ?) b) s        sync ();
" L6 F0 d* X! `4 }        if ((val = *addr) != 0) {) \  o8 T3 e1 o' K
                /* Restore the original data before leaving the function.
6 K$ m/ s* p- i7 `( r                 */
2 X) A% }( P) T, P5 j, I. x                sync ();$ R, r* R+ R6 k& ?8 a  S& I( A- i
                *addr = save;. G4 L1 G; z' I
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {0 u5 O( Q0 Y& M& ^2 q
                        addr  = base + cnt;. I  \4 u6 @* \! L  ?1 y3 Y
                        sync ();5 U) W& o6 z& s( q) l0 f3 \, O
                        *addr = save[--i];
* u2 T$ F$ |; ?# b                }1 `+ O5 m) G4 [: Y' b
                return (0);
- T. D, o* r6 G6 z# t0 j7 e8 V        }" b9 }) ?& w2 ]' l7 S: K
! ]* z7 R- P! M; w! Z; Q! ]: B
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 l. J( n- R5 ~+ R. A1 B$ Y                addr = base + cnt;        /* pointer arith! */0 p5 y; F" q- L0 h! [" n" U
                val = *addr;
! k( Z" `8 K8 h' Y, ]                *addr = save[--i];/ N$ b6 U, [! H! Y, N
                if (val != ~cnt) {
" s' D4 I& m. [" A! p9 N2 O                        size = cnt * sizeof (long);: v5 z' |% r, D- h7 Q% P7 P1 Q
                        /* Restore the original data before leaving the function.
/ y( [" ?3 ~! L: |                         */
: L. d* u+ d, ^# R                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' [- l5 x' z% n$ c0 `                                addr  = base + cnt;
( n" U2 A  ^9 @0 s' Q" N2 C7 E+ B                                *addr = save[--i];
1 T) B' Q) i) n  i0 N& O                        }
* c; m+ n$ S0 ~* M/ Z# W                        return (size);
. H* z, n! J3 V9 O" n+ x: f4 j. X                }: u. d* b- T. s- t! P7 q
        }
4 y5 o# G, f( `! v( U1 ]6 ~& J$ [5 L
        return (maxsize);
2 N8 h% j% U3 i0 `3 o}
, a8 K! U) v  R3 y# z/ S0 oint dram_init(void)
) u. u/ b6 ?) }0 D{
  h) ]8 U2 \1 q9 X! D: M  o- |% H        /* dram_init must store complete ramsize in gd->ram_size */
9 h& Z9 Q; C, k( H- R        gd->ram_size = get_ram_size(
# ^8 ?4 r) g- v% J/ K) e                        (void *)CONFIG_SYS_SDRAM_BASE,
/ q9 K6 A  A9 N) e                        CONFIG_MAX_RAM_BANK_SIZE);" \. A3 Z3 E% a" \6 p
        return 0;2 w% T, y* r+ J& e# G/ x
}
/ C0 d" ^$ k. S# C1 _+ b5 i' z$ j. o, @
! v# J$ y( s0 t; J1 R1 o# \3 X
) y3 r7 O: S! r: R! O8 g
0 p7 ~6 l. X- K( p3 e. h8 B
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
  g  Z$ s6 [: j8 S- [: _5 D! f8 W8 G2 B7 t( L' K0 G% \5 f
4 S9 r2 j6 w; }+ ^5 e

) B6 Q( R/ W7 I8 @




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