嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit  v; v' ]2 y: Z4 o
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
5 Z4 ?  T2 G( ~0 R" k这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
  e& {* t5 ~9 o2 e% ?  p: L$ w. S& h( u  R3 d/ I+ H
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
& ^5 f6 J& o4 H4 D, v3 P& s5 Q4 M; l" N" n  T! j

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
* e3 }3 o4 k- E# Z- [  U) F0 R3 U" u/*
, Q3 l, g3 T0 `" u& j* Check memory range for valid RAM. A simple memory test determines
1 h) ^# s0 b6 S# I* the actually available RAM size between addresses `base' and
( r3 T* {# [$ M* `base + maxsize'.
1 s1 P9 B4 q0 e! t* ]- E( P' F- d% |* F*/
6 Y/ T) B6 }" y! ylong get_ram_size(long *base, long maxsize)$ p' ^2 D& A4 D, T+ H& o8 i1 u
{
+ ~6 X; s! l. E& R- u" e        volatile long *addr;
6 W/ k* `; ]( [9 t        long           save[32];
( j; C. P- P+ e: H# ?, T' Q9 R        long           cnt;2 V' V$ k  X) X7 t; n
        long           val;9 L1 P2 @* v# a, `3 X5 J( g0 U+ u* p
        long           size;3 }% S& a3 N8 v% r4 T
        int            i = 0;
) T, h0 _" H; ~7 T( H2 b1 K
3 G! j  i9 z2 X0 ]. l4 K4 ~1 d        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {2 @* t1 F: K& i4 H( B4 l! V) S( J
                addr = base + cnt;        /* pointer arith! */
& w3 M9 |( O5 Z" m! Y                sync ();' b9 t5 _/ S1 E# h& v& `( i, ?4 D
                save[i++] = *addr;
, w3 b  f! B' G                sync ();
$ ~5 m- W- V& V                *addr = ~cnt;
- w+ Y+ t: S* j        }
8 m5 U2 j, \0 m# u$ p: R, ]) K# K* C) q/ j: @& v  ]3 U
        addr = base;* W6 d* L5 l* I
        sync ();
0 u( }6 @3 C3 B6 L) a( U$ }        save = *addr;
7 g- b( s5 ^6 B3 A8 d% f* k) n, ]( r, ~        sync ();
7 h- z1 L( }/ U$ S" i* n3 Q        *addr = 0;
7 d- t0 J# g0 Y; j% q( G" J4 {( u9 y( j7 P
        sync ();9 I( @) D3 @6 H) c8 s- f
        if ((val = *addr) != 0) {: x, Z; x& D3 J2 J0 e
                /* Restore the original data before leaving the function.- W' L9 p2 w, k; @
                 */0 l7 p/ ]  M2 Y2 H& ~
                sync ();
( I% n9 \+ f1 p) _2 A                *addr = save;$ M5 {$ o7 s# h# m* t
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
2 k( c' k) B' J- O& Q                        addr  = base + cnt;  ?" Z: w' }* r9 f! v5 h8 t0 a$ w
                        sync ();% G) a( @' ]  K8 a4 e8 E
                        *addr = save[--i];
* \8 `' T: _" J) g+ Q7 Z                }
  H, R+ C5 w% Y6 T: R                return (0);
/ U: @- Q, q$ x) O4 X' I6 U        }; I% r0 j- h  x! S  R& v
2 Y5 |, d" y2 d* n3 X  o) _$ F
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {7 J1 x# E9 j9 c
                addr = base + cnt;        /* pointer arith! */
- c  o& A( n, d) K6 P+ @; N                val = *addr;6 h  g( j/ C# X# x/ N0 Q4 M
                *addr = save[--i];' D+ C" x5 ]9 P3 r6 f- P
                if (val != ~cnt) {4 u. D" U5 b, G
                        size = cnt * sizeof (long);0 |0 l; L0 a3 ?, p  @. s
                        /* Restore the original data before leaving the function.4 p& q; r- G0 G: l3 e( q0 Z
                         */2 P% Q- J3 w0 o- x( K. X; z8 W
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {9 V: s( W! y6 X  Q
                                addr  = base + cnt;- m2 R) j0 w6 M% _
                                *addr = save[--i];
3 `5 i( I/ t" c' g# g2 w, @                        }
; f! V* b$ Q: L+ F* C6 ?                        return (size);
- D2 N9 o2 Y& e0 p                }: o  i1 P3 Y4 d+ w
        }
$ i: |( ?4 [  \- |! W7 X. P* c, Q4 V8 _8 {, `& p9 J
        return (maxsize);
- C" j; W( m6 G3 W% i+ d}+ S- h# _+ M* r& q  W, [1 O5 N
int dram_init(void). h+ ^" X0 q- d! Z, Z) j' H' T
{
. y" h2 _/ L% \4 B, T        /* dram_init must store complete ramsize in gd->ram_size */
5 i( n% u+ Z% T4 o) h        gd->ram_size = get_ram_size(: j& g* x& O" |+ E. X5 g3 X  ^
                        (void *)CONFIG_SYS_SDRAM_BASE,
, ]4 T$ w  {3 x! e                        CONFIG_MAX_RAM_BANK_SIZE);4 w$ V) p  b. A6 d+ p; V/ I7 P
        return 0;
: p) e9 a' J/ P/ b: P, Y}& g2 e! T, m" P/ e1 B

$ ?7 T* P: F1 Z, o4 K2 _3 X" c* l; j7 E/ |' k0 y* c& x

% Y7 o% S: D2 h8 j7 b4 ~- h" E( H% @; r& W% j1 y$ D
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!5 d4 L3 ^) S7 {; A5 W1 [
+ g2 }7 Y% ^$ H; b! I
( P3 g% m4 E" A

% f7 Z7 X4 x. w( e




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