嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
- U$ ?1 H! N6 Z" g* n6 C核心板2:DDR2 256M Byte   NAND FLASH 8G bit& b: S) o) D  D9 s8 S
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
( B' s0 D# C* C
9 M% S( m# T& d% v8 C0 d" \) v是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?. }- C& j3 N# {6 P5 J, X# D

) j  G$ e5 N$ E
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
8 f. j% G  L: o' u1 y+ C5 j/*
7 q2 R! i: b3 L* Check memory range for valid RAM. A simple memory test determines
+ m# Z3 }7 Q7 l* the actually available RAM size between addresses `base' and$ a5 A) l1 q3 k
* `base + maxsize'.
4 A8 D: Y* h0 z  u: a& A*/9 s* W3 u" H% N7 r1 P1 |' n
long get_ram_size(long *base, long maxsize)
; d, p- i: V  @( j  p, t{- R+ L1 g0 g$ J) I4 A7 C* o# w
        volatile long *addr;
; \* y5 Q0 t' Q: F5 E        long           save[32];1 R2 A9 B( P" B. ~# f
        long           cnt;+ F3 H3 j% y9 }4 h4 b- {
        long           val;
- `+ Q- O4 @: n+ E, d        long           size;7 J9 S/ V& [) |' j- i/ T' }
        int            i = 0;
0 d% [$ z; V! E3 m' ^9 i1 Q2 y/ V: y# a2 k3 n( T
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {8 l" A6 q" Q7 x( s# C: e
                addr = base + cnt;        /* pointer arith! */+ l* k4 i/ T* b/ _) O: k; ~
                sync ();6 I  K" I* Y' g  S- k
                save[i++] = *addr;2 w# l: b! M/ K3 U& q9 U; Y2 @; P
                sync ();
# s3 H" w+ `' S' N6 W                *addr = ~cnt;
6 O9 ^1 p- l( @  ]; i/ r1 i' x4 d: E* n        }
1 Z8 K6 P! ^" |( [  X9 d
+ M4 o+ s9 _7 V. [' i        addr = base;" O: x: S- c- M0 q  H
        sync ();2 e/ t/ S5 t+ ?0 \7 y
        save = *addr;/ o- N! [' j3 \" x3 z
        sync ();8 N& ]0 X% }/ ?3 T; ?) R# u
        *addr = 0;
5 a6 [5 e0 {/ ?- @5 `" b' @. ~4 r6 X4 w$ g6 {1 ?5 H
        sync ();. }* N( u- e- y
        if ((val = *addr) != 0) {/ b9 J7 c  f, Y  `" k
                /* Restore the original data before leaving the function./ Y: v" @7 T( a) u1 q/ P8 l
                 */( G( |: {( Z% @2 [8 |
                sync ();
; b+ {" D5 D. \! w( L$ `                *addr = save;
, _" X4 x" t3 n0 ]8 _/ Y- B                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 l. f' L- ?7 Y3 e                        addr  = base + cnt;) t+ s/ [& h( D4 w* d9 }
                        sync ();* Q+ r- `4 y# `7 L7 v
                        *addr = save[--i];
4 d/ }% n7 q% K+ v: l2 R                }
) ?' f3 a1 H. i5 j) L; d8 @1 X                return (0);; P* Y, C# f. W! {9 W
        }( d" ^' P- I: g' ^: r

( i5 f5 h9 `# J" D+ s" k6 S        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; K' B7 d, o" V% b+ F! z                addr = base + cnt;        /* pointer arith! */
) @' _) z! z5 H. }                val = *addr;  f0 P2 C4 O7 ~0 P' K$ r! g( ?
                *addr = save[--i];
3 P- F' O3 ~; e& t                if (val != ~cnt) {
0 v% v/ d- o6 ]7 H                        size = cnt * sizeof (long);# T' Y8 ^* s$ K# d# Y# G& s0 K
                        /* Restore the original data before leaving the function.
' t6 r3 j0 W* g8 D( X+ E                         */
/ S- G" U7 D# {( R- B                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {. [, D/ x) l8 [% M% ~+ m; V* |  p
                                addr  = base + cnt;
  @0 a: z- x2 D4 [. W4 d! {1 o                                *addr = save[--i];
0 I9 C3 n/ u/ q/ @                        }
  G$ d- n0 G# @2 s/ e                        return (size);
" B1 |3 y. m. J3 J0 |                }# C5 \( {0 R: x! j
        }/ f6 z! z1 c  p) f: I

0 k8 r4 i' q% o; d2 u/ B        return (maxsize);: z# I( Y" I# o
}
8 D; t7 z, R1 y9 Z  Nint dram_init(void)
9 u- |4 D6 i- i& H+ v{
5 v9 f/ F! H7 f" z% g        /* dram_init must store complete ramsize in gd->ram_size */
/ I2 b+ b1 _! C        gd->ram_size = get_ram_size(! M/ o- m) O  c) I  M+ M! {- b6 [: D
                        (void *)CONFIG_SYS_SDRAM_BASE,, ]  Q, {' X: X/ c+ u% t* e" a
                        CONFIG_MAX_RAM_BANK_SIZE);
: ^/ \( h8 r5 s+ X0 M' D/ _! ]        return 0;3 @0 T5 }. ]% T" A% m
}
+ t$ V3 f" a. r# v2 z; [+ K, l1 a* H% c' u
6 V5 p# Q) U/ C  ~9 s/ f9 I' r8 e

" f5 _' u$ P. Z& L/ q% @! ?2 p4 u3 x8 K4 r! y2 [; T  d
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!& h1 n' p) l. a1 [
; E* N; D$ s0 x" Q' G

4 N5 f6 }+ ]" ?" i" t  n% G

6 j  s3 Z, g: b! q




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