嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit" Q& t! s& R1 ~! m3 X/ z
核心板2:DDR2 256M Byte   NAND FLASH 8G bit; ^$ e6 M9 N# x0 b" e- r! y
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
( M1 _- I. b- D5 f- u
; }: p& }: }) ^7 U6 l# X% F5 K5 q+ V1 T是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
  [6 c3 a7 q8 [
. ]3 y2 o6 ]1 r7 u9 i
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
$ ]5 d' q' K6 b' v/*8 s7 P8 H5 U2 ?$ F  T" f9 G
* Check memory range for valid RAM. A simple memory test determines' L" }7 r0 z' v% r/ |! x/ p
* the actually available RAM size between addresses `base' and8 u) i: W& |( w! p) D# _0 j
* `base + maxsize'.
: }0 v& g& B! V  {1 M  ?( F4 D2 u*/
, ?* o+ `/ z% c3 a/ I6 t  Z( `, }long get_ram_size(long *base, long maxsize)& V2 u+ Q3 F/ f7 [$ L% x$ @* @
{
4 m0 T, U! m: D2 q7 j3 y6 x        volatile long *addr;
" `. H* {% g/ C0 ~& W7 P        long           save[32];
, g7 n2 Y) I( ^5 }        long           cnt;6 ]6 h2 e( O8 H7 }8 u
        long           val;2 Z, Z  x" }- N1 U
        long           size;' x& K/ g% u0 e- P4 f& |; A+ A3 e3 Q
        int            i = 0;
5 i' f  I. W# I/ b
$ n/ ^3 e# {0 }6 \' ^$ p        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {5 _; _/ W0 c! w1 Q) }$ C
                addr = base + cnt;        /* pointer arith! */
$ C8 C, ]  O+ b$ I) _% E# M                sync ();, d" K# O6 o" N! c& {) I
                save[i++] = *addr;; r: N1 Z; u* Z9 N6 ^2 r
                sync ();
$ ^6 m: W7 w# k                *addr = ~cnt;
: y7 B3 ^4 w4 j5 n9 X        }2 A, p( R# V& z3 a% V  W

5 Y6 Y. b2 J5 [( H' s        addr = base;
( d" d" U8 X3 P7 ~$ k# [( X        sync ();
% {- V' J3 f. C; j* A% \        save = *addr;8 M1 r; A, i( O  I
        sync ();4 D) Q) M* I% Q( Y  J  I7 o
        *addr = 0;
: f: W7 ]8 w% |% V" {0 h" R- [+ t
6 w8 r" X7 s3 k' [; ]* y6 L        sync ();
/ \0 |- N* v3 h/ L0 r: G) K        if ((val = *addr) != 0) {
% e) O$ l9 ?9 `" X" q3 w- Y                /* Restore the original data before leaving the function.
% U3 S+ X  }1 T                 */7 \) {* m2 C% N- |, g2 m( P- K5 D' D- p
                sync ();
- x/ g9 g/ y/ C4 L8 V                *addr = save;5 p0 l% W; Q- m7 s9 x$ @# R+ s/ L3 X3 x
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {3 m3 V! H1 m' l; L
                        addr  = base + cnt;
8 _/ s: }8 `7 A+ i+ Y  o                        sync ();
& `( I* ?1 q% O! L                        *addr = save[--i];
5 C8 `0 t% t6 \  w9 M* \                }
7 v' F" w5 m& f                return (0);
' {1 k3 Q# }, P/ t# l, C        }4 p# g( N' P* n+ `. Q8 V
1 u' @0 t1 l% R, [8 _3 @
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 ]/ l! W3 W* _) E6 d& T                addr = base + cnt;        /* pointer arith! */4 B+ N7 g0 D* C' C, q! M0 A
                val = *addr;( ^: F5 D3 H- Z6 C1 E1 ?
                *addr = save[--i];
7 n: l/ _/ ~; u9 ~" ~                if (val != ~cnt) {
" i/ E8 o0 t% S% M7 Y                        size = cnt * sizeof (long);
9 {& q* d9 N; j$ `2 a4 K                        /* Restore the original data before leaving the function.4 [) C) V" }: L1 R! B
                         */' |4 l( M% i( ?
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 p6 V9 S8 S9 k) s. K' H                                addr  = base + cnt;
4 B1 ^3 o. c/ m/ H                                *addr = save[--i];5 b( p# Z+ g8 T+ z$ Y2 H. c: \( ^
                        }' v" `6 E. y* s: E9 s9 K- k6 W
                        return (size);8 l, S$ ?6 S8 o. j' w3 r3 r
                }
* i) v& f  e: ]$ t7 s: q        }* [& j+ L" O+ ?) c8 q5 t
* w; |. {/ [6 t- l8 \0 {3 K
        return (maxsize);
: x$ Y" ^3 R# n+ r}
: @* ?( H$ Q" Qint dram_init(void)5 T5 s& E+ b' @" h6 g. i& O5 W. p
{0 w+ Q8 h2 x+ F1 n  ]) T- p
        /* dram_init must store complete ramsize in gd->ram_size */
, V; J4 F0 f! {$ V        gd->ram_size = get_ram_size(
6 \4 n! O! c0 Z# o+ s                        (void *)CONFIG_SYS_SDRAM_BASE,
# w* n( H6 U# o4 X2 \                        CONFIG_MAX_RAM_BANK_SIZE);
4 e. s9 p. i; f        return 0;
4 \, W2 W, x% m& e+ r) D5 S7 M}9 W+ ]7 B$ _! W$ Y
+ a7 ~  A! \% k# l5 k2 b

/ ]. i8 n  [& ?6 L* q
+ D8 K3 M" ^7 t/ P: w# `: a: I
7 y( C, O/ V, l! \FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!% i% F; s. U; J; S

7 `! r6 K( ]; n* ~' J
" q% z& c1 f2 y' d

3 l. [( u2 K* o& z- R+ d; b




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