嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit  G. k! O& }1 P# c
核心板2:DDR2 256M Byte   NAND FLASH 8G bit: ^  |; i- J! \% l0 _
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?1 C$ T# Z" D! }9 M

  s& s: N% g: y2 J/ |是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?) B2 u! C$ W* Q2 B4 z( p

% t+ H8 j- X* c+ @4 g0 l
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:+ H; s/ A' O1 E& J" p
/*
* o$ R8 r9 B0 X2 k5 k* Check memory range for valid RAM. A simple memory test determines3 U6 X5 ?" {' Q9 i0 o
* the actually available RAM size between addresses `base' and
+ B' J9 l9 T8 Y; G% `0 O* `base + maxsize'.
, U/ f, {6 G( c8 O2 `; _6 i2 L*/+ R1 s+ W" C/ a- V
long get_ram_size(long *base, long maxsize)
2 v& {& C1 W, ?+ A0 i8 X9 j{
2 P$ r. f) ?! E! F1 ]2 |- \5 E: G        volatile long *addr;; ]) Y6 q1 W7 w( o: x
        long           save[32];5 X& v: e7 \" l+ }; ]
        long           cnt;
2 N" K5 e" }8 Z( \        long           val;
4 K: @  l! j) _% z        long           size;! I% p5 ?% D$ f
        int            i = 0;
7 {& C4 j9 z  ^3 d( {. V. P4 c) D* Y. ]3 t- w4 B$ M
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {! j/ u  q. g9 X; M: R$ i
                addr = base + cnt;        /* pointer arith! */
2 ]3 ~9 p$ p( i  f4 N                sync ();
* L* d$ n/ \( k  i0 M                save[i++] = *addr;& G! d* z# j( Z# d& F
                sync ();. [2 _- _0 q' G. d
                *addr = ~cnt;
* p: Q* F2 y" h$ U        }% S# t6 l, k" e4 `$ `
( `* a& m' @9 h2 j0 w4 S
        addr = base;
8 M& X7 q4 w8 L8 l        sync ();: P) ~/ Q1 E, d4 t0 v
        save = *addr;2 _( x( r8 i$ C3 S
        sync ();
# j0 t8 w( ~- M2 _! C/ q$ j        *addr = 0;7 s1 z9 Z1 [# w0 B  h% f% @

* i5 X* j1 |4 d9 L2 X% ]        sync ();
; m4 k( U  d7 l/ y# i        if ((val = *addr) != 0) {
# i2 @* N6 [1 J                /* Restore the original data before leaving the function.9 Q+ L* q5 d' R% r: N8 i! p( Q
                 */
) Y$ K* D2 j5 R& M                sync ();  m# ~# K3 c) R2 s
                *addr = save;0 U7 a/ v" \2 P' U& a( \
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {) Z3 x, y- {; [) E* S' p
                        addr  = base + cnt;
- m4 B" m7 B; P7 t4 V) S! `! k' N/ |                        sync ();( h# U7 D% p( w) }
                        *addr = save[--i];9 U5 O$ N0 v( |! A9 ]2 l) {
                }* m) X6 m$ m5 x) E+ o4 s" K* K
                return (0);6 }( Q2 K: a1 X0 y- |$ I& H) T2 y
        }0 i5 L: j  f& @+ Z5 S/ G

8 }0 Y7 v5 `- d+ T, v        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ f! g; c' N& I; C* X
                addr = base + cnt;        /* pointer arith! */) z3 g3 `0 p. c# h. R
                val = *addr;, e8 `" r0 K" s9 F  z  t
                *addr = save[--i];
; n9 \  ?& X6 F0 z% p                if (val != ~cnt) {
1 |; t4 ^; y2 d. ~/ N7 [                        size = cnt * sizeof (long);3 \; _$ X) ?- d! U/ U1 f
                        /* Restore the original data before leaving the function.: [. [  h' y) b
                         */* v1 ?" t& b  e* S8 U" w
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 ?4 @' I4 g+ V$ q. Q+ O" `1 z3 U                                addr  = base + cnt;; n% E  y8 D9 V8 ]
                                *addr = save[--i];
4 X4 k5 ?3 B1 O5 b( s6 q' n& ~                        }5 D$ x( h" w  \% b9 c" {
                        return (size);
- e, w7 m% i" a, l8 P* a9 h! m                }
  D6 O+ ?" l, K3 S1 S8 F        }0 d; L, @0 V0 g( t7 C: m

, L  l1 ]' w# Y( Y: _. R% X        return (maxsize);( w0 A% G! N- o+ O) q4 `
}  G6 n2 d% S; q; p& c
int dram_init(void). L; a5 d& C9 L% S4 ~
{
5 \0 z) N! ?+ V+ M  x1 Q        /* dram_init must store complete ramsize in gd->ram_size */
, Z3 l# I4 |% S* f; c        gd->ram_size = get_ram_size(
7 y3 O, X4 ?: T! v$ q# l' g: a                        (void *)CONFIG_SYS_SDRAM_BASE,/ v6 A# l. K: ~0 a
                        CONFIG_MAX_RAM_BANK_SIZE);
% D0 X# p" u  T2 k% o9 u$ S( `        return 0;: l, d6 {* U. x
}8 |3 \. E3 p; i+ z

! |. x) y) L% ?7 [" f" S2 k
- u% k' V& F; Q3 e0 Q. Y- T' t( o' g" m4 ^+ N7 u" U8 V

: P# _' P. q6 o3 f7 fFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
1 |; Z* w. t% q$ ]" X, ]! n
* p& {) W/ L5 j  \! L, l
! N$ Q$ V- g" V
) w) h1 |2 _; e( }/ u





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