嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit7 q3 K& \( a- R& w  g
核心板2:DDR2 256M Byte   NAND FLASH 8G bit+ q3 n% H' X0 `$ X- w/ X
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?9 K& q  v& B; p! J2 P9 W# s  Y- ~
' q+ t: L. K& {4 i$ ?5 R3 y
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
; G5 P; N. ?% J1 D' C5 v$ A, z+ t, H% A6 E+ s& t# y7 s! ?

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
  w; ]+ {( J  y" E/*
: b1 O- `0 H; L/ N# p* Check memory range for valid RAM. A simple memory test determines4 ?0 O" L6 g2 `, M$ W
* the actually available RAM size between addresses `base' and& M/ [; A+ h; z  T4 F8 [$ g9 u
* `base + maxsize'.
7 B4 P1 ^/ F" ~; j# _*/" Q: w2 ?$ ?$ `( o' `2 W
long get_ram_size(long *base, long maxsize)
* }, l. A/ r- i{
7 L7 q8 n+ {; F! t6 N1 f3 R        volatile long *addr;
, a- p3 S7 h6 i+ a2 B+ @        long           save[32];
4 Y- Y/ [- Q) l; ^" I, m        long           cnt;
- a) ^7 g" Z9 z" C; u" L3 r9 X/ Z        long           val;6 Z5 N3 H: B$ d3 k
        long           size;
1 ?4 e3 i; T2 \        int            i = 0;
: b  Q- w# e: H$ R# M/ O& E2 S) v
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
  O' L5 _' H  x: x7 k                addr = base + cnt;        /* pointer arith! */2 y9 r1 V% g) F8 b) H; J
                sync ();
+ T2 u1 Y6 ?& Z) c! f, y                save[i++] = *addr;' w/ p' K: c% P1 r( T& |
                sync ();
$ Q+ ^4 j: g1 v* `% O' W                *addr = ~cnt;* g) |; y; ]3 v; j$ H
        }
/ ^$ x! b/ a, }& ^; \6 a# W, |/ t# p+ U
        addr = base;
! N! }8 S) G. s, q& _3 h# u        sync ();! C% g* R5 D4 x( T7 t2 \
        save = *addr;9 a2 V( R+ V& U- `
        sync ();$ C* r- u3 G- ^" \6 r
        *addr = 0;/ n$ g4 R' b$ t& [; X' V3 X0 `

9 u2 n  L1 |4 q& A        sync ();. X6 F$ O. p3 [2 }6 G& _, T. t
        if ((val = *addr) != 0) {4 i+ F* r$ C3 V8 p# C* A& D; J7 i
                /* Restore the original data before leaving the function.: G, c* }- O' Y2 a3 |
                 */
- i0 @! x2 I/ T" R9 y6 J/ @/ d                sync ();
8 L) d$ E6 r& ~1 s                *addr = save;& f; U4 h0 Q$ k& T/ n
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {& L& f  B  U5 s0 w$ a
                        addr  = base + cnt;
6 v3 G: M6 @3 t2 X# N                        sync ();
. `' P; ~2 R1 n1 E  Q% o3 o( L& W                        *addr = save[--i];
0 V# g/ D: w4 Z$ L% G% z$ b: w                }5 C- O& T1 R. ~& y
                return (0);1 b4 ?0 m+ E& e$ J
        }
' P& `" R4 w# g+ H9 s: T9 [  q
4 Q5 N6 S- A" q  |        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+ D0 W- v) A+ |8 }0 P                addr = base + cnt;        /* pointer arith! */
& y( O* M& d. z" z* S9 p' G" D                val = *addr;
& Q) t7 ?6 |/ h$ p7 X1 Y                *addr = save[--i];6 K: n$ n7 n2 u$ D* ^. S  \/ i
                if (val != ~cnt) {
" v" C% i' {$ P1 z                        size = cnt * sizeof (long);* `. F9 l% W' v3 v' [
                        /* Restore the original data before leaving the function.
; L% ^3 h( K; C) c& n                         */- b) I: w! m" B8 h) Q% ~$ A" T
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {3 z/ D$ S% N0 F* ~. T$ Y- |4 n
                                addr  = base + cnt;( l0 A% o* V. P4 S
                                *addr = save[--i];# y& D4 h; m$ ]& |, K7 C' O- q
                        }
2 J  H7 Z6 X5 R5 X9 D, h1 m                        return (size);
" I+ O9 m. _3 x                }
! l$ a) e8 A  T% z- y- K        }  P$ ?1 P+ n4 w+ Y! f

" q7 T9 _  k0 m4 [        return (maxsize);+ L( M* K5 a3 k
}
, n$ n) r- ]- m: Vint dram_init(void)
1 o4 {) Z, P, y2 e/ Z6 ^{( Q1 H; B' ?$ Y3 a
        /* dram_init must store complete ramsize in gd->ram_size */
+ w) C3 u8 |. j        gd->ram_size = get_ram_size(* `# L* x/ B3 y9 x& W
                        (void *)CONFIG_SYS_SDRAM_BASE,' ?- R' X! L1 b4 m6 E
                        CONFIG_MAX_RAM_BANK_SIZE);7 k2 V) |) B! ^* P( H
        return 0;
* P/ L6 X9 l, L; ~% C}! U4 f  Q% ?  t! j, t

8 \& I! S/ q8 H0 K( N6 Q# ~7 D0 L$ O) B0 `: w" [. j

+ R' i1 a3 K/ P0 {/ ^4 {
; q) n$ A; m9 r7 a# V0 gFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!: j7 W7 _, F/ D4 l: f3 }

7 L1 p, [5 N8 Z% s+ k: {, w3 i8 j" v% z
; S* [# U4 i, U: E0 j6 [( |1 `
: Y# l5 U1 x; ]! J5 X& q0 Z





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