嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit2 n/ R$ k6 p' d9 h
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
. b/ W4 j+ @/ `% Q& M这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?$ B3 m2 v% W4 k0 E

- p8 E7 U# E" U* G是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?: ^* t( J: u+ Q; i3 ^( {

3 I) A0 M' o9 Q1 V' A) j7 T' X
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
. H6 J) y2 l" Q7 t* U* Z7 X5 r/*2 g8 M: U1 u9 ]( V
* Check memory range for valid RAM. A simple memory test determines
: ^* E, X% g$ H9 C4 I) z) m* the actually available RAM size between addresses `base' and  m! t/ y! v' v
* `base + maxsize'.' l& J; g( G' k2 u- K
*/" X. @& u2 D/ ]0 ]( c3 @
long get_ram_size(long *base, long maxsize)" }( h" T; ^' Y8 X8 t1 L7 [" D
{
5 u3 p; `- W: x# ^7 X2 ~7 L        volatile long *addr;- j% R2 H) O, i3 ]/ L
        long           save[32];
5 D9 x- Q/ m1 n        long           cnt;
, z; }; e: [& M; s/ I        long           val;
% ?1 N& F! z6 H) X$ V        long           size;8 n; M) h* G8 `+ q: U3 ]: v% r
        int            i = 0;" F* L+ K% _! t! i; q: Y! r

" H# Z. p, A9 Y5 A9 d        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
9 p: y' I( r, M& v7 n' u# `                addr = base + cnt;        /* pointer arith! */
# O6 a  v4 j- W7 u! P7 w                sync ();: `# [3 l. }# r1 Z, h
                save[i++] = *addr;* c/ V$ y' K; c7 m( r' x% l$ R1 K
                sync ();9 }. D4 g7 B# N/ _6 r
                *addr = ~cnt;5 {$ x' ~0 P" Z& J
        }
7 {( ^0 w8 m) V6 O$ i, Z# n$ j
9 g- F, ]5 K! M9 h" D- \        addr = base;4 {$ A' J$ u2 e
        sync ();
: Q. F. Y% q8 U" y/ A9 x4 Y- d        save = *addr;: G, Y; r. D3 ?  Q% w. M6 y
        sync ();
+ n& c5 K  K. h7 ]        *addr = 0;7 j, `! o. K' T, N/ E6 r
6 j; R8 g) a+ D4 }& p+ o2 H
        sync ();0 A1 C5 ?4 T( z; j
        if ((val = *addr) != 0) {/ {3 i0 s" l$ u- V  G0 |
                /* Restore the original data before leaving the function.1 o: j% l9 i! ~8 T) ?
                 */
, J6 K$ n) ^, z                sync ();) ?" N$ a/ B, [
                *addr = save;- M3 j0 T& g8 T
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
0 O( B) M" ^" |9 s+ G6 \5 A; C                        addr  = base + cnt;( A4 B3 W7 d4 H
                        sync ();+ ]; h. r* H/ T4 u$ N4 }+ l. e8 `
                        *addr = save[--i];# F( [6 T& m. q3 v' l
                }$ x) x6 q6 n) `) A1 t4 Z6 c' f2 y, D
                return (0);7 A/ f- h9 Y6 n1 f4 `: X
        }
9 E5 {& O9 P- [; {/ _3 c' Y3 i- y9 R4 F' P3 ^  t
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {1 y6 U5 H2 s' V# i4 o
                addr = base + cnt;        /* pointer arith! */
8 @2 H; N4 o7 @9 P6 V                val = *addr;
9 |- d$ E, X  X  ^9 b                *addr = save[--i];2 _! z0 C0 {5 `% r
                if (val != ~cnt) {1 D' I% I4 U( Z/ H/ Q, @
                        size = cnt * sizeof (long);  W+ o& `3 s& h. `6 `+ \* o/ `3 |1 H
                        /* Restore the original data before leaving the function.3 A( \3 n% o( F6 f. ^& e
                         */
$ z( K, O" q  b3 [; x+ n                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {# N4 \! }: F1 W9 _
                                addr  = base + cnt;3 t8 O7 Y+ @. i( b  x* `$ ~5 m
                                *addr = save[--i];6 O% @- {8 F% \4 F5 M; M9 d4 \
                        }
) |0 d( K+ H9 A3 G+ x+ A$ R                        return (size);
0 c6 C! F: ^+ v: d* ?/ D                }
' {  G; |( g/ O& b' e        }
5 G3 i; c- W. f4 |" K9 h% B+ b
; g$ ?$ z7 D( ?+ O3 j1 M, t        return (maxsize);0 F+ Q8 d3 H. m8 {: g/ F$ b
}  |/ Z, r$ c3 ^3 Q# [
int dram_init(void)
, ~" V& ~( m* D: z{
* h) _2 b2 I3 F  ?  {        /* dram_init must store complete ramsize in gd->ram_size */1 a3 o) Q4 S+ x, x
        gd->ram_size = get_ram_size(
# J2 h/ i  d7 \0 Z0 w! d; x1 W% B                        (void *)CONFIG_SYS_SDRAM_BASE,
. x; o: O  i/ }3 H6 y3 n  u* k5 b                        CONFIG_MAX_RAM_BANK_SIZE);
5 x+ ^4 _. a8 t2 w2 j' T  x$ x        return 0;4 l  K% m: `4 s% o+ V# h% Y; J
}
& ~# Y+ L2 s+ R4 q0 r3 B4 M9 i9 x6 s0 {% |0 U# ^  M& k; F

# I0 p% n9 {2 J3 k8 ^
" t: E# G2 @9 u$ @' k1 W/ v0 z1 v- p6 |! [1 s
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!$ ]) T. x. c$ q" j: p6 B% F

  B9 p. P" ?/ X  _5 i) o3 N9 D2 N
* O5 G7 |; h. o9 B- O
" S/ v/ t9 a0 m/ o9 B$ ]) R/ g7 D; Q





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