嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit) q6 I" ]2 ]2 J9 W' ~
核心板2:DDR2 256M Byte   NAND FLASH 8G bit. x& W* ~" Z& G3 U7 k6 M8 g2 ~& {
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
8 F8 f* C, s/ y' y8 v1 N! X+ X# @0 D0 h6 ~$ X$ n# q
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
# q) S/ E) n1 F2 T) h  |
$ N/ x. B% i- @" u8 R
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
% B: w: |/ H* ^" ~' S/*
! @" K" b" E# @' H2 Y' }8 ]. j! q* Check memory range for valid RAM. A simple memory test determines! x" o+ I3 ]+ a) i! q
* the actually available RAM size between addresses `base' and
0 q6 [& I" p: m" U$ a* s  T* `base + maxsize'.8 k1 o: |- ^( y  y
*/, [9 m! g9 P! m" H* X+ o7 J
long get_ram_size(long *base, long maxsize)
( q9 h4 o" h8 n) W{
' [- S% w, S/ e8 }$ n: c$ O        volatile long *addr;% f- n0 X/ m* V. b
        long           save[32];& ?8 m- c, L. |1 V& P2 a4 _1 @& _0 v
        long           cnt;
  h, ^' \' q' ]$ p5 E9 _, M        long           val;
" A) s, S" x  x3 J        long           size;8 r- O5 U! W1 Q  |
        int            i = 0;
  y* ^6 Y" H3 ?! S& Y; U4 O  e) M- e- |* [+ L, @8 ^8 H
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {2 @, j( I2 d% `5 R1 W- ]
                addr = base + cnt;        /* pointer arith! */# Z; g+ v' l/ ~+ L
                sync ();8 p. v. R! _1 A: L) I
                save[i++] = *addr;# s( d/ f1 s! \! D
                sync ();
$ d! O1 T1 r' w) W6 E0 Z                *addr = ~cnt;' I# o# H: Y* f/ G, H
        }* s1 c( G+ e- a; P, D2 Y* K  D4 b

* s, W$ P% ^4 e        addr = base;
; o, u* P7 {% w7 |  c3 G        sync ();
! X: H! K# ^: J: v        save = *addr;
. _, h9 Z) p; N8 @/ F* W& l$ a        sync ();9 M  b6 s( S% x, f6 }6 M
        *addr = 0;' M/ X7 y( h2 f3 K$ x2 _- O$ o

+ @. s" I. C- z$ y' W        sync ();
. @& I  b8 l) Y        if ((val = *addr) != 0) {
7 ^& f* c% {8 `& l& w                /* Restore the original data before leaving the function.
, N1 e' L* b5 X. M8 w2 _; [- W& [                 */2 K6 M3 c% b" A- Z: G3 F
                sync ();
7 C4 u2 D5 Z) w                *addr = save;8 t! f9 g  B2 H8 U
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
' N' [" m( j8 S/ w5 h: E+ ~: ^: e5 d/ o                        addr  = base + cnt;# ~6 w/ `9 `; B6 g3 j  T& ~$ K* _$ s# g
                        sync ();
% e/ s% P2 b! {1 p( ]+ b                        *addr = save[--i];& M9 b$ m3 g4 J/ j4 Y; U) D
                }
! D  G9 }% z2 l4 V0 ]3 d9 R                return (0);
# n8 p6 `/ r0 Z( T1 V& d. i0 m        }; d) w! @7 f& v6 I: G2 T, o

( |& n' J: o/ w! {* Y/ u) t) e        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
! c& T* m5 O( T0 N& h' \                addr = base + cnt;        /* pointer arith! */6 P1 Z+ ]$ z% Q$ r' n6 I0 J
                val = *addr;. T6 c7 W6 J+ k. |2 R/ @
                *addr = save[--i];
% N& ?9 P! }9 k1 l& F                if (val != ~cnt) {9 |4 U+ |$ l! O* h" ?5 |9 G
                        size = cnt * sizeof (long);9 j9 [- f& l% G: b' ]2 q8 @
                        /* Restore the original data before leaving the function.
7 F& G3 V+ ]8 G                         */6 V; K# {1 T2 W1 c- V
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {, L. s3 U# j7 J$ E
                                addr  = base + cnt;7 ?2 Q$ V8 g; F* ]/ i! D$ }& r- g
                                *addr = save[--i];7 u0 E! n2 F% U& f7 y
                        }
6 k9 i% L# X. {1 H) u6 a9 A                        return (size);
- x% `/ f  r8 G0 B6 _' u2 }0 T" P- k$ ~                }. I' n  i7 D3 W& K
        }
- a, _  O& q7 F: [" p' u+ Q, T- M1 s- \, y
        return (maxsize);
) k# Y" D0 L3 j: b}" S3 m! P' V  K! q# _- T
int dram_init(void): D& ~; D  r, f( {4 ]# v9 ~" H+ B
{
/ c; L/ q- ?. ~( U0 v6 \$ ^3 ^$ |. {        /* dram_init must store complete ramsize in gd->ram_size */
! \: ^7 c5 c; k$ U        gd->ram_size = get_ram_size(' P& v- }, S; |+ Y& i' w
                        (void *)CONFIG_SYS_SDRAM_BASE,
- Y3 ~9 f2 Q3 Z* o  z: J! q9 Z" i' [                        CONFIG_MAX_RAM_BANK_SIZE);
) `$ D0 f$ K1 t6 q2 ?# G( \        return 0;- M9 C& q# W) {- J: O: g; g  d
}
  X" [. {- Q3 d  T4 _( q  h" X: y3 M% m4 J( Y; H2 g( \( m2 O' U
4 E" [6 i+ r. W. o) U; o- ~+ q+ I
3 H) Q& I  t' S: y7 S( d

. [" H3 Z+ C: J' C7 e: VFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
7 c/ B' X2 C0 Q0 x) b. Q" E  v
& t* c4 A' ?8 h0 P$ Y% r! B" u" J4 W
1 w5 n* t0 ]9 P- X* ]$ A





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