嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit+ F# N1 p& @' C
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
% O2 b3 h" U  k- [这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?3 \% J! e5 |& h: N1 ?0 L& q' E# r
& z: r$ H2 E3 M, e" a
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
2 D2 W: B5 C3 b) L' D+ J6 W' `' q5 c! ^9 [- B

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:% F# R: Y' o& d, `  g
/*
3 G+ [& b5 K- ]9 J* Check memory range for valid RAM. A simple memory test determines
  }, S4 F/ l/ x" d6 Y/ n* the actually available RAM size between addresses `base' and1 L- t! K% R9 ]
* `base + maxsize'.
' p4 O3 g8 z5 e9 }9 g*/! ?8 n$ X5 v" f; }
long get_ram_size(long *base, long maxsize)
+ H! ?0 a( i- L, D{
: ^& K. X  O% j8 y  `7 ~7 x9 Y        volatile long *addr;6 B$ b  s4 y& r3 v# P8 W
        long           save[32];
! g2 S. _: ]. o) z4 Z! }1 A; T6 d        long           cnt;3 k! \0 C0 G' L7 b
        long           val;7 }6 M4 x8 E6 \( c. ]
        long           size;. ?: S8 T* r0 a, p. a) R
        int            i = 0;/ H6 s6 t8 i" T& d/ \9 m  ^( T* `' x3 K
$ J- ~; z7 s3 T) |6 y8 O
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {% C& g' L, c7 ?3 W- s5 A8 h7 Y# g
                addr = base + cnt;        /* pointer arith! */$ f8 l5 _9 a; Z- h" M% ^( t9 F
                sync ();* N- \* u7 y3 d4 W+ L
                save[i++] = *addr;
0 _/ F% Y, I; X4 T$ @4 F                sync ();+ P4 d% V) V4 \+ w$ @: [, y9 A
                *addr = ~cnt;6 a3 [( a) l5 k2 b; E
        }
6 @2 t2 c8 g! W9 ^$ Y; g
: W2 e- y. {4 X0 g: @        addr = base;; j$ n' I. l$ A
        sync ();4 p' p& E; g+ A7 w
        save = *addr;
* b2 C# J& V+ u, S        sync ();) p& K  @0 |9 p( i
        *addr = 0;" x( Z% u" _! _) Z* D

; |7 ]" e, O: Y5 ]# ~  H! `        sync ();
7 e4 J, |* m2 {9 j3 y9 E7 C" X. z6 J        if ((val = *addr) != 0) {# L0 u$ _6 A/ ~* }9 x
                /* Restore the original data before leaving the function.
! Q& D7 g* F' K, m                 */1 m5 [- j; f1 d. f
                sync ();% f% S  h  z7 E" f' D
                *addr = save;% S7 Z) e& f6 v- y# X, @+ b6 V0 b
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
8 {8 D9 A  t$ r                        addr  = base + cnt;
; H: S" O( S  C                        sync ();' }8 Y$ ~4 w3 W2 n# s
                        *addr = save[--i];$ i1 P; S9 x) W7 l) H% o5 J
                }. P  K# r! r7 @+ F% C
                return (0);
1 K8 K' a* e( ?) B) Q        }9 b" F3 K  v' f( I; l! e% K5 A) ?
' k1 [( E4 ]  L6 `9 [; G  B
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
6 x0 K6 S# ?  o9 l, Y                addr = base + cnt;        /* pointer arith! */
; o0 ~  ?  z" f# m' m, X# T! H$ v                val = *addr;
- L) k( M2 d: W' k8 h: P, S                *addr = save[--i];
& ?/ j( [+ t: {# `2 ]- n) C! |) s2 w. v                if (val != ~cnt) {: L( G# s3 q5 t3 r6 N5 @5 a. Z
                        size = cnt * sizeof (long);
" R4 M: d+ X- T) k9 E                        /* Restore the original data before leaving the function.; P' z7 ?/ y" D1 R9 k0 S% Y
                         */- E- z  v7 R! J  ~. ?/ X
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {& k  L, R$ d! z* S! ]
                                addr  = base + cnt;" a/ Y: O4 B* V' W6 |* N1 }" b& i5 W3 k
                                *addr = save[--i];
6 L$ `2 p( u  M- t. S6 E                        }
3 R  w! M, l  L. {8 i, a8 i                        return (size);$ o, {1 }4 o4 Q4 W: L! h+ @8 @$ }+ h1 p
                }5 |9 n2 g/ ~! N- E! }  `8 w* x
        }
; T1 l* ?0 t. Y' D" I& t7 u5 t
5 c) _( [- J! f        return (maxsize);
% K+ L$ m* b, {1 q4 u8 h" C}" A1 _4 w$ \* r* C4 I
int dram_init(void)
+ Z, h: I& a$ e- V3 C* l! t$ @{
0 y! p& X, M7 c# d        /* dram_init must store complete ramsize in gd->ram_size *// D& w3 |2 {  F; o  b3 P
        gd->ram_size = get_ram_size(
6 g, j, ^* M2 A- [& |2 d! G: {                        (void *)CONFIG_SYS_SDRAM_BASE,: C3 R& N' }( A8 ]) }
                        CONFIG_MAX_RAM_BANK_SIZE);1 K1 p2 {: Q5 Q/ z
        return 0;; Q6 m  Q0 ]8 x% `1 ~" _
}; ~' q, R2 _6 s  |+ u! i* ~; @8 |
2 d$ p( f% Q# h& b# {2 `; M

( T9 }/ b- _- ~! _# k* q4 v  `7 \: g& i# i, M* [! Y& z

# U; E8 o* `% L! X- j$ N% ~FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!0 V1 e! G9 @/ `! h1 s& n
9 f, I/ x4 W) t6 A  s1 R

6 E( g5 O6 q$ F3 \

$ q$ ?1 A5 s" c3 e2 U! f' [




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