嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
# I; y6 i7 s  q+ I" N- C核心板2:DDR2 256M Byte   NAND FLASH 8G bit
1 g: p" u+ X, R5 M1 ^0 M这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
. a0 E, c/ c) n5 I) C3 H; b' P. S# [
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?2 _1 z* |. X# l0 Q. d  |( i) O

$ r4 N  \$ J: N0 h
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) g3 b# t+ A; Z0 T/*
9 J1 p6 J% v  i5 g1 [. X9 Z* Check memory range for valid RAM. A simple memory test determines5 O- B; {; G2 ?; O$ O5 V2 q  I
* the actually available RAM size between addresses `base' and# N" W! x/ g( }; m% c/ T
* `base + maxsize'.
( d) a, Q  ?5 j/ j" V& b2 `$ D*/, ?! B0 ~# W; v8 Y/ V7 R0 c
long get_ram_size(long *base, long maxsize)( E, _0 p4 V0 y3 i1 D
{1 a$ z! }/ F3 n0 ]5 Q( H
        volatile long *addr;$ ^5 m6 G- B4 V
        long           save[32];/ n. A- a7 Q" K0 L5 l  _
        long           cnt;1 h" W: H9 e1 \- w; j
        long           val;9 s/ }, S% m) {
        long           size;
! V; Y. H8 x% [3 t) s$ ]        int            i = 0;
/ E* ?% i$ A4 ^# U% l& r3 q8 a; g3 I  V6 D) @
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
  P: Y- h& [1 v  [6 d: Y$ [                addr = base + cnt;        /* pointer arith! */
7 }# p% N  Y- P9 G: v9 c  H# s" J                sync ();1 D& c7 [7 P- Z! S
                save[i++] = *addr;' X! o7 g# I% X( s
                sync ();8 I- K( E+ X& i  m
                *addr = ~cnt;
9 J! W" U" a6 o' L6 v8 Y# V& t        }5 U+ F: l+ G) @( \

5 N2 P1 Z7 B8 v0 @; k7 Y# \        addr = base;
3 o3 H" n+ L# v* c' z* O        sync ();) F1 s% L' Z: M2 M& n; Z# D
        save = *addr;4 O) G$ Q2 g$ ]* M8 j
        sync ();
* L2 l) i2 M. O" T& y/ o) r9 f        *addr = 0;# g& V+ {7 }0 Q) H+ q3 a

) `5 [; m& d/ u0 ?1 ]        sync ();
2 t! N7 t! |/ u+ }" I, |% F0 Y        if ((val = *addr) != 0) {+ L( r$ ^5 A- w1 m7 a
                /* Restore the original data before leaving the function.
; M- }5 R# I. b( a7 k( F# F                 */* V7 |4 ^. I8 J! l1 ~- u3 G% j
                sync ();2 N# E0 z5 P# p1 i
                *addr = save;
1 x/ C' @6 Q$ \* K% o                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {. d* n, _. u8 O
                        addr  = base + cnt;  r5 L$ \' R+ s, o, t# O
                        sync ();
* d+ _4 I7 y( F3 K6 d+ F                        *addr = save[--i];8 {* Q& d6 o; H
                }: g; d- K, g+ V0 ]. V
                return (0);
! X: y4 q$ p: n  a0 N        }
: c! {3 Z% E) y! \2 D2 G" `' e4 h% k' U. n' D  u7 |) W; I
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
* y2 [( F8 c! r                addr = base + cnt;        /* pointer arith! */
" g" \  I( c1 o4 k                val = *addr;2 B: @2 A7 [; H2 q+ t2 p0 X
                *addr = save[--i];( X  M, ?8 ]/ k7 Z! ?: c
                if (val != ~cnt) {1 a6 N  W4 f* F6 S, h
                        size = cnt * sizeof (long);5 f" G6 k  ^7 S& y. ]5 R
                        /* Restore the original data before leaving the function.% }- }$ K  ?0 r- B. A& `
                         */" D2 A8 c' |2 J$ Z( R
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( y+ F3 ]' i. m: U& p' M3 F  e                                addr  = base + cnt;1 q! U8 x! G" {" ~3 f% |' q
                                *addr = save[--i];
  G$ [; ?% E% M! n0 \; b( U                        }
: m, }6 K( D9 M' g* j' x! x                        return (size);
( L$ j7 p! |8 y* \' r) q                }( D+ J: O5 q$ @! ?( {
        }) k' P% o& f$ Y7 P# }9 D
9 I7 y( v5 o( j8 O5 e: P
        return (maxsize);
- A+ M0 ]3 u3 B5 i}
* @8 J, p7 ^% K3 ?4 v& i% tint dram_init(void); j  n3 I3 C& s" j! m2 G- B- S; Z1 e7 K
{2 E$ \$ L0 P5 @3 F+ [3 h
        /* dram_init must store complete ramsize in gd->ram_size */$ D7 w/ S5 d( h. g0 R
        gd->ram_size = get_ram_size(
  ]& |' j5 t: y& X- N3 d                        (void *)CONFIG_SYS_SDRAM_BASE,
8 x3 O2 O5 e1 v6 Y8 `4 H! `$ J                        CONFIG_MAX_RAM_BANK_SIZE);1 p0 R7 B9 s( k* A/ L5 G8 @, a+ L
        return 0;
1 r) Q0 q5 N( ~/ p: O+ Q}" b  k* ~; l1 G) y  p
, t% L. {+ L6 Q

/ R: C! J0 k% \* m; g. R2 z# ~; f' d* @/ B$ N

- s/ f1 u8 j5 U# ?! h) R0 l. OFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!- x% y9 ?/ c# O

" `7 S: p" {: c( N; c+ r6 u3 D' \
2 h' P5 ]* f3 ?1 U3 w" a, \  G
2 b7 l7 ?5 o# H





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