嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
/ _/ c# }, j; h1 o9 f# p核心板2:DDR2 256M Byte   NAND FLASH 8G bit6 H. m' r( ^' D1 p6 G
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?, r+ f, R5 g& w

1 q0 N6 t  \# x8 D1 ?+ K是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?0 V$ m7 {" j, @" u) t- Q( c: a

9 Z4 j& Z6 c) s" U$ l) E4 Q
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
8 B& V. N2 G! G% O/*
& R2 `0 d  g& I* R* Check memory range for valid RAM. A simple memory test determines
" l$ y  L3 D, K% U2 b* the actually available RAM size between addresses `base' and$ }! k: C5 K4 L( K
* `base + maxsize'.
: x- G% I9 ?( s, h, S6 R1 Y*/- _- p) _9 p+ U  }$ u+ E1 @
long get_ram_size(long *base, long maxsize)" }: J. C  J. j1 E6 i, t
{
, b# G& X7 J0 \! q6 e; Z) N5 ]6 x        volatile long *addr;
3 C+ O- {* N3 k- g' v4 ]: I9 u% {        long           save[32];
) X% ?; [: d* @* j' V- M        long           cnt;
3 ^: a+ k1 u: H: O7 }! r        long           val;
& n; m( o5 r5 l# Q        long           size;- I. `3 F, f' {" F
        int            i = 0;
$ H! `; V  A: p" ^  W( U( k/ \" [: R. l  Y
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {. `( \/ p& }+ E  n
                addr = base + cnt;        /* pointer arith! */
  n. b& i  w% e& X7 o                sync ();
% O! C/ w1 B4 w! P) A0 D7 j/ i- g                save[i++] = *addr;
! o  i7 Z1 \; |& I9 O                sync ();+ D! p9 N2 O* M6 `/ \3 h" o
                *addr = ~cnt;' f  @$ p0 Y: g6 R
        }& h& U+ E: H# O3 ^! w8 |6 A8 y; |

9 J6 J4 k1 w7 k  a% b        addr = base;7 j& l- l9 u5 N& |1 r6 w) y! f3 \
        sync ();0 B& Q) P3 v$ H- f2 i4 e
        save = *addr;
# u7 r0 a. |/ G# W- a) O1 L        sync ();6 U6 T6 r) b! q
        *addr = 0;
4 C, v) j4 y; m/ X- M" c  M5 G/ K9 k# i3 `' @' R! I
        sync ();
: G' u, ?2 T6 w' X) B* a7 H        if ((val = *addr) != 0) {; g1 U/ F+ _# Q) |2 v
                /* Restore the original data before leaving the function.
. ]- d; u$ U9 B3 P* H                 */3 }0 n: t' M- g7 i" m0 e
                sync ();
* Q+ r; A* p+ L5 ?                *addr = save;
  o9 f) [8 ^; w! K6 l* l                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {; f2 i$ X' H. W! z" Z7 I
                        addr  = base + cnt;9 {2 ^  Q/ [4 W( o5 u, N0 F
                        sync ();
6 x& x! I/ b0 [                        *addr = save[--i];6 O, ^, v" |* {+ T6 O5 T
                }( j- N6 @/ R& d" s. `
                return (0);
6 v% ]5 `8 i2 D( @& \! ?# q        }! L7 [6 l; L# T: T& h2 T
8 q; I" w2 u) [7 J5 m4 J6 H
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 Z0 K- d/ Q; v; b  m9 M0 a: Z                addr = base + cnt;        /* pointer arith! */6 M8 Z7 y$ A/ s( @9 K) z. o
                val = *addr;
$ @* I( Z& }( ]: h* M) ~                *addr = save[--i];
1 L0 v9 q6 R3 J                if (val != ~cnt) {
+ l/ g( J  V2 W8 i$ N                        size = cnt * sizeof (long);
! d* E% h( A/ ?                        /* Restore the original data before leaving the function.2 o* n5 g1 n( `& q/ z
                         */8 @. _$ d9 ^2 {* p
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
8 |- g) S9 a% j9 y% c                                addr  = base + cnt;0 S+ _* C2 K. X: e/ X' e$ p! A
                                *addr = save[--i];1 O$ `9 D8 D/ ]# n  a
                        }% _1 p8 I0 ?% q5 j0 Y  s2 y7 G' f
                        return (size);1 W, g, o1 o' Q# U+ [, Y
                }
4 \, Z8 O" _% n! S7 L        }
* ?, \: ^! U, l5 s+ ~
5 m) c3 E8 P8 t1 L# x- L        return (maxsize);
2 _  c6 R' f/ e}
7 z) ?" O% m" r* t- f8 a3 Yint dram_init(void)' `" I! b1 K+ c2 J! o
{
0 m8 H6 \  ]5 c! _0 p        /* dram_init must store complete ramsize in gd->ram_size */
$ C& ]1 b( D6 \8 i/ Q( Z        gd->ram_size = get_ram_size(
9 p9 W' |' O5 K% R8 y9 d                        (void *)CONFIG_SYS_SDRAM_BASE,
& |  b) j% y* t! S                        CONFIG_MAX_RAM_BANK_SIZE);
8 @+ j1 K* s' }# P        return 0;
& u( k9 _! h2 Q# @}
9 o+ j& Q5 Q9 ^4 P9 W0 y, D# ~2 Q0 d$ o2 s# c4 }+ j, e6 _
0 i5 V9 Y! j- Y6 f; \

7 u, e' w, B1 Q6 X0 j. ^! I1 R7 R& H$ d; T% x
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
- E6 W) g' l  `. ~* i/ `0 A  H0 @) j4 M

* U/ a5 e. {" @% f

* _  t- d# _" g3 e  }




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