嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit% H) a% ^& }+ z
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
* B( Y4 ]1 p7 P' n( K4 ?" h( k这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?) ^/ Q" Z" J+ ^* ?- R+ @. r% p- T
5 p; }) F5 c# U
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
& V7 b7 F  E! K( n& `1 c1 C4 D0 G0 s- ~$ b$ Q& ^, C2 T; L" g

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
% C" ~  z5 ?/ u- F& j. p) P  C7 ]/*3 c8 h6 _% p& q+ `, H/ L9 }
* Check memory range for valid RAM. A simple memory test determines! y& V7 ]1 ~; z: ?# n
* the actually available RAM size between addresses `base' and# S& A' @1 a. Q/ o5 U: L
* `base + maxsize'.# p3 h0 c" t' @, H$ E; s
*/% M! U/ g2 i( V1 J/ z+ v
long get_ram_size(long *base, long maxsize)! o9 A# _2 R+ {. C& b
{0 K3 T4 F/ l$ I6 }) r- D1 a
        volatile long *addr;
; [0 c. ^9 r( k$ H% B, s( j  n        long           save[32];. ]6 V3 e3 E1 }6 e; n- f6 J
        long           cnt;
  v# b# H% a7 j. \2 d" S, X4 S% R        long           val;* _. t7 G, ?  N5 W# M4 {
        long           size;1 ?7 C+ U& I7 ]* L% |* e' h; B
        int            i = 0;
' \3 `: x1 J& D7 h
2 a6 O9 M# V% l" v        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
. V( y/ J; s# {. x                addr = base + cnt;        /* pointer arith! */
1 Q4 l" D! V+ m/ V! s1 \                sync ();- R0 ^( y' }3 H
                save[i++] = *addr;
1 L# S- L) V+ b9 q( n+ e8 ^                sync ();
( E9 S# _7 ?" _" B( ^                *addr = ~cnt;
( X* f" R$ K6 B( ^        }" k& h* [  v( a. m* f

' `5 B! o& _( T7 F        addr = base;4 V) z5 z3 D. ~
        sync ();5 V) I9 w+ p6 i7 r  {( B( O
        save = *addr;
. V8 b6 k: P9 I" A: p/ R/ }        sync ();
3 n" L  _8 Z9 L# _        *addr = 0;
4 F& i. }1 j2 `/ Y
, Y- p) k+ [% L8 ^- v        sync ();
% q/ u) d5 Z7 h- K' L5 D        if ((val = *addr) != 0) {
) ^+ k* s. [2 j" n& U$ c7 u                /* Restore the original data before leaving the function.
7 U4 R+ @/ q6 N  K1 @& J                 */
0 f, c% }- u0 T  e( `) S$ O# V                sync ();3 ^  ?* G* d1 q- {
                *addr = save;, O) I. C: D1 i+ r) c5 |" B
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {3 k# ^% E3 X9 V$ m5 U
                        addr  = base + cnt;
  O7 o# V8 R9 W4 ~2 r3 d6 z                        sync ();
' X8 m% [% s1 ~: I: ~9 j                        *addr = save[--i];
# o$ o6 t1 o$ S4 t0 ^                }
" ], a3 O% n: J8 C  q+ D! Y/ K                return (0);/ n% I& O) e. g# B8 A
        }: d* x! O4 ?/ ^$ S' h% P
" i% o; g  J' m2 f- V
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ H  C8 I6 j0 P1 u  t0 p
                addr = base + cnt;        /* pointer arith! */8 Z, X( [' ^, L! T
                val = *addr;9 p9 N+ q) r+ C) a0 M
                *addr = save[--i];8 q8 `% w( T. Y" M  ^; ?
                if (val != ~cnt) {9 Z# e9 o% r$ ~% ]
                        size = cnt * sizeof (long);
- j; J4 F8 d+ E% V- ~  L                        /* Restore the original data before leaving the function.
: f3 S7 D7 l) ?6 D4 z2 R                         */
3 k# e  `0 ^6 U& U- r4 Q                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( K5 W+ E3 D, _7 r                                addr  = base + cnt;
3 x8 M* U) |* `                                *addr = save[--i];
$ q) ]* |2 R" z% G' P, l                        }
) K7 N- o4 I' [1 t6 f/ f6 ~                        return (size);# N# n  f2 ~: H9 s1 h2 g
                }, G  ~9 u# J" |. J
        }
/ [$ x$ H7 p3 @5 E
) P: Y0 J/ P1 N! Z' ?+ C; e/ H- s        return (maxsize);1 ]' f+ D& d+ J/ w# E' K
}( N& f- A! w/ g+ N" p* l$ Y
int dram_init(void)
- {* V. G& j/ a9 |1 B4 Q{
3 s! u/ U! S8 L1 _3 c/ u        /* dram_init must store complete ramsize in gd->ram_size */5 h0 ~# `: [8 Y, |4 x3 J
        gd->ram_size = get_ram_size(/ J# n9 J' m, f; o
                        (void *)CONFIG_SYS_SDRAM_BASE,2 w4 L" p( z. h5 }
                        CONFIG_MAX_RAM_BANK_SIZE);
' x' |$ M0 }* R7 _1 c( y" }0 M        return 0;
: D# H; ^5 h- m& ?}
) E' m" C* G! A5 I: I6 ~- F( c  |* v3 i0 E( v0 e  W; f
1 n" ?- S4 Z4 y

& ]9 m* Z: g( I1 B3 d% v0 V; C% y' z- o  l$ k/ V
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!7 g$ Z; \+ D. E7 b4 P

8 d" ~7 C, ]5 Z2 b3 J  h& W, J6 T/ A& r& c
& ^4 y- R" V1 L( G





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