嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
7 f6 z: t9 u" }核心板2:DDR2 256M Byte   NAND FLASH 8G bit0 B, `: m$ P& o: t' g2 l/ l: J
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?8 b! B8 ^. t# o

$ u; p+ U8 R' Y- R% S是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?, l+ l% R5 f  ?9 `# ?2 A2 ^
' v8 |) P% F. X' A7 @% r. H/ g

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:9 {% u8 i8 K$ V; F/ {
/*
+ t3 O" \6 i3 z; ~+ u$ B$ o* Check memory range for valid RAM. A simple memory test determines/ E% D) w9 ~( M  o
* the actually available RAM size between addresses `base' and
7 F6 k. z9 t, ^- ?* [& r" R* `base + maxsize'.
0 c1 i2 v- }; p4 D# e$ K  t*/( i5 a# [: _$ _, F
long get_ram_size(long *base, long maxsize)
% K, c: f2 p+ f. T$ O1 A3 \3 e" P{$ v9 @3 W  `; D( G
        volatile long *addr;
: p  ~2 E# B  V0 g) ?        long           save[32];
& y; b" ~" o  h, k6 B. t        long           cnt;- N2 [- g0 H1 @' }
        long           val;8 y; x$ |2 C6 d
        long           size;& b9 K6 u) u1 p- p( r( G
        int            i = 0;3 k" q2 ^$ q+ ~4 ~, W% c
# b, t* ^2 @6 K
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
) A6 M9 d: _( D7 z8 m6 \: ^3 n                addr = base + cnt;        /* pointer arith! */
# b9 I: [) F- C/ y# x                sync ();1 M, z4 d6 F: }1 {+ @2 C
                save[i++] = *addr;
5 {2 q, M9 f: Z7 h3 L. ]' g2 J8 K                sync ();
  p' l% N. ]. A" K6 v( v( Q1 Q                *addr = ~cnt;
8 }7 O+ F% |' v3 L+ q2 F" [        }$ ~% \5 z- i, d* ^0 t  \, [
5 G* G0 E  l* N# b4 d, z
        addr = base;0 \3 v# n3 N) Q! c( s, P* }
        sync ();; x6 R0 f4 f! g+ e# J
        save = *addr;: w: ~* Z' ~! S+ ?; G+ E) d
        sync ();! L% N# S. `+ M  q7 d
        *addr = 0;- m6 i9 P; Z' X4 u/ d! \
$ e  f0 v2 B4 q) [
        sync ();8 u2 ?% j9 m1 \9 o4 J
        if ((val = *addr) != 0) {5 K+ B/ B+ q1 o
                /* Restore the original data before leaving the function.) q% q2 L5 j  w
                 */
( d8 r4 V6 c$ z9 Z( q$ D( `% n9 d                sync ();
5 S: A* h8 r1 Y                *addr = save;
' B9 C5 c- \2 M% }1 C7 z: j+ x                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
; G9 Y3 R1 d8 T& u* n5 C% Z  \                        addr  = base + cnt;
8 _* Y% r. f2 u                        sync ();' h' l5 w$ Z, O% B! }
                        *addr = save[--i];
! u# [( J) K% p$ z3 D! {                }; _8 J( q: T: P2 a9 @
                return (0);
1 X1 ~% |9 V( N2 e/ V        }
  [( l) k8 c% \8 W! ]+ T- Q6 x; ?, {, A' [: N8 |
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {; |4 |6 [" ^( f  X
                addr = base + cnt;        /* pointer arith! */8 u5 q6 E8 `: W9 M
                val = *addr;$ U8 `" ^+ {3 d' E/ M5 a& b1 H
                *addr = save[--i];
) K5 z: W- ~# r( _: K+ ~, M                if (val != ~cnt) {
( s1 J. }' m$ k) Z                        size = cnt * sizeof (long);( L$ L+ _+ o+ q7 i, f
                        /* Restore the original data before leaving the function.
, g/ P) j8 Y+ ?9 c) Q                         */  V% s! s* {8 o  t, O3 m
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
  y0 V) l" W$ F* H: D' A5 e. R4 B                                addr  = base + cnt;
7 A' p* `- @& R" Q                                *addr = save[--i];
! l: R8 T$ ]: {# P7 B2 {' `5 O0 T5 h! {" i                        }4 _' Z0 n7 s4 X6 g" Q, U
                        return (size);
% j6 C- M2 c. `8 e; D                }
% Q& l( m" g, i$ H6 I% O. Y; J- z        }, f/ m6 C2 `6 z, f

4 A/ A- z$ f9 @7 C+ A9 \8 ]        return (maxsize);
- d& N$ \' J7 o- I7 C3 O}
1 B8 k. i+ j( c2 N0 qint dram_init(void), m8 H6 W" P4 _4 d1 J
{
- M5 I0 S( u7 t) L* n        /* dram_init must store complete ramsize in gd->ram_size */
; o6 g5 T/ f0 W" g/ q$ F        gd->ram_size = get_ram_size(
* m/ t4 |8 n5 b& P                        (void *)CONFIG_SYS_SDRAM_BASE,
# I+ b( z& M; s3 \7 X8 M6 J                        CONFIG_MAX_RAM_BANK_SIZE);
  \2 e, }% I0 S& s: s0 q        return 0;$ J1 V0 {' s* \7 O; p
}
' J! R* r3 j! H* c1 w& F+ G5 ]2 X' u- _7 F" Q
) E, P/ g4 y& I/ G4 z

- r- s; u2 J7 E
4 _" i/ h8 X% ~& Y1 j  zFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!/ V% U2 ?! d, l( o+ @
9 B2 H7 Y+ B9 T$ P

$ M" P, Q3 Y2 A( T

" J  N# v. u) u( L




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