嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit* z, O$ F& R6 A" n5 z' \7 |7 U
核心板2:DDR2 256M Byte   NAND FLASH 8G bit* i5 h: ~% h3 Y6 |1 z: T0 T2 w& h
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?# a  [) g- Z" U: r# d1 L

+ e1 s) Y; |( l: e是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
' ?& X: A) c) F" T( |6 L; L4 p( ]) p" X

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:$ x' ?- b9 m" P
/*& \8 c8 X; S7 S! V% r( q9 P
* Check memory range for valid RAM. A simple memory test determines
+ K+ W+ F  Y5 Z4 _- R: S* the actually available RAM size between addresses `base' and
9 @: R0 R2 a! H* `base + maxsize'." ~$ a! b+ P+ c4 v7 r
*/: y/ E% Z3 P3 S
long get_ram_size(long *base, long maxsize)
; J) A5 F' E/ e* V# h{
# \+ E" v0 ?2 N6 ~8 S        volatile long *addr;
" d8 x8 f# C; f) t4 d+ t) N+ H        long           save[32];) I4 D, S6 C+ n3 U: I
        long           cnt;  Z3 k6 n0 J" Q  v' e1 |, o
        long           val;+ V& K4 y/ r; s
        long           size;
7 ^) C1 J+ d3 c* K3 u        int            i = 0;
- }* o  h4 R1 n- h; N  o1 R) W+ x4 S
" m* l! i- l& R4 @* H        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {) C0 B% ]! v6 H/ }- I
                addr = base + cnt;        /* pointer arith! */
# E6 h/ k' Z! {* t7 n                sync ();$ s3 y" l& @5 m
                save[i++] = *addr;: t* i3 c, R& v5 Z, X) {) |) m
                sync ();  H9 y3 h0 }, y  H) @
                *addr = ~cnt;
7 |( j, l; u4 l2 |! c6 _) V! P        }/ {/ l; b% y# n5 S. Z/ G* i
; ~* D5 W* U9 D; \( z2 ]
        addr = base;% V" m5 X; U* T$ w9 C
        sync ();7 ]# u  l: Z) f7 |
        save = *addr;
! {7 a  I. C1 E' e' o% E        sync ();
) L( j! I8 X" |        *addr = 0;
& N$ t/ L7 k8 X- C
: C& u, d/ U) V5 p        sync ();3 }! `% y' U& t  @) P
        if ((val = *addr) != 0) {
; B! v+ U/ r: ~! t3 U7 w7 y                /* Restore the original data before leaving the function.
6 t1 ?! l: Q$ ?                 */
' S  x% `' `; F& L  X1 j                sync ();: B5 i; }4 m) o% e4 ?
                *addr = save;: _% k, Y  A( c* e4 Q  C, a) |
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {/ [5 L0 U: Q$ l
                        addr  = base + cnt;7 f& ?; w2 n7 L: ^0 ^
                        sync ();" H5 q0 }; Y2 T' ^+ E& ~& d$ |
                        *addr = save[--i];
( O0 l# o7 R3 {5 K" o# U4 E                }1 ?) s9 v* N/ W1 H0 e" Y  g
                return (0);- S" Z& I4 u$ y6 J
        }- \. O+ b- j% e4 \
: r9 [+ @- B; F9 N
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( L: I' m# B" [$ V% Y2 e                addr = base + cnt;        /* pointer arith! */
% ^% w* T" Q# k& ^- _: T                val = *addr;
- N- `0 Z- Z: s                *addr = save[--i];) R* ~1 z- B3 W5 U# ^4 s
                if (val != ~cnt) {* E: L: e- e  }2 W
                        size = cnt * sizeof (long);
# G" H( L8 j& C9 I  a- l% x) j  A                        /* Restore the original data before leaving the function.
; N# U+ u4 }/ X8 F) @9 A6 [$ z; E# v                         */* t+ S0 U8 J. P. M9 F6 o2 b
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ `# _2 f) O5 l) C' s/ P3 K! N& |4 l
                                addr  = base + cnt;7 G: i* l; g% ]5 X* ~
                                *addr = save[--i];
; o# F9 _3 ]: ]8 ]' n5 C+ Z/ I                        }
9 m0 I6 q) f4 a/ h3 Z                        return (size);
+ M- ~# }- j$ _. |                }
- X" y* b5 {$ J        }
( i1 Y' G2 ~5 P7 Q( D
' l- h) c& t  X. h        return (maxsize);
" n- H: a+ m! Q$ S( u" R/ ?. `' E3 v}. Q7 v( U2 ]5 {7 c- r% W: t7 S
int dram_init(void)
" @1 G" |: h% L9 s5 z# C{& m" L0 P( W  M
        /* dram_init must store complete ramsize in gd->ram_size */
0 b- z6 J) ^% `# e( _, \, v) Q        gd->ram_size = get_ram_size(
: F# {# }9 J. M; V                        (void *)CONFIG_SYS_SDRAM_BASE,
6 e2 \. V7 X9 E+ s+ y% i6 M                        CONFIG_MAX_RAM_BANK_SIZE);+ q. w6 K$ ?# E3 Z0 m- F9 Q3 W
        return 0;( s5 G5 E( y& C7 O3 @" K! g) V
}
; M& k" n, ^; m& L3 G# }% [+ b8 Y% ~* V# G$ @  H
+ b7 D- X6 m8 b, W& q
/ S( v, _; |7 N4 U, M

- m% O& M/ s5 WFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
: x& t/ z' a1 c2 O/ x) _6 u$ J' z

# d$ b+ p  q% w6 l! w

7 ?) u, ]& Q6 O3 o5 Y0 w1 D




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