嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
0 D% P0 C! R4 k2 i% L7 ?- |核心板2:DDR2 256M Byte   NAND FLASH 8G bit& U3 J9 \4 l1 }5 W1 d( S
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
3 d# s4 B2 s- D. i
. \( e* v3 A" `, C7 y是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
3 o, ^! F$ ~3 ~& K
. I! ~5 L* h, X8 n) |4 Z0 B0 s
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:1 l: M3 P$ f8 }7 B' W
/*6 d( M* J* i, y- _# R
* Check memory range for valid RAM. A simple memory test determines) S4 V3 a" a( r. ^. s2 J* I# }
* the actually available RAM size between addresses `base' and$ g! t4 N+ Z, g& m
* `base + maxsize'.
2 U) Z0 b7 P* @& b/ T8 s' ]*/
# U% I+ O# P  y! g* Zlong get_ram_size(long *base, long maxsize)
' @& i1 b5 N7 d" M{' N' j% c* k& q8 R! ~: x
        volatile long *addr;
2 f) i1 h4 }: U! L  M: d2 a1 k        long           save[32];
4 k9 v% m2 F0 c% r        long           cnt;
- S0 w9 M( X; q/ R        long           val;- S1 i0 J2 U- `) a
        long           size;" ^0 _: Q8 B6 I9 ^5 {) B# V2 c
        int            i = 0;
' J( n) }9 ~3 f/ U$ x3 \3 E1 T. e2 d4 m  u+ R3 Q
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
; E2 g6 z9 _4 h0 H: A  D# G% ?                addr = base + cnt;        /* pointer arith! */
# n; K4 Q" t0 B: p                sync ();# l* V# W# P" o; p
                save[i++] = *addr;
# h. Z8 ^: U* d. ]                sync ();
; i! y' d0 T3 F  p, r                *addr = ~cnt;
  f: i; C7 n- h        }# a4 j* H( R8 f  D! ~
$ N; R0 k, m% c5 t5 U' F% a
        addr = base;* y# K; H4 H4 |! m
        sync ();9 P+ W, T/ B4 W& ]. m
        save = *addr;
% W# }" `  O, b1 O1 i        sync ();& ]1 R# \- r& b7 X
        *addr = 0;- P2 {$ }1 P# h; X# `3 Q

' z0 J. A: i5 l& Z: y9 a        sync ();# g! E# b: k4 Q& N
        if ((val = *addr) != 0) {
" t% P1 Y- C6 K0 S- |                /* Restore the original data before leaving the function.8 z. M. z+ P0 v/ T. ~1 D+ F
                 */  S' K9 {* C) W  \$ C
                sync ();
; k- x- s7 i% k5 h$ k+ K                *addr = save;8 B' J, w$ Y0 H, j, Y
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
/ `; }1 D3 \) h                        addr  = base + cnt;
) d% v! P& {+ `; [: M                        sync ();2 L4 |' o3 v4 z. S$ q4 G! U( f
                        *addr = save[--i];! V) ~3 R6 p0 H9 F' ^7 F, m! d
                }
! B+ \6 s; p9 g; d                return (0);
0 w. k- H% |- a( {        }; _  v( p* A, y( B/ v6 E$ p0 d
" Z# Y# K% z  c
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {% Z+ z) q$ X! Q' {  n6 F+ I
                addr = base + cnt;        /* pointer arith! */
" Q7 G7 s' w9 b                val = *addr;
( T9 E2 T+ I1 R: G( g                *addr = save[--i];* O% k0 T2 V0 F( e3 s
                if (val != ~cnt) {
* q' a# J* W( U' T2 r9 m/ q                        size = cnt * sizeof (long);+ Z4 d, |2 E+ \) Q$ t% X2 B
                        /* Restore the original data before leaving the function.
/ g8 D1 {1 t+ _4 A                         */2 |$ J2 f/ ~1 x( F8 a) F" T
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
: d% H1 l+ Y/ i! D; E+ g) v) F                                addr  = base + cnt;) y$ c. d( I3 n6 W8 ~
                                *addr = save[--i];, M0 e; x5 G! a: I
                        }3 t. v3 l6 [9 q7 J+ |4 w9 [6 V
                        return (size);7 ~2 \' q6 v- u4 _" V5 {, C5 m4 m0 ?
                }
% C" {7 q9 y  O0 A% n2 f  B* a& W        }8 |* Z6 S6 ?1 n3 @  X9 Y
5 ?$ o2 X+ K8 ~! [3 C
        return (maxsize);
8 C6 Z( s7 c" N! a; F}1 y# B0 ~' ?/ Q9 A4 k  I# k8 V
int dram_init(void)
+ J# o. v: d1 |  y9 h. a{
, a" m! w$ U: @% p$ ?8 Y        /* dram_init must store complete ramsize in gd->ram_size */
) U6 Q# z' y$ q8 t, G; d6 e        gd->ram_size = get_ram_size(
# ^/ H) X4 K  \2 f7 H1 G                        (void *)CONFIG_SYS_SDRAM_BASE,
' \! [6 t" G0 ]4 l5 Z                        CONFIG_MAX_RAM_BANK_SIZE);
. J7 d  @, n8 Z% u& s1 E        return 0;
# \; P5 O& z4 A  Y4 @}
5 P) Q6 i3 o6 \. `# t3 @" I+ m2 A) B: v
3 K* S) ~$ K. }# f2 }+ g( P2 H

3 A* ^5 n. x' s$ B8 S
  u: V& N; `3 W" ^0 y- c- gFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!! ?9 M7 r0 X- u' z5 a" Q1 S' ?& [* m1 t  c
3 i/ w5 L4 N* c8 D* d# y# Y
# R! \, D, I: H; j" T+ h3 ]
8 P1 {3 d6 X( @7 m4 u4 v





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