嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit/ g( y" L7 \) x8 G
核心板2:DDR2 256M Byte   NAND FLASH 8G bit: d& x5 y5 S2 v1 Z/ p1 w. e+ @
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
# D4 b; ~9 t/ j, U; ]1 @2 C# \; [" T- j' ^$ W. Q
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
, U7 f. V) j. h/ c0 }* T, R: P% X3 i" ~# P( h

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) ]6 K$ x3 v  k3 W$ W! j" P/*6 ^# ~. w8 N: t4 _
* Check memory range for valid RAM. A simple memory test determines: Y& T) G. l9 s6 {6 H7 M0 q) S/ M
* the actually available RAM size between addresses `base' and1 c5 r) `9 E% q
* `base + maxsize'.% A: G$ U, f8 E2 x& Q* D; o2 k
*/
: U) t) s8 B9 L6 _2 Plong get_ram_size(long *base, long maxsize)% I  Q" {# }9 s7 ~7 e: u) i3 J
{% _" s& r; f) [" a
        volatile long *addr;
# B) x/ S7 q- O        long           save[32];
  {7 v6 b) g0 \3 V6 D5 Q% g        long           cnt;
0 H1 z* `' D/ C- f        long           val;
7 q3 D( M4 W2 m0 \# P# d        long           size;3 X" F" A9 d6 X* _/ d
        int            i = 0;$ F, V0 p3 y; W5 c/ Q

; _4 H& v: H  L        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
; G! G: P( I/ ~! k& B" c8 X                addr = base + cnt;        /* pointer arith! */6 C" ]% Y2 Q7 i* l
                sync ();
+ k; ]) C* u( `1 U; f* k                save[i++] = *addr;
- l( s7 b& W7 w                sync ();
4 [' m2 M$ W( _) E; A                *addr = ~cnt;
7 i! x; x% X5 N1 n9 _        }% |6 V7 @  [, P" u
; k/ y9 r, T8 Q, u1 Q" H- B! z
        addr = base;. z* I; q: y+ ^2 e
        sync ();' m  p3 `/ f& Q$ ]4 n% t
        save = *addr;
5 J: r- W  ~& [- x  A8 x& N        sync ();
2 l; [. v3 @) s( m        *addr = 0;' u; \! i/ ?: V6 a! ]

8 L9 }( [! G* @# D9 O; X# ~( `        sync ();9 s. `& s$ d- h3 ~8 n" S6 R. ?6 s
        if ((val = *addr) != 0) {  ^, I" k4 ]. {' h5 J
                /* Restore the original data before leaving the function.
; J1 T/ T. i( y: T6 b6 {/ V                 */
) ^# S9 E4 C0 E: U+ H! J5 i                sync ();0 g8 l" f. q8 ~' K# z0 g$ g
                *addr = save;
# c0 P, h8 ~; f                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {/ R6 r% }; T1 h0 M  B( U
                        addr  = base + cnt;( b: s: n( a$ M) \8 ^
                        sync ();
! N& A% b6 ^/ V+ }. n+ B                        *addr = save[--i];
' w- T5 q* z, ^) Y) }, v$ ~                }5 q" O) l" o/ F1 d4 A
                return (0);
) y2 `( }) a* u8 a  w" f        }4 q' k. z. {) M, C: ?4 A5 S8 N
5 b! o* E) C2 H3 f! M" Q
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {0 {: ]9 Z6 h' d+ h3 L& z# ~
                addr = base + cnt;        /* pointer arith! */
0 M- I. n$ R' X# F+ T& t                val = *addr;
; V: V0 ^* ?' N5 p6 ]                *addr = save[--i];+ v& j, k' v9 a$ C, _
                if (val != ~cnt) {
/ s! e5 O) O. p5 j3 W$ V, L                        size = cnt * sizeof (long);3 t* z  v! U: a
                        /* Restore the original data before leaving the function.
4 n( R& s& ?+ q: W                         */; ~0 v$ |; |* S) e% E0 \
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {2 B0 b+ j+ G: m/ m) f3 H" K
                                addr  = base + cnt;
1 l& g& g  X8 G9 O7 G0 M" u) k/ o                                *addr = save[--i];
* y* ]0 o* w  \. z& r                        }" d# V( l7 N5 r: h6 L: b
                        return (size);+ f  H: V: U, b8 X
                }
; t& T6 f* L, m$ D        }
+ ^0 j' H9 q" i
, @# A6 `- o& l! O# o        return (maxsize);
& A' {: s* P7 a7 z& P6 Q}
  E$ c# i4 U% Kint dram_init(void)5 V7 c5 p8 ], f- s2 [/ b: e
{
! E- p/ ]# O/ m5 {! j$ q6 L        /* dram_init must store complete ramsize in gd->ram_size */. G( Y' n' l' b/ [+ H, u
        gd->ram_size = get_ram_size(( F9 m8 e  Q( Q: a/ v7 Z
                        (void *)CONFIG_SYS_SDRAM_BASE,. k, n. h8 {' }0 V8 J: v% a' t
                        CONFIG_MAX_RAM_BANK_SIZE);$ Y3 S. |6 n/ g. h- y! Q) l
        return 0;2 j$ {* z" Z7 P
}) s5 m" W2 L! }' }' m

3 k& J! w! }0 z1 m( N1 i8 i- A" a' x5 T1 x, }. n0 b
0 _9 u5 D  h' u( Z, w) s; G3 g: s
! ~! Z7 ]: k) O5 I9 x1 a7 W' i; I
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!8 f1 {# y" A, z; A; Q: }. O$ K

: R/ ?- M0 p; H7 o
4 D3 N5 d+ B& j" z2 `3 i1 D' Z% i

; G8 g" I; z% [* ^8 k6 P( ^




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