嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
5 m) F5 D$ ]% N7 K/ [8 n% ?核心板2:DDR2 256M Byte   NAND FLASH 8G bit
: f; h- h$ p# L  }$ I这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
# W1 @5 x; B: ~2 k# f- w
/ u2 L' |# n( W0 b' I& I: K  ?是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
5 U$ m6 s; Y1 \) L, F2 m4 r, _/ D, I  M: [1 r! S

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
) `, S2 a: M9 \, Y& t- b/*4 L' E) v0 p$ v( D$ }, L" y
* Check memory range for valid RAM. A simple memory test determines
1 C+ x8 x6 F# S* the actually available RAM size between addresses `base' and' O9 ]7 G/ |  j8 E; M7 m6 Y" O3 j
* `base + maxsize'.
; S3 k3 f! V) {+ _" M*/7 Y" }/ D: z  C0 w
long get_ram_size(long *base, long maxsize)2 L' H- q1 j4 q+ K
{
; g3 o. \2 E% @, n        volatile long *addr;- q5 _, C' ~% E' c; s; o
        long           save[32];9 M4 H8 p3 N- c4 p% D% \
        long           cnt;
- W( S' A# y7 i) k* N        long           val;0 {6 ?6 B0 a% e
        long           size;
/ r1 G' ~! k+ z' E1 o4 \        int            i = 0;
3 q! L; [- q! n* f9 I
0 \& l% U9 s1 {5 P: [3 u2 X        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {5 f2 {. Q5 B/ a& b; L) q( m8 }
                addr = base + cnt;        /* pointer arith! */! @! w$ X1 x# z& I4 S5 X
                sync ();
. V0 F: j/ ~- U! }2 @) F) c                save[i++] = *addr;$ ~+ V4 M( G" T/ O: X
                sync ();! W7 E. ]# L, y6 Q. v% ?
                *addr = ~cnt;
6 z7 _& s3 v7 r1 i5 o) d. g        }
- j8 c6 p) l$ a4 m* o& l; q& A0 z. r
        addr = base;
5 C' C- n+ A( ^        sync ();
' F3 |7 _  H- R4 I5 W$ r, c2 z        save = *addr;. J) L" a1 Z( F) K" f/ W* O
        sync ();, y0 ?7 C+ c2 K9 e
        *addr = 0;8 h# Z9 r5 g% f/ ~

& w6 e2 e4 o, E9 E2 i- m# }+ }1 O        sync ();0 \0 `$ m9 S: w
        if ((val = *addr) != 0) {& v  s4 T: N& \7 b% t6 u
                /* Restore the original data before leaving the function.
. F4 g- z- `$ l% v                 */6 m: `/ }1 o6 U5 m: l3 \5 T" v
                sync ();
  l0 h- J( [4 `6 \/ U3 I# I                *addr = save;' u: M# \0 l/ G) a
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {1 H& L3 B# @4 X  w4 `+ `8 D
                        addr  = base + cnt;
( A, k! ]3 O2 ~                        sync ();
# z" v" @/ F- j! O/ J  y" C                        *addr = save[--i];
4 T5 l+ r( K, p' d9 N                }# T* S& k0 q2 h, H
                return (0);1 s0 N" F! ]) S1 P- v- c
        }$ U1 X# B& V8 @0 }

( L+ P7 {" h8 ?' s        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ _0 i) `/ \" q, c
                addr = base + cnt;        /* pointer arith! */9 U% V4 M" N, m1 p9 a$ o9 U' ]
                val = *addr;
0 L9 q  M7 U. H, k( O9 C4 m; }                *addr = save[--i];
. n* R1 ?4 g5 |) P# U. z" J                if (val != ~cnt) {$ z6 H! w8 A5 u( R) w
                        size = cnt * sizeof (long);
: K# I) t& K3 R$ G& v# c  ]                        /* Restore the original data before leaving the function.
5 h# H! O, n* \$ B; |/ i9 T                         */
4 r0 U5 E  E4 |6 ]% Z                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
3 F: i6 X( g; f: M. r& |                                addr  = base + cnt;/ b7 e# C" z4 K/ J5 ?. F- `
                                *addr = save[--i];( Q- h$ M$ ?$ P9 [' E7 r! r) h
                        }
8 h6 @' a* f9 @+ v% m& c                        return (size);
( ?  s% b& N- [& Q( a: V                }+ ^9 [9 P$ d$ v3 J! o% _$ i4 m7 N" k
        }  Y0 F& J* C8 O5 }0 B, Q: `

" i% Q. i) Z9 E8 x1 o% {4 B        return (maxsize);
( h& ?  V4 R6 q8 h$ d" j" F# d}2 c4 `0 V. d1 }8 ]& {% e) ^
int dram_init(void)8 E9 S6 ?: K) y
{) ]4 c& ?* r& g
        /* dram_init must store complete ramsize in gd->ram_size */
3 d0 {) _$ C' `! x6 w! Y        gd->ram_size = get_ram_size(
: R, C2 ]* ~" c) ~- k                        (void *)CONFIG_SYS_SDRAM_BASE,
+ M* Y6 V. j! e                        CONFIG_MAX_RAM_BANK_SIZE);% t6 @! C) B2 z  f
        return 0;# k0 F9 Z  t* k" j
}* c, k- o  a$ x- z. a0 y  M

4 q7 M( F1 [- V: s) Z
7 S3 t$ Y' v  O. Z  h3 m
- w, g1 ^7 I( c- j
6 X6 |+ _$ y" ?5 y" }- PFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!# n, |) d7 g& S4 t5 K

* i5 g! |" \" w+ y: \9 N6 [& p2 ]
1 d9 v% D5 U4 K1 A' _# E8 H( f





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