嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit) W8 c5 T& d( _# Y" ^0 X4 |2 O4 M! @  f
核心板2:DDR2 256M Byte   NAND FLASH 8G bit& f$ z. |$ O) i. k2 J
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?4 D& {; }, O1 I4 }
7 }; o# o) D+ ^* m. f8 e" |
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?, u( j; w7 V2 d% ?) A

6 U5 b. `* k+ U' r2 ^
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:1 E8 S, C( c3 ~& D" Y  e5 X
/*! Y& I4 I8 T7 j8 N
* Check memory range for valid RAM. A simple memory test determines% S" n# C$ ~  `' i! R. A4 [+ e
* the actually available RAM size between addresses `base' and* `. K' ^5 E0 }; \8 b$ I
* `base + maxsize'.4 ]% i1 U1 {& L- x9 @8 [
*/9 b: G! g1 L1 E- S
long get_ram_size(long *base, long maxsize)
/ k$ ^( H5 ~+ ~5 |: d7 {- F: M{
0 T0 k  @# t5 L& S" I        volatile long *addr;
4 `, {% y. o$ ^3 n) V% G9 b& t        long           save[32];/ K8 N7 t! S: I  T8 J
        long           cnt;
+ S' h0 _8 s( ~        long           val;/ p) S% _8 r2 U- S8 e6 U
        long           size;
; O- `& k# T  X, J        int            i = 0;
$ ~' w1 a- G9 v, {* [$ g& p" d4 d8 q$ M. }1 H9 @
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {" C3 q$ U# O2 B# C1 w: O$ k! M
                addr = base + cnt;        /* pointer arith! */4 t, I, w+ F9 `* N0 B; n
                sync ();1 W4 c1 Z8 \- j; b7 R
                save[i++] = *addr;/ c' B3 \4 M( @& ^
                sync ();7 _* H9 f; ^/ s- L8 K8 l1 a: w8 N1 j
                *addr = ~cnt;
8 i" U' t. Q+ s# h( y        }! s, @/ f( c+ I* {: z+ m

! l( I! U: S6 K! \. q* F$ ?$ x        addr = base;/ ]# a; O# Z$ ?, M7 E3 A
        sync ();1 B, t  w& H% C% l. F3 S3 m
        save = *addr;
) y4 s0 X; }; y2 M: o        sync ();6 ^4 P" J1 e" e! y; y$ z2 N! |5 g
        *addr = 0;
  J# G0 }# B" L8 ^
1 [3 L* ~/ b7 ~& s  u" n        sync ();2 t* c. \, T) p
        if ((val = *addr) != 0) {
1 R1 T0 O) l. I  R) b7 [1 m! G                /* Restore the original data before leaving the function.
8 p8 [6 U$ I9 n1 M& J                 */; l! Y1 u4 N! z  \4 b. m
                sync ();. C/ C9 l$ ~# \4 y7 ?
                *addr = save;) G% Y: }4 J# T0 E7 C1 I1 R
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
& C  U+ W8 c1 m! x! \- i; W8 r0 L                        addr  = base + cnt;
# Q  k! L! }) o4 o6 j: `+ c5 I                        sync ();
% l/ {8 F, F7 j( s6 V                        *addr = save[--i];
( o% g6 F1 w2 ^9 z( X# h7 ?! K8 i4 `                }/ Z$ y- c  e8 ]" m8 ]% {
                return (0);
% P! C( T4 j: ^" W3 [& W        }
  L6 f7 s, ~' W6 A# m6 h! k  `# F& K$ L3 H, m/ Z" E  U
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' H) D- K& X5 p8 g7 N/ q$ `4 s                addr = base + cnt;        /* pointer arith! */, c" h$ W4 E4 J6 f
                val = *addr;  v5 w3 X3 [, l5 _% {
                *addr = save[--i];. e# |% O% m0 T1 |9 N
                if (val != ~cnt) {
6 i7 b! C9 x; q# r                        size = cnt * sizeof (long);7 c8 N1 f( N. x3 i3 n. t
                        /* Restore the original data before leaving the function.
) J/ x2 o0 ~2 X7 S" l9 N+ c$ d                         */& T8 K" K( V4 E. L7 Z1 b+ A
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& P8 ~" R2 C, s" o                                addr  = base + cnt;7 g- ?5 I9 f8 Q9 Q. \, m6 @' Q
                                *addr = save[--i];! _& a* |3 p1 ~1 Y' w& ^8 e& @
                        }
( }5 F; ?9 U5 M) Z! k' [& |. W; a                        return (size);; F4 @7 }  |7 q" t3 W$ j3 P
                }
6 u, d, L$ [) B# }' N  R8 D' g        }* j+ G1 ~) i& f2 h6 b! D

- v4 L6 \' p/ {+ |) {% r        return (maxsize);# R+ V# g" H, B  O, C2 R0 b; k
}
& F4 R3 `3 c! ~& n  y2 `int dram_init(void)5 {# a- P* V- d& C
{
( }; M- R* [. ?        /* dram_init must store complete ramsize in gd->ram_size */" M9 l2 i  e+ N" ?( {# T# R" l) i
        gd->ram_size = get_ram_size(
: k( t$ M+ L+ a- e0 \0 f- A                        (void *)CONFIG_SYS_SDRAM_BASE,
) R8 X* k1 N! [; @3 s* I+ \, \, S, i                        CONFIG_MAX_RAM_BANK_SIZE);
0 U( P4 K) b8 s- U        return 0;
& C: E  ]3 O; N, {3 ~! S. r! B}
! z2 o& L* {& z( h5 z. Y
! b; b* w" f$ S  k6 {$ V/ `0 @. z9 F0 N# X/ w

  b+ |, z" a5 D$ ]
3 N" J5 n  n+ A0 D/ V7 E4 W. DFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!6 C( `, A! x) y/ F; N1 N: Z

' f  [4 i9 _' q- d2 F' Y
+ F) z8 h: H- ^+ |2 |3 z
  B! Q9 X: l# N# k+ u





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