嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
* s  H- L3 ~; A# T1 N% [. Q核心板2:DDR2 256M Byte   NAND FLASH 8G bit
3 H5 d  ?; L) J这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?0 D; m2 N  l4 u- d1 _1 S: C
- O( d3 }" B" D- e: y' i6 p) w
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?- i, p5 Y7 J1 L! ^0 d2 K
( z! Z( f+ @5 d5 H' ]

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:( Z' s! T' G; m, B: M
/*. w- U: x- u; M2 a
* Check memory range for valid RAM. A simple memory test determines
, m/ f' n  X' s1 T3 ?* the actually available RAM size between addresses `base' and0 W! {" M" @$ D. a6 ^9 |
* `base + maxsize'.
9 W# j! r$ {: T*/
* M& j+ Z( w  D% S# ^) dlong get_ram_size(long *base, long maxsize)
4 O3 K8 C  S; ~' N% }" k, G! x9 k! h{
6 [5 j1 u0 ~0 C( H- O        volatile long *addr;
1 [: c! s: ?( A' \& `; ^% J: @9 y        long           save[32];
  L) L" o; ]$ p        long           cnt;
( i) M! H8 q7 A3 R; I2 N% I        long           val;
6 x* Z5 z) O7 h: L0 J: Q        long           size;/ z0 h. |, r! S1 D. |2 i1 o
        int            i = 0;8 J1 m! H' N4 q6 t2 Q- n: V

5 r3 q6 B* E, g9 f. q        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {5 q: t& E6 x9 Z3 {- K+ o
                addr = base + cnt;        /* pointer arith! */
- w8 I8 w# J* n7 s" Q) R3 c                sync ();& M0 ^: x% X9 Z: |* g- N5 T: y1 _
                save[i++] = *addr;8 d' G3 G+ P! f! S+ t6 Q# e  U9 m% ~$ _
                sync ();
, \) D# k# p3 @# I. P  K6 D3 L: d% t                *addr = ~cnt;
/ d6 H, ^: |8 \. W# s* v8 G5 y; [        }
+ \9 u% s" Q4 O5 A; x
0 r1 ~7 j/ {- N; E9 h        addr = base;
, Z0 q% `, f8 X& a$ u4 N8 H        sync ();8 A$ W5 l6 e3 P
        save = *addr;. c3 B' e, S% e: e$ a8 }* [: u
        sync ();7 y( C: V6 g+ Q% F- h
        *addr = 0;  x% H1 h& ?: J1 U
" s+ k9 |9 x9 {
        sync ();
0 g/ Y- U* L3 U: V8 C1 {' [" r        if ((val = *addr) != 0) {
0 C3 k$ k3 [( j" s0 `% }+ o* c- P! w                /* Restore the original data before leaving the function.+ Y* w4 H0 a1 P4 T
                 */( O7 \& o4 |: q6 }) [
                sync ();. H5 W+ c% c0 v
                *addr = save;$ S0 f: ^# z0 w2 k9 P
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
6 {) `9 o0 \- Y+ y# s                        addr  = base + cnt;! J" h; P( c6 V) U
                        sync ();
/ h  D" W% |( E. }( B- \                        *addr = save[--i];
5 M- ~% V: T9 z; ~- u  O" G0 a# l3 W                }+ J1 E6 M/ ~  O1 H2 A7 A) p
                return (0);% W( A! s/ ~) k$ g- ^, }
        }" @5 g4 ~$ S# _; v. ]; K: b' j
( m: Z. p* S" l% n& ^
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {' e* x( p! J# F' t
                addr = base + cnt;        /* pointer arith! */
- q  H, q# f, E) x- r                val = *addr;* ]7 \4 f: A) e
                *addr = save[--i];
# T1 L  W, T7 |$ \1 l, O- Y                if (val != ~cnt) {
- n! o4 c, E4 W; A7 {# T* E                        size = cnt * sizeof (long);
! |8 ?* {4 K. u0 S* @                        /* Restore the original data before leaving the function.+ I0 J7 s5 M  r: b% p  ^, t2 m( p
                         */
, r* ~5 U9 l/ N: B; r: t                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ A. J2 i/ O3 G
                                addr  = base + cnt;  _8 P! n; @, p# v
                                *addr = save[--i];
% a1 Q0 k7 n0 C, Q- k/ l                        }
! M1 [! ]( G$ h                        return (size);
- f1 q  }) L9 Z/ a/ m                }
9 k, M, U* q2 y0 C2 [- {        }& F; z& \5 {; p" ~$ y. g9 b% J8 t
) [1 o9 ~+ j4 J: E3 _2 P
        return (maxsize);
. Y" }- L( k# N; a$ Z}- x6 B1 l) W0 Z" K3 t) _
int dram_init(void)
! a9 y' |# |4 p. [$ K{
: N  i. H7 E# v7 G; M# \        /* dram_init must store complete ramsize in gd->ram_size */4 I* P1 Z! p4 r* |
        gd->ram_size = get_ram_size(1 Q2 @* u5 L  p: U6 w
                        (void *)CONFIG_SYS_SDRAM_BASE,; Q! _  U) w' z9 P( p; Y2 s! v
                        CONFIG_MAX_RAM_BANK_SIZE);+ t' ^# j- N9 T
        return 0;
7 w0 f4 A3 s# W5 ~" C. N. f' `}
5 {4 `4 Q, t6 N" w  }9 H& w& I. {
* H: Z: M, Q' ~$ ]8 w/ _- B0 h9 @8 O0 x8 u; ~
  x" Q) w9 `2 E& _$ e: ~; V7 r) N9 S. x1 x
: {2 `* d7 m' r( c2 a! i
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!" {" H8 C. S$ y6 o1 e$ f1 I
% k5 E) X5 A, J' x

9 C1 ]7 o* q: E% }2 S5 `
' J9 p  K* `2 @0 n





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