嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit/ ^; Y) T6 \% S0 d7 {. u+ u5 ]
核心板2:DDR2 256M Byte   NAND FLASH 8G bit. \& l  m5 _# h% E+ X9 T( {
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?! {7 {( O2 P, t$ L# \

9 `7 g0 S* m2 `是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?- \7 q% j' H% w5 \9 s7 {: q
* y/ K( S% p! {' w: R4 V

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
5 Y  r( M$ r0 H2 a* l4 g/** M' Z: V# Z( N0 e
* Check memory range for valid RAM. A simple memory test determines; x; j, a3 r1 R) u5 i
* the actually available RAM size between addresses `base' and
0 w. k" e4 s; L; w, G* `base + maxsize'.1 p$ o% w, S, Q# b; f$ f8 ?
*/
( G$ F6 n& R- s+ o: X: G* x' ulong get_ram_size(long *base, long maxsize)9 T9 N/ I. B1 P6 G
{3 ?* {9 ?! {. s( A+ K
        volatile long *addr;0 O2 g9 e, Q3 O2 l6 I) x. r0 W
        long           save[32];* c: c; T. z% `% p2 ^5 K5 T
        long           cnt;& M* m9 S6 w0 f, q6 ?. E( d
        long           val;
0 [, p0 E. w' O8 h        long           size;/ Y7 ]9 X, H! r
        int            i = 0;& A/ o2 e8 k- f! J, d8 ?7 M( @
* _* D' g2 I6 d3 u4 h1 e) l: ]
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
/ P3 ?) z- G" t) l  t                addr = base + cnt;        /* pointer arith! */( j$ u) x, G6 z: V7 ~' B9 S
                sync ();
2 ?- U. ]. v+ J2 n                save[i++] = *addr;! X; j  _! x9 B9 R. @% G1 o
                sync ();0 V5 T! ~( O6 f! |
                *addr = ~cnt;
6 ?) o4 K7 a% S. O        }
) D! n6 J3 ]: g6 u, H  s* B
+ C  O& F! U* i; V, f- d; |/ Y        addr = base;  O$ F: e0 \3 o; Y* _
        sync ();* i, _3 x  L# y  ~1 n0 P2 k1 Y
        save = *addr;, u) e! H0 [* K( Y! N  i
        sync ();( J. v% V% V; E5 P3 d2 X
        *addr = 0;
8 W1 @( D* r0 l4 U1 s+ G% I4 N+ W6 M9 D6 x8 D  Y
        sync ();; F+ V( x0 T! @; p
        if ((val = *addr) != 0) {  L2 t8 J  J4 j  ?" G
                /* Restore the original data before leaving the function.
: R5 H4 _0 A# B7 i. q                 */# A: h1 a7 P8 s2 k# e2 p. t& C1 e
                sync ();2 ]  w- t3 ?1 f! z$ M
                *addr = save;
* H+ I+ n: i7 ^* Q" Y$ Z                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {2 c" L! @9 x: ]5 J
                        addr  = base + cnt;
1 p1 ^" O" C) ?                        sync ();
+ ?! Y+ J2 m) G/ V3 i, y                        *addr = save[--i];$ q7 A6 d9 g2 J5 H, P2 Y& z
                }
* t6 B0 h+ j8 w                return (0);
0 F, ^) U" Y: ^& C$ H        }
! I1 x# V# w& p3 b. m$ a0 i: t6 O/ T
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ y; K1 E$ V& A8 o+ W
                addr = base + cnt;        /* pointer arith! */
% Z8 {. g- x- L6 G                val = *addr;
& c6 E5 S- M" h3 b% L: w                *addr = save[--i];& S! a+ ~  R* A3 Y
                if (val != ~cnt) {
2 m0 \, h. u8 A5 B9 F! h& B                        size = cnt * sizeof (long);5 I4 T  b( G* M+ {9 s1 T
                        /* Restore the original data before leaving the function.
+ \4 {2 g# f8 a                         */
  m% s, x  u! V8 o9 V* S                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {% M; K$ ~0 ^3 f& E- r4 W
                                addr  = base + cnt;
4 B$ Z4 b) I/ ?! \% G3 h3 G1 `- n                                *addr = save[--i];
1 A% y/ Z. s7 v% i$ U- X                        }
; i9 `2 H. A/ B0 q' L9 c                        return (size);
$ l" R0 _6 d3 N. ?                }
( t& _: C$ _! L        }4 b# g) I) f5 M- `. U9 [9 e; W* t$ l

, N% C+ w! @( G: r1 x        return (maxsize);
8 Q7 c0 r( i- a4 T}
: v  r5 A# D9 Y, B7 y- ?int dram_init(void); b) A/ q7 A" d& {* w! b6 Q
{
' b. T' N9 D, ]) V' \        /* dram_init must store complete ramsize in gd->ram_size */
8 ^/ k, h( t8 J; G2 S        gd->ram_size = get_ram_size(
* r8 R6 S# O& @2 Z& f                        (void *)CONFIG_SYS_SDRAM_BASE,& N# E/ t: d; s; r" A- L
                        CONFIG_MAX_RAM_BANK_SIZE);
/ R! \) ]" |: G0 J; \5 m        return 0;
7 v$ P; n7 o5 O+ @' S}3 g, H4 q+ Q& `, l- r  E( ~
+ F/ {6 m7 k% d% ^) q) ]3 @7 [

8 l1 z7 ?$ H$ f3 R' Y* W8 b! @. j- w( q
& b& G( a+ }$ q; }6 `( X
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!, L) e+ ?! k) X8 e

# G6 V0 H5 `' G  ^8 y; W5 P8 o: |7 I3 D' S( h

. X6 h  c/ ~8 o4 k' |




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