嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
/ |) Z1 \8 k- i  D( r( F0 r/ Q' C) ~1 r核心板2:DDR2 256M Byte   NAND FLASH 8G bit7 K3 [* p' S, R- P+ I4 `
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
* \: z+ Y, d8 r: y$ v
' E& Z2 z( m( R9 f; Z7 L+ x是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
- i& H3 Z4 y3 O
$ p9 v* V) x8 c7 N6 v$ {4 T
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:+ j8 m1 {1 Y# S% q' `+ R
/*
! t! Z) d+ f$ K. A, p. w* Check memory range for valid RAM. A simple memory test determines- x5 K; T. I& h: p
* the actually available RAM size between addresses `base' and
4 E/ z( b9 Q' c' w! H1 g5 r3 c* `base + maxsize'.6 P1 W9 Y! X- Z5 I
*/0 o6 l  F0 M7 ~( w
long get_ram_size(long *base, long maxsize)4 f0 X2 a" g$ x0 g7 T, z+ l- ~
{/ V& y5 d. D+ j. O& H; }9 V% w
        volatile long *addr;
, D3 F0 Z0 A" m( V4 `2 {+ v        long           save[32];+ g3 o9 `0 u5 ~+ C! f
        long           cnt;
' M5 b  t: g. X# D        long           val;9 @* u: X. L* ~( Q- W6 Y8 ]
        long           size;. f# l/ b  D4 f8 ^% \9 u1 U0 l" v
        int            i = 0;
, m- @2 m( Q# E# q1 n  B
5 V/ Z2 ^) P' N        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
3 x" y: S# t; `# V! K1 y0 u                addr = base + cnt;        /* pointer arith! */- L6 L2 Q. @# Y/ E) w7 E: J' k
                sync ();$ ~# F& b, Z8 f" P
                save[i++] = *addr;
& p) B9 @# _3 U& n- O; ]' {                sync ();
/ N9 f+ h5 h  n- _: ?1 i# M                *addr = ~cnt;5 k% f. H3 I' z3 Q
        }$ F7 Q9 R0 s: ?* f7 D- M( m& \

  A6 a$ E9 g. _( h5 L3 l& L        addr = base;8 y9 B4 v& b5 p  w# `
        sync ();
& I9 s% S# y) [/ a  P: W. F        save = *addr;# e- B! W5 g7 d* {# J) ]! D0 ]4 u
        sync ();
% @' k! K5 M" Z        *addr = 0;
* [. f3 e2 k9 y9 e! L  V& s0 I2 S7 |) {, V+ l: q
        sync ();
0 }0 e4 |9 T  O, Y' K  x; k        if ((val = *addr) != 0) {1 M+ z) t; x& C9 l( e& D7 y
                /* Restore the original data before leaving the function.8 S( e- K& N8 \
                 */
$ k5 C' M& P& m2 I% n) |                sync ();) T7 M" Q" s8 E2 o% u5 [( W2 M5 T" f
                *addr = save;  F* T( Y% k; }" r% Z3 M, |/ w$ o
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {/ K; R  w9 I2 U! n8 p3 O1 D
                        addr  = base + cnt;
) w+ x' u; e/ y( i                        sync ();% O7 f8 z  [6 s0 x
                        *addr = save[--i];6 M- f& d* G+ v+ L" y: l
                }
, w8 D' T- p3 c9 g2 A                return (0);4 v# X: d% b; ?- t2 L
        }
  B6 O& ]+ ]3 L) s- F/ c0 `2 O. ^" _* e+ J) n" `
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, w' X* {# o$ S8 ]                addr = base + cnt;        /* pointer arith! */9 w1 `9 Z1 @6 C* x
                val = *addr;
2 T+ n5 M2 t' ^                *addr = save[--i];2 g2 o5 u4 G. z4 I
                if (val != ~cnt) {
! I/ g2 q( [. p                        size = cnt * sizeof (long);
( f; v# W' R, y; Y8 T                        /* Restore the original data before leaving the function.
/ V/ {' ^0 ~' Q  x; Q% |6 m                         */) U7 w' c6 L# i
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ {( I9 a$ v5 X) c
                                addr  = base + cnt;
! B) W& z3 ^/ r' N! t5 i! d, A( I3 P                                *addr = save[--i];
( N2 N; I" T7 I                        }
/ j6 J3 D( O5 F" k6 @: Y                        return (size);
: n$ z9 ^2 d( B3 R                }/ U; L$ H2 F7 U2 l: w5 F- O
        }" Q( r4 e  J9 f  E" G2 C

. U4 H% b1 k2 c  E) c8 T& M  _        return (maxsize);
! @9 y7 P  L! h4 H& V3 [}6 t5 d; y5 g5 y
int dram_init(void)
" Y% |. [5 g9 Z{6 E4 Q$ F; D; ^8 V- t# K5 G) o
        /* dram_init must store complete ramsize in gd->ram_size */
3 W: f4 Z; i% @& N        gd->ram_size = get_ram_size(. r8 ?( I. T3 E) e: T+ X
                        (void *)CONFIG_SYS_SDRAM_BASE,
  o5 \- \- z* C: B0 t0 M                        CONFIG_MAX_RAM_BANK_SIZE);6 _7 y* D5 x( {9 R* F( Q
        return 0;" O$ u+ @7 `# |* g8 d" `% h
}
! n1 v3 o; F1 U$ D. g3 h3 m& H5 e5 d7 U/ t( O% t; {) Z
2 S" m9 E' y8 t4 r, j9 D
5 X' F' Y( t! m8 w# G8 a

! i' A( M1 y+ M* s8 D5 X: o- L, g) T& h" iFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!, }7 l5 K4 n: |% b$ y
: |8 _: v4 Q; b, H) S

0 N9 Z( G# h4 u- Z0 S2 O

# t/ A1 ~+ L! c; U




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