嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
2 B* p) z; W' U1 D0 k# F: ?% M5 [核心板2:DDR2 256M Byte   NAND FLASH 8G bit
7 h5 V5 p5 x0 O* X6 T这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
0 L5 P# C5 q, g- r" D! U5 j
0 \* y9 E. m" e+ `是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
$ T0 ~! ]5 X% `$ M; W
; Z' y8 h" _4 c) h. k
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:1 B: F6 O2 x3 |/ ?# V  h- W% D
/*
" @6 N7 W0 J3 {; F4 h* Check memory range for valid RAM. A simple memory test determines
8 V  l0 c! }4 @, P) n) Z2 o2 o: x/ `* the actually available RAM size between addresses `base' and
( r% o+ o/ K8 t: W7 `$ d, I7 w* `base + maxsize'.
/ c& F4 O6 A" n6 L) o1 l, S: m/ n3 D*/0 D0 l9 t1 L/ L: \
long get_ram_size(long *base, long maxsize)
- n: m$ w; Z. O1 |4 y2 l. y8 i{  t: w9 ?! U. _0 s) g
        volatile long *addr;
7 B5 J) j. D0 F/ F        long           save[32];
) O6 p( u0 l4 ~4 d) P- Z7 B        long           cnt;" F% {) z  S) Y3 v+ I) R
        long           val;
( s$ S( S! J+ k( B# x0 M        long           size;
' e7 b3 M6 A2 {. D        int            i = 0;
" z9 A. R4 U' H, b2 Y; |  \3 u( G" n! v
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {$ F( N$ o$ j" q1 @5 ~0 U2 D
                addr = base + cnt;        /* pointer arith! */; S' j9 @( x$ s  q" N
                sync ();' o* }1 E0 m  ?
                save[i++] = *addr;' j) M2 x# ]9 X
                sync ();
+ l& c, X: ]( h                *addr = ~cnt;
8 \+ Q( x; j$ t! a) [& @        }
  N: Y8 I- ^  C3 w% _1 G6 }* W# s
- ?0 C/ D: h/ i' d, J# j& i        addr = base;6 i/ |7 E+ N1 m. Y: e4 j. }4 Q
        sync ();8 F" s7 M7 U5 J( _
        save = *addr;; T% J& D+ D+ E
        sync ();
' ^9 q- m& D- h5 ~        *addr = 0;/ ~0 v$ v1 |5 S* R  w& b
& i' p0 {2 ~# H% o" m5 P
        sync ();
: o" a) j. e. k3 Y0 I9 S5 }        if ((val = *addr) != 0) {) L2 |1 ?% W- F
                /* Restore the original data before leaving the function.
4 C& C9 v& c0 i                 */
7 |2 }9 S$ x+ ]& O* a% ]' ]) _                sync ();* _6 ~2 z# K# G0 z
                *addr = save;
8 V& S. t' |  Z* m* M' z9 d3 r; ^& ^. ^, z                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
7 r* A# c. n+ M- V0 y0 q                        addr  = base + cnt;
" J! ?2 Q0 u# L* E/ a0 h                        sync ();! U7 A7 ~1 h- {( {& [* z
                        *addr = save[--i];1 |2 F) C0 m$ |, z; a8 `0 q6 \4 P
                }/ ^2 `+ r. S" N1 Q
                return (0);5 `; _3 D4 }) Y
        }
2 o8 I1 w' R9 b- r* v4 U/ P* s% V  w! V
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
* E- M0 q3 Y  r                addr = base + cnt;        /* pointer arith! */
( f" v: N; V  s                val = *addr;' U, J- a" v8 b1 t( S, V
                *addr = save[--i];
! \, R5 m$ |. {. z6 M7 j                if (val != ~cnt) {% G! C  u/ s* O
                        size = cnt * sizeof (long);/ \' J, Y5 V3 u( j
                        /* Restore the original data before leaving the function.
5 ~8 \. R  i& E" M( d! I: S8 S                         */
& C% Y( `. _0 T  h2 g                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
4 ~$ V; ], @% L- c, P; C8 l5 N                                addr  = base + cnt;' x' g: ?) n8 a4 x* J; }0 W0 I5 k: q
                                *addr = save[--i];
" f  D' R, u$ c; @) q( |% i) w# N7 j                        }/ j) |- i2 O+ g/ ~  u4 m- U
                        return (size);! U& b6 x4 c9 z: R
                }  J) L3 }  }2 h5 F' r9 g
        }
% a  j& g& O* p% L
1 O9 I. z) n' Z  F9 m. t8 ~        return (maxsize);% {" s! I: u% k" S1 r
}
4 B7 t! W; W1 k' K7 u8 t# W$ oint dram_init(void)* d  j' R) D# p4 `" M. \
{( @; ~! H2 U  w( R) c$ o
        /* dram_init must store complete ramsize in gd->ram_size */
  l& h  z& i9 E, k' k; o3 [8 h: k+ Z        gd->ram_size = get_ram_size(
, Q) l7 L" I* D6 u+ B4 l+ d                        (void *)CONFIG_SYS_SDRAM_BASE,; J9 a5 l# E4 i: p+ {; z
                        CONFIG_MAX_RAM_BANK_SIZE);( g9 N6 L3 I; p  k! H
        return 0;
. G/ _5 I3 [2 |* F8 z3 M}- B" N2 H( E* x2 G' Q; N
; W+ x9 g; K# F7 c0 f9 Q- T6 d
* D" ?; Q. F) g7 |# ]

4 B. [/ h1 x, c+ Y$ f/ z! f$ Z3 ?( n& b  I  R; \
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
0 \% `7 U1 N  Y4 F. y6 {8 z7 T: ^3 {8 y, ?

2 ]7 x8 e  R( S2 z5 w+ G) E
0 t, x  A) l; g  q7 [* f, y





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