嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
9 w+ W8 D3 ~. ~! Y, H2 `核心板2:DDR2 256M Byte   NAND FLASH 8G bit  H/ A$ M" l1 t& U, E1 }) O9 }/ H
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- b# t/ l/ l" H8 j0 D0 i: Z+ Y: G: g; o" B
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?& E) t# \2 M5 ]+ s. `

9 _- P, I: H! f5 W6 _8 T- U/ A
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:$ L2 ^) ], s7 m" Y% `
/*) }9 i# `7 ?2 z) \8 R% Z/ L  B
* Check memory range for valid RAM. A simple memory test determines! b9 F2 g& q# o# g5 N" K4 V7 F6 u* W
* the actually available RAM size between addresses `base' and
1 @/ i# I% I1 R* `base + maxsize'.
! G( Z4 F9 E. O6 Q4 b- `*// L: P" r) R8 n7 {% _' J
long get_ram_size(long *base, long maxsize)4 ?/ `. i( V3 Z9 s5 T5 G: U- |' T
{
% [+ k, l, B$ o4 M2 \; I        volatile long *addr;" B9 w- y- Z1 c# k% r
        long           save[32];" z, L9 u9 c/ m2 o9 {
        long           cnt;
/ D$ W- g7 I  F        long           val;
6 Q+ D8 p" }5 n4 P  j        long           size;6 @0 F- E4 d. U0 U; Q
        int            i = 0;
( l  b/ j9 e* m: {) L1 h3 e. e6 _6 `8 m
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {* v2 Q6 ?! Q( V/ I) m
                addr = base + cnt;        /* pointer arith! */
4 b( D0 [. b) P                sync ();/ X& ~* g* n0 C3 Z* u- v- I! S7 q% @6 d
                save[i++] = *addr;2 S" f) \; s5 a9 p
                sync ();
# o! p7 ?9 M' d8 K8 Y* _                *addr = ~cnt;
4 {) K. C* r( H" J8 z1 F+ r        }
1 ~6 T8 o9 R7 z3 Y8 }% R. d: q0 H/ w& a2 _% j7 R
        addr = base;
. P2 Z9 j9 |, S: L* w        sync ();# _7 Y- ?! `. I5 O# T: T
        save = *addr;
6 {4 y- k3 u: l5 a        sync ();
1 G# G- J! J' K/ u) Y$ Y        *addr = 0;
9 x8 u: s! X/ f$ m1 _* M( ?* G
3 w+ S, R7 [7 ^* G5 _8 |        sync ();
* J" k$ s& ]6 z( h1 h  g        if ((val = *addr) != 0) {# r2 y$ Y( U$ W. i. B
                /* Restore the original data before leaving the function.
8 a$ r8 q" n" `6 \  F5 \1 H                 */
' _, R. C7 J8 d! ^                sync ();
7 M$ |) P% l% T9 L( J) P2 u                *addr = save;
, A- ~8 q% p9 [  N: l                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
0 E5 J7 ^' |1 f) X. V  q" C( ^                        addr  = base + cnt;2 u% ?1 [1 A5 n5 W. R) q
                        sync ();
* `& E' u, w8 i: F: s4 Z4 N                        *addr = save[--i];# |$ J& D! D* s1 e5 B' T: Q
                }
+ a& }  k/ x( s+ s3 ^6 ~- S                return (0);
5 [* m9 y' z4 q9 W! f' L- q3 C; L. V        }
% u! O" b" j8 G, H+ u+ F
# G) m' Q, H# Q# o( Y0 O        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% c2 ?% M" b8 V9 t' I$ z0 u                addr = base + cnt;        /* pointer arith! */
# `4 [& _+ @; j# A" N9 [; c                val = *addr;* ~) l# }5 S3 a) b% Q
                *addr = save[--i];: _4 v/ J" C, v& D) I: w
                if (val != ~cnt) {
! V" Z8 B. }6 k! x. Q/ R                        size = cnt * sizeof (long);
7 W! i. n4 r: ^# H* K                        /* Restore the original data before leaving the function.
" F1 T( k; W1 j7 z# h3 a" G: n/ i- T                         */
0 g1 ~- D+ X$ b0 L7 v; M                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {, R& _5 ]0 d" f/ R' q* s5 J
                                addr  = base + cnt;
6 A- a0 y2 \# [' B: r                                *addr = save[--i];
2 R% p7 p' Y4 s7 D! D! h# X) A/ ~                        }
. h7 g! h% I' e9 {2 m2 ?                        return (size);: b" B1 O0 w9 b) V
                }' ~/ d% w5 P0 u  ]: H$ ]
        }
0 A% U- M" D! @! l7 m, R
. I' P) i. a6 v1 e6 [( L6 E% ]        return (maxsize);
! ~) f8 k( F( [; N}  h5 r! M4 M8 m0 M: L8 v
int dram_init(void)7 B, d0 I7 s# X7 S9 p  K
{" [, k) s/ n, i8 `. ^
        /* dram_init must store complete ramsize in gd->ram_size */8 V1 D+ Z; {/ D: C) a
        gd->ram_size = get_ram_size(/ X/ J+ n% y$ A
                        (void *)CONFIG_SYS_SDRAM_BASE,/ R, l+ P+ O% }+ v
                        CONFIG_MAX_RAM_BANK_SIZE);1 N: ^/ h: d' k3 q$ A* i* Q
        return 0;/ f  {+ q$ a! S$ T
}* q* l4 q& e* ]) Y! U  q% y

( l! X6 R3 L0 X; r
2 N$ L$ p& ^' H0 B* r4 ?! L6 i* A3 P) ]+ q( z4 B

2 |$ c6 Z5 @4 I! G6 \FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!0 ?5 ?+ A$ E2 _, b( U. |  ]

+ q8 U: B) C8 T7 z' G
$ a( w0 C: D" a$ z3 R
9 ^$ r6 Z' L" \8 |, H





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