嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
7 Q3 @7 u2 K1 Y核心板2:DDR2 256M Byte   NAND FLASH 8G bit
4 T- S& N2 |3 U$ o; N这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?! F- m/ |# l* f/ h

; g5 L* g7 c3 @- a; Y. i* y是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?3 o' u/ S8 H. B: a  k- @

! ^- U. O# l! }+ @3 B/ f2 ?" M
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:( ]: B4 @2 z; G* y: {
/*3 K# J  a: [, I/ a1 T  G9 Y
* Check memory range for valid RAM. A simple memory test determines
4 \+ g/ w" z; _8 Y0 G( t4 O3 a, }* the actually available RAM size between addresses `base' and
* E) _! A5 A- H5 q' `* `base + maxsize'.
, p3 m/ S0 [# p8 b*/
" P( {4 N) N) ~/ F0 R  U" n9 j+ Wlong get_ram_size(long *base, long maxsize)
* q2 r5 p+ R" E: ?1 q" Q/ e{; |' _4 V: U+ }9 Z8 {/ S
        volatile long *addr;
7 I- f- {1 c9 T0 E2 W( ]        long           save[32];& S3 r: ^& z7 M. J  x) [& v
        long           cnt;; `  R2 X1 r% h8 o3 \+ T
        long           val;
& ^5 Q; j* G* S        long           size;
; l' v! y  s$ U& I# v& Q        int            i = 0;! K8 x. J9 |8 K- a# }) {

; d7 i/ Z5 W. B' i0 \0 {        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
/ Z/ l0 }+ }3 R8 S7 e                addr = base + cnt;        /* pointer arith! */& o; S7 Q; ^- J) t$ y$ y
                sync ();
/ U' ?  R: t, i1 H                save[i++] = *addr;
7 _7 w3 i; |' Y( Z                sync ();
7 `) P, p8 W& I' U                *addr = ~cnt;
5 t9 P2 s2 P8 ?, ^        }
1 L) |: W& t5 u
' E  }: z* D6 u& z  J) P+ N        addr = base;
8 K- \  p+ K3 Z        sync ();. L7 Z* Z( x) x. V3 k# D3 v$ i
        save = *addr;
# N  Z5 U- y: F- j. H        sync ();
+ ?# B& \( Q! A0 F+ ~( V        *addr = 0;  w3 H' q+ S) A: ^& {* h0 R
1 W" r7 a6 V0 T  c8 \
        sync ();: b) l7 {$ Q+ l" @3 N
        if ((val = *addr) != 0) {1 C) m& K" Q/ t) ^
                /* Restore the original data before leaving the function.0 @; K1 E6 a' e( B% D% a% X
                 */
: u" Z- n2 M% R! R                sync ();  R" N9 w# M2 W$ w! n9 N+ r
                *addr = save;! V( P4 F3 ]2 B
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
4 a7 c& u: H1 o4 x, P$ X                        addr  = base + cnt;" T! U3 v! S3 |* L
                        sync ();" j# r5 ?6 Z6 l
                        *addr = save[--i];' {! Z+ x" V! q: l% G
                }8 [  Q6 h5 N" ]4 U7 L+ l
                return (0);$ ^1 X: G0 W- V4 z8 ^' u
        }. ]4 }, C& x% j% Z. u

4 o6 u( n' K/ L! ?        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 t0 V. G# }4 R                addr = base + cnt;        /* pointer arith! */
* u! _4 H1 h" p: L4 g4 U$ A) |                val = *addr;
( v2 x' ]% k+ O9 ~) N! r: ^                *addr = save[--i];
" i0 j; q( c7 p8 q0 h# r                if (val != ~cnt) {0 C9 z0 q8 M6 C* [3 O
                        size = cnt * sizeof (long);9 m) I* P) X1 a
                        /* Restore the original data before leaving the function.
1 v3 w( _. G1 C; }4 _                         */4 k6 {0 l. m3 }
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
: e; n3 e# y" O' w9 r! d- W                                addr  = base + cnt;
& Y* `4 c" o9 m; c8 X1 g/ h                                *addr = save[--i];
: j8 M) R$ X! {1 q                        }) W+ L7 P* d8 r+ h) a/ R" r
                        return (size);. z. C, m; W. m
                }; E6 j, P* I  e4 k
        }' R9 B- E9 C4 G9 k  d. ^
* a/ f# Q8 ]0 i9 L
        return (maxsize);* ?9 G5 Y# }6 v# R6 J/ U& j5 a
}
0 z, @# x. P! e( {- W  Uint dram_init(void)8 }- w, R( P9 j; D! }
{
- L3 X+ y6 g6 _  @' k        /* dram_init must store complete ramsize in gd->ram_size */2 b/ x' e( ~6 W. T* C0 [0 ?2 i
        gd->ram_size = get_ram_size(
" A$ k: o# r, p, u: ]+ g% G" a                        (void *)CONFIG_SYS_SDRAM_BASE,
" w. @3 P1 f$ i4 a7 a+ v9 K                        CONFIG_MAX_RAM_BANK_SIZE);+ }# a. E8 F% \4 g2 U
        return 0;
% z+ j  A) |" {}
3 _/ A( H5 t  @' Q7 i4 J: l7 A, l6 f# w
$ [- S) H3 }- C* H$ `; A& c1 A: r  b- Z  w
4 T$ |/ E0 Q6 l, D, {! K+ m
, d; E! a. t* H% y2 u: f7 a6 v- x& g1 R
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!2 j8 e8 ?% W9 O8 L* A) h

& }  M- Q. Z, d; Z% h: W/ D' l4 x% y5 y; r
+ H! l8 r! W) @" ]8 a. t4 c





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