嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit& g, N# A# E3 b
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
) v+ p0 V; {! H) a: M' h这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?% N  g* ?. L' ]& o0 L, k8 \& E7 w$ V7 R

! F$ p# k* N" k/ o* f. E, \是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
' p( ^, K' x. Z3 g0 ^( }  z, `
1 R: g6 Y9 N) Y6 ~
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
' G0 p# V  X% n  ^* @/*
* N' S$ E; g% \6 z3 W! v% ~, K* Check memory range for valid RAM. A simple memory test determines- d, D9 s' H& p3 h* V& A* Q
* the actually available RAM size between addresses `base' and6 c- f! i9 o5 y
* `base + maxsize'.
% o$ B. _5 W% J0 ^+ @" z( Q1 ~) ~*/
" A- w( g) `; H/ k' wlong get_ram_size(long *base, long maxsize)+ N, p2 G! G! l. f, d9 z
{4 |5 V7 V0 J0 R# p* E/ e7 [
        volatile long *addr;
0 ^) s8 k2 M( ~2 L* d- U        long           save[32];8 X9 F6 g: W9 F/ \4 A
        long           cnt;3 r" u, |7 \- ]( y% e# q+ {
        long           val;* y' P- Y6 h) |2 y/ i: i
        long           size;! [# w( E  t6 h4 H; c1 Z: V2 D0 V
        int            i = 0;3 A8 k0 q: F4 j4 Y7 Z* Z" `% T
5 r3 f' j2 N# m- x
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {/ g$ |* D; ~4 F* X, m# H+ o
                addr = base + cnt;        /* pointer arith! */+ D1 E3 L1 s: |
                sync ();
% b; V- e& h4 x0 a  j" f  |) y                save[i++] = *addr;  S; f( [" Q2 K3 Y
                sync ();0 Y5 G0 H9 {" s
                *addr = ~cnt;3 B) F1 |7 [) f1 q$ j9 b
        }
+ U; M- P/ d* Y0 k
( q* ]& U* ?" ^: Q3 F! V0 ^5 d: {        addr = base;! X) F. ]; v7 M  m3 k4 t4 d
        sync ();
9 y2 g! ]5 h6 T: G- S; L        save = *addr;: V( C2 ~  G4 e
        sync ();
3 Y! D5 K+ i4 g* `8 `        *addr = 0;
/ I2 M. [* o7 S' S
: O( j: ], {+ ?        sync ();
6 L: b, F+ ^- `7 i, d        if ((val = *addr) != 0) {
  u' c0 `: Q/ j+ X0 Q6 d  U                /* Restore the original data before leaving the function.
% F, U2 m! |/ y, ~% p                 */3 j/ i" ^3 @% x) k) e+ v6 |9 w
                sync ();% i( V9 P% T/ D. U% [+ |
                *addr = save;6 p& b! S2 t7 l. p
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {5 ^4 ~6 _" R, C4 Q: R1 S9 s
                        addr  = base + cnt;) r5 n2 f6 y0 p
                        sync ();$ L& g3 H: h. y$ V. k+ l
                        *addr = save[--i];
$ J# {* a0 G* B4 }7 w2 s# p/ \                }
+ ]0 X) k+ j. q3 O  b) `$ T                return (0);
6 {5 r& O6 m6 W0 V' _8 d        }
! z0 a' @: E9 |( i$ k: ]( S$ x& H
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {  v2 Q0 V. r; ^0 E6 v1 U
                addr = base + cnt;        /* pointer arith! */+ t7 Y4 P) v. x6 ^
                val = *addr;  v6 X1 b1 d$ n! r8 V5 k
                *addr = save[--i];
' o; {( S1 W& s* j9 E1 H& x                if (val != ~cnt) {9 O2 i& h7 n% r! X& a; K/ X
                        size = cnt * sizeof (long);
+ t' Y3 Z, X! }2 Q+ i) `( Y; \# w                        /* Restore the original data before leaving the function.( m, h  J' M- L- z; `, p
                         */% Q$ }& Y7 q, `# y
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {- |7 T* ]/ ]: |, Q, \* p) e( A
                                addr  = base + cnt;; w: f) `8 }$ y- J
                                *addr = save[--i];! b9 G  E6 @) w% G- s( Y
                        }, r/ o9 U. ]9 D  P) `. l3 i
                        return (size);
7 R* S3 p$ h1 f4 C4 i* v1 l: C8 b( ?                }
+ _. m2 L' t/ w( w" E. N( _        }" D  l6 r) R+ K

9 v/ e  F) D( I3 p; m        return (maxsize);7 \  x5 `9 [# z8 u' A
}
9 s/ v1 f1 k4 ?int dram_init(void)- {) x; r7 s' a1 `; I( L7 E
{
4 x  V8 b# N2 n3 o" I        /* dram_init must store complete ramsize in gd->ram_size */) M! ]7 i# N1 P4 M/ F
        gd->ram_size = get_ram_size(
6 n5 }- N5 H9 r- v* W) F: C                        (void *)CONFIG_SYS_SDRAM_BASE,5 i0 R7 ~3 i4 N6 Z
                        CONFIG_MAX_RAM_BANK_SIZE);7 ^# H7 O8 }4 v8 Y! k1 e
        return 0;
% H, \7 x5 w& A) {3 n}; F; |  d9 C8 L, o  l+ h, D
% V6 H' z6 m; q% ~7 E8 o# g4 i
* ^  ~, X2 V) n
4 G3 Q6 h% S. L5 h2 P6 @

+ x! r1 ~1 _) n, NFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
4 y& `- J8 C. N8 B0 f7 o4 I3 x) T6 n
  X8 Y) `  ?0 J2 i2 t; R) \" j! V( G% |% F8 S, e
, Z6 L) t8 }7 T) C/ i* S8 t% F





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