嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit$ j7 j8 T' M/ r! A
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
5 Z! [6 l+ {( ?! x这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?/ F6 z- W- }4 ?( b# Z( `6 W

1 z, h* F9 c! s* v! p8 G) y是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
6 @; ?/ C/ l! K( v& P% H
" p2 @. [1 R  K
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:. n% ?2 x. l3 W
/*' m6 p: a: V2 r, h: M* p# C
* Check memory range for valid RAM. A simple memory test determines
. J: n3 ~6 p% o+ N% D* the actually available RAM size between addresses `base' and
' P. o4 r  x( m& w, ?  X; d* `base + maxsize'.
9 `/ _4 P, |/ l9 J1 I*/
+ U7 z" }. [7 ylong get_ram_size(long *base, long maxsize)
/ S5 t9 x0 c0 N, g0 c" b" H! g{
, k! w, J/ a1 T, h( ~        volatile long *addr;) z9 y* I) E. t! ]  L% S+ x3 w
        long           save[32];
1 l+ {/ f/ W! x9 C; `        long           cnt;% |; L- @8 G$ \- t  p2 G8 d
        long           val;
) F: {$ o3 H% {/ @: H, I- @9 y        long           size;6 v% h* Z; P  e2 o/ K( n
        int            i = 0;6 e8 M/ ?1 ^( |" k) O+ s

3 T; Z# F6 f1 L( R% m        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
7 D2 y+ g" v! w4 g% |5 I5 n; m                addr = base + cnt;        /* pointer arith! */
. M8 I* N" t9 J" n" G0 W$ U                sync ();) k3 A& p/ L! U3 F# O: v
                save[i++] = *addr;. Y; k# n! P9 q! Y; X: [: g8 A
                sync ();9 j& J1 ^  r/ X3 c9 b$ n" y
                *addr = ~cnt;% j- A% b# |9 ^+ V1 c$ S- E: p8 w7 `
        }
8 U/ |, J9 _! Y2 e' Y2 X
: ^5 F) F9 Y- H7 A        addr = base;
6 O2 x( T# K, ~9 a" o        sync ();
1 y3 u2 I- u5 G, f3 A) T        save = *addr;
9 D8 k  x7 i$ s4 s/ ^; z* e        sync ();9 O& N( K4 L" f+ V+ m
        *addr = 0;
1 z" a% o! F. m( `4 `1 C+ }: P! b" g$ K% O% {9 k
        sync ();! T" x( a1 n$ T
        if ((val = *addr) != 0) {' s7 c2 o6 t) J9 g, ^1 h
                /* Restore the original data before leaving the function.- |) Z3 ~5 j. P! h
                 */; b9 X! j, t4 L
                sync ();
/ E7 |0 F% y0 a7 e5 C# y1 m0 x                *addr = save;
( w6 p+ B- v7 ]' c# h8 x: o                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
+ z( `  F; d, x! a3 ]* h' Z4 i& _4 M, e                        addr  = base + cnt;
( h2 z% u7 F% A                        sync ();& ~0 Y2 |" s0 L
                        *addr = save[--i];
' E. H$ q4 F* A' M9 g  w                }
/ u0 a9 q* ?& y                return (0);$ A8 R- i; C% D6 {7 U4 I* a5 B
        }- p$ `4 c, b( Z! P1 R0 l
3 q8 g5 H/ _! m4 ?  h6 [6 A, W+ Y
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {& k7 o( e, n1 }% S9 m' V
                addr = base + cnt;        /* pointer arith! *// g7 m0 i5 w$ P* g0 ?% r6 w, P
                val = *addr;
' q" W2 K4 a; k                *addr = save[--i];
4 P( s- O! N) s: Z; x" _2 I# g+ X9 |                if (val != ~cnt) {4 K& r9 Q) M3 M! K" N: t4 g
                        size = cnt * sizeof (long);3 r, v( G& E# t6 D- C' Z" e" {
                        /* Restore the original data before leaving the function.. h" o% Q! y0 r# y/ ~  s
                         */
! N" X! q, h, H4 v1 _                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {" |8 O& b' _8 b" Y* Y
                                addr  = base + cnt;
4 p  H5 B8 x. Y/ V* n. t                                *addr = save[--i];4 Z5 M. K# W( W3 p
                        }3 z4 i1 i$ o0 b% i# U& K7 I* i2 G
                        return (size);- c8 F5 M" v5 \3 T
                }
; e. e" ]& W: H, r        }
$ I4 N% T# \( F- `3 p* b6 W
, k5 O& y; x- [5 [        return (maxsize);! g- l; B. q) P+ N
}0 f: ~5 f8 [4 j
int dram_init(void): Q# r2 o9 U$ P, E7 y' E  D# @+ |
{
' J- P$ l% v& i* c        /* dram_init must store complete ramsize in gd->ram_size */
/ _8 }& b( ~5 D* |        gd->ram_size = get_ram_size($ p2 D9 g. T$ B9 H9 f9 \: ], h
                        (void *)CONFIG_SYS_SDRAM_BASE,) N9 f5 w9 n% q& q
                        CONFIG_MAX_RAM_BANK_SIZE);) I. {( ^: K& _* e9 L& ~$ z8 s/ x
        return 0;
3 L( c' l( b1 c. l}: d% c( f9 q% ^, q8 U( q' _* Q

6 |- {4 W( b6 z8 h4 k/ S8 L3 R5 l  J" L

+ Y" k6 p: |* i. Y) L
  e/ N1 A8 s9 U; P" K0 x8 r3 LFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
. `9 v. X! B7 i* z' P
& W, j, D2 q! _/ W! P; g. o/ O0 k' u" F6 v
/ l7 {4 d% Z" y& N6 @3 o





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