嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit9 }, Q: \3 W1 i+ h7 Y! ?5 L
核心板2:DDR2 256M Byte   NAND FLASH 8G bit! D5 B2 F6 c: g
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?* g9 w8 u  T/ S
( x8 u7 C4 i, `+ _; |
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
. p+ [& W8 a2 c& V# Y  `" z+ Z" W3 I& \( T) X3 ?' L2 E; q6 Z

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
2 w1 Q/ o6 _, f/*! }* q1 L- b) R& y1 U
* Check memory range for valid RAM. A simple memory test determines
4 ]$ z+ U' ?- M7 F9 X1 b* x* the actually available RAM size between addresses `base' and
& `, Y1 B7 D% z( T* `base + maxsize'.
9 p  f* R' F  ]6 p*/* N' y8 l" L  J' [
long get_ram_size(long *base, long maxsize)
# ?4 I# r  S3 q2 j* {{2 P. i5 N% Q) R! _4 j
        volatile long *addr;6 W7 o! E# U) M
        long           save[32];
- Z5 \4 T5 F) p  T( b0 N* g5 k& G        long           cnt;- Y+ i8 I  m' }* F0 M6 r8 u
        long           val;
5 v8 ]+ F  w7 a) r' J3 H- ?8 {& h        long           size;& h4 r# `0 O3 i" `
        int            i = 0;- h1 C$ r2 W0 b4 T

7 |3 o7 {0 G  l9 e- l0 y. B- P- S        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {7 i- E! e8 k* X4 t5 r5 }% H
                addr = base + cnt;        /* pointer arith! */* f, G# `4 `, i+ [- G3 ?. V1 j
                sync ();
! _0 v6 q0 F- U8 d' @# j                save[i++] = *addr;$ L, j: F- l4 P  N
                sync ();
* Q( a+ q4 q& D3 G$ E                *addr = ~cnt;
: g' ~1 G' U+ i  Y) Q5 K        }; a5 _7 \5 p  \6 J, Q
1 ^, ~& {- w6 e2 R+ p
        addr = base;
$ Z, A- E; i; L5 Z+ |3 ~  K) ?        sync ();
2 u* T6 {8 g& b- c3 M0 ]        save = *addr;) |! N! F0 H: \( a2 _9 y. j
        sync ();
) I# |7 p" y* A; {5 \1 K        *addr = 0;# }; Q" X' \0 H# t8 x5 Y  V% q

" b( z& C* y: ~! A( A        sync ();& N$ I7 s5 t, w6 f0 n4 ~/ R
        if ((val = *addr) != 0) {
. V  @; V5 H' a: s                /* Restore the original data before leaving the function.0 w6 i) X2 Q: s; q9 r* R
                 */3 Z- N4 Q3 {7 E* V) G) d
                sync ();
% T' S4 v9 t! B7 j- T, I                *addr = save;
2 I1 \5 y) {1 G) l                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {5 Q" J2 n# A# G
                        addr  = base + cnt;! a) K# _& R; k1 @5 T. P' T
                        sync ();
6 K% H9 C5 l" S                        *addr = save[--i];7 Q. C2 z( K! M! p
                }; n, m6 b1 k. }0 G) \* K
                return (0);
# Z) O4 l0 G* X        }
: d$ R+ i: R+ g: U- m1 W. C' ~9 s
! t9 |7 D: i9 k- V9 o/ r        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 x& r2 {5 o5 S                addr = base + cnt;        /* pointer arith! */, s8 U9 G6 |$ z' `; n6 D0 ~  i7 z
                val = *addr;8 E& `4 Z7 T3 B- i8 w2 W. |
                *addr = save[--i];: E. {3 h& }6 W7 @! Q
                if (val != ~cnt) {
; m  f7 p! E; t                        size = cnt * sizeof (long);
3 E) ?; w3 f! x! |! I: R) }                        /* Restore the original data before leaving the function.
8 K* F$ J" S3 V* N9 Y- T                         */, Z% k3 E  G  L: E, s" l: P
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {- j) ?& m0 m5 w
                                addr  = base + cnt;4 _( X3 V0 ?. {# v& n
                                *addr = save[--i];9 B( k; c( a- I9 }% U. j
                        }
0 O& A( d/ x3 ^/ X3 E, `5 Y                        return (size);, ^# ]+ [( Z; t" a( a6 A8 T
                }
8 D: _$ C+ a& e. J2 Q, y2 Y        }' s6 t5 v, r: [, l' y$ I

; }" S9 N4 v& X0 v% i6 ^! V        return (maxsize);
- `  w& t7 g! u2 Q. k}
+ d' q& n( U/ ]int dram_init(void)4 Z2 w1 H+ F( x. P+ h
{
( a& B0 u+ a. |" k8 f        /* dram_init must store complete ramsize in gd->ram_size */
5 \4 \5 V9 B7 D& p" y: ^        gd->ram_size = get_ram_size(
- \! h% r! Q0 W$ o+ p; C7 q                        (void *)CONFIG_SYS_SDRAM_BASE,
5 b+ L! t  D6 t- M) S* U                        CONFIG_MAX_RAM_BANK_SIZE);% T  y: [# N5 Q/ O3 O& P
        return 0;
. [3 Z, x9 s& t6 @3 O- g}
$ C) G) Y# f! V7 U7 n  j3 m2 D* ]: j7 b+ ]3 z3 J9 Q

/ E5 P2 X4 U1 ?" N3 n2 z* c' C: \$ W$ W2 ]0 U) e0 Q$ F

; C" x0 l& n/ S8 QFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!7 n# Z3 H) m/ z2 H4 Y

0 i% d& e4 q4 q! L) {
* V7 E2 w! T* M. U8 s( |$ i
$ S; V/ ~: }2 s





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