嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
) O" V' ~' G, u2 t  x3 ~8 S8 Z4 P核心板2:DDR2 256M Byte   NAND FLASH 8G bit0 u7 b( P, ?* y) B6 U6 P
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
7 M/ k: u7 Y. E2 _+ w6 L' l
4 S6 f) D* w+ W9 {9 n. H是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?- }: ~$ [1 b$ `7 ?/ ~

/ w9 W  z1 U' X' q& n
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
% a% E# s# s7 ]- f3 E$ n/*
: B, O1 d; {* z) M* Z: X+ m- e* Check memory range for valid RAM. A simple memory test determines4 L, D5 f: K, y
* the actually available RAM size between addresses `base' and$ _+ ^3 R/ N- K/ |! v
* `base + maxsize'.
. R+ [  _% V  Z) l5 l% f*/; p( k0 g' A! s/ F
long get_ram_size(long *base, long maxsize)  u  f/ w7 h/ I# N
{4 h/ u, b9 E, c8 X' s
        volatile long *addr;
; G) x4 N5 n! D        long           save[32];
% a0 a0 |. W; {( v2 V+ S        long           cnt;
9 U  K9 g/ p4 J8 ]8 n- r        long           val;  w% k8 F5 c0 F
        long           size;6 s. U  r9 H# _; s
        int            i = 0;
  D' F# g' }6 _0 Z. v$ F5 i
! R9 g2 k9 g' }0 q        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {, w2 E* o' @4 N. c1 J
                addr = base + cnt;        /* pointer arith! */
  b, J4 d, n! F6 V! U  n  L                sync ();' {3 E- T' W# w9 d4 }  f3 w% n3 r0 f
                save[i++] = *addr;
3 t- X" f# N8 ~/ _3 g4 \6 \                sync ();
' }/ Q+ I6 X, @( G6 Q                *addr = ~cnt;
8 ?* H# u1 b! [        }# Y" l7 C0 I! x' L% x

( ]9 j; l- I/ t+ @& ]9 J4 `, v        addr = base;# h& X& a" f' T0 i6 Y8 ^( t  ?" \8 \
        sync ();: n- g# _5 z! _! J4 S1 r; u* E
        save = *addr;0 V# {+ X3 O9 f7 e* M
        sync ();
/ j6 v  L, a: P, w, K        *addr = 0;
. p8 l0 N) o  K& [4 f1 Y% v  n) K7 }7 n/ q$ f0 D! B
        sync ();
# H( U6 o' v4 K) [2 A$ u        if ((val = *addr) != 0) {- L; d; v3 s/ ^$ C# {; g
                /* Restore the original data before leaving the function.0 n7 i' l& e& u* j5 s% E; t" m
                 */
9 R- k* E) a5 D! J9 F3 i                sync ();
+ @7 N, E! }- d: r( P7 u8 L                *addr = save;# x! c' d2 ?$ Q
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
$ ?6 K7 |1 _; P                        addr  = base + cnt;6 c" ~6 f* q) {+ U' c4 L# x6 X
                        sync ();# o/ d3 \0 z+ `! r( C
                        *addr = save[--i];
3 v2 e4 n7 u$ L9 _. O$ I: i3 i1 H+ t                }
* ^5 I! U' f- L2 p4 W1 }5 Y8 e# S: K                return (0);; T, D$ R4 I, d; a5 W3 f7 _
        }1 t# k: Y( A# |1 G$ e) u
% W- V& O2 `, i
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {4 }3 l; A% G3 f# U" k6 V3 k2 Y
                addr = base + cnt;        /* pointer arith! */
( }/ O# A# P2 n5 p+ ^                val = *addr;. a+ b/ Z4 I7 k1 _+ J2 {4 U' z
                *addr = save[--i];
$ ]' q! ~/ ^. t( G6 @                if (val != ~cnt) {- m! a) x! E8 D. r: c( A2 _8 ^
                        size = cnt * sizeof (long);
% H" ]* F3 [7 n/ Y' i- a+ p2 e$ O' Q% p                        /* Restore the original data before leaving the function.& {2 W( N7 Y2 Q2 o* ^/ {
                         */- A+ m( g, |/ d( X
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
/ y' q" `& h( W. g0 c                                addr  = base + cnt;
5 N2 Z2 |' v$ X! ?2 U, J% z) S' |, f9 U                                *addr = save[--i];
! r( O' W* V8 }' ^. p2 W# W' P                        }- d4 ~# p2 ^* O# z, T$ _( x3 J
                        return (size);1 C$ _+ |) \& ^6 l7 p
                }
' w$ O- H- D- S0 _& s2 j; Y  I        }( N4 e9 C0 Q/ [* ^7 n; ?+ u( x' s

9 S2 N2 D" L9 Z3 F        return (maxsize);
* H. [: q) W$ m3 `}; D/ t$ S6 R% A7 c
int dram_init(void)% Q1 z7 M; @( s6 {
{. _; D2 v' b3 j9 o2 D& y' \( u
        /* dram_init must store complete ramsize in gd->ram_size */
/ b) b/ _& @/ W7 }8 G. K% T        gd->ram_size = get_ram_size(% g. Y5 j& U) T3 k7 _6 ^  E- H
                        (void *)CONFIG_SYS_SDRAM_BASE,
6 P" l% [1 K3 y9 K  j+ b, d                        CONFIG_MAX_RAM_BANK_SIZE);) D' s9 \# X1 O2 W- L# u- s
        return 0;
8 j1 w' K( N) r6 q2 q7 T" B}
& I/ D- V3 A. m6 }! I2 N7 d
0 u: q: j( ^# u0 I. o* G
. \9 `% ^! i/ J% M& Y! Z5 v. g0 @% e& C5 J
/ ^+ p" _3 s: [
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!3 ^1 G  J8 z  {; u) q- E5 i3 u
, V1 a. Y: c( `

# |+ m" ^; S! a$ ]; F6 x( O( A

: |. d1 X) o! T$ w( ^




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