嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
. {/ w1 w) W8 F0 E# _$ ^# [6 ?核心板2:DDR2 256M Byte   NAND FLASH 8G bit' m0 b) a0 ]8 B
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?6 m1 B6 F% m& b+ z

3 t) P+ S4 w1 `是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?! H) F1 c& u7 B! H; C1 q! f/ A

+ |5 m9 M7 o" {" J5 K$ y" ^
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:9 s/ b# a0 S3 O# \" }
/*/ u' x5 G! p2 U& {" I, L' d
* Check memory range for valid RAM. A simple memory test determines- z- t, u* V/ h3 T  d4 d
* the actually available RAM size between addresses `base' and
, \# j8 c6 J& s1 z" S0 x4 y* `base + maxsize'.
  u5 ~/ M  f  V: a" P*/
; S" H; b) b6 H# T8 h4 f7 e; Jlong get_ram_size(long *base, long maxsize)
7 F3 H7 f* H/ ]5 O( r- r{
$ e! @9 T; e/ R- i- h2 x" W        volatile long *addr;8 T3 [. s* z4 g$ Y& W1 q; i
        long           save[32];
6 J7 {7 h  ]; C, ^+ |5 N# ?( e        long           cnt;0 f1 U1 u. A5 U- q" r- U# U
        long           val;( [. w& h8 g7 ?
        long           size;
, e$ U7 h+ }' \! P( Z. z        int            i = 0;* E# U. f6 ^/ i
( e+ K- h2 a" y) Q- \
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
7 r* f- c- E. H% [9 b                addr = base + cnt;        /* pointer arith! */  i! Y# Q; V) e! q- |  N
                sync ();+ d$ l  p; S0 D" [( j
                save[i++] = *addr;, }: V; p% E; v+ E0 r' n
                sync ();1 u1 {" E) x% w- n+ `
                *addr = ~cnt;
8 N' b. B; }5 R* R( ?        }8 p9 a* a3 y/ U! S/ F& a
. u( t& z: y# s' G6 ^
        addr = base;
1 i/ n/ J2 o. m/ O1 Z- V- [: w        sync ();
  g9 H/ v! ~7 x' d        save = *addr;$ t! B3 q. l4 l. [
        sync ();
" c  T  H- [* x. W3 D        *addr = 0;2 _9 v4 d  F3 d, ^/ r* Y

/ K, @/ V8 g4 t" V        sync ();
% e4 q9 Q. H1 s/ M0 d5 V" J        if ((val = *addr) != 0) {! G0 f" K3 n( f: g+ I  F9 t
                /* Restore the original data before leaving the function.
; |  @2 R3 ?+ U! ]                 */
8 S& S2 U1 g! b                sync ();
0 L+ C- O. N  h$ ~( h# M                *addr = save;, b0 s3 Y1 b- c7 d2 l4 R
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {; X& d8 w9 f6 J0 o4 N3 J/ R0 C
                        addr  = base + cnt;4 G; Y( s7 K5 }" I/ d  r8 v6 `
                        sync ();/ `6 S# c" t0 l6 ~, A2 x9 ?
                        *addr = save[--i];  F$ _" {4 q1 P' A8 d
                }
8 c( |) G1 v, d$ b; L, \                return (0);8 }! m! R" U2 b1 P2 l
        }
% I; n* H. s4 a5 @7 X8 r( \" j+ ~( e! a' N# l* \
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {9 m+ C+ L; P  w, L3 C
                addr = base + cnt;        /* pointer arith! */
' v8 M! w- _3 H, T6 X5 K                val = *addr;
% X7 z# `( r! E( s/ F7 a9 H& F                *addr = save[--i];0 f! g! L7 R  a) F
                if (val != ~cnt) {$ Q& x: v, L" n. A5 I1 T! a5 H
                        size = cnt * sizeof (long);
/ B; c- T6 M$ i' p                        /* Restore the original data before leaving the function.
" U" ]+ }1 G2 P  v0 k! X: P6 K( _                         */5 n5 r' }: L& I/ n- S  z) Q8 d
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
+ D4 p( V0 ^4 N; v                                addr  = base + cnt;5 D! _. j: ]) G
                                *addr = save[--i];' z2 u6 t; d! U4 J% C% f5 f* }* N
                        }
2 D$ Z7 g# ?/ B& h/ c* r3 Y7 X                        return (size);
9 l: \9 n" G3 K/ C                }/ r9 [8 M4 Q3 B/ F$ b4 _8 T
        }$ m5 Z* W$ j5 Y1 c' s, I
* w) s2 c& B/ L
        return (maxsize);
1 L) C% n5 Q0 V; R; {7 V}
3 d$ o% H+ q0 C+ A1 gint dram_init(void)$ ^9 [1 M% ~6 ^  r- `7 S
{
/ F, {, o/ v& I5 ^6 h9 u- @9 @) H        /* dram_init must store complete ramsize in gd->ram_size */
% S- ^. A1 }& ^. {: m+ m& U. ~        gd->ram_size = get_ram_size(
3 ^( g! e) \9 G                        (void *)CONFIG_SYS_SDRAM_BASE,+ g/ J; A+ C0 s+ H+ V) g9 M/ L
                        CONFIG_MAX_RAM_BANK_SIZE);
' C9 Q8 x( S4 y0 U- N        return 0;
7 G. M% m$ i  F* d}
. N& @4 |1 b' g) G1 O/ p
) N" r9 [! t3 s* I; S& G, P" O$ h
7 o( {' I5 c6 b, e# {  E; Z! Z- }: l7 C
5 m. X& ~: b: V( t8 x0 |: d$ g+ o  o- L% ]* |, m
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!7 {# a' C$ ^' a7 n% y& V; O  o# \9 Q) P

9 @; Q0 o% B1 s& _9 @. |: D# g* |( r5 r; O& S) U
$ o( u7 d6 T# `. O3 _





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