嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit; p% J8 d0 E, B2 E, d
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
" Q: ?( w9 ~( g# b2 b" U! x2 ?这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
+ _% `' P. Q: Z  t. {4 M" I+ w3 J' g3 @/ `) m2 s1 f; s1 {
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?3 D4 n- H# k6 g  O& A- T& d+ u' f
1 a, m$ W& q" a% w

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:) R& o4 U( m- k9 L
/*( p" B" w8 S0 J. F9 \6 ~; \
* Check memory range for valid RAM. A simple memory test determines: C0 Z6 F" P) T; Y( {5 c
* the actually available RAM size between addresses `base' and
9 {# S& \$ q+ N, Q* `base + maxsize'.
7 K+ ?" l  S: \" g" f7 X7 N$ E; q( s*/5 q* a9 n; E% U6 t% U0 a+ `
long get_ram_size(long *base, long maxsize)6 o1 E) Y# h: W( c) a: Z! X
{5 v. q, _6 C$ S3 L% c- x
        volatile long *addr;: b8 t5 L! \" A  ~! ^
        long           save[32];* v! {* m- O+ t: v  q8 w
        long           cnt;
; P# B* S! i3 \  p        long           val;
, @, \3 i* W) P, x/ K( I- \( f        long           size;
7 D/ v5 I0 F- h* }! Y. k        int            i = 0;1 M5 R  y! X+ z& a, T; H
6 }' o4 U. G+ Q  Z* o
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
" i7 }1 v  J5 N+ F, `, O: A7 p  w                addr = base + cnt;        /* pointer arith! */4 ]& N* X) N5 X+ q5 j- A1 V+ F
                sync ();) X+ k1 H9 P$ s& Y% `/ p
                save[i++] = *addr;- x! R4 B3 E; Z: d. P) A3 M7 o9 b+ r
                sync ();
$ g7 T! n. X4 {: e6 d) _7 R                *addr = ~cnt;: p+ C$ C! ^2 d7 s3 a
        }+ y6 _, l! J* K5 F3 J
; a' U1 P$ f- F3 t( t) I" D; `
        addr = base;
* k/ Q0 f. y9 p' P        sync ();
* d. y8 t+ m! \* g& k! Z! C& o        save = *addr;
0 c* F5 L5 Y6 i: f3 r        sync ();
% M+ Q8 o8 W# S7 [( V        *addr = 0;
( P% R5 i1 Y1 y: V3 P) D! R& R- `  J
0 ~1 s, f5 {7 x3 c# ?! q2 t6 m& e        sync ();3 z# }+ ?( j, G7 h- N3 X" F4 k
        if ((val = *addr) != 0) {$ i. h- p$ h5 r, z
                /* Restore the original data before leaving the function.
* @' G$ @$ @4 S                 */
( c+ x8 v2 e5 M/ J' A; s$ p                sync ();( s1 V+ C$ h/ ~4 y& r
                *addr = save;
0 S: s) Y; O, d2 [' J& q7 Q                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {. ^5 ?0 W3 \( a, U+ m
                        addr  = base + cnt;& o1 f2 W$ ?7 R! @; B" `
                        sync ();! e5 t' F6 ?- U5 L! @+ [9 Q
                        *addr = save[--i];
7 H& y. ^$ a2 w                }
! @7 |) i! e/ N5 N6 T) V                return (0);
5 E. ^$ M" Q, k' ~) o: W0 z        }0 J8 O+ Z  U8 {  a- s) q
6 |9 A) j3 x: U0 p
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 B4 X) r( J6 A                addr = base + cnt;        /* pointer arith! */
' B& R8 m3 w( L                val = *addr;
9 {: R$ I; t$ V' Q+ n5 ~8 [6 \                *addr = save[--i];3 D, h8 H. W1 g1 p* M/ F
                if (val != ~cnt) {+ o- e$ i  O+ g& [- k
                        size = cnt * sizeof (long);
' r4 y1 W! V2 d0 G+ v% @: {                        /* Restore the original data before leaving the function.
! m6 g& v) l" y5 `8 C: E                         */
8 D( R# x% r1 t& _4 a9 q7 |& p7 c                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, [5 n, X7 ]  [: g4 D0 _. m2 O  K                                addr  = base + cnt;
8 A1 W. P( j5 ]. {% }                                *addr = save[--i];" N" b, r; M1 {
                        }
6 O" z! p) B. t, E                        return (size);6 _* m1 I7 P* @% y# ?/ g
                }3 q9 ]7 n3 w4 C
        }6 T$ `' |8 U6 x% d& L! ~. o
) m7 j# Q2 T! \9 Z
        return (maxsize);, e% v; h2 n4 p
}6 D0 p; {% a3 ?1 V( w  o$ {& g
int dram_init(void)5 ]2 F% `' A& C- z% {
{
! Z' V7 i- \/ i1 w( r        /* dram_init must store complete ramsize in gd->ram_size */3 V2 s4 n, R) I
        gd->ram_size = get_ram_size(' X9 p' T( i1 f0 ~7 e; z- J* |
                        (void *)CONFIG_SYS_SDRAM_BASE,
  u+ Y+ v# D; G' z8 U$ S                        CONFIG_MAX_RAM_BANK_SIZE);
7 |& {8 H: ]2 n3 y0 S9 S! ]$ @: |        return 0;
2 [! T6 Q& f, f/ V0 F* S( X  g}) l$ c0 H. Q; x9 |" y4 F% P6 t1 L

6 h$ O+ f/ W) i/ F& r7 w: o3 ^" @# i3 a

' g* R; d% T( w# y* c6 T+ f( u1 C. L. n4 x. [
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!+ v- G$ M% V" S$ `5 \8 Y
, i% S( R" r  m% H) J
& x* k/ _# r$ j( o/ h5 T1 |2 f" {# a

, m! O9 [: y8 f1 @2 w1 `2 G7 Q




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