嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit% ]1 A/ G: I) ]
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
5 b$ h* r, k  ?& Z3 a这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
1 r3 Q4 ?3 o. k. @# d+ L' E  y3 C/ v6 o+ |) o% C
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?5 K8 a7 b/ \. l, F
# A, A% \* |9 v/ M2 B' l. M( a

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:) a% }8 a5 N: L1 Y2 p. m" J- k# n
/*7 N+ l2 m) M; N5 T
* Check memory range for valid RAM. A simple memory test determines2 L+ |! j" s- z- }
* the actually available RAM size between addresses `base' and: H1 @% Q  _1 Y- b
* `base + maxsize'.0 Y  n/ O# {1 U
*/
. @8 h9 p/ U% R% q' Llong get_ram_size(long *base, long maxsize)
- e0 B# R+ C( d- `) o" w- M{4 @- m6 v5 U2 j& B* x8 n- Z5 @  _
        volatile long *addr;2 C8 h' g) S7 w- U
        long           save[32];
8 u# n6 z7 H9 D: H. G        long           cnt;: G! Z, h3 }. T* J5 [
        long           val;
' z5 R( h" ~. q# m7 ^5 ~# G        long           size;( q# N3 S4 I% J$ ?: b, x9 H
        int            i = 0;* F6 Y) V- S" t2 ^; @  o

- s" S- z- T  ~! H: p! \3 |1 N        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
$ R+ l/ C7 w1 A& ?% P                addr = base + cnt;        /* pointer arith! */
6 U+ F' q: U7 b/ m( C7 g" ?                sync ();
" C" @+ t! a, @                save[i++] = *addr;2 J/ C+ Q( ?1 g5 u
                sync ();
, l  r: U* z+ P( z                *addr = ~cnt;
) H) g( I! `' y( f        }" `0 R) f2 d; C( W+ @, z3 r

0 @- e1 d( B6 m4 P* B        addr = base;
1 c2 W9 Q( f6 \# f        sync ();5 ?) R' @% s- T  x$ c
        save = *addr;
6 Y$ G) ?- y! _4 ?" l) P9 @, d) f# q        sync ();
/ t% b6 E8 k7 ?        *addr = 0;
( ]; N" w. Y* n5 ]7 }. R  T1 W2 I) P( q% K* v+ j1 v9 V
        sync ();
0 w( Z7 L) t) U: e0 T        if ((val = *addr) != 0) {
& L6 u) ^" r: b6 W4 n& q1 N                /* Restore the original data before leaving the function.
: J7 a! J( \2 T+ n4 y1 C  T                 */
: B2 @9 M; I5 t0 |                sync ();
8 t$ m' u; l, T9 V& v                *addr = save;
) Y) M; b; S9 V, ^& I( ^, x* P) w                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, }# c7 p9 Y$ x: D4 u* C8 o) @0 F                        addr  = base + cnt;
5 Q8 G! D8 j, E9 p. Q$ `                        sync ();
# e( x1 o( r2 V5 m% s" d7 i# R: U, m                        *addr = save[--i];  x1 }0 U9 P+ ?& j
                }
; C# h8 x0 u6 d* b6 @5 M                return (0);6 I/ [5 \0 g2 _8 }6 d
        }
" P, j/ T% `& A  o! j
' x! s, `" A/ R! W9 t# D  n        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- q2 U9 `6 w9 |* `; @# M                addr = base + cnt;        /* pointer arith! */% i  ?# P  `  Q) c0 i. l" i
                val = *addr;& D# c# N* ^2 ]+ H+ E
                *addr = save[--i];- R' M7 H; T3 _$ M- @
                if (val != ~cnt) {
: O0 D* j$ M6 H                        size = cnt * sizeof (long);/ [1 s! V+ I  f  v
                        /* Restore the original data before leaving the function.
1 B& F+ e5 f7 g& Z                         */
, t) {- p) ?2 y1 ~& V                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {4 @6 \( D9 |- q" x! F$ c; l" G
                                addr  = base + cnt;
% N. q/ m. r$ y0 u1 C                                *addr = save[--i];% o' O; \# F% J
                        }' }' D+ m+ f' q1 B4 O& _
                        return (size);' q' B2 h" ~# ~
                }+ k7 I2 c- ~  t% {( t
        }; K% J" r* W! A
# I& z& t! y; W5 j
        return (maxsize);3 ^, s+ Z* ]# F" ]; F+ w
}
: s6 J3 Q/ W% n: mint dram_init(void)
; G3 G- z8 Z" E' e4 _9 X9 x* y{" E6 ], ^3 H* C7 U. D- m3 I8 m
        /* dram_init must store complete ramsize in gd->ram_size */' H2 f$ c1 X8 x! @# A5 d
        gd->ram_size = get_ram_size(3 p  s) i+ Q! X; u/ N; f* ~
                        (void *)CONFIG_SYS_SDRAM_BASE,
8 [- r7 v1 ~* V4 m; O                        CONFIG_MAX_RAM_BANK_SIZE);
  w3 x; K$ l9 N/ l6 Y8 Q% E8 I        return 0;5 q2 s2 L6 n* I3 D1 L: X* x
}
, e: Z' M- N( B$ j: w6 m5 r% L0 A. d. g) d: O( q* ~

0 f) [8 P" w5 o3 q6 Z/ m5 [1 T% o  j8 b! V% r  T* A

& k- g0 ^9 i7 f- [- kFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
# u1 L- O; X( @* }9 e5 p
0 Y' q& L- X0 K0 Y( o; G8 |9 @0 m, M9 {7 R
. E' k' c- s3 ]1 G4 G' U! a) C$ m





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