嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit1 y( x% g# a$ v. c6 {: V. v; R
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
! `  V7 |  n* R; \" @. B这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
& P- R9 e- _. O% s. {9 M
$ n! \; x: c: V+ B2 F% K是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?: I& s9 `2 v2 ?7 G+ h  z8 [
3 S; F# R6 E; R& U$ N4 {9 ?2 U

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
5 f8 s4 \: x' S3 j, b7 I8 [% O4 @/*( j6 d# R" W* B
* Check memory range for valid RAM. A simple memory test determines
' o$ u* c) d+ x* A9 C* the actually available RAM size between addresses `base' and
( H" N( h5 d% n! |3 l5 y* `base + maxsize'.
/ K8 h. M5 M* C4 J*/
" X4 s- P  h. m* R; C, |) vlong get_ram_size(long *base, long maxsize). g+ J) Y7 P$ e! k' l
{. o; D% @; a# R7 @! _- y
        volatile long *addr;
2 c* e  x% a' _# X0 K1 u4 t6 g        long           save[32];! C/ Y  y/ ?0 U) P+ Z
        long           cnt;
, b2 a, s+ H  u4 y% R$ W        long           val;3 t# l. r9 V' a2 j! ?# n7 ^
        long           size;) i6 Q8 D! M+ s/ J
        int            i = 0;+ F0 s4 ?8 g1 T; _
2 s" v4 y; R5 U: M- S
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
. s6 q) g  n+ v. V* L; F                addr = base + cnt;        /* pointer arith! */1 x5 ^; L& F# l1 G( U9 X1 I
                sync ();
2 k0 R& s( ^/ w# a) j3 l3 ?5 F( {                save[i++] = *addr;! F$ [- L" \  N- U+ \7 P- G
                sync ();
2 d- z3 F, A; m                *addr = ~cnt;0 ]' \$ S! h- D
        }5 X' p1 f$ u* Q; a3 U1 Z% r
9 t  y8 u0 [) P& c3 H9 r, c  M3 I
        addr = base;
' X; s1 F8 R  z5 S' e8 y8 M        sync ();; Q& |. ?: D/ k/ W5 j
        save = *addr;7 c) }8 X: ^2 Q, c
        sync ();* O: x+ y' F) C) b: _8 w
        *addr = 0;
$ M/ u. W( l- M" ~: e+ x4 `4 j+ Y5 {8 L0 H# p; f
        sync ();
( h2 [5 h6 o7 A6 G        if ((val = *addr) != 0) {
; ^1 S; C: w- }2 r% V0 f  d+ ]                /* Restore the original data before leaving the function.; w- a4 f% Q# w/ g4 p( ~0 h. X
                 */
' B6 c6 }- Y! l0 Q# \% u& a                sync ();! H% U2 L0 j+ Q$ D' E
                *addr = save;7 F3 L- X5 H- I* [8 \% A1 Q( o
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {) Y; f. c9 [( p
                        addr  = base + cnt;
- O1 g2 Z0 N2 ~6 d$ M; W                        sync ();0 w7 W- ?( U- u7 o2 I7 l+ s
                        *addr = save[--i];  l6 T1 k+ I5 H  g1 j
                }
1 s6 [- B; X2 A7 s                return (0);1 M! b% @' @2 m1 D
        }
. M: n: D, S5 N; E6 @! O1 G  ]% M; M, \
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 n0 @7 O' X) Q4 b4 C( }                addr = base + cnt;        /* pointer arith! */# d4 ?4 i+ X5 ~2 Q; @. C3 v- I
                val = *addr;6 {# x  Z5 _! m. u! t7 o8 J* X
                *addr = save[--i];
" H  M5 G7 N) g8 n                if (val != ~cnt) {, }7 \8 ~: }' O% r+ z1 A5 z. y
                        size = cnt * sizeof (long);) P3 T8 I# _5 @( i! B  z
                        /* Restore the original data before leaving the function.
3 X2 _8 i: u' n, V, a# C* K1 c                         */
9 G5 j' Y$ V4 |$ `' R$ z. H                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- Y, J9 x/ k. l, y' O. J1 |+ E                                addr  = base + cnt;
, Q. u! \% j6 t* z/ a                                *addr = save[--i];
' W' e8 B% r6 ^                        }
* J$ x' T  @3 ~1 O8 O                        return (size);: k9 \: f2 G/ [( \3 ]) ]  {5 x
                }
" I2 D% H" p8 |+ g4 ?" p9 s: X: g        }
1 W9 Z* m  u  A' ]0 {4 J: W* ]: e1 ?+ h/ Q2 \1 L: E8 Q
        return (maxsize);: c6 P+ O/ S  j5 {
}( \( N; h$ Q: ]3 H, j
int dram_init(void)
) N0 m* y$ ]2 U2 m. N{
" k0 c0 S# z- X( Y1 J0 y/ N0 n        /* dram_init must store complete ramsize in gd->ram_size */7 H' e8 W3 V8 f% o* k
        gd->ram_size = get_ram_size(! ^! L" [1 D( M/ B1 f2 ?$ S
                        (void *)CONFIG_SYS_SDRAM_BASE,9 A# Z% f0 G' X* y+ Q
                        CONFIG_MAX_RAM_BANK_SIZE);/ m1 B" ~& _& h
        return 0;
7 q9 V5 }  w* |' b* D; r}
; Q4 M1 E$ _+ V9 K- N$ r- W# @6 L  {  L$ y+ i8 r, u2 o# q% b
& [& d8 \+ c; h
- f/ n, Z# o4 W. h( c7 v2 D% K

( M# a/ P7 D4 w. D- J( }/ bFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!! Q  K1 _$ [' ?# n, x' w: H. v

9 ^+ m5 r5 l$ ], v1 b$ n. U9 c/ J0 Z3 R( n! I- }7 U

& L1 p/ f, n8 f8 M$ @; U. W4 o; g




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