嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
0 {- i; t% |# o) F3 G2 B8 K核心板2:DDR2 256M Byte   NAND FLASH 8G bit% R1 R: W* f$ d* R' T: i( e8 _
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?; r1 i% G+ k2 g1 M
. N) |- ^4 _/ ]
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?. n  r( n: U* P3 k( U" X; G% K
$ u* o$ v; x& T: J+ i' }" E

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
* A3 d+ W" w. a9 ]7 ~" q5 x$ {/*
+ n" y- O( J. d, ]* Check memory range for valid RAM. A simple memory test determines* X/ @' b( \5 J8 q' j
* the actually available RAM size between addresses `base' and
2 u7 E5 G) @3 I* `base + maxsize'.0 J0 r4 h" J9 O
*/
( {. S3 n; @& W' Olong get_ram_size(long *base, long maxsize), I6 {) D# v) @4 d; N
{
. k$ T, h; J( z/ i7 u' t8 j        volatile long *addr;
5 A) @: ~) s. o- \2 o        long           save[32];
* c2 m4 {) C) Z0 F6 V        long           cnt;
. d6 Q2 a2 p3 v! z$ Z        long           val;
2 _/ A4 H& s! R        long           size;
2 g2 ?: t& u& ^: q& ]  f        int            i = 0;( A* Y. {/ h/ {" L5 w
( B* v+ E+ g; u
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {- T7 F+ A& v" B$ J+ A6 G- t- g) e
                addr = base + cnt;        /* pointer arith! */
  y  I; a0 o6 z  e8 t. y                sync ();- m* F( o5 p" w- ]3 X0 q
                save[i++] = *addr;6 {! g8 Q; b+ i2 \# I( c5 j+ L
                sync ();  h6 Y  f7 d# U; V
                *addr = ~cnt;! G* J( b! c) n. V( g
        }
; o# o8 T% F5 F% X5 A. {
4 G9 u3 a6 ?, Z# e        addr = base;
% Y, M7 U. V: {9 X* M4 T" o% ~, R& X* F        sync ();
, z7 K6 i1 q( @+ K/ i! G        save = *addr;8 e0 M4 N. H0 t# n# x
        sync ();
' c' L, {; H2 ^% b. ?$ D        *addr = 0;) ^4 A) U7 X) [& o; G

+ \6 J" N, U$ s9 C# `6 w- Q        sync ();" k0 a$ J5 p# w: L- F
        if ((val = *addr) != 0) {
* p) K( p; }3 Y  v& B$ `% ?                /* Restore the original data before leaving the function.1 O/ U/ V: s- ?) R
                 */
5 Q$ ^. Q6 u  r' V- c) f- ?                sync ();
- b0 a, D* e7 a" a9 z                *addr = save;- d1 `) Y' `, _7 {* t4 v" k
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {; ]! A8 y. d. S- m
                        addr  = base + cnt;
+ x* s6 d( c9 \, p; G; M                        sync ();
1 X8 g6 n, T( Z( [$ R                        *addr = save[--i];
/ f1 S/ o; X. W. g+ V! }9 e+ c                }5 X/ H2 y$ S2 F! C) n
                return (0);
- ], U: o  e' r, a" |0 Z& N, ]% l        }
- H. C: b0 f6 ?4 V1 C6 M" r1 b# f# J+ W* X/ M. V' _  i
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) p' j* c8 p+ t                addr = base + cnt;        /* pointer arith! */2 e0 w2 [: C6 S3 D
                val = *addr;
* E% v6 n  @! I3 @- L                *addr = save[--i];
% n( ?+ X, R0 L* r0 g; `0 H                if (val != ~cnt) {
0 t( |: M6 X( A, k! G                        size = cnt * sizeof (long);7 r. S7 c7 `0 H; v
                        /* Restore the original data before leaving the function.. R# k, t1 l$ Y8 o6 o! {% z! @
                         */
1 _5 x9 a) R; D' Q8 Z" ?                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, I" `/ z( p+ ]; q. \4 e' q                                addr  = base + cnt;
+ O) h8 r6 M! W# v* w: r& w                                *addr = save[--i];9 G( |8 r3 v6 @1 B: E! R
                        }
7 _. B- Q6 R) U9 h" e2 J/ Q4 `) X                        return (size);
5 d3 ]! ?1 o: D                }
0 j$ t. {. I. T3 C        }
* G) Q" g5 z9 _$ P3 }- v: B* I
7 ~' [& b/ T0 e# m7 A2 Q# o+ y+ ?        return (maxsize);$ R0 w' f. q. k9 C
}4 v6 |! G6 \% N2 T8 u* Q" c
int dram_init(void); y# ?  l% t# v1 O" R% y
{
/ @$ ^' q& L) Q8 d8 Y) c        /* dram_init must store complete ramsize in gd->ram_size */2 S# C! V$ u/ D
        gd->ram_size = get_ram_size(
) k) H2 Z- q4 k+ k1 |* I) i                        (void *)CONFIG_SYS_SDRAM_BASE,
* x6 q& ?0 U# Q% }  R                        CONFIG_MAX_RAM_BANK_SIZE);
& b0 B8 Y, y/ B        return 0;
" w5 @/ x/ P5 j) E- {" R}
7 v4 {4 B. R" v
9 n% y* p5 [" |; S1 S+ G$ H
8 o7 P8 f: \. \* T& O* f
' L) S6 V! ]9 @! W& |4 t6 u* d# m" G9 s! o' u* I8 o
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!, }$ D& z0 U' h4 x

3 L+ |3 G# ~& [5 \! A2 S& x( E, }) e! t5 o7 s9 u

: B* L3 Y2 {7 t0 s# }+ U% Z5 }& H




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