嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit) f. d9 R3 }4 ]
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
7 s: o5 B9 A. ~9 t3 G# b0 K这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
2 O. F5 K$ Q2 Q6 H( S. C: q5 ^" A) m4 l7 a. R
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?% s) ~  K1 O# G1 j' R$ N  L

0 B* |1 E& I0 `! v) c# L  B
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
/ V2 L) z: i- A  d6 S9 g+ V/*
  i! `$ q4 v7 b: H9 c* Check memory range for valid RAM. A simple memory test determines
. l2 ?/ |" l5 z4 E* the actually available RAM size between addresses `base' and4 R6 n# Z! C$ w- g/ f6 g
* `base + maxsize'.
$ n4 o& x5 [# h& E' @*/2 j2 Z* g3 J9 M; W
long get_ram_size(long *base, long maxsize), [. v; O1 ^" @) _
{/ M4 |2 l' v" Q: o; Q$ g$ u8 |. Z: o
        volatile long *addr;
: w2 M, C0 q( [        long           save[32];( [/ c1 M4 N7 X5 m
        long           cnt;$ ~0 Q0 ^# ^; W! m
        long           val;, {2 y' ^( E. t
        long           size;! K4 C) s4 F" [( m, e& [1 H3 Y
        int            i = 0;6 T7 C4 \* r- n6 H& a/ {
  ~$ s! A, i% d0 t6 U
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {! ~+ r/ A. u: E1 ?' M3 B! ~
                addr = base + cnt;        /* pointer arith! *// r6 X# p0 K9 Z, Y- M+ _
                sync ();" t$ H9 j* P. w! v7 T1 _3 ]
                save[i++] = *addr;
4 j6 C+ X* E% V4 r1 {+ L1 A                sync ();  ]6 f5 |4 q1 Y0 m
                *addr = ~cnt;
/ p$ l, l: y: o2 |+ r) `( P4 ]0 ]7 ^        }  q9 l' m  W& @
8 ?# W# m! E( z
        addr = base;
. L+ `* d3 }! Q+ \        sync ();+ |$ G: N3 Y8 n/ }" w3 R) X% Q
        save = *addr;2 [4 y" S( Q: a0 y: J& w3 s$ A
        sync ();
, D8 D4 i1 P, R* r5 g        *addr = 0;
0 _$ z6 r5 Z; h% ]( `9 U/ y' |$ H! F" _6 x
        sync ();, T5 {; e! c2 e5 `
        if ((val = *addr) != 0) {1 [9 ^  i  j* R0 Q% m$ ^; |
                /* Restore the original data before leaving the function.
3 ?" w4 j7 `' Z5 E. I9 f; s8 a                 */
* t0 F) ]. t0 `                sync ();
, S/ o. c, U7 R7 \, d+ I) P                *addr = save;
4 z& }. x( m1 S8 ^                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {& C  z! P, b) t9 T/ X
                        addr  = base + cnt;/ R& J( K  p; k2 p4 a# ~1 T$ X
                        sync ();
* ~2 ?' N" f& i: i                        *addr = save[--i];
" v! |7 w; ^4 {+ L                }2 Z' v6 _/ Z' L" g
                return (0);
' f3 `2 j* X1 S+ Y# i3 N' m! [5 R        }
3 \. G9 K( F5 {2 U# {( [# i) t5 {+ q' P5 K
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {4 K6 s( x6 c) E$ {" [
                addr = base + cnt;        /* pointer arith! */2 g( q2 q0 u2 C; `( y! z  o% Q
                val = *addr;
$ ]- {, k# P5 G4 p! [                *addr = save[--i];5 b, u# l* \' n4 l% q- p
                if (val != ~cnt) {+ }" G; |# f5 }4 x! t5 v( W
                        size = cnt * sizeof (long);
  E+ ^3 C2 ]1 N) j                        /* Restore the original data before leaving the function.4 ]+ m: X. F& e% s; n* m# n
                         */
! t3 R2 V% g) }' t# a1 ^$ x                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; I* V6 s; H  U$ [; s                                addr  = base + cnt;
9 R. o  J: [/ `- z& d' i6 D                                *addr = save[--i];6 V* [' D0 U; [' b+ m5 S# H
                        }8 G, o1 W3 [' r$ H; g% a, M
                        return (size);
1 x' x4 p- O. p3 E* N                }' }" |/ Z2 |: m/ |3 n
        }0 J* H! i3 c( r5 F" m, z

5 j$ i4 D- y1 l* R; Q' P- k3 t        return (maxsize);/ G) I4 L0 H+ }# M1 [* ~
}
. v% v4 X/ S; [2 S! ?int dram_init(void)7 S5 O; w5 t* B' J' \% l! q" f& g
{
* Y: r$ V: ~" j: y# l9 t9 q        /* dram_init must store complete ramsize in gd->ram_size */! E. a" G0 U3 ?; |" s" F6 t% |. A
        gd->ram_size = get_ram_size(
  p) ~" v3 J/ P  `4 o                        (void *)CONFIG_SYS_SDRAM_BASE,
* z7 q3 T( j  \( |1 u                        CONFIG_MAX_RAM_BANK_SIZE);; F2 _# N" ?9 o5 V; I
        return 0;
6 ^3 j% o- ~1 C* `, Y& w8 H}
, h/ Z4 {$ f; \- J0 ^& H- n" i# F" c3 ~. s8 D
' I7 h, z% {: @; s7 e! J6 h

' D5 y: u0 Q$ W; {$ R0 e# k' L0 L' h# I9 G9 I1 [7 F
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!' d1 X; E. b9 B0 a9 c/ |6 o' s

! P% H8 @. o3 ^% k, ~3 h, s3 H: V$ x( ~  M. a
" s3 }9 Y- b# P0 n4 M0 U/ n





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