嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
( [2 C" H$ x" h4 t% N; c9 w核心板2:DDR2 256M Byte   NAND FLASH 8G bit
8 e. Q, n4 K" p+ `5 b, ~8 k这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?8 W0 p6 @( n$ i! i

2 i# [) y! i5 o( H6 k是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
2 u7 b6 Z9 R( S& V
! _7 a$ l( t1 @
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:, S4 }1 @9 L9 N" S& R
/*1 E- ^: }. |- j9 V& E! k
* Check memory range for valid RAM. A simple memory test determines+ [7 J9 L+ ]) s. p& G5 U/ Q9 S: K$ c# c
* the actually available RAM size between addresses `base' and
& R8 e& t+ a- N* `base + maxsize'./ H- x5 }$ \( Q( H' G
*/
7 B. y. j( X. r  l0 Hlong get_ram_size(long *base, long maxsize)" f: m+ O% \, T) |* O
{3 Q8 q0 V/ s1 i! \* C" G& D
        volatile long *addr;
" Y3 o) A( |* u" X- o  x( \# u$ H        long           save[32];/ V" N# {3 }2 b" J+ |& `% l
        long           cnt;& \8 r9 _9 R! O) ^5 i' _$ d( F$ t/ K
        long           val;2 C- ~9 L2 b, u& w/ A1 O
        long           size;
" |/ n0 `" Q+ q, ^7 X        int            i = 0;3 T+ S3 t% d1 B2 a/ x; E. u
! F5 U4 ?* P2 T4 Q9 v
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {, T, P3 h* W% Z9 z  m- u
                addr = base + cnt;        /* pointer arith! */
6 \& J5 V# n6 o2 G                sync ();
0 _! `$ M) }* ]$ V9 t5 C- u                save[i++] = *addr;3 v# j* d  r0 L/ M5 b  s9 b
                sync ();
; V& o% b* o/ _. g  i. H0 M                *addr = ~cnt;
- ~" C& Q3 _2 D( E        }0 p' D4 L0 t  S2 T

2 ~: Y7 e* \: e. h% h) {8 N/ i# k        addr = base;+ @  T, v' r) I5 q% ^8 x1 V
        sync ();2 w  h7 a/ _- h. K2 H! }( W
        save = *addr;
( j; i) U' W3 f3 n; D" I        sync ();
: }' Z/ D/ N( f& e( c        *addr = 0;) |) t% a/ l  c, z, [+ z1 t% ^) @
/ |0 o/ Z0 m! K: r
        sync ();
, m' m3 Y) i+ ?4 a        if ((val = *addr) != 0) {8 l5 O8 e2 `$ w! u% u5 d) ?
                /* Restore the original data before leaving the function.! _1 C, P9 [; a) a; e
                 */, E8 m# e, ^* D- r: \- P: N8 ~# @
                sync ();: w; F& O; X  l% E5 E% G& w4 T
                *addr = save;" M/ T9 E4 R, B, s
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- ~6 |2 c* }  j# O* ^9 T                        addr  = base + cnt;
" Z$ T& l" Q; q/ N! T2 r1 _! O- w                        sync ();) x$ i; i9 l  A5 d( V: e: @
                        *addr = save[--i];7 c* z& O* J8 t  W, L. H
                }' }, j- V( `2 j# k
                return (0);2 v* n: \$ n1 S- |4 j
        }
" q  {, e& z9 y
6 i% l0 ^. Q% y- K' F6 o( G        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% }. D) i: N8 c! I7 A                addr = base + cnt;        /* pointer arith! */3 s7 B5 l3 j% n: r* b8 C, Q; @7 s
                val = *addr;
' s0 V' r1 t( d                *addr = save[--i];
# @; J5 P  q7 }) W$ [  p                if (val != ~cnt) {
5 F' i% o; t# m# s                        size = cnt * sizeof (long);" ]: `: H2 X2 o: H5 n
                        /* Restore the original data before leaving the function.3 Z' z. `/ Y5 S) n# P
                         */2 {' Y9 ~+ i+ O$ \  c: w* |  A
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- m# X/ u9 F; V% g; w, b% I                                addr  = base + cnt;7 X) k# w, r! Y/ F* ~: D( p, [
                                *addr = save[--i];
2 |; r4 {& L8 I                        }! ], \; w# |; V3 L
                        return (size);) S9 U0 |' p  ]
                }
5 W. ~, [3 S' N7 r        }, E# K( P1 @& ?0 E$ H! w$ F' i# C4 z
* Q( D/ B* \6 @
        return (maxsize);) W2 h6 D, @+ G6 U$ ?/ X
}
9 x8 A* a& N: b! |: I* y$ pint dram_init(void)
# q' x' q' l1 x% `{
; h  f0 ?; Y" f% H" C        /* dram_init must store complete ramsize in gd->ram_size */5 N8 Z0 F3 o% t( ^/ D6 p
        gd->ram_size = get_ram_size(
' y8 l2 Y% ^9 p; A' p& [! Z/ T, i                        (void *)CONFIG_SYS_SDRAM_BASE,* f+ p; y5 x- x/ g6 c, L. Q
                        CONFIG_MAX_RAM_BANK_SIZE);/ |6 \8 u+ t/ |! e
        return 0;( r- a7 Y8 @4 M; [, Z
}1 d% R, I7 @; o, l$ u, u
. y( j/ z/ y6 _3 I; E% u2 e
7 |0 P# Q4 i2 u

6 y! h6 S( g9 Y1 I4 P/ _6 c, Z- ?/ v: @& g$ [
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
; d' M3 q6 x7 R& D7 c" G
# v5 P9 q+ T& Q1 F6 q$ E# _) H- g# A# c

% E6 b% k; J' {




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