嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit5 h* @$ C, D% t# T
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
$ x1 r/ s- k+ Y* Y这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?2 l6 O& t* z: b: D0 G5 N8 _% L
/ v$ X) Z; U6 {$ a6 ]
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?5 F" `: I. X( H3 x

$ j* U6 E0 ^" y4 ]
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:2 A; ~# P4 U& O6 h, @
/*# m' g0 B6 |  e8 m: C; a9 |* M
* Check memory range for valid RAM. A simple memory test determines1 J0 c8 F; s: e  ]
* the actually available RAM size between addresses `base' and- @9 z* D/ u, r" N
* `base + maxsize'.) C* Y+ _# j1 C9 c" z
*/
6 k9 X# R0 x2 S% x/ plong get_ram_size(long *base, long maxsize); y2 V8 a- ]1 \: _( N
{
9 D- D/ }/ F& }# ?& f+ U6 f        volatile long *addr;
  k" J$ _7 ^9 M9 U2 N- ?        long           save[32];
5 w0 @0 o" Q; W3 M8 o+ ?        long           cnt;5 n! X9 ?! W6 s4 {1 R
        long           val;2 C2 U. A5 q2 S" B  A! u7 q
        long           size;
8 C$ N, a' V6 g3 k% C        int            i = 0;( g5 X- Z: R7 ?
) |* |$ G) G1 [; H
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {/ `1 C* Q3 W8 ]6 d5 D" C
                addr = base + cnt;        /* pointer arith! */
, H& J6 u* k0 o) L4 }                sync ();
8 B0 i- [$ N) ]% P( E2 C8 m                save[i++] = *addr;0 Y* Y" u$ h0 ?. g3 U. f& O
                sync ();) x* h  }9 p2 c
                *addr = ~cnt;7 l  g0 i- c% Q
        }1 l+ X$ x% c& n/ j4 T, V% M
+ ]& y/ d/ v/ d" J! S
        addr = base;
8 I+ ~$ j' b9 `! |        sync ();
9 l" a1 J( B0 t& N. E        save = *addr;0 X9 {5 G( j$ q4 X0 g6 R( z. @
        sync ();7 X% U+ r9 e& z# B
        *addr = 0;% Y( \& B) Q2 k: `+ j
) y. @/ g8 D$ F/ a- h
        sync ();
  e0 ?( H, _& h        if ((val = *addr) != 0) {
! f" c- g3 @1 W! R! r* n                /* Restore the original data before leaving the function.6 o$ r! S; j/ P, N# x% A& Y& y
                 */
5 `; {# R* e" N7 I% k% k                sync ();
/ ~+ r( Y& ], _% s: n( X, l                *addr = save;, U/ K2 o+ U  q3 j! {1 {
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, G* a. S6 A2 B1 V' b: x( S1 E" L                        addr  = base + cnt;
3 x' g. G$ y. L  f' i7 L  o- u                        sync ();
* @  R( H. j: }" o( O- N                        *addr = save[--i];
- N* f5 m3 l% a* V6 P/ S; s1 E                }# q; ]/ Z9 F% {" S9 E7 T/ z
                return (0);& {; ?! z3 z8 [, ^2 o0 T) R/ E* N
        }. A0 i* }8 ~* q" O
& A3 a& e& X# v
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) E# o! u# Q: \9 H5 Z& R                addr = base + cnt;        /* pointer arith! */  }3 H$ T5 U* Y4 o0 H, d
                val = *addr;0 b: P6 ?& b9 F& I/ Q3 h3 x/ J6 Z
                *addr = save[--i];
  W2 z1 N3 r0 r                if (val != ~cnt) {
( U- X) i% u. F4 Q* b2 X                        size = cnt * sizeof (long);/ ^; G; h4 @' U; C
                        /* Restore the original data before leaving the function.
& J* J% ]: U+ a$ ^4 p- Y' Y                         */. e! f" h) }2 n( s
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ O, W# @% s- b: L& G* t, _1 y
                                addr  = base + cnt;  p7 u# R  l" `, c3 \) J0 m- R4 E
                                *addr = save[--i];
/ ]/ t6 l* f  w  T' h% X6 T                        }7 X3 n" Q- D+ F) j  ?/ Q% F; c9 D
                        return (size);3 ?3 F# J3 q# z
                }2 t9 d; Q- }4 m- h: n/ y4 p* K0 q
        }
6 Q4 }6 }1 V, O9 C* d& k
8 B- Z* ?0 C* s7 d: R* j8 t        return (maxsize);
* g2 }- L2 l* z& U5 H& |( v8 F}
3 t/ h5 L' b; F. r5 Z; B- {int dram_init(void): m  b6 o) c! m) F$ P7 v. N* q
{5 L" o0 h# H- |, ?, I
        /* dram_init must store complete ramsize in gd->ram_size */: C5 ~& d$ q! A; [
        gd->ram_size = get_ram_size(
0 g8 X& G5 a' j7 l                        (void *)CONFIG_SYS_SDRAM_BASE,
( C" O3 d" i1 I3 A% V, P$ P2 @$ C                        CONFIG_MAX_RAM_BANK_SIZE);
  N9 l" u( H& d) O% X        return 0;
% x& D$ L% Z. Z2 E" d2 d( m' ?5 g}7 r8 R; w& ^3 w0 A# C

4 n% ~. w% X+ Q6 S! I" S/ |0 A1 r5 J6 [2 {

' p7 n! u. b; J. O" ~( g6 L" v$ w3 o
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
& y, h$ m7 t$ H' p0 \3 m7 m$ Q1 [/ f
4 h4 \4 y6 K  W1 W7 p- x9 o
! N1 H5 F7 A, F5 K





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