嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
8 M/ S7 C/ M6 P3 ^核心板2:DDR2 256M Byte   NAND FLASH 8G bit
" X) I' H$ r; s" s( `这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
7 W- M& w# U8 q+ _7 l$ M
  `: ]1 q# ]5 T  p2 Q9 J( f$ ~是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?; b) \5 J. ~* ~+ d

5 R3 g* k' [, c( }/ t, q) [
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
: X  X4 ?4 {# I% B' F/*
+ [5 o5 V: P8 v$ M0 D* Check memory range for valid RAM. A simple memory test determines# S6 k6 Z' g7 u8 x7 U9 P
* the actually available RAM size between addresses `base' and
& z, l. C3 W, n* C6 q- b* `base + maxsize'.
& Z6 z% D' _+ K. Y- ~# X*/
1 s, j/ I) E2 Y/ r# Rlong get_ram_size(long *base, long maxsize)( k7 E' \& w; L, V4 L8 q: b
{' R/ g2 j" r6 }* E
        volatile long *addr;
  D2 L( @5 f  X( B* P        long           save[32];! T6 R( X: s- F; D- L
        long           cnt;
  }: S5 K5 x) f3 D        long           val;% L+ C( D: I+ v: x9 }7 x
        long           size;
& R( |, J' l) f5 C        int            i = 0;
) P& l; ^8 s7 A0 l7 I
& w$ d% z, x4 @: y: k! K1 {2 f        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {8 E5 y2 c- b+ R0 c8 B1 G& T
                addr = base + cnt;        /* pointer arith! */
: b# w! Q  \( |! X% M                sync ();
- E$ ~: Z) C, {- u0 k+ E% `                save[i++] = *addr;9 J+ L- b( z% v' v
                sync ();
3 T% N- R# d0 l" x. b) s                *addr = ~cnt;
) x  @: W6 @" p        }! T/ n/ H8 {* f+ i6 G. W
/ S" U  N: k7 a' R8 D- f; s0 i- X0 l; c
        addr = base;  C2 E3 L: w% Q+ e. J2 P- B( ?2 x2 f
        sync ();7 ]& b- h: Z7 v7 G" s# p
        save = *addr;
. b( b9 M& F+ q5 b. T        sync ();& z7 I! S& n& m4 S% D: A$ H
        *addr = 0;% t2 a; q* r; P2 ]5 J; S
" V# ~) `1 k. J* ^, C
        sync ();
/ i' l: l! o. V6 H' m        if ((val = *addr) != 0) {, |; V! [: {4 W& t6 R- @
                /* Restore the original data before leaving the function." w; z' ^" X" p' j) z$ B: y3 w
                 *// f, Y1 v- Y. ~  Y
                sync ();. J. ?1 _! W$ [# v0 j+ }, @* q5 I7 T6 z, |
                *addr = save;
: b0 M# n. ~8 |; f% y) _                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {  K' Q$ G3 K2 L2 L
                        addr  = base + cnt;5 K+ {% s' K1 x
                        sync ();
4 _/ s/ M8 l6 c                        *addr = save[--i];, g" v4 W; b  x
                }2 v- M5 ^# X) V5 M8 @6 H9 H
                return (0);
1 E8 ~; F" X$ o        }
3 x+ p2 d5 N- {  h0 S4 B: q' M) Q9 W# z7 v  M! o9 W& S& ~  L. Y
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 A$ d  G) V8 I. L! d  v3 Y                addr = base + cnt;        /* pointer arith! */
0 J) |( a" B) V; E  W& Y                val = *addr;
6 n- Y  y" y) ]  D                *addr = save[--i];
$ C3 [7 C( w* q                if (val != ~cnt) {! U! K( z, ~/ x' v
                        size = cnt * sizeof (long);
, N' m/ z% [6 d( `5 c+ {                        /* Restore the original data before leaving the function.
& A" t6 U) p) f& M3 }                         */) ?# c; g3 i6 b, V8 S
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {- T9 z/ ~4 _7 J" ~% n. Y$ e
                                addr  = base + cnt;9 H4 P% y# h4 [/ z! G
                                *addr = save[--i];
# T! ^/ O+ D, U/ q; y                        }
* P9 j) `7 P; s0 j& \) H% t1 _                        return (size);% I7 Z6 t, l6 X$ K6 V
                }3 W9 ?# D1 V' U) X! @$ }
        }
3 m1 C* a8 B6 b  D9 A' ]& S# }$ Y& E) _
        return (maxsize);/ x2 ]! w# r+ ^- d7 ^6 E* S% o/ v
}% G) X/ j, R/ ^8 D
int dram_init(void)
2 z2 `# o, E, ]+ r/ t: A$ L{, p) {* x) R& f, r
        /* dram_init must store complete ramsize in gd->ram_size */
! H* J! d9 u& G3 f* P! f/ \        gd->ram_size = get_ram_size(
# ?& l9 V: r( q& p                        (void *)CONFIG_SYS_SDRAM_BASE,6 V( _9 k5 G% ^$ I
                        CONFIG_MAX_RAM_BANK_SIZE);4 ^- l7 j8 t$ y& c6 D1 D
        return 0;6 r+ ]* L/ [9 Y6 ]! i
}. I. ~: `" A2 F. V/ ]8 P! g$ K5 M

8 S7 j# f$ i% d/ }' U$ Z9 p; M" @" _+ z, H+ `/ k

" m6 J9 ?8 f$ K. @
; Q: q& s! c8 e1 T8 s9 rFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!$ I; d5 L% J; M/ i7 b" f

% T8 e' [3 l) d. `4 C; G: p1 C' G9 P9 v: h

( b( a% k* H! ^" N




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