嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
, k* g- c2 x, t/ k核心板2:DDR2 256M Byte   NAND FLASH 8G bit
3 E" Y9 c6 b  f7 ^4 Y' Z) W; s这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?; R$ I0 Y  W. C4 }/ z3 v0 T
. r! T1 ?( O+ b: L7 I8 e: T
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
9 ?- m8 a4 o8 r* b6 o* b+ m- F+ O9 Q, H  a) p

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:4 t: F' l0 @) ]% V2 p( a1 G; m& V
/*
; g* J6 f1 k3 D* v, J* Check memory range for valid RAM. A simple memory test determines
( R" k& g! B( l" ]# k& u1 j* the actually available RAM size between addresses `base' and# B# b! j& ~  u' Y
* `base + maxsize'.
4 I! |% z, b6 P* u# e' ?*/
! M9 {% g9 b! I2 f1 Plong get_ram_size(long *base, long maxsize)2 h  S3 h5 T1 l7 f) n2 _* t
{, x( Z$ C3 n0 }% f% l
        volatile long *addr;" r1 P, i- b0 B. b3 i
        long           save[32];: d( K% N+ j! t9 L7 i9 @0 k9 B
        long           cnt;* ]! Q7 y7 S% p4 d  {/ s
        long           val;4 N7 P( b1 Z% I& X4 m/ ^! Y
        long           size;% ^$ f9 j. E2 j4 N
        int            i = 0;
7 r- k( m6 R5 V+ z  \. B/ o/ L$ t8 o* Y8 F0 I
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {2 J7 z$ ^+ v# y! ~+ w( J
                addr = base + cnt;        /* pointer arith! */: D9 R  F0 f6 E
                sync ();. e0 I7 ^" ^$ v5 w) f
                save[i++] = *addr;
/ Z" q& a" y* l: w                sync ();& ?; K3 ]6 ?6 I, @/ S
                *addr = ~cnt;2 Q" \# ~. n2 @  m! |' F( z7 s2 G* `5 Y
        }
* M  U2 H( Y  u$ J# u$ s4 l* B2 y9 m9 u0 f# G6 _0 Z9 k
        addr = base;
; D" C$ I0 F8 ~9 [; I        sync ();! q0 ~" j) a6 R3 o; K
        save = *addr;& Z3 j5 _& y6 i! [9 N
        sync ();; g, m7 a* I3 C" G6 ?4 W" s# q
        *addr = 0;
3 Q3 b' `  x0 K$ t3 n
' @% r. n9 n) W% T/ i. X) I        sync ();+ c' T9 o0 T1 B* E7 s9 q+ ~
        if ((val = *addr) != 0) {$ w3 T3 V6 x. Z$ B" r3 B9 q2 s, c
                /* Restore the original data before leaving the function.& j+ Z- o" N7 D$ o6 L" h! `+ x# C
                 */; v* D# R& @0 E( Z
                sync ();$ Q5 s: O. W9 H/ {" \" V8 }! Y
                *addr = save;
% U5 G. b5 e- m6 M8 B                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {( _  l" ~+ \/ H+ c
                        addr  = base + cnt;" i% Y% ~6 @7 C' c, M
                        sync ();
. K3 y- L: P* V( j- U! ?                        *addr = save[--i];8 Q6 Y/ K2 i: ~) s3 e$ i
                }
5 {9 ]) \; }$ s) k& Y                return (0);7 M- y# g' x! |  w: z% p
        }4 e$ T4 m. [" ?
- U5 }$ J: V. [: \3 e! w
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {5 ~) h5 b; _+ i8 c0 K
                addr = base + cnt;        /* pointer arith! */9 Y: w& e% J4 D, G
                val = *addr;
9 ?6 W! y; R: U) K  x2 }. g0 k1 g                *addr = save[--i];9 o, w8 }! J8 E2 P4 o
                if (val != ~cnt) {
( B5 L. v* v; J" u9 {8 n" ^* g                        size = cnt * sizeof (long);
! L0 q& T7 J2 P! s5 d  x5 l                        /* Restore the original data before leaving the function.4 D' D6 x% s9 j' a% A. {
                         */
/ L' }% J% U( J6 d; q                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( k. t% a% g8 b7 V                                addr  = base + cnt;
% T! a" Q3 Y6 M( B                                *addr = save[--i];( X# ?! R! o" r) @3 W4 |1 F9 B
                        }
# U+ V) R3 a* P6 ~2 X8 X                        return (size);
/ L  [& f4 j/ n5 J1 Z                }
9 ^/ t% J2 U* g6 K* D* N$ S        }% X) i8 w( [$ f9 b2 C' _3 z

2 f* f7 H: W) ?" Q        return (maxsize);: a( N4 ~3 Z5 o( Z
}
9 V8 t6 Z& w/ J5 F% Vint dram_init(void)
% C( x5 P+ _& z0 I) s- _{. b( ?$ y' _5 b
        /* dram_init must store complete ramsize in gd->ram_size */6 M" }: u7 ]9 O
        gd->ram_size = get_ram_size(& j  `% ?% i- S' x8 E' c
                        (void *)CONFIG_SYS_SDRAM_BASE,
; \8 X, b9 D3 T, I) k                        CONFIG_MAX_RAM_BANK_SIZE);
6 ^6 ^2 d# u5 V) }        return 0;
- K# V; D5 t! i9 N1 w}
  D9 ?  u$ l9 \7 P; f2 u1 `. u, j5 ]: w- Q- W0 O8 \  _
9 O8 w+ y) b3 \2 |/ L' a  |0 E

' w* R# p1 L" y9 z' c9 l& J
0 P% F1 f* S* P, f( ^2 {FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
; h- W4 s+ d1 q# G5 z$ e
, r- G- Z% Q# e5 y- }6 H4 i6 K7 C

3 e$ Y, g# M, Q3 l, n




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