嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit# F8 A# s5 o* G, C! A2 ?) w
核心板2:DDR2 256M Byte   NAND FLASH 8G bit) Q2 N$ I: l; h* N& K' g* _
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?9 }0 l& f* N; ^- L, D8 O
, y9 t+ |' h5 |1 O  d1 O: q
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
4 K8 L2 @8 W8 f9 L
, _7 t  b4 w. e' }! z
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:8 d3 J  n8 I  z3 F" M
/** U2 E7 t. n: t' k7 V- Y, s
* Check memory range for valid RAM. A simple memory test determines
8 Y) _- R! ~3 m8 r% {* the actually available RAM size between addresses `base' and
* y7 B$ Y+ q5 s! S) L' F* `base + maxsize'.
6 P2 C7 e/ B( v2 |! X; t8 i*/3 [3 S- L7 I$ ^' a& R' |& z0 x$ U7 N
long get_ram_size(long *base, long maxsize)
' b5 [/ u8 l% C% X5 H1 l{
# w- C. {  s' E8 J& J$ n9 z        volatile long *addr;0 |3 v+ J$ Q( M' }3 n
        long           save[32];1 D; S* |% L9 ^! p# w- F5 E
        long           cnt;$ }% b$ \2 {* a% U, h$ p( T
        long           val;
( t5 N* n' W% R( p8 G% V$ A5 ]$ z0 Q/ u        long           size;) P  Y% P) k$ d- @
        int            i = 0;
, O1 D, Y3 q$ x! M& S# O3 [. G7 h7 r+ d& z( {( d# d: n9 e
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {- x3 Y; e) V0 f0 D2 t+ q* ?3 Z
                addr = base + cnt;        /* pointer arith! */
) }- |- f5 Y" {: O; O/ t                sync ();0 X. V+ X" s" n3 T$ N9 B1 ]7 g
                save[i++] = *addr;: c/ u% o; c5 k( f6 \
                sync ();
2 `, F3 s7 B& `' u                *addr = ~cnt;
! y) U6 V4 _3 u: R9 s9 S+ B        }
5 i$ ^2 x0 P0 @! i( A# s- B2 a! ]2 D, r
. `" C2 z0 h( }+ o) Q1 W1 I        addr = base;
# U6 L* [5 B* F3 C3 M& y        sync ();
3 x. c3 T8 |; c5 C) V7 z8 g+ T( K/ C+ G        save = *addr;
) B* N  ^( N% `( u        sync ();* o, d$ w) O$ W8 Y! g
        *addr = 0;
( \9 H  A5 c3 i9 ~5 N! W/ Z
7 j1 l: C9 m' P        sync ();
2 K! H) q4 s2 j- h- ]! F        if ((val = *addr) != 0) {
3 s8 Z) y) \  f( N' S: |0 B                /* Restore the original data before leaving the function.9 \( T+ ^: k# C  Y
                 */
/ M" s) ?7 g, a* [6 G. N& S                sync ();
& y" K6 H5 q  }, B                *addr = save;2 z( y- o2 o7 q6 Y  a( C
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {' r5 o" X0 Y7 _# Z3 {2 \
                        addr  = base + cnt;
- Z9 n8 x' ?; N+ l# o                        sync ();
& J& Y7 X9 d0 Y6 f- h( K! C8 W                        *addr = save[--i];7 B/ Y- b4 T) G* q; C( ~# O
                }( \3 r! K' k0 f+ o- A# F+ n
                return (0);! a7 B; h4 I/ j) ^/ a
        }
8 ^0 b9 w4 P* z  E' z+ r$ M' P6 k1 K$ e, A& D
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
4 u6 ]# d. V, _% W; T% b+ S                addr = base + cnt;        /* pointer arith! */5 b# _9 d3 z0 S. |5 v
                val = *addr;
) ^) o" d, ]/ w1 \                *addr = save[--i];
$ N& K: K( I/ a" j* d                if (val != ~cnt) {" V0 ?% G7 t4 p
                        size = cnt * sizeof (long);
' e5 z; p0 k/ j, o                        /* Restore the original data before leaving the function.
; `. b+ p# H8 \  V/ s5 F                         */
+ v& ]. J0 |& H' h4 |+ Z                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
# m8 h& u) V' g- U5 X7 w. K4 m                                addr  = base + cnt;
5 w7 e! ^% L+ W; Q# N                                *addr = save[--i];% l5 U" R2 l$ e: Y5 c  \
                        }6 H" ?) W  H: k& ]# l( \
                        return (size);9 _2 j9 D8 o% ^/ C" g
                }' w' O* |* l3 C5 [# a1 h% R- z) U9 I
        }
$ r; i5 @- O* f. T* I+ A" U: p' n3 q6 {  n% V9 i
        return (maxsize);
' F& u: S. s5 Y' {4 Y}
% P( R, r/ a- }int dram_init(void)! j6 Z+ V$ a# k
{/ Y' N! ?* `! x& a
        /* dram_init must store complete ramsize in gd->ram_size */
! T7 ^8 R, G) ~( f7 \: y        gd->ram_size = get_ram_size(4 x* B# o6 \) N
                        (void *)CONFIG_SYS_SDRAM_BASE,
/ r+ ]  Z7 T3 n# R  p2 x/ z                        CONFIG_MAX_RAM_BANK_SIZE);
4 B7 g+ f. q, r: g8 s0 n        return 0;
$ H0 t6 Q9 g4 H5 P4 l$ ^) \+ f}" f& ^/ k3 x8 K; A6 T

4 r3 e6 b, M7 c. W% o( |7 q% @  H4 e- E& n* Q1 V# R: O4 g& E+ A
+ B* v& i3 {" _. V' M! t

/ m" A- H  B! @0 qFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
- }: @0 o" N2 E# e# Q. d# k/ O% ?3 k, S# Y* h6 c3 A. y+ A

" V. m* Q, S' p# B
& L3 R/ [; k# s/ Y





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