嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
: x. g7 x4 v# M8 a) e/ H& h核心板2:DDR2 256M Byte   NAND FLASH 8G bit
1 Y9 P3 j: R6 J) n- \" A7 ?9 \  s这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
5 Z9 q, }3 b. M9 B5 S9 O" w/ Z7 c4 Z9 D6 v1 o
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?9 T, l4 P2 m( T7 m
5 K1 W# q' U$ \

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:7 V% g6 Z* E4 z' L* P
/*
( C3 u/ f& b* l( n2 _* Check memory range for valid RAM. A simple memory test determines/ u# s$ F5 e% w# v7 @
* the actually available RAM size between addresses `base' and! x  V0 P8 {2 d$ r7 x5 \
* `base + maxsize'.
$ ~( `; _3 D, z* i% K*/. N# q) Z8 W% f3 f  U/ A6 ~7 ~
long get_ram_size(long *base, long maxsize)9 d) G3 R! _/ _2 b$ y9 l  b
{
7 u2 c7 [: \) |4 Q        volatile long *addr;
6 q' y7 ]) e6 M, K: A        long           save[32];
3 M% _7 t" C9 l0 s; _8 k        long           cnt;2 S$ y- Q  P+ r: L
        long           val;
- W( {, v2 \! g8 j" r. }1 K        long           size;* {+ g( k' E( Z- `
        int            i = 0;# V- X" [/ J) Q+ F( s  X/ j
1 z& O% D# V% j/ ?" V
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {, b8 m5 o4 }5 T5 I
                addr = base + cnt;        /* pointer arith! */5 x9 [8 U: K9 T; \& j1 d1 i
                sync ();8 |3 d' R" E1 j( Z3 w
                save[i++] = *addr;" I1 q. j7 h' w5 ^: g! F  {1 g
                sync ();# f  o7 y/ `0 U/ \
                *addr = ~cnt;
0 e2 ~4 l7 s, d" a        }" B' M2 ]8 E6 [" r

2 M- z9 C0 w' q; @1 o5 |        addr = base;
  b! V+ D6 w) t6 i, e; ^3 i9 c        sync ();" h) q: N" p7 P" K- J
        save = *addr;
  Q2 C) x2 z( `% Q        sync ();
7 ?# z: k, \+ U) H  `$ y) _        *addr = 0;
( {, s" m0 p$ u( P% c1 w
: ^$ h, \. V, Q" P0 u  X' O        sync ();( C0 F- X" i8 e7 T  m9 K
        if ((val = *addr) != 0) {
% c! @, h; }) a" G$ _                /* Restore the original data before leaving the function./ K5 [0 R9 \; ^' R; `
                 */
0 j5 r$ A0 q& Y% b" H                sync ();: j2 `5 N# C) K% E% w
                *addr = save;6 M) I- S2 G) h# j/ C6 X
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
  ?7 u) ^/ \3 p                        addr  = base + cnt;
: I/ N0 o5 [9 R7 w; K$ a                        sync ();: A% B1 w7 ^( [  w5 `1 t0 R/ i
                        *addr = save[--i];4 m1 |2 `+ T7 N1 b7 f
                }* w6 c' y5 {/ ^' K
                return (0);
, k) j" h0 y% ?        }/ F0 i! f# c$ W; F

( d" T  `. J& W9 p        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {# w4 E" o7 b4 M% ]
                addr = base + cnt;        /* pointer arith! */: g" t0 U+ |( q
                val = *addr;
3 J9 g5 {" _( t; [8 R" v                *addr = save[--i];/ ^9 u1 z! Z0 c2 m2 `9 Q$ Y5 }) d
                if (val != ~cnt) {
, c* Z" K( R2 Y2 Q' N                        size = cnt * sizeof (long);
8 ~9 c! U4 L$ N6 k' k0 x: ~                        /* Restore the original data before leaving the function.5 T8 G& g# o9 L% |
                         */1 L3 j' z6 \* V5 P2 e2 B
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) W* o  H0 P( Z' f+ V: l                                addr  = base + cnt;
4 I* c" s- b2 c4 x7 Q                                *addr = save[--i];5 R' {7 K6 x3 v0 s7 |+ j
                        }) M' A* h% }4 H) P% x( _# |" I  u
                        return (size);+ n( H  V! ^* N& c( B
                }
0 S$ n! e) b) C; Y! X4 D- X        }8 {( f- a/ P2 `6 r6 D7 y% d2 t
  c' p: S+ t( Z" B% x
        return (maxsize);2 s$ j* X% ~% {/ u
}
1 u1 |( W& t/ K( L4 a1 S# S) o: qint dram_init(void)" h) k+ q( v7 f2 W  \. e9 u+ n
{6 I  I/ D. T. N  L) f$ S& o
        /* dram_init must store complete ramsize in gd->ram_size */
+ \" ~9 x  O# \8 N+ g        gd->ram_size = get_ram_size(
& l1 i9 T- A9 y1 T" T                        (void *)CONFIG_SYS_SDRAM_BASE,) |! S+ i4 h; i/ o  L
                        CONFIG_MAX_RAM_BANK_SIZE);: u* ]/ y$ }8 g+ D! n8 o3 E5 ^* t
        return 0;3 d# y5 o4 u; H: P  n) s3 I1 Q$ ^
}" ~& y9 Q  j  Q0 \1 E9 E

7 f. p9 D' l; r. x& U  d  j& c. S5 C

* i- S& L0 w8 U! L; }; A3 _0 `+ F* c
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!" |# l9 m8 I9 |1 k' }" ?/ k- Y

, v% {& v2 J- D6 l8 u/ X" s, i0 m- V* O; D$ M$ C

& G* J# s' a& N' }9 l1 [! \




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