嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit  a- j$ R4 ~& c7 |
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
. |5 C; s6 {; [# D$ B7 U4 K9 A这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?8 p: c' B$ r# B% T

( z( t# h0 _9 i8 m; |; P: ]" \8 w  P是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?& f2 w$ `! ~& w& C

9 ^# d3 ]9 B+ K, @* A" ?9 n
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
& x: y2 |1 b( F2 ^* j* H2 f( q/*
4 h% R7 h/ a! g* Check memory range for valid RAM. A simple memory test determines8 @+ G( u' k6 e0 q+ w! k( y
* the actually available RAM size between addresses `base' and7 j2 M: Z  e( R" G
* `base + maxsize'./ W, u. d1 Q0 d4 K# B( j: h$ c- C
*/+ |: [2 p/ @- i* n$ C, Q! t& P4 f
long get_ram_size(long *base, long maxsize)
8 Z7 o; A  S3 \8 V5 `5 O+ C6 u( x7 g{
2 j' x9 J! J! q* x' N( r6 {; u        volatile long *addr;
' t+ {, S/ b9 j8 }5 q( k5 U        long           save[32];
* ]& [, t- Y2 Z/ U6 D( i        long           cnt;& d& I8 u9 o- v  J$ B- W
        long           val;
' _' P  b- P; J9 G) d5 q2 H        long           size;
$ ~+ M$ [5 w$ `( R7 r" a0 C        int            i = 0;
( y$ I1 v$ u1 S/ {' ]* c3 w- E- Y! F2 z' L2 a$ U# i) o4 {0 O
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
' X) f  y0 H' w' V                addr = base + cnt;        /* pointer arith! */
0 {! s! N( n; r6 J/ s! D% T                sync ();
. Z. ~7 ?8 W( q' @2 R2 X4 k0 X                save[i++] = *addr;  C4 X5 y  j# Y7 X
                sync ();
- R# E4 g) v. t: l2 Y1 _                *addr = ~cnt;$ z) ^* D4 J! j6 C$ x
        }8 e, [" b. \" Z$ S

/ \- W+ j. A, ]9 H3 }% }        addr = base;9 D, g) b* |0 A3 y( Z, x
        sync ();9 m& Z. O7 E% l6 V' i
        save = *addr;
( S2 l  O& V- a* w" f0 l        sync ();
( ?2 c) e& Q: K4 ]5 Q        *addr = 0;
  h5 v1 l  N7 X5 n& V# ~, Q$ X8 n
" C* K" Z) C9 F+ ]& L$ k  e+ p1 V/ {        sync ();" f' D! }6 p. B+ i' A- y
        if ((val = *addr) != 0) {
5 E5 x( e" c/ z" K1 `# n/ c                /* Restore the original data before leaving the function.
1 T+ {; {+ A# Z+ Q- {  i                 */
: y* c) [, Q3 S$ [                sync ();  b4 I9 U) _8 [) v) h6 _
                *addr = save;* {" N: j( S/ e' y
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
5 x; s$ B1 X8 D4 x: J1 K! y                        addr  = base + cnt;
" b# g$ G& t0 p! d                        sync ();6 j- d+ g# {( a
                        *addr = save[--i];8 N- A  |+ X% e. b
                }
! W  K% t; r. A# z% ~5 F6 K. C( V                return (0);/ ^6 X. I8 \" X; L/ F
        }
5 q1 J. K* E5 ]; v! s' Z+ k) r% P6 V% g. n5 Z4 Y, `
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 P* K# r3 T/ a% n, }( h: S+ m. D* ]                addr = base + cnt;        /* pointer arith! */
1 |8 @  `0 u! q6 s% u                val = *addr;
7 }$ N% E1 g: O; `8 ^( }; u                *addr = save[--i];$ x, M! T$ G  s5 u  Y1 s
                if (val != ~cnt) {3 U1 ^7 i  X1 W$ L
                        size = cnt * sizeof (long);) D/ C$ \+ O8 O; Q, [: B
                        /* Restore the original data before leaving the function.' q. F* C: i7 |& @
                         */
5 \7 F0 h6 d: x                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 F9 B# G$ V. O; U                                addr  = base + cnt;$ l1 n% |4 C% {8 X% K- n6 m+ Y
                                *addr = save[--i];
) Q: u3 F3 b. m" {6 a                        }
- [9 }( ^) L% _7 A! A$ {- x+ H0 n: q                        return (size);) s/ h+ }0 s% a2 K& q6 w
                }/ S4 L8 u& n+ H! O
        }
( Z( e- V" m" v/ J6 _
7 K& U0 c' H  d# Z9 Z" u        return (maxsize);
* }& w/ X+ c0 G8 ?}' [' B- T2 h0 f7 O  G
int dram_init(void)$ u8 p2 T4 x3 I/ p- F7 R! ~
{) y# D5 Z$ V# ~. j
        /* dram_init must store complete ramsize in gd->ram_size */
& _7 q; }) ^. d& U3 d        gd->ram_size = get_ram_size(/ F1 E- r' A4 A5 X7 Y
                        (void *)CONFIG_SYS_SDRAM_BASE,
1 B  W& E1 |5 _5 e                        CONFIG_MAX_RAM_BANK_SIZE);% A5 c* f- n( |: s1 ], D
        return 0;
# P) v' @* H2 S6 `! _; z}& c, j  B) s6 J" m5 k  c, G
6 B, }; t+ N  E9 l% x

4 q: `6 ^( X( ^. ?5 x" S8 f7 f8 a, ?( J) j  R, I
: ^* x4 I, S: V
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!5 f" F- v4 a( l* ~. ?, X

: j3 U8 F$ U$ \; o1 r! \. v
2 s; ]. ?! L: Z. f- @0 }

( v+ ?: [6 D& H% d% e- a$ t: A




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