嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit' S+ n2 U& F8 R( r! C( a- {' K
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
! }: X( M$ Z: I这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
! L1 m# Q" X$ n; X/ U) {+ B6 E# B( `! k1 {% m* D& j' m, x
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?" k5 B# ^  t$ X' n( _2 L
# @1 x5 y4 q3 x5 J

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:# y. Q/ {" ^: I% X
/*
0 C# R" l* W8 D* Check memory range for valid RAM. A simple memory test determines
3 @, U# n& n/ V* the actually available RAM size between addresses `base' and
8 X; g7 m6 O. |- \1 g9 ?6 ]* `base + maxsize'.2 S) T/ d" l7 w
*/
( E. o2 h5 y' D2 V  X' ^* h9 l% [. {long get_ram_size(long *base, long maxsize)
* i( o) \1 n3 k{1 f8 B/ U2 @/ e) y9 j& G- Y- u
        volatile long *addr;  w. T  E1 O; |0 X- ~3 x
        long           save[32];
" M" ]/ u7 F5 C8 R4 {0 c# r        long           cnt;5 q% `* Y' @) B8 w5 C9 R
        long           val;
% z2 U7 P1 ]1 j2 |8 ]        long           size;
) `3 N! d" C2 S( C        int            i = 0;1 }! A8 p" B$ |; R6 Q3 A

- I0 W. v  G; f% O3 i0 N0 {% n' ]; J% l        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
* R5 o( V5 a; H( W# q2 A                addr = base + cnt;        /* pointer arith! */. u7 @) Z" t8 K4 L
                sync ();
$ E9 g' ~/ ]2 X0 y# k7 x                save[i++] = *addr;+ B+ g4 F* ^5 F2 W6 r/ n% s
                sync ();
. I1 @4 J2 a7 B                *addr = ~cnt;
% |* ]; A: v- H0 E- Z, v) a! A4 T4 Z" X        }4 F# s* s9 \  R( j) g
; r' ^+ G0 D8 m5 O  V# N7 I$ D6 k
        addr = base;& G: ^" ]+ E* ^0 g
        sync ();4 ?) b( I5 Y- d$ T
        save = *addr;% H* z+ W9 z9 D$ m
        sync ();
/ z( N! b! U$ J        *addr = 0;
; M8 }' u/ v" w: d
; K2 R5 T  _# y6 |        sync ();
$ q0 W4 t/ u1 m        if ((val = *addr) != 0) {2 _  Y  [7 Q( O4 Y# S" b; C( p/ e
                /* Restore the original data before leaving the function.) r' p0 E. M3 w# i
                 */" A4 l, T# c( f6 V  [8 ~1 o
                sync ();
1 [, u% Z" j9 J: T0 r; ^5 D                *addr = save;
$ T/ B  q' U* g* u( a: R# _, L                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
5 K7 X5 a- S9 i% o; M                        addr  = base + cnt;
8 I4 R7 {5 @! C& _6 [. B" u) U                        sync ();
' @, l# z% G. z9 c# @9 `                        *addr = save[--i];3 K9 z# m' e! h
                }% J* ~& s: E, o$ _* l. U
                return (0);8 i. a! Y, n3 a
        }
, `9 H2 F  I: Y  G$ {+ b9 Z
6 b/ o: V* M! i& i& l        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {, B3 L2 r0 c/ S& d
                addr = base + cnt;        /* pointer arith! */" J" ?8 p' P! b8 [- r3 k8 F2 \
                val = *addr;+ }, T" K$ A/ m- ?9 f" A
                *addr = save[--i];5 G4 M# c% V3 n5 k1 G4 j3 s& v  y
                if (val != ~cnt) {" n4 J3 o0 H5 D; g, r
                        size = cnt * sizeof (long);* h  ]% r! a/ q* n4 P
                        /* Restore the original data before leaving the function.' [# O9 F7 R* |- e8 e
                         */+ P1 n5 J+ H2 [  [/ o$ v) V; K; e
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {7 Z% A' U6 z+ X  n
                                addr  = base + cnt;! v# a1 ^5 d4 r, |$ B: ^2 C
                                *addr = save[--i];1 f% \1 W4 d2 E5 O
                        }
0 X/ ]% E0 q: N                        return (size);0 V: T( f, }. }
                }
  t4 I$ l* e% [1 n/ Q# S        }
/ B  q0 B3 O/ U/ K0 ]
$ g2 Z) i$ O# h) u4 s- w        return (maxsize);
+ N$ z& p$ T- B7 h0 ]; E}, J- \+ s3 S5 B9 B6 f  Z2 b
int dram_init(void), e9 N( R  Q$ J: Z: q. B
{' k( A/ `# H7 M3 ?) S/ r
        /* dram_init must store complete ramsize in gd->ram_size */
/ g4 G- C6 O9 ~( A1 H        gd->ram_size = get_ram_size(
2 F! _2 a3 w' h: N9 ]) k$ M                        (void *)CONFIG_SYS_SDRAM_BASE,3 M1 `9 z2 R  |$ r
                        CONFIG_MAX_RAM_BANK_SIZE);+ M9 ~9 W6 d1 U8 r, B4 `
        return 0;8 T7 w/ F+ \3 o& H$ _# S& P
}; w6 u5 x" U% S+ E0 U" K

. N$ i* d6 s( ?0 Y- }6 W5 g
4 e: L9 t" j+ E0 d( A* c0 @9 n$ v* s

% t) \1 h5 I/ Q* X3 N; W# \2 F6 BFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!. v) `7 y9 l" y+ C+ Y6 H

$ `2 V/ g0 l  f0 k6 D4 y2 c% ~8 _8 C  Q7 O6 a" o6 f' u' y
" k# n# Q& S/ N+ ]) O





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