嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit+ p8 h+ e( G9 V. F3 {) Z7 J
核心板2:DDR2 256M Byte   NAND FLASH 8G bit( `9 E& @) }# i* {3 o' d1 V
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?1 {7 ?: m) s6 ^$ S4 e- h( @

( D" G+ o5 a& e- X是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
( {& V! @) v! \5 p, |4 S5 w
" B8 [" U5 {: d3 D
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
& X0 D1 ^. W# f, H! w, B. g/*! ~; `; P6 ?" Z' u3 {
* Check memory range for valid RAM. A simple memory test determines
0 _# h7 U( O+ O/ n: m* the actually available RAM size between addresses `base' and! k; `2 J9 ^6 r( D& z1 @" S
* `base + maxsize'.# Z, t* z" _) p6 g# ^4 ~" r1 q
*/
  ]" a1 r% O9 q( @# w# R- Qlong get_ram_size(long *base, long maxsize)
  A( d& `+ [# S) h) ^3 h8 a{
8 d. U( s1 D2 ?4 `        volatile long *addr;
6 e' P3 m( j9 ?8 t2 O% _- [        long           save[32];
& z3 }! P9 g& X9 G/ v        long           cnt;9 j1 X4 J' x# _
        long           val;
. ?8 N" |7 X; o+ O        long           size;5 q* S5 o' |4 E+ ?1 U
        int            i = 0;* Z9 `# ^3 s% W$ w

* U% T- E) n+ c( b  w; E        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
* s5 p( n7 Y. T4 w+ W6 m1 ]                addr = base + cnt;        /* pointer arith! */
6 I  {; F# C# A7 R7 V2 p+ I1 }7 o                sync ();$ y7 ^8 l! @. ?' b% j
                save[i++] = *addr;
% }' x9 \) y6 E* d: l                sync ();4 v% Y! R! e& L& v  R4 B4 r+ D
                *addr = ~cnt;
; j' ^; `4 y; M/ \        }
+ |, V/ }: m! l9 t& X  i$ T3 r/ s% {  N# R! O: j3 ^9 n* m  J
        addr = base;
/ V3 y/ d0 Z4 I3 Z; D        sync ();/ j3 N  x- J6 z) J+ O
        save = *addr;
) v6 I  w+ x' h8 j        sync ();7 n! P2 U( |. y' C* C2 }7 z7 R- o
        *addr = 0;; E! q# ]0 t& R7 ?, R# @7 |
) _8 \9 I3 v* q: r) Z
        sync ();: }8 H# \& V9 H9 l! ?  B
        if ((val = *addr) != 0) {! k- r0 T' _  M
                /* Restore the original data before leaving the function.
) Y) B3 L2 s6 z( H+ }                 */
% _+ n0 n/ @" K8 \8 e$ U/ h                sync ();. M; N+ z+ t3 ^7 C8 b( K7 Z5 B5 o
                *addr = save;
% {, Y1 U1 i2 V9 a: e7 C% ^4 A                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
8 O, X) ^0 D3 R( w0 U                        addr  = base + cnt;% h( z( S7 f6 u9 }/ G- O
                        sync ();( C$ D, s( b4 {: Q
                        *addr = save[--i];) d8 x2 ~8 A0 I
                }) H- z4 d' ?$ i
                return (0);8 Y3 @* p0 i; n! M: |! H* @
        }
. N  G/ K1 @( d) j( ]
8 w0 c4 `, h; K' H! n$ V+ m        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {0 ]* }, Z/ L1 P" k* d$ z" C6 c
                addr = base + cnt;        /* pointer arith! */' x8 J' F9 J# I, m8 K2 W
                val = *addr;0 i4 s3 W6 A$ s/ M- F% l' v
                *addr = save[--i];
5 `) p6 K& K: v/ r                if (val != ~cnt) {: g3 g, m! G# c% o; K( a' Q
                        size = cnt * sizeof (long);
3 q- j: v) t2 G1 |% [                        /* Restore the original data before leaving the function.
# ]5 R# h# R& l- e5 S1 y                         */
( e  a( H' F1 H                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {* F7 ^( {; m  s  V9 H. t1 f
                                addr  = base + cnt;
* o7 ^; r* W2 W+ Y6 \                                *addr = save[--i];, z. i) W5 M, X1 Y' H2 p
                        }
; @7 m6 i) _0 K# [4 W) t- t2 u                        return (size);
  Z0 [% h9 x9 e: J$ y4 W                }  k! i9 ]# D, s- ]7 ^
        }( M9 y. R& C# Y* Y: c; r0 v8 t! K

) y" I' i1 I8 U& J, D0 x3 E        return (maxsize);! N4 Z5 T% ~, i/ \, k$ Z
}
3 X! \) d& q# `9 C: a2 V0 jint dram_init(void)( X5 {- H9 U' T% }& S7 G1 G
{
# h2 D1 Y2 E, Q5 T! S) X; H3 P        /* dram_init must store complete ramsize in gd->ram_size */
% ]! X4 M; V' ~1 Z        gd->ram_size = get_ram_size(' F9 {* |4 b3 n/ P, R  N
                        (void *)CONFIG_SYS_SDRAM_BASE,' n. K6 ^0 d* Z: \3 C* O
                        CONFIG_MAX_RAM_BANK_SIZE);- V. t+ B/ M& L) l6 a. N7 B
        return 0;
. [8 C, V+ H% |! T7 v4 \}& z, j2 b9 o& z+ H! D1 J! B
2 Q6 ]$ ~/ W/ ?4 o; X; i7 ]: |( V

1 B5 d4 ?# j( v% i  G
5 i& l  a5 a' W/ J3 ^; o/ ~1 g( P9 o! n
+ g4 D, k: y" I4 v, }FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!1 I' z- _7 x; y' `0 s& ^7 N, l

3 R7 {* R- K5 j( N
" P( ^$ B3 I4 }0 f3 d

; N- N% ]0 P0 F: \; {7 O




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