嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit) N7 N4 W! B; s0 x& Z
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
( A3 z$ j( d. ], A这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?" q* k9 E: S; O( U: V5 X! `
2 N, J9 K6 D  B9 f
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
$ O2 M; i$ ]9 ?: [! L8 B" y/ b* Y* d

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:& u- {2 ]: ?/ e1 K
/*
! s; L5 L3 V, g% W! V- M* Check memory range for valid RAM. A simple memory test determines
# S! e0 I" ^0 s/ i4 a* A* the actually available RAM size between addresses `base' and
  L$ x6 z$ m* d% C4 }  e4 s* `base + maxsize'.& Q/ e: R+ X+ k2 _+ R
*/
0 D) d. N& `/ G8 ylong get_ram_size(long *base, long maxsize)7 ?2 m5 ?- n) s# \
{7 }) j, C. a. e2 I. U; K6 O' |
        volatile long *addr;
0 e/ d6 \9 s0 \0 e" `- C( f        long           save[32];  W; B4 d* f  P. u# F
        long           cnt;
& F7 ]" w) E7 K1 `$ x( r        long           val;
! }3 T- S! B3 \& h4 J2 u, V" k% A& K# ]        long           size;
. i7 S, r  I7 u" ~( P8 M7 r" g0 K, q        int            i = 0;- f0 V2 W% S8 u

) L/ O: W2 c1 W6 g1 P        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
+ T5 X! b* \( K8 O                addr = base + cnt;        /* pointer arith! */( N9 z! J: L! b
                sync ();3 C6 h- g0 b/ L% u, C7 o
                save[i++] = *addr;
! D. @/ ?4 V! V3 n) V8 k                sync ();3 F) F  i1 G: G% {9 I- }
                *addr = ~cnt;
" P9 D* J7 q# M7 j/ |4 T" t; L# J) f        }
) g1 {3 ?) M8 F* l& }: V8 _2 t/ G" @* }3 J1 p
        addr = base;' I# I. P0 B) Q0 |
        sync ();  s9 m) v. h0 P5 |2 r" @+ v
        save = *addr;
1 s- J/ B. N0 x        sync ();
5 {8 s, G3 {5 M3 ^/ g* O        *addr = 0;/ z. F; s3 ?, \. V# N

" A6 ?. K  B- t: ~4 f& r        sync ();' O0 h: e4 F1 K$ Q9 n: Q3 z8 p
        if ((val = *addr) != 0) {
" Y1 |" s8 s. J" e- ~  C1 |; P7 l. }                /* Restore the original data before leaving the function.) q: T+ K" J4 K4 h) k* n: C
                 */
/ k0 W5 c9 a! ]% u# W                sync ();
1 A. w; o) a8 u  M, _5 l/ V# e                *addr = save;
, p$ e+ W/ v9 @3 g                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {! L1 z9 F# ~& W% W
                        addr  = base + cnt;
' A2 u) w6 ?3 A! D. u                        sync ();( C/ S- @; z* Q* v* q
                        *addr = save[--i];" d3 A1 ^. ^. e5 @, ?; `: C
                }3 ~: H% A0 B" ?, d
                return (0);
/ l9 ?7 l# ~) x; g5 N! s% q        }* F) s; m3 X/ H4 |8 b& x, X8 T& Z

) w( A; R0 m+ k: l        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {4 V# u3 s% `# p& h. P( l
                addr = base + cnt;        /* pointer arith! */
; T! Y7 Y! o# f) Y3 z' S                val = *addr;
: \5 }  }8 L5 g' ~  F                *addr = save[--i];/ d9 j1 x- M' @
                if (val != ~cnt) {
8 p0 E% ~# G; f8 S                        size = cnt * sizeof (long);4 L5 j7 x  h; h/ k
                        /* Restore the original data before leaving the function.
5 x5 c* {" }3 C2 a# p8 `. A                         */
- [  G1 V) R8 K                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 g& I6 l- J1 |7 p4 w                                addr  = base + cnt;
4 J7 w* i9 L6 o( m9 w                                *addr = save[--i];6 y1 u# z- W$ R
                        }
, Y, z5 s5 x' ]; b                        return (size);3 ~4 c+ H$ x4 }3 @
                }
/ X7 s0 a8 a; v( z+ a& ?& T        }
& o: H$ }. z9 J! M2 P% ]1 D( ]& m+ y; I
) V! Y% \; v, \1 d$ |9 R        return (maxsize);  u. M: @0 N) E% U5 M
}
6 E: r+ T( G  w, t) lint dram_init(void)
- b0 A8 \# W& N0 _7 |) g{. o2 q" k" C, x# e) s" @
        /* dram_init must store complete ramsize in gd->ram_size */
( e" U# w- a* ]8 V  a  x6 H        gd->ram_size = get_ram_size(
( K3 i/ d5 j: _* i                        (void *)CONFIG_SYS_SDRAM_BASE,5 D8 k$ S0 F' E: }, H; }- ]! o
                        CONFIG_MAX_RAM_BANK_SIZE);
) D* l! s* J; t# e6 P$ U& a, V        return 0;* v+ U, ?# J6 n9 }0 n
}
: Z' F' c' a8 ~) I! R
5 o0 N3 M- c, R# r( I3 w. a0 v( B  {: V* B

( q4 c: F4 i& \  y$ ~( {1 X
) P& s8 j: ?: fFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
. [2 |2 T: |0 C# z9 d6 O
! ~) G5 b9 ~5 e8 z
# [) p( z' J+ q
( Z6 C+ k; x( B1 Q- N





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