嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit* E8 A% K% [- q, ?, C, ]7 B5 i
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
) n, j4 x8 @6 p+ G2 ^5 V( O) U6 i这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
! y& `/ t' O7 u3 r
' d. i) f# \- T4 z是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
) l0 _' Q  \, K4 @" `
! z7 x, T/ ]- a' U5 D! d. M6 L1 Y
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:0 M# `) G& G- M4 I( k
/*
+ {- `7 |) S6 c' u* Check memory range for valid RAM. A simple memory test determines
7 c5 D8 _6 F: U+ L! g* the actually available RAM size between addresses `base' and
  q" g( s8 s$ p4 h/ f# c: U* `base + maxsize'.
8 j  t1 T& ~0 W2 D% Y*/
$ x0 I% x; N3 V8 wlong get_ram_size(long *base, long maxsize)' ~0 B$ R9 z: ^) t* @/ |* F
{
, u4 ?- w7 ?4 u# ~; N7 q        volatile long *addr;0 N* J0 h; e( V6 ?4 B0 {
        long           save[32];
9 H& c8 S' I9 C  [2 W  R5 ]+ n6 V+ _: e        long           cnt;
- y* h! k2 R  N0 M- M3 g        long           val;
- B: Z* j5 ^8 X4 G1 \6 o& H        long           size;
3 Q# R5 W2 v2 z& h        int            i = 0;; f  a* _) }$ _, l( X  Y2 b2 Q
) {1 c4 N( v1 Z+ S" U
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
* ~2 o" v7 ?1 Q% R# c4 \9 s                addr = base + cnt;        /* pointer arith! */
) [9 d8 T: W+ L4 {( `( y' P9 ?  _                sync ();  n* V- w# N  c8 u# [
                save[i++] = *addr;
; l% E3 T& {% [/ v2 T( L& I% V                sync ();
8 [# Q" Q2 ?4 E3 J                *addr = ~cnt;6 C0 L3 q1 i+ G! k6 J
        }8 p* n4 t* e% N$ A
) C6 k) M3 g# |- s" u
        addr = base;% }( |+ Z, s2 m, A# r- C
        sync ();9 }7 V/ i" y* v1 ?  |  E% z
        save = *addr;% V3 L1 C$ U! ]
        sync ();
4 g1 v9 |' ^9 h# K8 ?! k( C        *addr = 0;
; J( C, |' e7 }0 W5 M" a, Q0 E# c. k5 D) E( t6 K$ g
        sync ();: L' H$ q& d# t
        if ((val = *addr) != 0) {7 A# p+ _; @0 P; v9 {$ ^8 z  p
                /* Restore the original data before leaving the function.
/ Z# r7 w" V) D/ S                 */4 h4 S5 M, |, \* f
                sync ();
; G# G% }2 n- U7 P8 G                *addr = save;
$ K' M( Q- ~+ I" Z* w( R" a                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {6 f8 `; j. W$ o3 u6 g5 n
                        addr  = base + cnt;0 S2 t3 f0 Z8 L' \) @
                        sync ();5 \+ M  j( K3 A/ F
                        *addr = save[--i];& h9 l! `; t7 E5 G# ~
                }. s7 J) ^/ [9 X
                return (0);
. |  V# K& \" x3 u, D' S        }
  G; j$ r3 `6 J$ j- l5 U+ _
: t$ r+ D9 U+ ]! ~# F- G/ ]        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {* c( h0 j- F# {" s. n
                addr = base + cnt;        /* pointer arith! */* B% c+ q" b3 O+ i
                val = *addr;7 l) p+ F0 k5 e# }2 E* t
                *addr = save[--i];
$ |; `  {$ C& g                if (val != ~cnt) {" A0 s! m2 ~+ z: j; h; H
                        size = cnt * sizeof (long);
5 {3 t' k( f2 |1 ^% S                        /* Restore the original data before leaving the function.
# I% }( h1 P( Z" }- N/ ^                         */
1 i, H- d+ ^0 g) J9 m# d% `                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {" O- B1 c% j7 L- V) |4 O, x
                                addr  = base + cnt;% \2 r5 N, V! l8 D4 V' V8 S4 ]
                                *addr = save[--i];
! m$ Z! \  v9 e! Y4 B1 F                        }. p, @3 b2 o3 \  F% q; {
                        return (size);
7 a, E7 x6 R, j: j                }9 Y/ ]$ X6 c' P; i/ N5 A3 K
        }
. Y7 k& Q0 s$ q" e
. k+ H5 L, s9 V' X- g# U; x9 J        return (maxsize);) B+ h0 M* g) H3 K
}
( b1 T- [2 W6 I9 @) l4 C0 z' Cint dram_init(void)! Y: k0 j% a/ C7 A
{( @! ?* a4 M+ m- I" O3 b" o( G
        /* dram_init must store complete ramsize in gd->ram_size */; B% D+ c, _  G! i
        gd->ram_size = get_ram_size(9 H6 D8 r; a. d7 s% ], n7 [
                        (void *)CONFIG_SYS_SDRAM_BASE,+ r& o2 I2 u+ ?% n+ [
                        CONFIG_MAX_RAM_BANK_SIZE);2 }! G# b; o. m9 K1 c9 \
        return 0;/ N7 Y& f2 L& o4 P5 q: F1 s
}3 |+ f7 u$ O# q, Z2 [

/ N4 P0 q" @" W" j' V  y0 M; e+ ?; h* ]5 X) W" h4 C9 y

- J# h" X+ M% y5 C& d0 R) ?
, T! S) ?9 L6 wFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
, n/ M6 u5 g; e/ z1 P! w( m/ {- q* y

' K9 Q: _0 E) `  a$ e* h' D& [% @" Q
# w3 l8 T% _3 H7 M6 b" ^; \





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