嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
  `4 z: P; V$ K7 R- m核心板2:DDR2 256M Byte   NAND FLASH 8G bit& a2 n0 x: c" ?  q
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 H4 N1 m" h3 f4 Q4 F# Z5 J3 Z8 I+ j  y$ U
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?0 |" k3 d- y! e! z- L) @# a

- @) m! i/ e, F5 |5 Z
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
1 H! Q8 H- a( L" \/*
+ i7 |' a8 x' R4 s4 D' n* Check memory range for valid RAM. A simple memory test determines
# C9 Q/ x5 Z% ?* the actually available RAM size between addresses `base' and# k! h1 Z# J( O
* `base + maxsize'.
9 I8 `5 X0 c' E+ u1 F*/
' d+ d* u% E  O* q) v, t7 Slong get_ram_size(long *base, long maxsize)3 k& U8 D5 M. F9 N+ ~- q  ?1 o
{- C% _& ~) R) s3 @3 x: T
        volatile long *addr;9 s- _/ f0 i# k" F8 U
        long           save[32];! I1 F( P# ^' K; z' ]8 h! C
        long           cnt;6 P0 T* E; V! N* y1 p
        long           val;% b* A2 ^/ w) o2 s+ u% z7 b
        long           size;% R  H2 W* I  N, J) F: E
        int            i = 0;
& _+ M; `+ X1 k8 C7 s8 q2 e+ f$ ~/ L, v5 j3 w5 p! L% y! T
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {" m$ x/ T, c: Z( j9 ^9 V! h6 L" {
                addr = base + cnt;        /* pointer arith! */
& |4 a$ q3 M6 \# ~( f                sync ();
+ q, i7 n6 S, U8 Y9 T  d. g0 o4 F                save[i++] = *addr;* D( Q; }( j, D
                sync ();9 \- j( i4 _. L  o
                *addr = ~cnt;
8 ?3 K; J: j5 T, H        }( c# }' z3 X" S& c9 v& T' s
5 f; m$ _2 P; V& e- \( q5 G
        addr = base;# n4 _$ c: v. [1 v8 L) k6 _3 Z! l
        sync ();2 l% P* m" B, u- \# v7 e! T0 _
        save = *addr;# k8 h1 i6 e. b  y8 Y4 ?
        sync ();
* p: k  v7 f3 N5 E        *addr = 0;' r& {4 O3 O, ]; d$ y

5 B/ C3 J, T* u/ h        sync ();
/ F  ~* o, E! O        if ((val = *addr) != 0) {. W7 R4 d7 P3 D; y$ k6 S" {
                /* Restore the original data before leaving the function.  P; U! {6 n7 v+ E2 p; U
                 */
# N- U2 [5 w6 `                sync ();
% l- A0 a. W+ G% J# g9 T9 G                *addr = save;
( ^8 l+ K* m2 G! ^) @6 \1 [                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
$ [3 z0 G! J3 M1 m7 _. Y) U! y. i                        addr  = base + cnt;* z- C2 L! o; }( ?& s# O
                        sync ();
/ G  A2 h5 Y8 k! t+ ^2 @8 O                        *addr = save[--i];* H1 J1 w3 U" W0 f
                }
7 M/ \/ h! h' U! U& T                return (0);4 ?  a& j5 @& k( |4 I. D5 E
        }3 _7 y* x& j: Z3 `
7 U$ y: T1 q4 `, y/ D& A6 ?7 p
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {. J+ L6 N( F4 @8 T, i  d2 D' L
                addr = base + cnt;        /* pointer arith! */
$ F# u9 u# \1 L+ X, r                val = *addr;9 u/ ]6 U2 e& V* L2 Y; @
                *addr = save[--i];
, t1 z/ [" B/ \( l$ e7 |2 W                if (val != ~cnt) {
3 }0 t; |- A/ Z" x                        size = cnt * sizeof (long);5 K) L1 e/ g7 m
                        /* Restore the original data before leaving the function.. E6 P. c1 l% A$ p
                         */  Z+ {, t4 g+ d( y. ^6 r7 R' p
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {3 [4 f  E7 l+ V( G/ U& J) W
                                addr  = base + cnt;
5 I- {! ~. N/ z+ @9 w$ a+ [" d+ y                                *addr = save[--i];
8 D9 M4 L' q1 G/ j6 E4 X: C) Z                        }
' t) U8 o. D& L+ h$ n, s  }$ T, u                        return (size);
1 {2 a# A9 D4 `/ o4 B$ z                }( y8 {; w2 x! |: k
        }+ l1 W8 F/ ?/ C% U0 Q$ O6 w! _

! f3 h) w! y5 [# R        return (maxsize);
7 O; q8 s# @2 [! D}
- w* M# d1 f# U8 o& p# ?int dram_init(void)
% x* K4 Q, V/ b# `{* G- [% D* k5 D0 g+ K9 v0 ~4 Z
        /* dram_init must store complete ramsize in gd->ram_size */
" N4 ?/ c% _" H  U8 D* _        gd->ram_size = get_ram_size(
9 `+ V2 U8 z1 s% R4 s: ^# P% B# B$ }2 p                        (void *)CONFIG_SYS_SDRAM_BASE,8 z& E- V$ v, [; e2 [
                        CONFIG_MAX_RAM_BANK_SIZE);
+ D' A0 F# p- R( a! i+ Z7 k        return 0;; f" r' A( b7 n# y0 @
}
+ G* C1 u/ i" b$ N8 s0 W/ r6 l! ], N. h2 s. `
) w7 ?: a. S  t" u1 v
' w# ?! {+ o, s

$ Y! m) q  U7 q& V7 uFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!- [/ D5 K3 g4 q

- k+ V5 L% N5 w4 z; A2 o) d+ J: y/ N. i

. F; G' ?! }+ p9 R' [




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