嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
. l. e9 c, Q) O, W9 R. f5 D4 P7 e; c核心板2:DDR2 256M Byte   NAND FLASH 8G bit
/ w  F+ \# r  V( p这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?4 G$ ]5 c* W* K' A2 I
1 D# x* [& s6 _0 l: ]2 F, e
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?. d$ a/ k* I7 O$ ^% K- g3 T; j

( p" t# a" s! M5 c/ Q. R/ F  e
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:7 A- Q- d$ i% y2 a( X
/*) |9 u  X9 x# T; G+ `
* Check memory range for valid RAM. A simple memory test determines
; n( _: P/ \3 J- \' L* the actually available RAM size between addresses `base' and
6 B1 J! w7 d0 T, S  f! U/ m* `base + maxsize'.# M0 L! O1 |2 R0 `7 E
*/) z0 D8 d# W$ j. Q& R
long get_ram_size(long *base, long maxsize)
4 M: K/ i/ o& R, p4 Z/ q9 n2 N/ Z1 Y{
: K  _/ c( o4 U, G6 W8 ?: H        volatile long *addr;
- B/ h* }$ E6 F# T$ S' j        long           save[32];
' C: y% {7 \5 ~$ b* V        long           cnt;
, f* T' Z$ m1 |% h. B" \; T% A        long           val;
5 X0 R) M9 s: ?        long           size;' {5 y# \( a7 M, t  X
        int            i = 0;
, b0 c) F' Q$ Z* k: s' T4 b9 Z
7 n& u7 r+ H8 x- M        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {; F; f1 S# b; \! {! p
                addr = base + cnt;        /* pointer arith! */' b" W" M' K% I
                sync ();
1 B2 ~: _" @4 h                save[i++] = *addr;
" J5 a- @# N" M                sync ();
5 G# P5 u9 C8 P8 k6 i# n3 _8 l" V                *addr = ~cnt;) T; B4 {0 c& t% c: D$ f$ k0 Z4 T
        }
3 G, w. V* H$ G  Y: |1 L1 g" d+ h0 e+ c4 m
        addr = base;/ P' ^5 `0 u2 ~$ ^# k2 D# C
        sync ();8 [9 E, q* R7 S
        save = *addr;- b" M. Y- q9 A2 ~* g
        sync ();9 o2 e6 o' s1 X2 D" i
        *addr = 0;
% O7 i2 i. e8 L5 L% a, @3 P
# Z3 H, g( G7 o/ R8 n3 ~5 m        sync ();- U; |) p$ [. V* O, \9 Q
        if ((val = *addr) != 0) {2 J; @  C  A0 Y
                /* Restore the original data before leaving the function.
# A4 l7 r) ^% E; {1 t( o                 */
4 q  W. l; O8 O4 C! J. F# |                sync ();* s3 ]6 r- a& R" S* Z" i3 G
                *addr = save;6 Q: t: s7 w- d9 t( n4 W2 B
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {# w# U: S: A7 c
                        addr  = base + cnt;
3 O6 v" Y- x- P4 J' k. v                        sync ();
1 ^$ N' s: h$ @0 O4 |7 ^3 K                        *addr = save[--i];; p0 ^+ y7 s! M% m5 ~% j2 n
                }6 s" U3 I: N# u5 y0 s3 e+ r
                return (0);
) i5 Z4 C! [5 C: H        }
1 {0 }  ^  z, y. H, Z) N) q' t: F0 C- |# L3 V2 z
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 Y9 X* R. G, k! i+ J                addr = base + cnt;        /* pointer arith! */, I: ~2 U4 D, c: W
                val = *addr;
4 a+ f' u1 ]( h+ x' f/ X3 ~3 q- n! z                *addr = save[--i];
9 ]7 R% l- Y5 g: L' n% o" j                if (val != ~cnt) {
; N; _5 ~* }) K                        size = cnt * sizeof (long);: Z4 a8 h/ w; N+ |3 j8 c
                        /* Restore the original data before leaving the function.. n7 a% \( J5 u6 X& [
                         */
1 R4 a* B% ?" C! L( x2 q! V) H  i                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
4 m1 v! q( j( @; E- m+ x/ l& z                                addr  = base + cnt;
  _9 y/ h, t/ }                                *addr = save[--i];
6 S1 A2 v+ o3 g4 p9 M' j* }6 ^                        }& @2 E1 u7 H/ v2 S1 o
                        return (size);
( f* {: U8 _2 q: B* f- Y6 N                }: L/ y& H+ o. N+ l* |; j
        }
' B6 N; H4 q% G; r, |0 {
3 h# U0 V1 o/ M2 ]$ R        return (maxsize);
# P; `* y& \$ d# D5 y5 t}2 q) ?$ H4 @9 L+ p, {, D5 v8 i0 ^
int dram_init(void)! a7 `. U/ N* H; j$ {- L
{
8 b( p# T1 p: r- P1 @6 {$ h' V        /* dram_init must store complete ramsize in gd->ram_size */
! [; e" |# E* n, K, z        gd->ram_size = get_ram_size(
$ T8 y0 N& J; G6 H2 L                        (void *)CONFIG_SYS_SDRAM_BASE,% g& y1 V; h: |" ]$ w. x9 v! ?
                        CONFIG_MAX_RAM_BANK_SIZE);
1 `  j( H, h* t* n        return 0;
/ V: d/ F' m3 v5 |5 ?) z7 ]# g7 i}* t5 j" Y+ `* L; ]  j( ]

7 Y+ l8 u8 B3 i3 r  E
: V) e6 i& P9 c- l0 H5 K* F3 n; E- J+ C. X  G' E
- I, H- v: |* g  x. i7 U1 f- y: Z
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!* ~" W8 }) l- d' Q
* U+ b6 |. u1 N4 L
6 e$ z" v; k2 R9 s  o
& R% Q; ?$ i/ z+ H8 i0 p) `" o





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