嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit4 G4 {) G1 W  Q
核心板2:DDR2 256M Byte   NAND FLASH 8G bit& c; D: S( Q6 \5 g6 D
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
* N6 y# M: g8 n! C+ X2 r; R; Q1 o
6 _8 x3 g2 X. \' W$ B1 q是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
/ C8 a; [# d- _5 [, k/ {, b4 }  M# W7 n) n9 T- a- M3 Y. p4 l

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
" i' G" g% x5 S' F9 H/*+ x) a3 f7 N1 C/ [8 B1 e) U7 R- r
* Check memory range for valid RAM. A simple memory test determines
! I+ f! L0 X% W7 m  `0 v( I* the actually available RAM size between addresses `base' and: o' q; M" i) o- _
* `base + maxsize'.4 K: f/ s, x) y) h5 Q  _! m0 X
*/
( {' P5 H) T. t% @( j9 N" i; dlong get_ram_size(long *base, long maxsize)
$ G7 d6 z, }. O9 R{6 e: V4 f( _7 \* i# I2 F$ l' J
        volatile long *addr;' u) v. f( o% G) _/ F6 {2 N+ J  s
        long           save[32];8 J2 q0 s; E3 }' H( i
        long           cnt;
8 h& w; P7 v; j  N- D+ M3 i5 G' S) Q* R        long           val;
: M  z8 b' ?8 ?! ?7 ?# I- `. M        long           size;; b( S: {/ M, B7 w* f5 U
        int            i = 0;
6 i' l$ g8 @' w3 ]/ p; S9 ~# |) r" `$ Q' }' k4 @; V
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
$ u/ r& z) q4 ~; E/ r                addr = base + cnt;        /* pointer arith! */3 X8 c8 f& I( ^. N  S
                sync ();
) T; \8 \" A, s6 e9 t                save[i++] = *addr;5 x( L3 R! c4 s+ D4 g6 z
                sync ();
8 `! A+ ?8 M3 [: A& I( }                *addr = ~cnt;
8 l3 [8 T" d6 O" @3 b        }
- P, I+ y; Q! y1 d0 ?8 e& `+ c$ Z2 L% X' j. U
        addr = base;2 U/ O) W. S+ q* Q; O. `- P
        sync ();1 T1 N% V- p& n$ m1 b3 G: }
        save = *addr;
9 H: L' R/ j9 S        sync ();# i: s% q2 d7 [( {) C- _
        *addr = 0;
9 @# W; E* R/ j( F7 t
6 M( F1 @- ]: r. W) b! L        sync ();
& }5 k% x9 d% L: ^2 k6 P        if ((val = *addr) != 0) {
8 ]0 ?' c2 E) i. Z& c0 O' [                /* Restore the original data before leaving the function.3 P  i5 g5 M  J: e# x5 J
                 */
  s0 z5 j$ k, l, A! Z7 F                sync ();
" v8 J/ z  C% H: L5 x% E                *addr = save;3 ?! a4 U, @: L0 n. s" z" l1 \
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
7 [  f$ W. j# y; N& k                        addr  = base + cnt;3 W# _& {( ^) w" s/ S
                        sync ();1 {- N; Z1 y8 p0 ^  |" I) j# V) V
                        *addr = save[--i];
) y) R$ e6 b5 C5 F" a9 G# O                }
( t$ Q5 Q  P$ B( H                return (0);
. w( d  D  s, D, f( |        }
$ c3 q7 o) y1 g) l. m8 B. i( c' g  C) ^
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 X( f8 q& `* a8 ~6 q6 h; S$ ^$ P                addr = base + cnt;        /* pointer arith! */8 n( }- s* \5 b5 p1 \' y/ X. L
                val = *addr;9 [3 N+ }0 o' G% c& C' |
                *addr = save[--i];; ?8 W, b9 N4 y: X8 i7 h
                if (val != ~cnt) {$ @. X4 _- K" F6 X
                        size = cnt * sizeof (long);! a, y$ L, Z9 T5 N. G# g
                        /* Restore the original data before leaving the function.
5 ]! f' [, m. b, w+ Z                         */
1 G+ z1 K8 ?8 p                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" E' s1 c: v& g, u  R# S                                addr  = base + cnt;
& ?7 w0 }5 ^; {4 e                                *addr = save[--i];
$ }, E8 C" g! @( y, }5 n* K7 O8 R: s                        }8 ~& u. ?' ?; M/ w6 K% H
                        return (size);  T& Z1 Z; \1 \& T: p: `  z1 }
                }
1 X1 ~2 {! |- r. B6 g- k        }  q) ]& |. W0 f2 y- p0 P8 M

* b. d* h/ d( R& t        return (maxsize);1 f2 t/ {' T2 w9 I. Z+ S
}
* X, D7 r6 I: ^! }" ^2 C* _: l3 pint dram_init(void)+ I# ~2 m  L/ I& U
{2 i3 W6 k" n7 S
        /* dram_init must store complete ramsize in gd->ram_size */* [3 b+ N  U5 D6 ]4 O
        gd->ram_size = get_ram_size(- z3 L$ l% m! {$ s
                        (void *)CONFIG_SYS_SDRAM_BASE,' a: O% o3 Q' g; Q2 r' u
                        CONFIG_MAX_RAM_BANK_SIZE);
$ O0 i9 d* c; t+ W2 i4 s( t        return 0;% `; T/ P  w* `5 J9 P7 ?
}
" s& y' W6 y  f  E% b2 w3 o. B$ i& p/ `5 F9 }8 m

# b: v$ Z) u0 P. i- O
1 }0 x# L3 r, z$ F2 r
; B3 x9 Y2 I6 }2 Z& m, z( f  qFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!( J9 z( s5 z; h8 l5 M1 S

8 X% \3 z4 g' K( x
) s. Q, B8 A; w
+ K+ G& w+ E" T





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