嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit0 @! N% F/ ?, U# M0 A9 c3 ]
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
7 w/ O. s/ y: T& q, q9 K这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?1 ]/ X$ _, Q/ O" `; |$ q

6 [9 N- J& i8 m+ [是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?8 S+ ~1 C+ s! h: _0 P5 [

) @) \8 ^: r5 E6 \# p( W7 S
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:$ Z* B2 z( R2 n
/*2 c# r) U; {- `* l  h
* Check memory range for valid RAM. A simple memory test determines
+ _- W( p) Z: @/ O* the actually available RAM size between addresses `base' and: c7 r2 S( G' |5 p
* `base + maxsize'.4 X3 R$ f  G* [5 `
*/0 _2 N& c$ {0 @7 N
long get_ram_size(long *base, long maxsize)' \, S3 P  N7 i1 _% c, a
{* g& P) V& `9 g# M1 y: D7 C) C* ?8 D
        volatile long *addr;4 x2 Q) A3 c# I# Z$ i
        long           save[32];$ r5 D2 w; j" k- }) G: x* n6 d! }
        long           cnt;
7 |* x! f0 A( L/ n        long           val;4 {# f& j( X/ i9 o* p3 U
        long           size;
6 \, y& d/ c+ p, Z4 A! l" Z        int            i = 0;! g9 z/ b3 R7 S3 C) S5 Y

& P1 j8 i* W7 g' s" ~1 k( Y$ d+ h        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {' @9 ?+ R0 I! ^4 P! v7 Z% b4 y! G
                addr = base + cnt;        /* pointer arith! */7 a/ ^9 ~- K- f7 N7 k
                sync ();
- k( M+ y4 V7 O% Q" F: Z                save[i++] = *addr;* c* N, [, }1 ~& k0 m# y9 w
                sync ();+ @; G/ H& L1 I2 G$ {8 R
                *addr = ~cnt;
3 I% Y0 k9 A0 _        }. |$ z0 n! b- P4 H/ y% B& e

4 E% \- v  W% F5 P        addr = base;) U8 d/ s  C' R6 g  R1 V
        sync ();
1 r, \  }) h5 k0 c# {        save = *addr;
# ]2 |$ T/ l$ `/ J/ w' X* M1 h" u! u        sync ();
) n1 o% K0 {' M  g        *addr = 0;6 r1 V0 e- l& M3 T" z4 E% ?  l

/ X: ^6 i! V' L) ]9 j' n/ f        sync ();% u4 G4 J4 n, j9 H/ G% C0 V: R
        if ((val = *addr) != 0) {
8 h% F" A" z& H. e( M                /* Restore the original data before leaving the function.
! I1 Z# {; T: E+ ?! i                 */
* k2 c, p1 Q8 X! c2 I7 a                sync ();! m2 M" ~4 ?$ {
                *addr = save;4 @! p+ O1 ~+ l& E
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
# R! R1 h3 D7 n" Z! F+ k                        addr  = base + cnt;3 @6 T. F7 c4 Q6 r* W2 b/ q6 X7 V
                        sync ();% m( c3 j' c: e# \' u8 r
                        *addr = save[--i];
5 j4 d4 s; x2 ~1 U7 z                }6 c1 ~- h( _2 N8 \+ \; J% B
                return (0);1 \* b' ^# p" g! @4 x  W
        }$ P& i  A* H- @! c5 I
- [( p5 t4 |0 E% [, l* Z
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; l* V2 }3 K$ |$ w, [                addr = base + cnt;        /* pointer arith! */
/ u  J  K. a9 ~7 A8 R                val = *addr;4 n" K% A3 L. T% O& j
                *addr = save[--i];% H: k$ P  z4 l1 s
                if (val != ~cnt) {
1 ^7 c  t  O4 [                        size = cnt * sizeof (long);# `% S5 g8 W! n. p0 x
                        /* Restore the original data before leaving the function./ r) ~& I- e! S- Y& Z% n6 v
                         */
3 y8 y1 _7 B$ K% P' Z& W                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ ^6 J4 \) t3 o' U# N# A  n
                                addr  = base + cnt;
2 P( u2 Q3 B' Z! D1 y0 H  w/ W. f$ o                                *addr = save[--i];4 ~% R/ U5 ?9 \+ a! ?& ^
                        }8 o9 ?" U. L5 [" X: K9 n" a& k
                        return (size);
$ s/ n+ l6 o2 }* Y) w( q                }
  c; b0 h' a% c! K/ i        }
& J- O, G& |. j4 W7 Y' b7 B+ T! F- T: j/ M8 [/ m$ N/ [
        return (maxsize);' C) d$ E6 G$ ?# {$ \6 ]) y
}' H# P; }. L; C  M$ l5 ~+ |' O
int dram_init(void). g' U2 m7 j. d9 S% n
{
, i( c% S' t$ ]/ D4 b) j- \8 l        /* dram_init must store complete ramsize in gd->ram_size */$ m& O7 V1 l  S
        gd->ram_size = get_ram_size(
1 x8 g# s: n8 i4 f                        (void *)CONFIG_SYS_SDRAM_BASE,- v7 l: {( l$ U+ h/ l- h2 e
                        CONFIG_MAX_RAM_BANK_SIZE);
% Y7 x: K! j$ E2 @# ?% [9 }        return 0;
4 D$ N: o: v! q* z4 s1 t; w}5 _- n, [/ z- n1 @; f  G% ?

4 ^: }; ^( f+ l0 c6 N- r! Z1 j
" D) |" t7 w7 q4 D3 ]4 Z5 D4 D' _  w
5 F8 D) d3 v5 b
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!0 t0 B! j; I3 `

7 H. a8 w9 r- l# w
% I  `7 S" a) a& X

, k% J9 d( ]1 L! e1 B




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