嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit9 ]+ J' m  L0 p; d1 Z" o1 p2 F# f
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
; f' W& r6 y) ~' v. h2 Q* l# m这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?! u6 P) S; l9 I  n, t5 T

2 C# A6 c0 i5 R. \) Y$ i+ O4 v是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
' P! j& G( T; _( O% C1 e! J* g( m, _- n9 i9 H

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:, t- l+ P2 |5 `" l% u1 H$ N
/*5 K. V( u  ?' B% q8 z
* Check memory range for valid RAM. A simple memory test determines
1 E$ l2 b. n5 y  T+ t$ q* the actually available RAM size between addresses `base' and; u; |' J9 }* Y+ L+ ~
* `base + maxsize'.
0 L" k/ V7 f& ~*/
8 g9 [5 T$ S+ B8 Jlong get_ram_size(long *base, long maxsize)
# |/ o. L) K: G3 r: U% ?{: @/ D# D+ w* L3 f6 |/ v6 P' c
        volatile long *addr;/ p- R% S: t6 O: [+ x, ]
        long           save[32];
$ h( [$ N7 L0 j3 H# Y3 l        long           cnt;/ i6 O, H0 @; b& I- V
        long           val;
* c/ {! I. _& a" f9 l        long           size;0 K5 M4 s. J. V! x- m
        int            i = 0;
; Q, s1 k$ f( x3 ]# w  Z- t
" C) A, f7 ^( p7 q2 l6 e7 L; E/ a        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
/ O0 X3 ~4 k6 ~8 z5 [                addr = base + cnt;        /* pointer arith! */
6 i: n& A: v' q- k! [                sync ();# V3 Z) ~7 a0 ?4 i. e+ N# k5 R
                save[i++] = *addr;
, w9 ?$ U5 S) T( _( p* J) K$ Y                sync ();
2 \8 ^0 J5 C5 m                *addr = ~cnt;/ x: ?& d- O! [3 `9 C
        }
( o4 R5 q! _) E: ]' h& F6 n+ C5 i
/ j/ |' ?* V% n: c, `        addr = base;; y8 a/ S+ N. X
        sync ();. ?1 j1 M: d/ E5 j- b
        save = *addr;
! S1 s4 }- v; {; t% x' {7 o/ v8 P        sync ();* P1 l. g: v9 P, a
        *addr = 0;
3 ?" H& J5 _7 \# s
" Z8 W1 `. p5 s% u& f5 u# u% a* {  j( Q        sync ();
, h( z  p; i# o5 Z# c        if ((val = *addr) != 0) {
! z' F) y6 ~/ C8 N( ?0 \( z: E                /* Restore the original data before leaving the function.5 n$ Q% @2 y* U$ |; l) T
                 */& D( I0 w! X' l) Q7 b3 q3 l6 d
                sync ();
8 o  S* i% u- G, |$ m% t                *addr = save;
4 j6 `. z# l  O& h9 I                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {( L. N- D& V* o6 d3 V) _
                        addr  = base + cnt;
' t, q, Q) n- z) p) }                        sync ();; \9 T  b: `: h+ `
                        *addr = save[--i];
; Z2 Z( L  S& b. Y( ]5 A                }7 K* h7 W/ ]8 A. T; C2 D# O
                return (0);3 T! U8 A) y" \8 X7 S
        }
/ a6 r* L/ W. Z2 j7 |1 V1 |: {5 ~
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; c# ~6 b+ ~* r                addr = base + cnt;        /* pointer arith! */0 h. j) U8 e' p1 w; P0 ]1 f
                val = *addr;. D7 s$ Z8 z( D3 F5 b8 x
                *addr = save[--i];
" A" [1 y; h& a. w! h. P! g                if (val != ~cnt) {: m/ i6 _1 ^! a& ?6 B
                        size = cnt * sizeof (long);* w2 I/ D- Z9 J/ [4 H" r
                        /* Restore the original data before leaving the function.% Y7 A+ ?" o8 K0 u
                         */
2 \# }/ G" s# j4 a- Q                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ D5 a+ o* P- F6 A
                                addr  = base + cnt;
+ s/ ?1 f# R4 q* c) X                                *addr = save[--i];' r7 w5 ~- W% B$ J- c5 q
                        }
5 d& {1 F1 P- R                        return (size);* w& m# @* G7 `  F
                }) T5 j, n  l; T- w0 u; _
        }
6 ~) N) p8 ]8 e7 A4 O  G8 E& g5 ]3 ^; u, h( `8 ~5 M
        return (maxsize);3 h/ e3 V& t* s( q
}( m0 S! [" b3 a4 p; u( |& H/ v
int dram_init(void)
% _8 N3 s) m- M. c+ w{
7 V2 q7 B) G0 N/ a" _" m  Q6 P- G        /* dram_init must store complete ramsize in gd->ram_size */
9 Z. [9 q- ?$ i# E" W( f1 T        gd->ram_size = get_ram_size(  L* D3 }% H" r& B
                        (void *)CONFIG_SYS_SDRAM_BASE,
; ^( Z6 y( K) t' C" u) f                        CONFIG_MAX_RAM_BANK_SIZE);
: t& T' t2 V( G        return 0;1 e4 q# c1 r% P2 z, i. ~7 \( W( Q+ Z
}
/ i  N% ?* |* Q  X6 W" Y, M5 S: r* D% {4 X% B' v  Z% a/ j

$ M7 j8 f  b. H3 o; u/ |7 b9 ?. j- s

% r, r. B/ \& I# C8 B4 B9 PFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
& |' i) D% _& c) U
) I- `; A5 ?8 k, q1 |
4 Y8 j% y7 J; W( k, Z) C0 C' K
+ Z" W. _2 C6 f4 r# W/ O





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