嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit0 y7 d& i6 q8 ]6 U4 I- B
核心板2:DDR2 256M Byte   NAND FLASH 8G bit' f  s) `- `, g, \7 P) `; ?
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
0 R0 T) h5 b$ Q% C" X. o4 y. x* n  ?- {  y' c  N$ d
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 |; K0 m8 u4 |. J2 c" `' n
* w) Q/ T  I% O& K$ n9 Y
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
2 @8 w9 B$ }! G/** r( q" E1 m  Z8 ?9 ], a: U
* Check memory range for valid RAM. A simple memory test determines
# \& B2 U4 X+ @/ ^/ `* {) ~/ {* the actually available RAM size between addresses `base' and
4 N8 d# n3 f9 ~; M6 T. R. A* `base + maxsize'.
! |* K+ S# w% R+ u/ [, X1 M*/! {9 W* y& ]6 r" N4 c. j8 o% X
long get_ram_size(long *base, long maxsize)3 x8 Q8 ^2 {# c9 ]4 J6 q% N3 ~2 M
{
) }$ m4 C, l' {8 t' `( g        volatile long *addr;0 f0 d- y: M+ |8 e6 U1 F
        long           save[32];
5 }1 ~" q9 @7 m        long           cnt;, N! y) P3 B( P  x
        long           val;& W) t; R& ~  M
        long           size;
) x9 k+ v- a9 w        int            i = 0;) u- f  J8 [. R% N

. G5 K% b6 j$ s. z        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {1 X3 A. W) @2 u& Y8 P
                addr = base + cnt;        /* pointer arith! */
/ [% K$ v- B) b                sync ();& A4 ~/ a* n/ W. V
                save[i++] = *addr;6 t. W6 c( l, C" {' }
                sync ();9 t4 y$ T( F4 J0 a9 N
                *addr = ~cnt;
3 m1 U. W" r, z/ f9 {        }
  b& ^% F  H- d9 [6 E; L$ M, Y, N2 f8 `; p
        addr = base;, X5 F0 Q' Z& `
        sync ();) y* ?7 Q3 N/ p6 d& z
        save = *addr;
$ @/ h9 l# C2 m- T$ P        sync ();8 B# I3 N# }& w. H, K
        *addr = 0;# E" o' q! f) s/ g; w  o

( G9 |4 c% e) L' E: r& k        sync ();
- T% N8 `( j, [% ~        if ((val = *addr) != 0) {0 n5 _4 Q  U' Z! {
                /* Restore the original data before leaving the function.
  k8 Y+ \+ @/ I- I                 */
0 i- o! o# V$ `! j                sync ();8 A; g1 f7 E5 L# ]9 G+ Z
                *addr = save;
4 h# Z8 x( H& ^$ Z6 I! T, V                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
$ y+ i9 N* E$ G0 O' ^4 [                        addr  = base + cnt;
  H! R( y" g3 b. R                        sync ();
$ D2 i( E$ p( {  N                        *addr = save[--i];0 C4 f2 |% F7 R
                }
0 i* {" |  ~/ K2 U! ~: v" _9 g                return (0);
$ c( ^0 I. x& u5 G        }4 ^+ I! }$ \/ Y
- J, b+ Q% V. U4 W
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {1 R9 C& p& K: l7 V. I
                addr = base + cnt;        /* pointer arith! */
$ W8 m# c. S: j& V                val = *addr;
6 H+ t/ _( q0 V- h) v                *addr = save[--i];9 L  J& H  V- C: ~- q1 U: y
                if (val != ~cnt) {
  c9 M5 u3 ^' \* C- _) b                        size = cnt * sizeof (long);
; p# E6 ~& _. J' m                        /* Restore the original data before leaving the function.
' i$ N# R2 v- h, k                         */8 c( U4 f1 H  k% |6 K& W1 Q5 e$ Q
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {; I1 Z( \; p; q
                                addr  = base + cnt;# \$ k2 C. P) I+ M+ {" s
                                *addr = save[--i];
; w" j: L$ A- F$ F3 A6 B                        }
8 C+ z# W- c0 }: t% K                        return (size);+ H& F6 A$ w  {
                }
+ P# O9 d+ I0 v0 ?+ C: j        }
& ^' {5 q- [1 b% ?( ]/ I3 }3 Q* \" P
        return (maxsize);
, p: y& J& {' d}
; A: f+ p$ U/ b/ k6 @6 f) ?& ^int dram_init(void)
. c1 _% A1 R% q7 L) o3 h{
0 b2 d0 @3 [- u- N6 J% S) ?        /* dram_init must store complete ramsize in gd->ram_size */0 x, q% ~6 }6 y- I0 _; M# r
        gd->ram_size = get_ram_size(( d6 A7 [. ]1 R( M; Y  H
                        (void *)CONFIG_SYS_SDRAM_BASE,
* q  ~. I$ m0 Z: z                        CONFIG_MAX_RAM_BANK_SIZE);0 a, V: j0 i" y; Z. W
        return 0;
3 `; A  Y. f# u8 @: C* p7 s}. P0 g/ H; S1 U- c( o3 }. W
; d4 v- M  H, }# L2 c; S

5 n# z! _) P. z2 a
9 V' S# L1 t: o0 U6 A" \! f- I: d) N7 n9 h* j  j, C
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!& i: ^& a" Q, @8 \! N' E
  T' l  H" G( W; z- W" i3 t
0 R( w( a: U: j$ D, E# {
: ~' v8 t' ~/ ~2 X/ o4 d+ }





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