嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit  J8 F& i4 n2 J1 ?, P6 R% u4 x
核心板2:DDR2 256M Byte   NAND FLASH 8G bit0 R+ f! t$ b( h0 H0 J9 @7 r; j: [
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?$ t$ ^' [3 j) R+ g# J9 t* _& z: x
2 x6 n$ Z5 b, H/ @2 }
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?6 i5 M. G( o; v6 I
8 o* a: P  H6 X- l( U* S% x" i5 `5 |

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:; S- }1 r0 g* Y* Z! {3 h2 F0 q& `
/*  n3 Z( }( Z* V
* Check memory range for valid RAM. A simple memory test determines
% c* K; N5 y: K! o/ h% ~: ^* the actually available RAM size between addresses `base' and
: c2 G& k) Q% |: k8 F/ r: v, _* `base + maxsize'.
+ V+ Y8 m6 h& g3 o8 _( r7 j*/' V" v: b- S# m: u
long get_ram_size(long *base, long maxsize)
. `3 n; r3 |! h9 }/ J{! k. S, ]% B) Q! w
        volatile long *addr;# w+ d* E/ v% p+ `5 C6 a4 ~
        long           save[32];$ j3 w# ]/ d+ c) z& b6 [" H+ v3 D# U
        long           cnt;
% |" R, d3 Q) |. o        long           val;7 e. s* ?0 G  r2 P) h1 n7 E& G2 x
        long           size;
8 G8 V+ l# w. @        int            i = 0;/ f' Z" X+ T3 b% }8 n# B
0 B! y8 `; G  A$ u: |: H
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
% Y1 O! ~# p1 z- f6 G2 g/ ^# g                addr = base + cnt;        /* pointer arith! */! d5 O; E5 J$ \: F9 }
                sync ();
% d: Z2 x6 V* K                save[i++] = *addr;
" n$ k1 W6 j, T5 c( X" m7 g  M* f                sync ();
% I/ G% C* n2 S" S" U  w9 Y- ^                *addr = ~cnt;: j! J$ u5 K  s& B  _
        }
/ W% k8 X1 u5 s
& R: v: [1 `5 V1 [2 v2 ~0 \, o        addr = base;% |- r3 _" C6 n9 `
        sync ();# V4 E9 F! i6 D- N" c  S' e
        save = *addr;
/ R, C, f6 f' d+ B# V" D        sync ();
; S. Q& O2 ^7 P" h3 v" E        *addr = 0;
, V/ u8 U' |4 d9 F, f( ^; y3 f1 u  s5 a, v! t* o
        sync ();4 R4 U) n& d+ s+ l- D3 i
        if ((val = *addr) != 0) {
7 q- O) y; J8 f4 b: I1 A! ^' Y                /* Restore the original data before leaving the function.. c4 E# v' k: h, p
                 */
$ u+ \$ n, V/ }5 P9 x                sync ();2 C) e, P' _. |9 t( z
                *addr = save;  \3 T2 ~! ^; ^
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {4 b9 [, B1 i! |$ R
                        addr  = base + cnt;
8 W/ t- t5 w: W. i                        sync ();
0 l/ ^/ h( t/ B' {. a                        *addr = save[--i];
. M$ ~; O# |9 p, J' E                }
" a; U1 b+ q) V6 T9 m                return (0);1 ^2 s( u" Q4 p; f$ `: \) v
        }2 b# U  x/ N! w0 x% J9 y5 p1 O

' b" N# w$ H; ]: x% w! B        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ S* n0 K9 {' n
                addr = base + cnt;        /* pointer arith! */& Q" r6 x4 w3 ~
                val = *addr;+ M% P* c5 s: ^9 Q
                *addr = save[--i];/ S/ `' |+ Z6 i- r( \0 }& w. P
                if (val != ~cnt) {8 a/ E7 V+ J4 K6 E  P6 x
                        size = cnt * sizeof (long);0 c* C; [5 P" @2 ~& @
                        /* Restore the original data before leaving the function.
! R& V1 h% v# b5 `, e0 S8 h7 c                         */9 }( L9 y5 C6 [! x
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {$ C; F0 p; @6 `+ k7 O* s
                                addr  = base + cnt;
5 f7 x2 m# x4 h+ ]8 p0 j; C8 a                                *addr = save[--i];7 B; V1 n3 @3 e* c* u5 V
                        }! i% _! |5 i8 A+ j( W
                        return (size);0 a. B0 Q& s+ F2 a- A
                }
1 J& e: R% |0 ?; L6 V/ i        }
) u8 m& g# N! Z: j
# ~  k; Y9 ]5 A7 N7 E9 K; M3 E/ d        return (maxsize);
; m3 _6 K" I4 I) ]}
1 o8 [1 q) u5 m5 h+ _int dram_init(void)6 b, |  W8 h% Y" v* w9 T
{
, Z! s0 ^5 s2 t# x% g6 }1 B        /* dram_init must store complete ramsize in gd->ram_size */' h) ]! C( g6 w+ }/ `  h1 T/ B. @9 K
        gd->ram_size = get_ram_size(& e$ y+ i4 B/ ~4 [$ X% I
                        (void *)CONFIG_SYS_SDRAM_BASE,
4 F3 S/ r0 h/ v) A5 f, g                        CONFIG_MAX_RAM_BANK_SIZE);
* E- G- K, J: {5 B" M) s+ n# y9 i        return 0;; P7 f" m! Y, L1 }1 a5 C+ O
}8 T" k# E; j  _# t/ j( ~( j/ L
( S7 {& C" @; m, [' V8 _
9 D- ?6 L7 Q7 v; g
0 [/ G0 c. d- N- }

4 G/ m0 N7 Z1 t0 N, TFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!& @8 g0 R. S$ {8 D# L# Y$ k
8 q4 G9 d: d8 F" e
! V# H. O- W- I( X$ e

$ [( b1 J/ i; z6 t8 T7 L




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