嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
1 N% n$ v$ k5 y! G8 }$ i- {0 V核心板2:DDR2 256M Byte   NAND FLASH 8G bit7 D+ y& c' m9 H+ Y
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- f8 u7 \. ~- A8 _) {2 t' O: ~3 t- Z& N- n) T# t9 e
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
' }( V# B' x& x8 [* H- m4 p" n3 Z$ o' B9 L- {: i4 p

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:' N$ K6 x9 O4 b) w: \0 x4 Y
/*
' X* m' C* T3 J! p* I3 E* Check memory range for valid RAM. A simple memory test determines
% Y: B( r. f. o, C% H3 k9 o! C7 R- I6 O* the actually available RAM size between addresses `base' and7 V: O/ i+ H) b2 O
* `base + maxsize'.
( q  f0 r- d; S( b  W. |+ [*/
9 l0 g' \- r9 l" j4 |- Nlong get_ram_size(long *base, long maxsize)7 F7 a9 t7 w! f: Q3 {9 p/ e
{
5 R- }0 s1 E5 {        volatile long *addr;+ {6 E6 K7 j, b4 ?) @* @
        long           save[32];
% ]  z' V' v* z        long           cnt;1 ]9 J# t3 X' [) z, z
        long           val;
3 a) E7 H$ X/ H$ u0 p/ T# H7 R) Q" i        long           size;
+ V9 s* ]  H2 g: A. L% A        int            i = 0;
; ^2 w* \/ B5 @: v+ U, J2 }" P6 t/ f. I- t8 R1 z* j& a# ]3 L
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {1 x: a) {" }6 K& R
                addr = base + cnt;        /* pointer arith! */% m/ ~- y) t/ [4 w  K
                sync ();: A* Y& p" g/ t  r
                save[i++] = *addr;
7 i8 Y. B2 D; L* J+ |1 N8 l6 f# g% X                sync ();: t, `% \: V& {% r0 `- w; I' o
                *addr = ~cnt;
0 K9 \3 S2 D& G. M        }
& h' q6 b1 E8 N' }1 q) U% V1 R! I0 _
        addr = base;& d- s* s6 }; f8 x! |$ P6 t, h; Q
        sync ();+ F( }2 G! m$ Q! J  }2 v
        save = *addr;) y0 |5 D) [7 I
        sync ();
/ v+ n* S+ m% L* t* z+ d2 i6 {        *addr = 0;
3 V' w6 d3 U& S) [  [6 H. j  p
5 v0 I9 S2 I/ U; V6 e        sync ();7 [4 L) V2 l+ u* Q1 J
        if ((val = *addr) != 0) {: [, b6 D5 Z; [% F/ B+ b, j; ]
                /* Restore the original data before leaving the function.; [% O% Q# C7 F0 y
                 */  X# W( u$ f0 M0 v4 o3 n8 ^
                sync ();
: s9 r$ [- z7 y4 _( \6 I                *addr = save;
8 p0 Q0 ?% T! P- u/ `3 v# g                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {+ s8 D" [/ Y$ P1 Q  z. U
                        addr  = base + cnt;: S0 i$ O2 Z) Q' _9 p9 |
                        sync ();
9 j; u" o- l% V  q3 P' Y                        *addr = save[--i];
7 X+ u8 s  @, n  Y4 s$ `) i$ r                }1 A( n6 a2 t( m
                return (0);
; M$ [4 g5 ^  k        }
) W- f" x/ _! R) U! v
3 C/ n, y+ z% S& [8 t4 z% C        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {# C  [9 W, h" S% q3 N4 A
                addr = base + cnt;        /* pointer arith! */
* d; z9 K7 I# d5 Q4 [                val = *addr;1 v+ o- I, g$ ^, z- O
                *addr = save[--i];
4 }1 n0 M' N* X7 [, }, U                if (val != ~cnt) {
$ a; P7 x. s: T8 A( r* _- G; a                        size = cnt * sizeof (long);
& _. q( i8 ^* y: `5 T" S9 @8 H                        /* Restore the original data before leaving the function.+ k4 v9 Q* [8 c
                         */
0 v, E) o' m9 M8 [, w# c                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {6 F, f0 ^) [2 z' N4 Q' E
                                addr  = base + cnt;
) Q2 n( B0 w2 Q$ N% |+ U3 |                                *addr = save[--i];  s  N. L: D. |7 G: K8 R# h
                        }1 R: S6 G- w& X, O) \! M
                        return (size);
9 S. \- A4 @9 S$ Z; O! A$ O                }
' X/ j# o. B# c8 g) d! {        }' j5 ^/ R$ X1 y
' C4 Y" M  `$ I
        return (maxsize);
3 E+ d$ y6 f/ [6 }* @' l}
- A+ [8 o9 _1 O" mint dram_init(void)
. S) c& ^% {2 w! j; _0 T{' j0 M7 p' M' @9 J+ V6 d7 V0 e
        /* dram_init must store complete ramsize in gd->ram_size */
2 P/ B( p/ R9 |: O# w, o        gd->ram_size = get_ram_size(
$ a# S) E9 L$ o                        (void *)CONFIG_SYS_SDRAM_BASE,; p+ N  p5 i: ?: W3 Q6 U
                        CONFIG_MAX_RAM_BANK_SIZE);
! X! p+ v6 t, i, @% m+ P! }        return 0;
' \5 A: ~% i& z8 d9 P# ]" M/ |}% i  @2 G6 I0 E! T5 A
* n* b7 K# T2 \$ F/ I0 }, |1 N
% O" T3 w$ e" O/ m9 R1 U4 G2 Z

7 n9 N7 ^  f6 _5 }" ^, ~0 I" N( L5 ?
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
- |4 d+ h4 Z3 ]
1 y0 H2 |4 B( f" f! H) S! g( \* h7 N: t0 ]! Q: v0 u" s6 m
' i* `; |" Z) S5 y& n* w





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