嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
0 v: t8 J. N6 Y. S: ?8 ]核心板2:DDR2 256M Byte   NAND FLASH 8G bit% s8 y0 w+ ?5 d2 @
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
. ]" y) }3 }8 O* S2 @& r
9 Z5 j& H$ g7 d0 k2 {' _是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?. ]  l0 x2 y! n- d, G( \

1 T7 u1 c2 [6 h% P
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
" G. M8 Z5 m7 t* i3 f$ Y/*8 G, }( b* T* Z" B1 Y
* Check memory range for valid RAM. A simple memory test determines3 X, d( ?, a7 H8 N# h& f
* the actually available RAM size between addresses `base' and
/ I+ F$ S4 ?  P7 k, z4 \2 y/ B* `base + maxsize'.
! V! C$ A2 ~& C4 U+ y" \*/
% V6 i4 z' ?: t4 klong get_ram_size(long *base, long maxsize)
+ f9 e* k6 r6 I- N, ?7 \; w) {7 \{5 G0 }- x8 d. l+ o  }1 x
        volatile long *addr;
3 J, P( f5 \: ]: N# Y0 B6 G& Y* u        long           save[32];
( P0 v9 M$ d! k7 Y! D. R0 N8 n        long           cnt;
. b2 a  G2 f5 |  [' _        long           val;
; {+ ]2 W/ M$ i. y        long           size;
6 w; [  ~7 N! o        int            i = 0;3 o7 v6 v- K% j" F$ x% Q8 h- t5 T

( ]1 w" R2 Y0 R2 e, u: |! u        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {% N: y* `( `0 G/ k
                addr = base + cnt;        /* pointer arith! */
# i8 t0 b/ o, f! O9 h                sync ();
  D; m8 A2 w0 O7 {- P                save[i++] = *addr;
/ O( z1 m( d8 D) ~  i9 x0 B8 h                sync ();
2 `, c) z1 [0 C; E8 g& R                *addr = ~cnt;
2 L( }- ?" O" l% ?0 [8 q, e        }# T% v. F7 i+ Q8 A! v& t

5 r* c5 D& E' @        addr = base;/ a4 m* D! u3 d: C- r% Q9 K
        sync ();2 l* q% }9 }, J; n
        save = *addr;2 F3 A. K8 L2 w6 u
        sync ();
2 f- p7 I' u! e' [3 z0 I  L( L6 Z        *addr = 0;: B4 i- ~7 x; L. i4 g- k, w

5 z6 o% b: W1 q5 w. a        sync ();4 I4 }3 x5 H* w3 m+ b
        if ((val = *addr) != 0) {
" W- F) D9 H  B. ?' E3 f- Q                /* Restore the original data before leaving the function.
: `5 j% K/ Q/ ?+ K! w                 */+ J; |, u7 @5 d2 n* J2 _
                sync ();- m% j2 k. Q& ]3 l! T
                *addr = save;4 _9 t# B; H5 ]$ S% n
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
; c& h; L/ F5 r8 _                        addr  = base + cnt;+ u9 ?1 H6 |/ M2 b
                        sync ();# j- N0 n) _! D( Z
                        *addr = save[--i];
8 d  B- B  M4 J7 R4 U                }
" `+ T# f! y+ r+ r                return (0);
* f5 C" c: i9 D* [& D) Y        }7 ~3 C: `2 H/ K  n2 U5 r- c$ l& _
: ~1 L; F- f, W9 }
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; H* e- N$ c9 l5 ]& x! Z  c5 c/ ?+ q                addr = base + cnt;        /* pointer arith! */
8 S5 }5 k: Y8 C. ]% Z; K                val = *addr;2 |( c6 e* B$ s- x
                *addr = save[--i];& I+ P6 a& S. h' f  [
                if (val != ~cnt) {
2 }8 U5 N& A; _; t4 x* F                        size = cnt * sizeof (long);
' c- c5 U& i. ?                        /* Restore the original data before leaving the function.4 B3 ~3 V" C4 V$ m0 J
                         */2 s+ F( T; }5 j# |
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& L! M( J0 S  K- f$ K0 \4 ~                                addr  = base + cnt;9 O) |9 |, f8 H! `
                                *addr = save[--i];6 Y9 ?  N( V' W' x
                        }. R/ u* b6 T% P9 O
                        return (size);6 ?+ s! m. k, B7 e
                }0 M4 A* m& r$ M' l6 _' q. p
        }/ v" O* T% z) Z3 d( U# `( x, Z& v

$ k- y2 l' j9 R( S* M        return (maxsize);
; n; I  w) K1 n: z* R  R}
* d: `$ }3 ]0 U+ Xint dram_init(void)
! W# H8 e4 y- o9 @5 B  s8 F& G) i{! ^2 }! V. X4 Z& r) A; @0 L% r  G- `
        /* dram_init must store complete ramsize in gd->ram_size */0 W, M) E0 V* c! j2 W
        gd->ram_size = get_ram_size(
1 r) M$ G6 W& V  a                        (void *)CONFIG_SYS_SDRAM_BASE,9 V$ f/ Z5 y% c4 Z
                        CONFIG_MAX_RAM_BANK_SIZE);. ^' m+ F# j- d
        return 0;" q* o9 o$ u9 l# L8 E: G& R
}( Z( T* ^4 `  a7 b% Z, b/ m
/ Z+ [6 u# t- C$ i6 f

# o$ j) T) h+ |1 w2 Y# _6 Q& r. P2 T) }5 S) o6 S

: c1 \  s( \- N6 s1 o0 |; j0 o# j' mFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!5 a- L/ e) I. y( j5 }

7 t$ `2 P" C" v1 O
1 v% V' R; U3 _: z5 d5 i* b

2 @: S2 ~( ?$ ?% ]- Y! p- H/ L




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