嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit8 V& S- T# S  l0 C! i
核心板2:DDR2 256M Byte   NAND FLASH 8G bit4 K* a9 P) g; b, b$ |. J
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?4 q  [- L5 R" [% m* w3 c1 D

0 t, a5 |& |/ `9 A4 W' G是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
8 t" ?/ S0 {" {# P
" s: p4 g; Z4 Q, B
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:$ m/ ?2 ^8 Q- `. z: s2 G  X( {
/*3 q( H9 [2 _, s) @& W6 ^9 I
* Check memory range for valid RAM. A simple memory test determines
0 z* n- K" Y8 o. A- _" U* the actually available RAM size between addresses `base' and
. ?# \  \6 z/ o+ ?* `base + maxsize'.2 H6 F: G7 U3 H3 y$ }5 X
*/) R2 A4 |) N2 r. u; p
long get_ram_size(long *base, long maxsize)
& M% T  t$ n( X# Q) ?4 I0 w{
( H  P5 r! q; J1 B8 K        volatile long *addr;$ e& U' V1 Z2 [$ y  N; ~. C) y
        long           save[32];
' h1 W. p; F' l5 r; R" y        long           cnt;. K! C( @$ h& g$ \5 s: C5 t, C
        long           val;
( [0 n9 j5 o" K4 b6 A        long           size;
8 d5 V/ t" O& |- p        int            i = 0;: ^, @  }5 ~! ^% B8 ]. G1 J- n
* |8 ]) [3 c6 M+ \
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
# @0 U9 A9 V$ A7 L                addr = base + cnt;        /* pointer arith! */
3 z5 u, l8 p$ g5 u                sync ();/ |: k. }3 z! P) P, V
                save[i++] = *addr;
* D( z$ S* U$ B, f7 p                sync ();
0 J9 p, B) ?7 V0 o0 E. J                *addr = ~cnt;
. o' W* A* y  e' P/ g        }
7 [/ |3 y7 T3 \/ L7 u$ u# W0 e; F
        addr = base;
, ^7 J8 {4 s$ g- M        sync ();8 m; W0 n9 U2 R/ P
        save = *addr;  A: f- d/ S6 J3 k5 B
        sync ();- n& f* ]  r7 }$ h0 L
        *addr = 0;9 }  @3 T* U, B# [: l+ p

3 w5 E. w, p) r& g4 E& h        sync ();4 a0 g1 h- G' L! B$ s
        if ((val = *addr) != 0) {
, C: @7 u0 }- H) y; T  t. t                /* Restore the original data before leaving the function./ Y5 n! e& L% H" \
                 */
4 _" p* s: h# Z+ Q; V8 f/ E                sync ();
) j. S5 i# @. M2 z* i' M2 Y                *addr = save;
- D; x, P0 ]; v2 F; X                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {3 O$ g9 n+ m0 f: ]
                        addr  = base + cnt;
) E' P6 l, W8 C* x                        sync ();- T( G, L( B  [5 |$ m. N. `# N/ Q
                        *addr = save[--i];
/ `4 T. |# B9 W                }
% Z, {7 E/ l, T( N                return (0);
) w3 f4 U8 Q3 I8 @: }9 U        }
5 W; `* W& l/ f# j& L9 M. v6 Q
  }3 c% ~, m$ I' \3 P# G) I( y1 b        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' a) s# a2 }7 [; k2 T- I                addr = base + cnt;        /* pointer arith! */
; ~& g; d  V6 P: v                val = *addr;3 f# i- s6 L) `# Q3 t; K+ j! S
                *addr = save[--i];+ k, l# @, d2 P
                if (val != ~cnt) {8 o& h2 y4 c& {5 _# m0 K! x
                        size = cnt * sizeof (long);0 A( ~' T' d/ U; R5 t& G5 ?0 h4 n# I
                        /* Restore the original data before leaving the function.4 ?3 g* a/ C: `4 L
                         */2 Y+ O5 W7 k4 E# }; V* ]5 h
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- i1 x4 ~9 D* o  h$ k                                addr  = base + cnt;  @* l! \3 e" b9 R) R
                                *addr = save[--i];
$ S" h5 A% r- \! c1 ]+ G' j3 L6 C                        }& U0 |1 q; c" r. Z6 |
                        return (size);
' H, q; b; V0 n! u' v% G                }
" B6 g7 Z' g7 O! T' E) `        }& X+ n  }8 E7 n3 e8 m" e
5 t$ i; J: P: k3 |4 Y, x' m- [+ g
        return (maxsize);
+ _8 o( l% H, `3 g0 V) N" v}3 j  k3 J! v6 p7 |' s) z1 F
int dram_init(void)7 i3 R. }1 c. [2 R  w: ^
{9 V# _$ I% w$ x: r: {9 J; Y, ]
        /* dram_init must store complete ramsize in gd->ram_size */9 k2 m+ F! G+ S2 k  u6 f
        gd->ram_size = get_ram_size(% ~; V6 [* `* A5 w' o6 s# e& _) q
                        (void *)CONFIG_SYS_SDRAM_BASE,
: t$ t6 y' |- D5 q1 n                        CONFIG_MAX_RAM_BANK_SIZE);$ I. T; \  s; \+ _- N
        return 0;5 P  T2 f8 a4 a) L0 [( c& r
}  d! O" I" h, ?. [
  d  s9 ^, _: _# ^4 G1 ]+ Z* s

. c* N* ^! v& _, ]2 P9 P" \2 ]: \: V

4 o) n+ d" w- H' wFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!, S; C" H; Y' ~6 N4 N& E

4 ~& f0 ]7 ^# r3 j2 Z
/ J2 t3 |2 J; g$ N7 u4 V

5 K# G  H/ [5 ]) k




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