嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
! _: r! b/ M+ |: Z0 X% l4 |$ K核心板2:DDR2 256M Byte   NAND FLASH 8G bit8 j5 r! q+ I( C) T
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?5 U+ C1 ^$ j) x8 ~' d: B

5 h9 n! C5 w" P" O6 S& \是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?: v7 E( M6 h8 f) L2 _2 }4 q3 @
* W: j* f- j3 d3 r, _

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:! p/ c, P1 p7 s$ R
/*
8 R! U, F# M# a  g1 i; X! b* Check memory range for valid RAM. A simple memory test determines
8 O8 ~; u/ {& a8 P# F" Q8 C* the actually available RAM size between addresses `base' and2 u3 p! N1 E. M, S
* `base + maxsize'.( y5 D9 f# G0 Y6 w
*/, d' g' k: ]# A1 @* q% w5 A2 f1 d7 \
long get_ram_size(long *base, long maxsize)) u' v/ T5 a! Y, z2 }
{- I% U6 {! R  R: B: M; x  B9 W: v
        volatile long *addr;
  Q: n# w$ f5 `# R9 D8 {4 i        long           save[32];
; j) `+ ?9 L2 F' R$ w        long           cnt;
9 Y: H2 R; I' Q& p! {" |+ o        long           val;% b7 S; u4 b$ a( [, f: [$ v
        long           size;
; o0 N1 t7 X! U; u2 U7 Z, e        int            i = 0;
! Y* w9 k- ?, |, W0 c5 m& E' }3 I- h1 H  Z
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {: Y6 I7 G. |5 e% N$ O) M5 \5 |
                addr = base + cnt;        /* pointer arith! */' x# |+ ]- G% d8 Q% Q& m
                sync ();
8 S$ u2 G; u' l                save[i++] = *addr;
  W' D! D3 d& G0 T' ]- O0 g                sync ();: p$ b! ^) d' S- f) T; K, Y
                *addr = ~cnt;7 f* a; h0 b' I6 C( Q) u' u
        }  X4 L- g! E7 w' P- q
2 x* R4 r. r  p' M2 b$ t6 L5 s" Z
        addr = base;
1 ^7 `, D& K1 R/ F; s        sync ();# J' o# _, \0 h: P  u1 f7 t; D
        save = *addr;
- _3 c1 ?. W, P        sync ();
  h& J' t7 g+ y2 E2 _3 t9 T' f        *addr = 0;
" e+ V7 e6 T- ?7 O7 h  N. q3 b# n
        sync ();& o9 V6 O9 ~" e1 A2 S4 F3 C7 [% D
        if ((val = *addr) != 0) {
* {. p: |! N9 h( |                /* Restore the original data before leaving the function.
5 E: k' Q9 f8 P4 W% |8 o) W7 u+ m                 */
2 l) J4 @( X! i  @: q9 m9 [, i                sync ();4 a& A( j, R6 v
                *addr = save;
( i$ X5 R' F3 S* K2 p, d                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {$ J" L) k' d0 q
                        addr  = base + cnt;$ Y$ F2 a4 L$ V- S
                        sync ();2 o3 C' L# o" {. \
                        *addr = save[--i];' D, C3 R8 m! l" _
                }
1 ?$ c$ C( A% o  m5 i                return (0);
+ @: z0 F0 H2 h- _        }
- o2 {' i/ P/ D
. _. z, g0 w, ^$ x" U        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' X1 r$ S3 X! |* U2 D5 B0 u" S6 _                addr = base + cnt;        /* pointer arith! */# L# U! B) |7 X$ ?) @- h
                val = *addr;
6 ]7 u8 Y% d! V' C& g                *addr = save[--i];9 b2 j8 `$ x5 @2 d2 f
                if (val != ~cnt) {
5 F$ L4 X& H7 M2 T9 S6 h" C                        size = cnt * sizeof (long);/ B9 p0 W% Y0 g' ^7 e; S/ b: f
                        /* Restore the original data before leaving the function.7 `  z, j& a) s
                         */3 T% q3 Y" s% l
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 `$ p  y0 ]: t; }                                addr  = base + cnt;
0 \, q" m# m9 _$ F                                *addr = save[--i];
1 \  l6 `1 g6 A( R                        }' g5 o9 X/ B. `! k: @% t
                        return (size);
" O" y7 `7 H- I  s4 k                }
1 n# u) w' W, V: N5 Y1 t9 P( T        }
* H) }+ ~3 X% v4 I( R7 L) U0 U
$ y5 c; B7 ^5 O& F# ]/ ?% a6 E        return (maxsize);) j0 ^) j4 |' d5 k5 P) P4 {" b
}* u  B0 ~- e7 `5 A
int dram_init(void)
) Z3 Z) V( B8 y; E" K{
& L# [- ^6 b- h4 F% Z' ]9 P7 h  B        /* dram_init must store complete ramsize in gd->ram_size */  X. U4 }, f; U: t4 f
        gd->ram_size = get_ram_size(
3 m1 m' ~# _8 G6 T% R' x                        (void *)CONFIG_SYS_SDRAM_BASE,$ r9 o, V* M/ R
                        CONFIG_MAX_RAM_BANK_SIZE);) M4 i9 A* ~" r# [; c
        return 0;' v6 L1 g4 {* i* y& w$ B* o! M7 f
}
  M- q3 w) u8 f; O5 u2 j8 l  D* E5 Y* L4 t3 l7 `- P0 @4 A% c
9 Q3 i, y, A0 s6 T" P; A9 Q

4 P  O0 i* n" J8 `
/ ~0 d7 o$ m" b1 v+ MFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
% h8 `3 R  c  P. T+ M, r4 i, D
" U: W% ^$ g! }) j/ @
8 [0 b" _+ m6 i, k3 X; I0 m5 h% l! N

& R7 w% Z) F% X/ v" S0 X




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