嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit+ [/ a; V5 j8 i# @3 y# Z
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
& Z  V2 l$ T6 H+ |, b$ q6 c( |. [* {这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
% x+ n9 w$ a! F: l( {. d7 M# U3 A: A
" _. L8 d' f' V! r% A; }" d6 J是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?9 Q; ^) p# ^+ ]' ^+ q( h7 @5 N0 E  F
- C, K" a8 h) d

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:3 S' [7 X5 O  V0 u2 J) H/ }% k
/*
% A, T0 j  o" E9 R9 z2 Q- F* Check memory range for valid RAM. A simple memory test determines
& E, `0 ~0 [; @- w* the actually available RAM size between addresses `base' and
! T+ o# f. ?  m# V* `base + maxsize'.
% P* ^- `4 H8 U! n*/
1 `. t9 v( v* ^' w: ?8 Wlong get_ram_size(long *base, long maxsize)3 A. V( z8 F) _7 l/ @
{; v' f" f9 {- K2 U
        volatile long *addr;$ b3 d; o& |8 E( C! _0 o
        long           save[32];5 \: c6 Z! i6 {3 q
        long           cnt;- L* a! G0 T3 O3 q% w5 e
        long           val;& G0 D" R( C' u$ h! \
        long           size;
  F+ l0 @0 T6 ~7 C" B* \6 f        int            i = 0;& P9 T& [) G% S0 J3 q
( l& u, y7 B) a9 R# n3 R
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
) P* {* c3 M/ a  F' ]  d                addr = base + cnt;        /* pointer arith! */# i+ q: f3 K/ g
                sync ();( j$ O# K$ H* L$ w
                save[i++] = *addr;
% W/ f7 M3 j5 i* l$ Q                sync ();
: [& s. K2 N- c" R8 J8 m                *addr = ~cnt;5 F' A" G+ [/ Y' ]+ I& E
        }
* y5 g! z' \. t  E8 N5 N+ s- w6 d0 r+ M1 M6 D/ t" a: V/ O2 `
        addr = base;) a+ X5 n9 h3 }- n
        sync ();- R% d4 _$ [" A2 I" P0 x" t% M8 l
        save = *addr;% k, E7 t7 x  J/ x. A
        sync ();* j* D) g; H8 j/ ?) y6 C- J
        *addr = 0;) Z9 h1 U5 w' G% @

. |4 |( t( @6 k1 J/ B$ r        sync ();' F8 ]( K8 C( ^( V& Z2 o, r( M
        if ((val = *addr) != 0) {
1 `$ P  m: E  y/ F                /* Restore the original data before leaving the function.
  p# e( i7 s+ I/ \; t+ L                 */- h* Z# M; A% Z% f  q9 t5 _2 s# v
                sync ();+ }7 r! O" m  b1 M3 D' ]
                *addr = save;3 [0 |. g" E/ T7 P* W
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- D- L9 |- c( f9 W6 Q7 g                        addr  = base + cnt;) N5 {9 |4 a7 U  P- K6 a# X
                        sync ();
* E5 r3 ?( {  Z% T; f" y                        *addr = save[--i];
8 B! y) r& h/ w' `, m                }
0 T) r# T- m) R$ e  P9 u$ Q                return (0);
! _1 Z( V) E( y& B- I% l1 Z+ w        }
% @) U4 g! S  _9 [
7 `3 u, `2 q. T; B        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {- X& b( t8 m9 _/ [
                addr = base + cnt;        /* pointer arith! */
+ k) c# P3 ?! v                val = *addr;
- s' L/ z8 n# U; K* [2 {* w                *addr = save[--i];
$ T4 f, J# @) w6 @% [                if (val != ~cnt) {
7 X2 h( U& G; ^6 z                        size = cnt * sizeof (long);: F) t5 ]% z8 }, w
                        /* Restore the original data before leaving the function.
, Q' K3 I. A& o) E3 H                         */
5 F9 o- B" o8 T7 L- |                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {* s; z* M0 M, @% U
                                addr  = base + cnt;; P6 G8 l. ?9 O, W8 q4 w4 f4 _
                                *addr = save[--i];' |6 Z" a6 X, ?. U3 }/ I
                        }
; v! Z8 ?7 s  R( l                        return (size);2 R) W6 S; H3 S3 [3 U7 B
                }) I& ]$ M  v1 N
        }
' x8 ~, o9 ~' v- L0 q, P' J+ z0 T8 Z' H+ X8 L, k* ?
        return (maxsize);
6 l& V1 I3 J& L  C% C6 x}7 x! R! B9 ?+ G6 |
int dram_init(void)- u% B  [2 O$ [
{
- g6 Q) Q0 q: G        /* dram_init must store complete ramsize in gd->ram_size */
" j& X0 r7 c" {+ |3 [1 m        gd->ram_size = get_ram_size(' e; Y- H+ P. v6 n
                        (void *)CONFIG_SYS_SDRAM_BASE,/ F: s  ?& _1 P( e
                        CONFIG_MAX_RAM_BANK_SIZE);
0 b. u% b% Y0 J/ Y3 r' D* `# i        return 0;
  a' ]* S9 K8 Y* g. D# p' E7 d$ {}. W  T9 {* B6 H. N1 N  ~, |

. q- V* o8 n1 C/ e( c$ g$ }: s9 s$ G2 r6 E7 t$ @8 }8 N

5 T5 u+ ]" t% _1 \3 F/ u8 c. D9 {4 V5 b
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!% |4 L) n& }) s1 ?' G+ c

: z2 v# E% e- f4 ]  B1 O  t3 z; s' R5 R& Q
  `1 {, x1 p. a; c  S4 S, X





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