嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit4 b8 C3 i2 u$ S' _
核心板2:DDR2 256M Byte   NAND FLASH 8G bit. f! q5 h* l# |6 O
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?' {8 B( W4 d( @  Y3 U7 w6 y

! o  t& b0 w: W+ ?: t是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?0 F1 \9 Y6 Q  }, k3 ?
$ G* h: i: {0 o- V& Q: L+ t/ l

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
; B% r# H" D5 H! b& c7 N/*
6 K# N5 |) Q& ?* Check memory range for valid RAM. A simple memory test determines" a8 W! b" n: `( o2 W3 K! B" f
* the actually available RAM size between addresses `base' and
' U, r' D+ ^: E- G5 e* `base + maxsize'.
1 g! E) [+ k9 L*/
& Z3 g0 }& c9 N* z7 R3 D5 E0 }* Ulong get_ram_size(long *base, long maxsize)
- X/ O4 Q0 s2 C& ~4 y{
; f% m' O; [$ }& q: D# V; y        volatile long *addr;' m2 [% D9 c! V- b6 W
        long           save[32];- G# w+ S2 j* O* {  r% P( J6 V' |
        long           cnt;& h* w5 T; w' U  ~" K
        long           val;+ t& g. Y( @- R
        long           size;
% `& ?$ r+ x6 i. E        int            i = 0;! @5 B3 B% z0 e, e2 z/ K7 T+ n
9 ]* c  [( b' ]/ ^
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {/ ?1 j- A8 ~! Z, {, `* x/ [
                addr = base + cnt;        /* pointer arith! */
  {: i# _. G5 E" _0 \4 `) r                sync ();
. _, K6 u# N2 Q9 n                save[i++] = *addr;
' R# M! \( _: Y& W3 l! R                sync ();7 Z* P' u- y/ M, ]
                *addr = ~cnt;8 w* Y/ ?; b! h/ D  z9 B
        }, t; c; a( w: ~; M. a

/ a; T! X8 U7 h! l3 J  ?        addr = base;" y. \3 f+ a' l9 R* ?& g, e* t
        sync ();* b- V" v* j$ Y  m1 ?5 e
        save = *addr;
( k# X9 C+ w3 F) W% [+ \        sync ();% Q) _" ?  v7 G: l
        *addr = 0;
/ U- ~' e. f% G7 {, v# Q
% k7 q7 z5 j% M, ~. ^        sync ();2 F$ n: B( P1 [' b$ R1 r: g
        if ((val = *addr) != 0) {
1 }! ?, K! ^$ k# r                /* Restore the original data before leaving the function.
6 }: l: K1 ~6 U( k3 L2 B                 */
# x2 \6 y" f1 C: f" l5 L                sync ();
! u6 ?* X. c5 i. M                *addr = save;
0 M! J) u" p! q) ^+ h( ^4 ]8 z% i; I                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {1 }' w) D6 q9 h8 L% A, K4 R
                        addr  = base + cnt;) x* d( k% P  `4 _2 @
                        sync ();! j1 L4 f2 Z, s
                        *addr = save[--i];' M* \( v9 v& n; Y
                }( ~" b  D8 }$ m- p7 K# D
                return (0);3 q3 Y$ x1 C/ r  K7 X) V
        }- j+ n. e/ e, @! h

; r' w: M  }1 ~        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. o5 D* T& B. r" Q( Z                addr = base + cnt;        /* pointer arith! */
) m& ]& C  y4 ^2 Z                val = *addr;
5 |( d$ ~3 s* g6 B* p                *addr = save[--i];
  H' L/ ]9 s7 [9 ]$ F' c1 i: @( k3 H                if (val != ~cnt) {
& v  t+ a7 Z' B0 f* C& f$ @                        size = cnt * sizeof (long);+ F0 ]$ `: ~; k! v
                        /* Restore the original data before leaving the function.
* p& [$ p7 ]) w! @                         */6 |1 I4 R0 {+ z% c# E
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ a  a8 Z3 K( J2 [/ _
                                addr  = base + cnt;
- o, @, ]* z0 U                                *addr = save[--i];0 e: z, u& N) |! N. {, ~
                        }  S* T; y! |% i4 a" Q: M4 _4 q
                        return (size);
$ B1 Z$ n( `) k  _                }4 @% V7 y, A/ _
        }" a5 m7 @# [4 j
; s. Z: Z% l. a6 A; d4 F4 }# z
        return (maxsize);: [7 N: r! K5 y6 _- T/ D9 S2 X
}
: Z: D1 r' N; ~( w+ q2 u7 Vint dram_init(void)( L3 T6 [) M) Q, p8 b# i
{% S% k2 Y$ `' M' k% K+ G
        /* dram_init must store complete ramsize in gd->ram_size */2 j6 f; t5 u; D
        gd->ram_size = get_ram_size(# e# \& i9 d: j" `
                        (void *)CONFIG_SYS_SDRAM_BASE,  L- O& h* o' ^
                        CONFIG_MAX_RAM_BANK_SIZE);
. ]# E, Z9 ~- V* d. w" |        return 0;
$ X. P$ f9 D% C+ {6 G: ]& l}
1 T/ K2 v' o( w# w7 {+ I3 O
+ Z' T0 S5 C1 s4 I7 B8 s, o+ k4 M, @3 `- K8 X

9 ]' ^4 p" c/ g" _6 z
0 \# @( w2 c3 B& H( D$ HFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!/ E, g9 o+ V) p' [; Z
! L2 D2 b, [5 l: m
  `! X1 T: M1 J& e/ v5 W
" Y( c7 L& |" j+ M+ \





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