嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
7 n% N* a; d" J3 ?) w. [核心板2:DDR2 256M Byte   NAND FLASH 8G bit
1 I* T& D' y" {. E这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
3 Z- N; e4 z- {* a
: s) r! D; g8 {是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?0 r0 p  l2 E+ f7 U
& L- c8 _* v0 M2 ?0 }

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
6 G2 U7 k  @  Y: P/*
! M2 u; A1 u3 L7 e* Check memory range for valid RAM. A simple memory test determines
( ^" ^! t2 x8 K% J% w8 O* the actually available RAM size between addresses `base' and" H/ V9 C9 U0 A- C4 n+ ^- V
* `base + maxsize'.0 i* \' `7 ?% d% O+ i+ v" w6 C7 c3 P
*// I2 D( g! i9 g4 i( W$ Z
long get_ram_size(long *base, long maxsize)( A9 b; V8 N; B8 C
{
: R; L8 E, m9 W: r& v, o        volatile long *addr;
, w- y( }2 Q# c. ^        long           save[32];
3 m; B* [$ D& i# w/ u# d        long           cnt;
8 O* k0 _% |2 @/ T; T' O' M        long           val;
! b* W# |/ s/ C  @, S0 _) f        long           size;
, f8 L0 W. A. e0 H: t  b& P$ g1 `8 \, \        int            i = 0;
( _% F/ e" u, ]+ B
( L- H$ x" W- I+ V$ m" W        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {- g" r, l( [% p8 h6 G8 m
                addr = base + cnt;        /* pointer arith! */
) |9 U2 P% f4 {% X                sync ();
5 o9 e3 I- l: h! ~* {                save[i++] = *addr;
2 O4 h# ?* y7 r7 [" C: Z" f) H                sync ();2 S* q" Z, I- }2 C
                *addr = ~cnt;
# z- |7 E1 w( {' c        }
( ~& P+ g- v; P4 l2 P0 M' w! ?% [. |7 J) }1 w4 u- j' l
        addr = base;- B5 ~8 e6 w, M$ C
        sync ();& k# s) v3 M) @2 j! P" }
        save = *addr;4 H6 N  }0 d0 A  x
        sync ();
9 C" r6 I+ T- J( `. E' m8 A8 A        *addr = 0;
# c( Z+ K3 O* c0 p5 D
) b; k0 p& Y* h8 h7 m% ~3 \- G# [: h        sync ();- L( Y7 {$ d$ P0 {7 W
        if ((val = *addr) != 0) {3 j: M- D) Z5 u4 x* j% p
                /* Restore the original data before leaving the function.7 R# A4 _" [+ i+ e/ F5 O% D
                 */
$ x" Y% H6 h) M  u* U# l5 ?; V                sync ();8 e1 P- L( J2 F, l: y, a
                *addr = save;: ^/ ^  [- p1 P/ {
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {$ Y5 C0 U  g6 Y8 e1 s
                        addr  = base + cnt;
; G' A4 T. h0 J5 M& S- D3 t                        sync ();/ S: q- j2 w4 o* u! r9 ]3 ~/ K7 L' P
                        *addr = save[--i];! h1 n3 Z& y% T% Q7 `
                }
. m' n/ ?4 [0 S+ g" E3 a8 T) @. J                return (0);
  D( q1 C" }: @& z) g! d5 |9 \        }
' ?" v& t- C2 E# m+ T( z) d* N, G5 l9 {
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {! _5 o+ z! O& o" @7 K  l
                addr = base + cnt;        /* pointer arith! */
6 W& T( |- X/ t% W. g0 ^                val = *addr;
0 k: F# Y  o: S+ q                *addr = save[--i];8 C" _5 k! l. |& _$ x+ u2 b
                if (val != ~cnt) {9 `, f) v0 z1 L5 m& J8 ]
                        size = cnt * sizeof (long);
* T% z# y7 t! O7 Y' p8 g                        /* Restore the original data before leaving the function.% S4 d  d8 d8 Q! V# i2 Z: J
                         */8 \+ p2 T% H! t  \" |. ~
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ T) e1 W/ f0 o1 k& D
                                addr  = base + cnt;
& N  f. a9 f) b2 Z9 \                                *addr = save[--i];: Y. j* }7 x+ t: ?
                        }
# |+ f* S' @8 r: V                        return (size);; V: Q2 y' k  h  ]- X/ N
                }
# o3 {* r* d( D  Y# f: ^        }1 s/ B- G- W; f- R8 `
/ ]$ s" d5 z* O3 g* T0 C2 n
        return (maxsize);. p- n: R9 q# A1 y* x( o
}
; W7 |: D6 U* n$ B6 Qint dram_init(void)
$ h* m& y; q; T7 l( p{, g( j7 V& D+ t3 {5 H
        /* dram_init must store complete ramsize in gd->ram_size *// `( L2 A% u* Q5 R# Y+ N% {5 q
        gd->ram_size = get_ram_size(7 E4 P  N* z8 G" O- W0 ~+ u
                        (void *)CONFIG_SYS_SDRAM_BASE,1 ?# Q2 T, w1 I6 K  t5 E
                        CONFIG_MAX_RAM_BANK_SIZE);
  G% c: E% N% S5 U: c( t' |2 O        return 0;
( S1 r8 i, n  Y8 b3 j1 ~+ m}0 L* \/ f3 `' I9 X1 g  C" [

$ Y$ a! C: M* z1 [
9 a0 P( D4 z- B" `! v: f/ b' f4 m8 [5 C0 _* F
3 I& J/ A6 `1 m6 }! o/ Q; u
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
/ h& l' M- Y" y6 h. Z) ]
& Y, u7 p  m7 C) V
3 |; p9 B0 p) N- \. E- [
5 O! ~9 g; z4 a! k% |9 o4 H: l1 g





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