嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
" V. Q: X) B$ c4 c3 X% ~, h% [核心板2:DDR2 256M Byte   NAND FLASH 8G bit) h; |: y& O) t3 }3 b9 Y
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?' z- c# h& _2 H, W/ k4 v
8 ?9 D( a; @& }
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?7 h2 R) W# q) W6 N. l
/ s6 d: L% E# U( V0 A

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. K  |7 ]2 [; \. l, t/*
' ~& A& S$ B' z# c* Check memory range for valid RAM. A simple memory test determines) P3 a7 f" B! B' S$ D! `; S
* the actually available RAM size between addresses `base' and7 R9 d: c, q0 W0 }" ~" N
* `base + maxsize'.* K* y# ?0 b* A" w' e( {) i6 K' e0 @
*/, G6 y# }1 t2 j% @
long get_ram_size(long *base, long maxsize)
+ b1 p1 J. v  r$ {5 t7 l{
) A: U$ k/ u- o  c: f        volatile long *addr;
' _. V2 u! @2 J' L4 `- d3 x. P        long           save[32];
5 h8 N# y+ G+ {        long           cnt;
- W+ f$ U: B7 m" q; Z5 j- }        long           val;
) M2 i' `4 S: H5 E% B' S/ G        long           size;2 V2 r6 L! E4 y1 q" h: x  E$ l
        int            i = 0;
/ W' H  L2 }9 u5 ~9 x1 ^& k# Z; V
! b4 O* o% Q$ o) @* P        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
2 W4 m& V* N2 D9 R! _% Z                addr = base + cnt;        /* pointer arith! */
" e- w: W1 z* d, W7 _                sync ();9 [- c8 L0 w% [4 |2 n1 {# H
                save[i++] = *addr;( f' t" s: ^7 A9 b  s
                sync ();
9 V9 b! Y0 u+ H9 @9 o                *addr = ~cnt;9 T1 K; E7 ^" N5 j$ M$ U
        }- `3 G. E) P9 K' E' |
; B8 u/ g, s+ h* K0 [) r
        addr = base;9 H: i3 w1 p" F3 d' m
        sync ();
' G8 {0 ?& Q& s5 v/ E; F! D        save = *addr;0 `+ u' |5 H1 D5 j4 x
        sync ();  J5 x* S! p3 y. R/ v9 C& ?6 ]- x5 T
        *addr = 0;
! k- X' H: \- z( X! M3 ?/ m  c
% t+ u$ i; P3 f8 ?1 p+ [        sync ();
$ `$ U, n# S% }  {6 M        if ((val = *addr) != 0) {
' z2 m: y! W( b4 j9 R4 s/ W9 z                /* Restore the original data before leaving the function.9 ]. w0 `6 t  `3 {* r
                 */
; @- |, F. K8 ^$ y# U& s* _                sync ();
  T: [2 \* r- ?. H! i                *addr = save;
( Y) t1 X% ^: A& o' W& [                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 }) p9 r6 j8 P/ e) I: V$ v( F/ }: j                        addr  = base + cnt;& x8 k- B' I  ?$ J8 f
                        sync ();. h' F! \9 Z1 y4 y# Y" \: X6 f
                        *addr = save[--i];
6 u1 t- B# f  A, H9 g  v. l  M                }
. i6 X# c( u1 r                return (0);
) H- e8 W6 f/ l        }
; r2 S; x. B0 ^: ~7 w. p* v+ h( g; Y- G6 I: e
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {0 f! u0 \0 L1 Z: d/ v  _
                addr = base + cnt;        /* pointer arith! */: E$ `! q7 x, |
                val = *addr;8 T1 j8 E) M. _. ?
                *addr = save[--i];8 P& L  x( x; z& q  B' {; h# o2 i* [$ c) L
                if (val != ~cnt) {  F: B  _7 g( P: N& t" H5 c- f
                        size = cnt * sizeof (long);) {* ~7 u" V6 r
                        /* Restore the original data before leaving the function.
$ U3 U7 A! g2 B: C                         */
6 {9 f& z: l6 S- ^' Z) t                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% i' h2 {. Z' ^0 T' x                                addr  = base + cnt;; R! B$ d" I+ i0 b! n) Y: j2 G; U
                                *addr = save[--i];
+ k5 w* [, z6 d* V                        }
& ~# Q5 l+ b* e. d  Y                        return (size);
8 e% ~" v2 Q2 |9 F5 _2 l) P                }
1 X; c+ e$ y# g6 ]: T, p        }
4 n1 N* J5 M2 c. [# d( ]/ x, }5 |7 J1 n8 K* i, S. W
        return (maxsize);
+ w" B0 E. e1 g  |+ k5 h+ O2 l}
5 [# p; F3 Y' A& r& S1 lint dram_init(void)
: U2 z( i) x$ ~{# f& [% b; B1 |
        /* dram_init must store complete ramsize in gd->ram_size */
7 ?" \4 }" K% \% ~9 y+ {4 `        gd->ram_size = get_ram_size(5 x8 [1 \% j) \, N
                        (void *)CONFIG_SYS_SDRAM_BASE,
- Y0 h" ]) i* t+ P                        CONFIG_MAX_RAM_BANK_SIZE);
. [3 Y- i: U; P        return 0;! D: ]1 T. N1 Y" ?  R0 c
}& x" _; G" j6 o

8 L, y+ r/ ^" U8 s6 C. s' Y$ k- G; i

$ g2 _: F4 f. R
4 |3 T, \% ]8 P$ uFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!& Y; }, ]+ y5 F" p* S5 N
, a4 P. x' s+ x& Q! `  \, w

( G  J) J0 `: ]1 b

! P0 X9 s: y; [




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