嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
) ]! a( M2 N( y5 z( V  H! {$ G核心板2:DDR2 256M Byte   NAND FLASH 8G bit
2 }* R0 L: }; ~8 P这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?  r4 b8 {2 B( w

- n' b& B! ~, {, Y: B是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?! i- z( b- A- X/ t. k) L' i$ c
5 G, s  }9 u: b$ j

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:1 L8 [/ k. R1 P6 k9 _2 D, g
/*
4 r6 J; m% S" x% e4 W; {1 {1 H* Check memory range for valid RAM. A simple memory test determines
0 F+ ^5 C$ P# E* m7 u+ a0 y* the actually available RAM size between addresses `base' and
& K, {3 B) J6 T, |, {' n* `base + maxsize'.
3 I( a- R6 s! g' Y*/+ W1 x5 ?6 v" o5 i5 v
long get_ram_size(long *base, long maxsize)9 S1 w# w- U* e# _
{
+ [" ^* L3 m; T        volatile long *addr;+ n+ T, I! E4 E& w8 G4 k% Z
        long           save[32];
6 N, I. u  B( l; I0 o8 V2 p        long           cnt;( l* f0 H) x" X7 V9 M
        long           val;
4 v( u+ J* v5 g4 a7 B2 M$ n        long           size;
$ ^6 }! P% }& p4 _0 R        int            i = 0;0 W6 n* s5 C3 g6 b: I
3 \( u0 K! Z5 g3 L1 u$ R5 q
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {9 _3 Q7 c$ o! f. ~, N* k* q3 ?
                addr = base + cnt;        /* pointer arith! */
. i' y* G3 N9 c8 e8 |2 p                sync ();# b: L# l$ I# ]
                save[i++] = *addr;0 q. r' m) m" S0 v* h
                sync ();
  d$ E. x9 o0 o" d- W: i* I6 O                *addr = ~cnt;5 w. @* ?, k3 q5 o% i$ |" L
        }$ J0 S' V& }. J
8 `3 i- _2 r" d2 W: h% s) l
        addr = base;( w  e. s  ?# ~* k3 o0 P5 h
        sync ();" A1 S! B4 @' Z5 r3 ~$ b  u7 Z% A3 C
        save = *addr;5 [, Y" y3 k- j, [3 \2 p
        sync ();3 I3 D. b: E$ U  K/ }, G6 a
        *addr = 0;
1 n% @+ r' b4 h4 P( h% h) C1 e* P
8 u8 B% M6 h9 @8 c3 H  H! [4 i        sync ();
9 d; Q' ^# n( O% Z        if ((val = *addr) != 0) {
: u9 `8 w* T1 J% B  i                /* Restore the original data before leaving the function.
. e. {+ X& j, U% L5 w                 */# g' W% i, P! a" j
                sync ();/ \8 z4 u" ]) r% T. V8 Q
                *addr = save;2 l7 S( ^* F% U8 c* Q
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
) Z/ ^+ f8 s- M5 ~" b6 ?                        addr  = base + cnt;
( A. h% |2 Q% T" |- r; ~: y                        sync ();; }: C+ C. f% v, u
                        *addr = save[--i];
/ F8 w3 v, m3 |3 y9 ?                }
( k, U  a& B- M+ C, O5 j( z                return (0);
4 q0 X. F0 T8 O, S: K, }, ?7 p        }. ]* S. r* Q! S4 x) z( Q& t& K  H

# Y, t- y$ t" }5 ?+ Y6 ]        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
: V$ G/ D& K, ~! Z                addr = base + cnt;        /* pointer arith! */8 o9 t5 i; a1 W; {
                val = *addr;" s" L4 {" }+ Z! i2 f! ^2 `9 _' T
                *addr = save[--i];
  c- r& y  i& r& r5 E  F                if (val != ~cnt) {- U6 D0 r0 K" q7 O( D7 d
                        size = cnt * sizeof (long);5 P- H* R8 ~4 P6 D
                        /* Restore the original data before leaving the function.
" A% M. B  E2 B  c8 H( l  J                         */
  R* K; G* l, x" i, ?6 g                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 R2 ~# J7 |, n7 b                                addr  = base + cnt;
# b' ~" c+ K5 X0 [3 U                                *addr = save[--i];
( ]9 a5 Q/ o6 B/ w1 G5 V$ l; B                        }
' \+ g+ |0 W8 s% y/ V                        return (size);+ Z) A0 c2 {/ j' n- n9 a$ @
                }& H* O( U+ z3 f- `8 Y  ~
        }8 e2 @! q/ l  ]7 W5 I

  D- d0 p% K& k6 I$ G        return (maxsize);
6 j& B. l3 _6 [2 Y}
9 {8 g  a+ S! Q. m. g+ @( [int dram_init(void)
2 r& Z1 ^* X, G7 Z{
5 f2 J. M8 R$ h$ C, Z6 A! ~9 a, g        /* dram_init must store complete ramsize in gd->ram_size */8 s2 A& O  N1 d+ r% f* V
        gd->ram_size = get_ram_size(
; e( h) \) s& U, s( E                        (void *)CONFIG_SYS_SDRAM_BASE,) N& k4 ^0 p8 X3 Y5 D1 l+ C+ k
                        CONFIG_MAX_RAM_BANK_SIZE);0 W% q7 p2 Y  `: X
        return 0;% Y( u- b5 J( ?/ e
}3 ^, B, e3 V( A8 @; l* J$ t. q

# A$ W1 C- c% M. g4 c% m3 J6 s, o
# \& b9 s4 w' {- x2 m1 L5 z7 N; ~+ [2 I: @) o7 K

0 @8 i& v8 g, y8 S5 M! @5 Y* rFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
5 z% a' |! ~( N# ~4 Z+ b% u  b7 E0 {$ v. J: D/ ?

7 ^4 l1 L" J; K4 v

' L! N0 F( S5 E2 _5 |; c3 ?




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