嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit6 _/ v5 |* `# p$ c+ j
核心板2:DDR2 256M Byte   NAND FLASH 8G bit" e: y, L9 T6 ]+ C$ o2 T
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
3 _* h$ S9 P1 S8 @$ [! v5 r5 ~1 l. I& ]1 X- g
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
1 z, a+ ]4 o- S* D& \: y7 D' q/ R% Q/ R& O" q: c

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
' }  i9 h/ }6 B9 v, J9 I/*; x# u! T: i# R, c8 i' z
* Check memory range for valid RAM. A simple memory test determines* s( `5 ^) b4 I, q. s6 U8 {
* the actually available RAM size between addresses `base' and
# j, f# m6 g& M9 r& b7 W* `base + maxsize'.
" ?; b* F1 _' t( Q*/( u" K; y" N# u( _; j
long get_ram_size(long *base, long maxsize)4 Z# B/ L7 J% N5 G3 h( E; P: F- u1 i  x
{+ _+ Y) ?4 P: V
        volatile long *addr;/ E# ^. f% n, q! ?5 A2 F: o0 Y
        long           save[32];: s+ q$ u! y2 \. l- e1 K
        long           cnt;
9 n: c* ?- z; n* B" S# q$ U        long           val;, A6 ~' {4 b" A$ T1 y/ F
        long           size;* f1 f* P1 Z+ g! K( B
        int            i = 0;
( W1 ]/ j+ N+ {, @( j+ j  l/ \; y6 ]& w! x0 T% Z& t' _+ R! }
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
$ T. _+ n3 B3 W" Q+ \) r                addr = base + cnt;        /* pointer arith! */3 Y$ e+ k0 [  h5 \, {2 H0 w
                sync ();
+ a' m' i3 J9 Z) i1 N. X$ `                save[i++] = *addr;- j+ R  }3 W' r/ V8 a! ]: [
                sync ();
, H; o1 J" v) ~                *addr = ~cnt;
; g$ E  c7 r. i# e* r( ]! I        }! x7 r6 x  y6 G' Z
4 n! Q( h4 s; ~2 R! r
        addr = base;
* h  B6 q2 J5 t. _& J$ [        sync ();
  t# R; j; W) M6 P4 u' [5 `' I6 N        save = *addr;0 U" o! B) a: u7 m; G$ {' d
        sync ();
9 @9 D% n$ V2 [3 `+ I) G+ Q        *addr = 0;
" G/ }0 c' f# \% {9 p* L
, Z: k; n( M; M% _" U$ o  W        sync ();3 D0 P0 c0 A+ h3 `
        if ((val = *addr) != 0) {8 o' q; ^6 S% Y( G! z/ Z
                /* Restore the original data before leaving the function.
! |% `. n/ d. B" ]                 */& b8 h( w5 w6 Q' c( f. r- k7 d' v$ I" W
                sync ();4 N  ], N$ H7 Z' S4 v
                *addr = save;
4 A  K# @- R  r7 M                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {& {: R! R, A# ]: ~  Q0 G
                        addr  = base + cnt;
$ z+ i) [: z0 I5 p3 Q                        sync ();* }* S. X" U/ X) H
                        *addr = save[--i];% [! ]/ y6 O3 q( I
                }) h9 Z# E) H2 P
                return (0);0 `$ t% A; ?2 e/ E4 J! O
        }: i3 t0 H1 _0 `, i
0 P8 l( T" Z8 N8 K% u+ I
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) i- o# @; Y0 r7 |  V1 k                addr = base + cnt;        /* pointer arith! */
6 C+ x- ]. y" J; I                val = *addr;0 e0 h+ s# H5 l+ C/ B9 U
                *addr = save[--i];
, ~6 \' w3 j+ S. g                if (val != ~cnt) {
0 X( h7 k5 q: }  ]) t# z0 l                        size = cnt * sizeof (long);
, n" G% g6 h: `* U* v( e, N6 I                        /* Restore the original data before leaving the function.
) y% E* ?$ N/ l( P/ N4 h  l                         */
/ d* B0 l: m; C3 |8 Q                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {; Q  g; ]" S0 a2 O% o
                                addr  = base + cnt;
+ _5 {7 q$ f2 N5 m& e                                *addr = save[--i];
* p$ d* b  _5 Q5 T5 y/ H; q                        }
9 ?: x. v, L0 T                        return (size);
0 s* u5 C' b5 [! e: G; |                }
& E9 O5 A5 ~' t9 m6 A        }
+ S2 T- C1 n* M( q! a' n7 ]: n" K7 C2 Z9 M
        return (maxsize);
" Q+ S( C1 l9 G& Y( s2 {. y}7 L, J: b, T/ K% X$ G$ d1 Q9 o
int dram_init(void)
* l! }/ k5 e  n{
: l% b+ I% c, ?6 y8 D3 ^/ {9 |  k        /* dram_init must store complete ramsize in gd->ram_size */
1 }/ I1 E4 a5 H% t6 `7 c8 I! Y  G        gd->ram_size = get_ram_size(+ J( [- m. ^3 [. d$ x
                        (void *)CONFIG_SYS_SDRAM_BASE,, z) m1 V# g/ J
                        CONFIG_MAX_RAM_BANK_SIZE);
8 K" s* H' ^3 I) j; a8 \" u* \        return 0;9 Q7 g$ \9 q& G9 D7 i: ~
}
3 U' v  m$ d4 k& }) x8 ?, i% w6 Z2 {4 T/ K! u. i

, t8 ]' U0 d+ t  L$ S, ?! E4 v" Q* |$ E5 ]6 {$ Q; k5 ]
% ]6 R- P/ Z4 v1 i
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!7 l# c8 k- b& q4 X
& i) K5 E$ V! L! V

5 `4 E& x  F8 V1 B% K

8 B# V0 t6 v, T




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