嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
3 x: w* U9 C- u核心板2:DDR2 256M Byte   NAND FLASH 8G bit
  j9 _( E8 C. o1 b* G这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?* B+ m! w8 t* b% N

  g! p4 @; x* d) Q* \是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
" b3 p7 ]" J, F7 a; |/ X
2 {# y/ K1 a6 a( T& g
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
7 x1 e& |8 Y5 J9 y& |/*
9 l: V/ ~( K  \4 t* Check memory range for valid RAM. A simple memory test determines
9 _8 @0 N) t) y* the actually available RAM size between addresses `base' and6 _0 w6 n. L; Z: E# i# L3 m
* `base + maxsize'.' Q( _" R4 s$ G" \. K( p
*/" l( p& H( J! L& V. `2 ?9 A
long get_ram_size(long *base, long maxsize). Q& j) U2 d% w8 Q+ i4 D
{
8 y8 q2 o0 E8 _) _        volatile long *addr;
/ [. j" d- t! R7 H, o* Y        long           save[32];! A+ b, m) d3 V8 W" P
        long           cnt;
& ]  u* b2 ^9 H        long           val;
- X4 n1 N9 y! O! f        long           size;* s3 G& r' A5 g) r* p9 r0 ~+ \# b9 i* X
        int            i = 0;
6 I% Q  |% x7 l: b
$ j: ?. S' ]: g' Z8 l, x        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
. y$ g: l; s, ]! |+ s                addr = base + cnt;        /* pointer arith! */, B  ?& m% H2 Z/ B! W
                sync ();6 `* R: u) S; q" f$ D3 h
                save[i++] = *addr;, n" V* A+ b! {5 e. E3 E
                sync ();( H7 H4 O! l  H
                *addr = ~cnt;' T3 B0 G$ a) j8 A/ ]
        }8 H$ o4 i; _6 m+ P

$ m$ @! R1 {7 a' j        addr = base;$ z$ q) ]; E7 k, z: @. z
        sync ();
# k" T0 |) C. `" ?6 X! l! v# u7 G        save = *addr;
8 {6 L; ]( D& o( d        sync ();. E( P0 R9 O# }7 Q
        *addr = 0;
# N' I2 f3 l5 X
- E6 F, D) B+ P8 O% P        sync ();: D% I( F5 P- T5 Z# f; _1 ?+ A
        if ((val = *addr) != 0) {
: Q3 Z5 d& n$ E3 N$ f; W* F                /* Restore the original data before leaving the function.7 x4 \& g% T% L1 C# t" o
                 */
' p1 f: {; @4 I                sync ();
7 i9 q5 v* N; V" w, ^" t                *addr = save;
4 V( r* n5 ~" E, z                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {* I! n+ e3 Q: \( S
                        addr  = base + cnt;& R/ K: s( r3 r. C" S: N( H
                        sync ();
1 A3 c4 |7 \/ f( |# F# B- Z+ L                        *addr = save[--i];: l- Y* x$ o5 E7 b5 u; U/ Y
                }6 u4 g. |; v% j0 e6 i
                return (0);
& a5 E9 X8 T. d' m        }; ^: N1 I, @! Z* O6 B' O) y
, g6 {! q9 L& E/ |2 n; U% v* j4 b
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
: p0 H- S5 b* c1 v                addr = base + cnt;        /* pointer arith! */+ c3 I0 {" l( Z5 R/ t1 W
                val = *addr;
( w  r: p; L2 K! R                *addr = save[--i];- X, O) ?2 V4 G8 E3 I
                if (val != ~cnt) {
  c# L; I  N# Z1 H' g                        size = cnt * sizeof (long);
3 U4 |4 d3 ]9 R% i9 a0 W                        /* Restore the original data before leaving the function.4 v" J; _) {! C  Y( n
                         */& j) b# o$ i. V9 k% r
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, k; O( Z5 B& f                                addr  = base + cnt;
) V9 B+ r3 N& U                                *addr = save[--i];
/ T: f* x$ v1 a( g. m( G                        }
: ]- _- B) v7 p2 X: ^5 y( A. l8 |                        return (size);. M' y: g$ I8 V& N
                }$ S2 W, D- {* C7 N- n
        }" t, K; n; S! @+ r0 u5 N
& [% a7 d) g( w& l  ^& C
        return (maxsize);% M+ C+ P$ U( _# \% l. O1 _$ q
}# A1 q! R) S( A
int dram_init(void)
( }) X6 P, u0 d' R{- W) V& _' F# x# |' ^
        /* dram_init must store complete ramsize in gd->ram_size */
# o& H. ?* n# R. _  H6 j; U9 U        gd->ram_size = get_ram_size(+ f; ?: \* l2 I6 V
                        (void *)CONFIG_SYS_SDRAM_BASE,
  n$ R: B) A7 C% p5 P                        CONFIG_MAX_RAM_BANK_SIZE);
- v( K$ _+ @% @' f  Q' g5 ]        return 0;
6 u# R: f& _: Z% O1 H+ E% |}
' V. v1 f3 P2 {: H# Z5 v2 H3 u( S, i. @: a8 A8 O

& D+ a1 V" L# ~. ?5 e  f* _. e& c; I6 A+ L4 Q9 o2 C

8 o# h+ v0 F8 r9 e5 y5 s# i1 d0 mFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
9 {" O) j$ I* g5 Y' N; R8 z2 o4 j6 I5 q; v- y1 O" o

5 d1 O5 {9 v$ o
8 Q) M. D+ \: ~0 C# E1 j





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