嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit+ |& z0 ]$ N2 \3 |9 h; n/ b5 R
核心板2:DDR2 256M Byte   NAND FLASH 8G bit* p: Q0 m& X8 C) p
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
& F+ J" H, e9 Z- q" T' R8 F* ]2 O& S& R/ w' x8 P8 W/ T
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?( y) P1 l% `# b- s8 g

+ T7 a9 B+ ?5 L2 n* {  w
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:, w& z, t5 D' j4 x5 Z1 W
/*3 W. ]2 d, f$ m- K
* Check memory range for valid RAM. A simple memory test determines* ^  {2 I! x6 t1 f6 D8 [3 F* Z
* the actually available RAM size between addresses `base' and& n- M& J/ y& q( A
* `base + maxsize'.4 q; G$ u, O( O* u
*/$ X/ p8 z& J: ^; m' V0 P
long get_ram_size(long *base, long maxsize)
/ ]! D8 T4 n) T{4 I( ~/ I" j) k0 t; w1 a' e- S
        volatile long *addr;
" C) E* b, ], G: |        long           save[32];/ J1 P' A' {/ x
        long           cnt;2 d! O; {9 c8 d/ Y7 \6 S" n) D
        long           val;
% U' g4 t8 Q  \2 H        long           size;
3 X- ~% N7 y. U% q7 A. {        int            i = 0;5 d# ?* r; d7 x' _/ l
! W7 q' L1 v% Y. D
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 f4 ]# o1 ~5 b, U9 X                addr = base + cnt;        /* pointer arith! */& r; q4 A' g' n5 G6 h
                sync ();) u7 S. n% P- u0 k
                save[i++] = *addr;
$ C/ d; x! W9 U                sync ();' D  I9 R  V$ j1 {  V
                *addr = ~cnt;
: ]5 Z9 p5 D7 N, }% c3 f        }+ ?7 t* j6 B0 d, y% k: _
. a1 s. E6 l7 {: p5 p3 R
        addr = base;% `' J3 W: A) G4 _- F/ @
        sync ();
) Y+ H; N- h3 u# @        save = *addr;
& c& b8 u7 @& n. m+ d! e/ p$ Q+ M        sync ();7 p- w% [0 p+ F$ V
        *addr = 0;
; t6 l' H+ w( i: G" e: T& U$ |6 C' g' k6 D6 m- u2 c* h
        sync ();
$ n3 q! B/ D- ?0 l" B        if ((val = *addr) != 0) {, @( X) P: |% J* ]9 Q
                /* Restore the original data before leaving the function.
' s5 A% p$ R; r, k                 */. S# z: Z$ F1 h6 D
                sync ();) d9 b2 A6 _3 }; [$ L' X3 G
                *addr = save;
+ P# {! [! s' Q+ i& c                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
! S! F3 l1 ?7 N2 W" G5 z- _                        addr  = base + cnt;
5 Z  a  a2 d6 c4 c! X, C, a4 n                        sync ();4 ^2 _: {: F, j0 J. y
                        *addr = save[--i];! b- E5 O  g" P! k! Y6 b( I
                }8 D( j; y/ E/ d% C4 G
                return (0);5 F4 Q; [: R+ o0 j9 p8 K
        }3 l3 U1 s9 G( ?2 l

' m3 \- W. x- x& N$ I        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {! y: W+ P$ N9 r6 k, L! `; Y$ W
                addr = base + cnt;        /* pointer arith! */% T' I. N' [7 t8 ^/ N/ m
                val = *addr;  d* \) J6 b) o
                *addr = save[--i];
0 l; y% [0 ^6 o3 q2 Z! j                if (val != ~cnt) {9 O' w) w8 _% M" T. t$ ?; m$ `
                        size = cnt * sizeof (long);
* |4 G. U4 v! r# X$ b$ ]3 U                        /* Restore the original data before leaving the function.
6 @# L& h; R% e8 M  W8 b( Y5 @                         */
+ S0 _6 W! L/ f# x" b                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) }8 \5 ?" H3 b! G9 n( w: a- Q. B                                addr  = base + cnt;
$ g$ k. E% Z% P+ d+ O/ S                                *addr = save[--i];
( K  c+ Y' s" z5 S+ f! D                        }2 U; |$ u+ e. }* q+ U  _
                        return (size);
& N( C# k( j' _                }/ h5 i* I0 q! h, I! X% g
        }
! Z3 D. H+ [0 ~, D2 H- a$ `/ b9 K1 C0 F: l
        return (maxsize);8 Z4 W* q3 e) s
}
( F, Z1 V  [0 n5 e+ a7 Z: \int dram_init(void)
5 F" K% Q/ _7 x3 S) w0 J! ~: s$ x{
: f& b; f, Y+ N5 k        /* dram_init must store complete ramsize in gd->ram_size */" r- c0 ]5 S# n7 u$ h* i
        gd->ram_size = get_ram_size(
& Y  {: K3 S5 g! @& E* x                        (void *)CONFIG_SYS_SDRAM_BASE,
4 d. n% o" b7 V( @/ i% s                        CONFIG_MAX_RAM_BANK_SIZE);7 s& }+ Q$ y: }- k7 z/ u- N
        return 0;3 e- m! Y& `" S5 G2 z
}
6 @8 x% w( c7 j- q) `( m4 n3 v
2 E$ I7 p/ t# z8 w5 e
/ A- w8 t. G0 O5 ]# O" O  k( |
" n' j+ ?2 f  ]  I, |" W& W
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!4 ^8 L7 e7 b  t" ~' B

' D6 ?6 @4 r  ?
  g4 N% H+ C* S
7 {/ n' C4 w7 f. d) |





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