嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
1 b* d$ n6 r6 e3 K. w核心板2:DDR2 256M Byte   NAND FLASH 8G bit7 t/ T& N* |/ j& [/ P
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?' K. {! U5 R" |
, W6 R- i% g0 H( b, }# p0 G
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?8 \" D" j5 j. P, s$ Y7 k$ V5 o* h
* e, W0 H' O8 d8 H5 h

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:2 S; K: ]' Y* {! I0 L( P: s
/*
; v" h" g5 T/ J% G. B& T* Check memory range for valid RAM. A simple memory test determines+ ^4 i8 g. C& z% H: V
* the actually available RAM size between addresses `base' and
% M* T6 e6 ]9 y7 Y" _* `base + maxsize'.* p1 m  k" I! ?0 o6 O; k% b. v
*/8 Y6 [3 U' r" M3 ]( l' K
long get_ram_size(long *base, long maxsize); l5 o9 `* J  Z& [* M! L
{
1 w4 S& t0 s& D2 m; f9 S        volatile long *addr;% X5 C& O/ C, T* b4 T3 @
        long           save[32];' T3 P# m' ]# R& u+ I6 A  k1 v
        long           cnt;
5 b8 ?! C( M2 t6 i/ h: r- l9 h        long           val;
+ v4 L' h& B1 `7 G% W+ O" y        long           size;
& I' _8 K: B1 [        int            i = 0;
3 V% L* a1 M1 I# [/ ]" m! f$ v& S* A9 w% h/ z
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
1 ]+ i, T* b7 _) ^% o8 M                addr = base + cnt;        /* pointer arith! */9 D9 @( {  f0 J  x$ F
                sync ();
# R  y9 }& _# }( P4 D& t                save[i++] = *addr;- T; [$ B# o5 h- ~
                sync ();. ]% r  \/ Z' D
                *addr = ~cnt;4 v8 K/ K& H* O. x7 @
        }7 j/ @, I: X( K9 J/ }5 j; T1 I
( O  ]+ v0 L! z+ ]3 F' ~
        addr = base;
; N. w( j$ u9 e7 B. t/ c( Y3 q        sync ();; y0 \; ?) ^% t  c- t
        save = *addr;7 ^; j6 Y$ M4 m+ U" M: l# {
        sync ();0 m5 d! }& D* Z& i" ^  V9 D
        *addr = 0;1 B  {5 Z8 ]& w# t* k

6 D- A( e. J* T  l        sync ();
8 Q6 i- X+ y: }) t) V8 D. N+ [        if ((val = *addr) != 0) {
/ y& h' r- V: g% f( m                /* Restore the original data before leaving the function.0 y* k. r9 Q* p2 y8 {
                 */) E5 e* P4 `  I' O
                sync ();+ a, R( ^6 {- `1 I
                *addr = save;
: |7 ?" n& y! D/ c$ h( O. [                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
1 S5 }/ W- S- L1 {; k) T+ k                        addr  = base + cnt;
: T* N: J& _$ K8 N6 A( `                        sync ();2 Z" F- }" ~/ r
                        *addr = save[--i];
; \" ^& K/ [- m( b& h$ }/ ]                }8 t9 f, w& r* g! h+ f
                return (0);0 S* u' [6 G: [2 q8 B, q! S4 a- V
        }% S) U* r6 y; K" l" L

$ y. S' ]0 ]9 o4 o        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {) ?2 e( h* e6 _8 e, Q  x( Q
                addr = base + cnt;        /* pointer arith! */
* v/ q; |8 u& i9 Z2 ]/ ~0 p                val = *addr;
1 s9 }3 U* h0 z, h# a                *addr = save[--i];
0 A( y: ]& m8 R0 F' ]" l" I$ G1 `+ U                if (val != ~cnt) {$ P7 P4 d: h* f2 _" Y
                        size = cnt * sizeof (long);
4 o) U7 j8 b' N: \# x& T( [% ]$ @                        /* Restore the original data before leaving the function.3 `, [, W0 r. d" Y
                         */8 |- K6 a" W4 M6 q& g6 x# q$ _
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 [; f5 N! b; _3 C: _% f8 f, `                                addr  = base + cnt;( i- U! e# K+ t* C
                                *addr = save[--i];- I) g6 x# t4 g( ]: f. a
                        }
  i) {' w) f. \+ f0 D                        return (size);2 G5 K. Q9 Z+ \& _8 R+ @$ m
                }
8 d# f! j' X- U        }+ J& [/ q( q8 y; H
. @" d7 c* _: c9 E! @& n
        return (maxsize);
; \/ o4 {; ]" O8 L0 B}
7 ^  E7 @* y/ Y) ~9 O  q* vint dram_init(void)
2 z" k3 h3 @! q- z+ T" d4 `# L" m{5 i7 d9 ~- K$ D/ F, a
        /* dram_init must store complete ramsize in gd->ram_size */
8 y- }% }, M0 b5 `4 i        gd->ram_size = get_ram_size(- G+ m6 x. p8 {( k
                        (void *)CONFIG_SYS_SDRAM_BASE,
6 O3 R4 U( |; P5 d                        CONFIG_MAX_RAM_BANK_SIZE);1 C' s. l$ \5 s, R, ]9 \3 I
        return 0;2 J: K; i: q. X3 a- D- _' k
}, L1 n4 }  `! l; @& n

9 l9 O2 r! I1 G
1 S. k  v. ~) V& V0 V! T5 C4 u/ `& H: p/ S
2 o( y1 S; D# a- w% e4 D+ ?4 x- `
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!% v, c4 k- M) d( F; [# B  S
! o+ S/ x" X& c8 I4 q

, K9 ~! D0 o; t  S

/ r: s3 r% F$ q; e- x




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