嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit1 z$ x- p( v0 a8 q7 M! }# s2 c/ E4 D
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
9 y1 M% O4 F# Z8 X) u: S4 ~这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?, l  A* h# Y. W% [; n/ U& [, D
8 e( Y) ?0 B/ [# j- P
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
+ l# y! j4 B# `6 C1 h) c2 _7 q2 }4 X- a* J. J  e+ X: f

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:+ ~# g0 n4 }! x: k: R! w6 d# D
/*
# O9 i9 O, T) ~* Check memory range for valid RAM. A simple memory test determines
/ V) M7 K) k0 l4 P: X! e- h* the actually available RAM size between addresses `base' and4 e2 g3 e6 P/ H* p
* `base + maxsize'.
- ]! I0 u$ h+ \6 G" V" m0 W+ j. g6 ?*/
) [1 S9 C7 M0 l- m& Vlong get_ram_size(long *base, long maxsize)0 l% G* C3 B3 n& e$ b7 D8 Z
{
/ j  A: y% }: k8 O0 S        volatile long *addr;) i, i5 F6 g6 |$ r: e- O& j/ R
        long           save[32];8 x  J7 P. g, l, o  i! ]
        long           cnt;, A3 K4 J5 M- K( U2 @6 Z$ X5 z2 o
        long           val;/ o$ U( t- z& H1 `9 k8 [: ~0 f( J
        long           size;
2 ]% r9 Q8 J. s4 H        int            i = 0;+ Z* d8 v( Q0 C+ Q( R1 J

- _% W! I, K# n9 R" p" ?6 L        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 ~' W. ^4 l6 u5 g                addr = base + cnt;        /* pointer arith! */6 l7 o! x) c$ b! z- ^# H
                sync ();
2 k8 T1 d. w# H( R2 w& |                save[i++] = *addr;! Z( R* C$ q4 c( v
                sync ();
; y+ \5 e  \/ y! r8 U                *addr = ~cnt;! C4 X6 N1 ~4 ?/ J( i3 R
        }
: e0 _! V! y7 l1 N) ?6 e% F
8 |- k5 m+ @6 N6 f# a1 f2 g  [        addr = base;
2 ^' `/ K! `7 Y) I& Z        sync ();
# B1 m" w+ \. G6 w2 a, n% b; z: b; K  e        save = *addr;; ~( {; S/ D3 n2 E, t: R! r
        sync ();6 _4 `* B5 ^; j0 o1 f
        *addr = 0;
; [0 i) J' b! e
! H' u8 [/ B: I# o) f* v( V% n* t        sync ();$ N6 O7 U( V7 ~+ l+ l- H
        if ((val = *addr) != 0) {
/ ~0 b! V8 `# ?/ V+ _. J6 J! k                /* Restore the original data before leaving the function.0 z% c& z" x( b
                 */
0 D+ B, }- I' O& J. l; ^- n# b' Z9 {                sync ();
: G% i; D5 F4 W6 T0 g/ H- p& q                *addr = save;
8 d4 v! t/ G( ?' w                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
7 P4 R4 |! h7 F) ^; I. ]" Q                        addr  = base + cnt;0 [* C, C6 N) T. |0 g
                        sync ();
' n# h4 P3 [4 ]7 P9 J* J# u                        *addr = save[--i];
4 q5 G6 N; z, R9 G; o7 Q1 b5 k+ M                }, Z0 d2 I, l$ e  T9 F
                return (0);- R" C' c% c& D' |) [
        }. |. n2 G4 N: [0 I$ u3 k0 E8 E

6 a- i' C1 U2 M2 @  n& s( u) t        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 k/ H0 e: u3 r6 @3 T7 t                addr = base + cnt;        /* pointer arith! */' g- H. j% B; V# p6 ?$ l  ?
                val = *addr;
2 J4 Z- f3 Y2 |* O  ~                *addr = save[--i];0 U; e  Z  l5 d. [: S
                if (val != ~cnt) {6 K7 k! l8 u4 f7 i
                        size = cnt * sizeof (long);
1 N) u1 x8 j% d& v. ]' m% v* E# T                        /* Restore the original data before leaving the function.
5 T2 g$ Z( L3 G* c$ R/ {                         */
' a' n7 N6 T# i! i5 ]5 {                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {! j0 m* l6 n6 u2 v4 c+ s% d
                                addr  = base + cnt;7 @( w' h7 M4 X# t$ J( K
                                *addr = save[--i];6 }) [# E2 t/ o$ e, X' _
                        }0 y% z. f; R7 Z: O" }
                        return (size);3 l: j) B5 J- ^, n5 N
                }" h6 B+ N7 o# @! \" O$ `9 E
        }/ f9 f3 E" u. y, u1 a

! j  Z0 D0 d  U% s$ B, e        return (maxsize);, ?8 ]1 w# n8 k, q0 `3 j
}0 Q2 ^% d, G. X4 [) B
int dram_init(void)4 J9 b4 W& k% J5 M! M, @5 ^
{4 c! p6 M5 A6 L1 |
        /* dram_init must store complete ramsize in gd->ram_size */
7 z# H# e: {: K2 n/ n( \& ~        gd->ram_size = get_ram_size(# k/ g( Q: e" m  z, S
                        (void *)CONFIG_SYS_SDRAM_BASE,
. Q+ |$ k4 j3 K                        CONFIG_MAX_RAM_BANK_SIZE);; i! ]2 E4 L1 Z3 {; w% C0 L
        return 0;! g) T0 r; ~- F- h' ^* h( P
}% x; d/ Y* g) }& s" x, w
! {$ i, a; w% z6 ~! o2 _) i
8 ^" I2 e* x( ]9 i% w3 C' V* ?* M: j0 v. E

$ z$ k$ J. B, P8 K1 h
7 t+ ]; q* k& N7 _FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!3 ?. \0 l  j5 V- l1 d
8 c' f8 q8 n; t. F, `+ H
$ L2 r* E/ y' }4 x) y

1 v3 R/ G  B- J3 t7 p




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