嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
5 y* X: m7 U4 V; c核心板2:DDR2 256M Byte   NAND FLASH 8G bit
" b2 ], f/ T" \$ h: j4 k这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
6 y  x/ c9 |- ^; \( A7 o& D  k; N& G/ \
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
6 u. L9 h( J% K  t/ E  g7 P4 l, P6 O% a1 D6 N0 \

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:% @/ E8 P" U2 O4 l0 }4 y
/*4 N" F) Q9 H4 N! h, |
* Check memory range for valid RAM. A simple memory test determines
) |$ @0 K+ ]+ d& ?. k$ o# f% z* the actually available RAM size between addresses `base' and
2 E/ R0 w3 c+ r* m: S" z( C* `base + maxsize'.1 Q0 ^, d! E" q* k2 n; A; @
*/6 M  O' Y/ K$ g% Z/ ], r8 h! L
long get_ram_size(long *base, long maxsize)
$ \! Q; E0 I$ w7 P8 M/ W6 l{: N4 }% h8 h# U2 a: |% C
        volatile long *addr;
  E4 f! ~: Q  P! `, |* ?        long           save[32];
( H2 y# F5 z) T' t        long           cnt;
9 C# P6 }4 s8 A& Q! R        long           val;
* M3 M' o: k1 b3 b$ G7 T        long           size;/ C0 W3 z- x. A: {% b2 ^
        int            i = 0;
5 ^" L, W8 L- N+ S( G7 K$ e* d( b: I3 ]8 b) F9 s! d" I2 {$ n4 w
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {4 A2 i8 g! K, K3 ]% w, s
                addr = base + cnt;        /* pointer arith! */
' m8 M4 [( S3 z! v3 |  h6 ?, @( h, s                sync ();# C) Z; ]5 A3 U, [
                save[i++] = *addr;" [; W" e7 B$ ?7 n0 ]. \
                sync ();! C# p, c) |8 V0 {5 U
                *addr = ~cnt;
8 G+ D" X* b7 s; k/ C5 Z2 E- g        }
* ?& c7 @" G  z8 n) y, X/ i- V  X+ }' T2 y8 D! p
        addr = base;
# C  K" ]8 G  _' [) ^        sync ();! a9 h' A9 d5 g7 v" U. M9 Y7 F+ I
        save = *addr;
6 }5 W  l9 `) `6 j9 M5 o* g        sync ();) c" l' Y2 b2 Z1 L1 t8 u
        *addr = 0;4 @2 h& @; O* K7 r" ~- o
4 @: g2 Q5 G* P. U
        sync ();6 S2 X2 R! h2 b, T
        if ((val = *addr) != 0) {
$ f* E& S: M  E. V5 y0 Q                /* Restore the original data before leaving the function./ D& \# n* Y! E% |
                 */
8 k$ o) {* c3 `4 Z0 A- T4 F6 G" M                sync ();
, n% O) Q8 F* c& [7 B                *addr = save;
. d; u/ k  D5 Y                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
4 r) M3 d& [" n# z% b$ Z: j# i                        addr  = base + cnt;% \  O. y' e* @
                        sync ();
- O* i" @' r$ G5 U# p                        *addr = save[--i];7 G/ B4 E, y/ q5 F
                }9 }: R  A& ~: @( {! Y
                return (0);* n3 v( h' j& W) @
        }4 O4 R' t7 J2 g/ O% w" T) H
/ s. R1 F) n' t* V) \. U
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( m8 _  \3 V+ ~% u. w4 b                addr = base + cnt;        /* pointer arith! */1 J- l4 h; w/ [. o5 s6 C) v5 s
                val = *addr;
4 \' t( o1 @9 o) n& s) s2 D                *addr = save[--i];6 W: y4 [) _9 ~' r
                if (val != ~cnt) {
  S; O) @- K' E9 P; s, E0 m                        size = cnt * sizeof (long);
( h! _7 i# _: A5 K( @$ g5 t                        /* Restore the original data before leaving the function.
# y+ o( ^' \! r& g                         */
7 p$ ~" I/ k# U1 a: {! D) f                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {$ r$ Q( F% ~* T! |) ~/ ?
                                addr  = base + cnt;
1 U, S5 U4 G1 O, W                                *addr = save[--i];
$ J) D& y2 q. L1 n8 r8 Y                        }
6 q( E! U+ M- R3 ]! R2 c# W                        return (size);
. c. B* ^0 R$ R' ?, q3 t                }) Q  z& t( z2 _9 `. U
        }
9 i+ J' x# l  I/ d- `; ~1 ?
5 j# W2 t" T  K% Z$ ?$ J7 j        return (maxsize);
; {# A/ g# p" J2 r- \* U0 C}  L0 ]7 m3 E) p! m; @
int dram_init(void)
( c+ d) h) y2 }{
9 z2 i0 K% [5 ?% G% N        /* dram_init must store complete ramsize in gd->ram_size */% G7 U. ]; X+ F* L; w5 `4 k
        gd->ram_size = get_ram_size(
6 @; g' b4 y5 @  r+ V+ R! A                        (void *)CONFIG_SYS_SDRAM_BASE,% n- }3 {. K5 X
                        CONFIG_MAX_RAM_BANK_SIZE);1 d* ~5 @4 i; a8 C1 o$ _" [4 D
        return 0;
) V: m9 T0 p' s}
; h8 F' f. _9 `1 {8 s
$ S+ y; C  c5 P4 F1 D3 M% W
: ^- \) t; r9 L) S
$ g- Z' ]* ?" ~. `) X1 A1 I6 @  I
' a! O: u1 G. Q5 ^6 H& EFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
1 o" p" Q2 n" ?5 U: m& p" r/ J8 {( T9 B5 W( U5 |- C
" q- \7 `2 ?" J8 {

# u! q" m8 B' k! Z




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