嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit8 k0 V1 I1 g: t. f2 O4 f0 O! n' E% e
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
% \8 i+ l1 Y4 v) T6 {这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?. J- `' C% D6 ~3 G2 l- _

# ]+ D9 P8 j& F: S是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
9 X$ m# A0 \6 n& p1 V& l, _7 u6 W
5 Z. b* T( R# c7 O- ?( w4 P
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:+ j% N$ |8 D, K# @  o
/*! f* f: A! E5 _* u6 O" i- u6 L
* Check memory range for valid RAM. A simple memory test determines. b( ?2 L. a, d7 [! o6 R" T1 M$ ?$ {7 w
* the actually available RAM size between addresses `base' and; v3 k- E% v0 d8 q5 f5 z1 N; B
* `base + maxsize'.
3 N4 y' C7 r  k& b*/
' g3 s/ v9 ^+ O% X1 P- llong get_ram_size(long *base, long maxsize)! p0 f: B3 Z% c" @0 L
{5 \" Q* S) o+ a4 h, J3 d# a: k( p
        volatile long *addr;
2 P4 V1 A" W; J0 L! ?        long           save[32];
9 T9 Q8 }& X; q6 T8 }        long           cnt;
! `4 m0 M( x! s' |8 p        long           val;- ~' H. ]2 n( y# q0 }
        long           size;
/ X6 U( x, A7 e5 b4 f, A        int            i = 0;; M; {+ x* f& ^6 \

& u1 X: x! W( W! S5 R8 N) z0 M! o        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {) h8 Z8 m' u5 H/ Y5 W: c
                addr = base + cnt;        /* pointer arith! */
+ e, ], E) F7 R  U3 _                sync ();0 P8 m5 L9 C" s. s" a& ~
                save[i++] = *addr;# M& Y5 E6 V, k. [* T5 K
                sync ();
4 N9 z! O6 @8 W                *addr = ~cnt;
0 M# E& s4 z  W9 _. g, Q! ~        }
" u9 M5 |0 l5 N8 e6 C# @  T& y( k) W: t! o/ U4 V
        addr = base;' p: C2 p8 V, R6 }1 I
        sync ();( y3 d. W; V( D+ \2 V
        save = *addr;
- t  O2 S+ U6 l+ Y. ~% o( g% \" R2 |+ Q2 p        sync ();
9 V, {# \7 E3 Z% ^6 q* T* B! f        *addr = 0;
. z8 R7 _/ N$ C1 l& b/ t: w% R' [; s) }, n0 p$ f& f5 f" }
        sync ();
; {! }1 t: Q1 f, m" O        if ((val = *addr) != 0) {
8 I# \' G. v1 E$ d" J! l+ H1 e                /* Restore the original data before leaving the function." V4 R0 s) X; m/ @! G" `3 b( H; D
                 */
/ _" q1 a. F$ L8 K, q                sync ();
( ?" h% R2 t5 [9 \) U3 y                *addr = save;) U! a0 e5 z- @& U& U( y/ T2 T1 B3 P
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
# Z2 S! m2 h1 \3 I# r                        addr  = base + cnt;# V8 L# G$ l8 Q% A* O" G" x1 Q
                        sync ();
& h6 c# Y" H8 [) v8 H                        *addr = save[--i];2 P9 M8 U+ H# ~" G7 r( q" W
                }. @; C0 D4 J  a9 U4 d$ J6 p  Z8 N
                return (0);1 \  Q1 H" X- A# w1 C- G
        }
: i# R; @+ i% l# h: Q1 H5 E5 k4 d$ ?. I! x( U) o" b- o
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {2 D& G( b; v7 }/ u
                addr = base + cnt;        /* pointer arith! *// D" T( U, }( U0 r+ S  |
                val = *addr;
+ L/ B- o% P' |& T2 ?6 Y+ E$ F/ Q                *addr = save[--i];
- e( _7 B! J" S6 s; h1 W                if (val != ~cnt) {
0 e# b- {+ j7 M6 u: s1 L                        size = cnt * sizeof (long);
2 a& L4 [# ?: [                        /* Restore the original data before leaving the function." y' C# M5 S# [6 L2 x/ P) r. x6 g3 f
                         */
8 y& ]; ^& T4 r: |$ l2 Y. f: k8 c                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {- t1 ~& c7 Q( {9 H4 u2 B9 z) f
                                addr  = base + cnt;) z  C' D9 `3 {. ?2 q
                                *addr = save[--i];8 V3 j. f6 t3 G- B, y3 \
                        }) }' _% O# b* w5 u" O5 U: n, X
                        return (size);: b* H$ s. z0 R# O/ w/ B9 i
                }' {% S$ ?: `1 m3 t
        }
1 n- e7 q) {+ o: f' `2 y0 L- x+ V
4 m; @1 w4 E5 f1 _/ B( E2 R# x' y0 g        return (maxsize);2 |6 n$ e$ E/ }8 }  O' B4 K5 F) x
}2 [" o' x7 r; V3 D2 f
int dram_init(void)0 ^' P( S/ A- w; z4 H
{
9 V' s" r' I% M$ U        /* dram_init must store complete ramsize in gd->ram_size */
$ F& w' F6 B. I+ V        gd->ram_size = get_ram_size(
3 B* r2 d/ L: j, O( v                        (void *)CONFIG_SYS_SDRAM_BASE," e; `; b: b2 ~. E; v+ v2 o! [7 T
                        CONFIG_MAX_RAM_BANK_SIZE);
. ~6 O- A& o# N+ W. P! K8 e' |        return 0;
- u+ o$ ^5 _: [+ Q; P, c; [}
6 Y9 Y  U! m4 q9 f$ R& [/ M! E8 {1 Y
& O* s& c5 V/ P' @& n+ X: |6 Z# l. [* J' w5 I/ p7 `6 ^
' \, |2 S. M+ W5 z6 N: Z: Y8 U

# w1 X( B  F: P' ^FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!2 ^1 N2 S: R  t9 f$ W( {& {

  C, q) b( G9 r7 \8 m& S5 I  C) D; V& z! y4 a$ D

0 n% s. m, F0 g+ v8 a




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