嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
' ]8 E2 \4 Y0 [9 Y核心板2:DDR2 256M Byte   NAND FLASH 8G bit+ t; T& G5 r. N
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?6 ]* ]- g% _% t% P7 W2 b; u8 `9 T2 C

, A* o% i' d& j! e是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?- u+ t& u, a- n2 U; ^

3 C+ _) Z( O; h% G# w8 D! d
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. t' G' W9 P  U3 z  J+ h* l1 w/*
! e) j: o  X) I& [/ C4 i# w' Z* Check memory range for valid RAM. A simple memory test determines
( b% E: K# |  Z* the actually available RAM size between addresses `base' and
, k1 S: A8 L4 f& L* `base + maxsize'.
  e; t  B/ ~3 `; {' a/ t% L*/5 Q4 V, j# |. g
long get_ram_size(long *base, long maxsize)
! w- O8 q- `" S, p% j{
, v3 d; m, j5 t        volatile long *addr;; b" Z! C) {3 P5 J& K  B1 q3 d, p) O
        long           save[32];
/ c1 U8 {: ], H! ]( a, A+ K) r        long           cnt;
+ P) }5 S: b# x, {$ r        long           val;
( G2 R5 Q& ^$ a3 N; O        long           size;( m: j5 c/ M& L; A; Y
        int            i = 0;
4 e! Y/ z) N3 Q6 _$ r2 T
- ^( g8 k4 w0 h, e/ R9 s% z: m5 E        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {( D% w& D* O9 T( Q
                addr = base + cnt;        /* pointer arith! */
/ g0 ], |  k' K! _5 `  t4 r; H) M+ f                sync ();
7 ]4 h4 N6 c& p  Y$ W; n  M( ^                save[i++] = *addr;
. c# v8 z" W9 B4 X                sync ();$ p. J( a" J( c7 s) d) h9 a
                *addr = ~cnt;
; v1 B: f$ i0 u' ?% z' O0 }% |        }4 P) w: E* s+ P  `  h0 {
$ t% x( a9 F! x6 \& d7 o. U5 F
        addr = base;  `# t1 R$ x2 `  D) ?% n
        sync ();( q8 X+ K2 I. q3 G9 t$ P& g, J
        save = *addr;$ m. Z! q& t  S0 h; O$ f. u/ q
        sync ();( b* J$ x) U4 }; V
        *addr = 0;
, _# ^$ g, N1 s7 a% h" q- w, I+ C3 P$ A1 L
        sync ();
$ G3 b8 K8 N6 e$ h  ~" g. P: H        if ((val = *addr) != 0) {: T$ P2 u/ ]. s5 y0 P* D7 D
                /* Restore the original data before leaving the function./ _& z  y! L% h! e6 f3 |
                 */
8 P4 Y% ?% b6 a* U  B+ B/ K                sync ();& @5 h2 C5 M2 E# ^5 j
                *addr = save;* N- r" ^4 J4 p# S& ^. N
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {9 y4 o0 y; L3 |( i
                        addr  = base + cnt;
8 O" ^6 |# e5 A  B                        sync ();: x9 d- R; r: b" ?
                        *addr = save[--i];  n. g4 O& M* G, |. t* P2 h8 o' D
                }& {$ {! p9 Z5 C3 x
                return (0);
, t" t# ?+ N1 e* G& o        }, k: U5 x( p  j* Y

2 }, S3 Y, t# Y! K4 e" J8 y        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+ g3 b0 l: h( S/ f: W                addr = base + cnt;        /* pointer arith! */
5 c+ Z  \6 P: ^9 _                val = *addr;
$ W8 y' T5 g4 Q% Q/ C% b                *addr = save[--i];
' y- {" p% `" c# n3 r% z                if (val != ~cnt) {
7 _4 y/ \: e* l1 [7 ?+ S                        size = cnt * sizeof (long);9 l/ p. m# _$ |7 T9 _+ f1 O3 S
                        /* Restore the original data before leaving the function.
5 E' x; x1 {* c! P  j  ?                         */" D0 ~4 X1 w/ e4 r2 N  H8 @' `$ y* R
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 H" [8 W. h. X% q                                addr  = base + cnt;+ d. G( Z# e1 x2 b! D- d( L
                                *addr = save[--i];
( M0 n" X, x' Z& ^. G                        }9 r% f, |3 V0 K* F: j4 F
                        return (size);
- L9 k  |8 z8 c4 o# K* h                }
- B. O* t6 i4 [+ P        }' d( k, W# ~0 _' h% j
; S: Y+ k& Z# S& H
        return (maxsize);! ?" J, r4 \/ q6 l, g& ^% G# l9 N$ `
}
6 q% h: E0 j+ k' d0 |int dram_init(void)
" B8 [' a! z8 e{8 d  I6 `1 l( a' r! x
        /* dram_init must store complete ramsize in gd->ram_size */
6 Z# j- y7 D& L4 D! V8 v1 y        gd->ram_size = get_ram_size() t+ D8 l, ^+ i; T9 u
                        (void *)CONFIG_SYS_SDRAM_BASE,  F% R' C: B1 l
                        CONFIG_MAX_RAM_BANK_SIZE);; v7 o# b1 [- g8 K  K- c' n
        return 0;. @3 b% q9 \& n" \
}
) F( T4 M: W! ?9 }6 C" i; v* A
2 f* W: K  z1 X6 P* u; @% X( j' r) Z
' G6 C- E4 j% I
5 ^- p( s% q$ Y9 c/ N5 ?2 P5 C/ F, y" u
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
  J  j7 m. N3 q+ T4 \4 X4 d6 E) Z. h7 f
$ P1 B9 M3 J  I" w

6 q) c& X0 A1 p" g) f




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