嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit! r& m9 `$ U7 \1 D/ ^9 @7 {; U
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
# ^! Y! V- H7 M这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?" M- D- w6 G* S1 G6 _! U$ m7 T
, ^% E) f7 A  L) S) d" n# T5 |
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?( X' P& t: l8 V( G5 k/ p/ c
7 e: l7 W+ t; n0 \

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
( z* B- i, B6 S/*
5 I& y' s4 A3 x. z0 {9 E/ {* Check memory range for valid RAM. A simple memory test determines
, a$ u$ `7 k& `1 H" a% `* the actually available RAM size between addresses `base' and
: T; _+ z' ]; |* `base + maxsize'.; T  d. y5 u9 V
*/
  @: n( N% g& D2 C0 }9 P6 G! D# n1 Ulong get_ram_size(long *base, long maxsize)
0 _* t/ j  T4 B. U& V8 |{
6 d) O6 k9 }) L& v        volatile long *addr;
  C& }) D; E. u2 C! ^        long           save[32];
2 P+ n% J  E+ t/ l        long           cnt;
/ g# W! s' y! s        long           val;
1 Z1 ]" E; }8 @! x: o5 m; Y" y        long           size;
9 D! Q7 N% ~2 \0 M        int            i = 0;
/ x1 C% _  p6 J6 T; i2 n, r+ r" K2 _! C" O% S2 @6 Q& v
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 Z' W( l( w. ^                addr = base + cnt;        /* pointer arith! */! S) N, Y  _3 n
                sync ();, w& }, T+ D- k* ?3 U8 `
                save[i++] = *addr;
6 n; |* S: \8 H. o3 j/ ]9 d                sync ();
, t9 i* B; e: S1 h6 H4 T                *addr = ~cnt;
9 g8 C9 V" E$ H: _( e        }9 i+ f# p5 `- c* ]
: f* a( {0 V1 Q0 b/ T9 s
        addr = base;
( `( m  C. p7 O3 M4 \) Y        sync ();" C4 Y- m9 u! [! F
        save = *addr;8 K  k$ |$ |4 ?% `& ^  K
        sync ();
4 f0 z  @  }" D8 _$ s! f        *addr = 0;3 O1 g2 M# s& i8 G# a& x

5 H" z9 d0 D8 ?. e, N1 G        sync ();
* f4 W# B  ]2 U2 n/ N        if ((val = *addr) != 0) {
+ b, E% z6 Z2 a' u, J# T* [                /* Restore the original data before leaving the function.
% }6 d+ Q! q& b5 E                 */
) U& P8 K: T1 j  |                sync ();! k# e5 h1 S' W5 P" ^3 l1 v
                *addr = save;2 u5 Z3 y. s, g$ K" E# l
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
# j$ @1 N: ], l0 f                        addr  = base + cnt;8 e' m+ K  d4 p! o! T- a6 B
                        sync ();
# ]+ D- j% \5 m9 A5 Q! o& W! K                        *addr = save[--i];! D$ H/ Q' l: F/ S  ]9 A. g7 {" @
                }0 R9 H' I4 V& p  u% x) q4 N" y
                return (0);1 Y( Z+ S" [4 d: p3 s
        }
7 c9 ^3 i: C# Y5 _2 ]' `& J- A
7 u1 x: P4 X! d8 {        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
/ f0 p7 }. a8 z, g                addr = base + cnt;        /* pointer arith! */$ b$ M: b* Z5 m
                val = *addr;
- F$ u) ?9 S7 v                *addr = save[--i];
( M2 T5 z: R+ J' u' f1 Z  T                if (val != ~cnt) {/ K% U) h: _' Q1 V
                        size = cnt * sizeof (long);
7 v/ U8 K, E8 N7 O' P                        /* Restore the original data before leaving the function.
3 s% W* f4 u# T6 [0 A                         */
9 H# x( V4 U  `6 V% D3 P                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 L$ w4 N* W  ?1 P) m% {) b# b$ J                                addr  = base + cnt;
) I4 A3 f7 g# W6 F  ?9 T7 @                                *addr = save[--i];& B5 f& a8 }* v* ^0 {
                        }
8 p) n/ b9 q5 s) ~4 b! p( d6 P1 D0 H                        return (size);
! R9 h% p. O: `% U& o% ?                }2 q& s: }' s$ ^- \! @' h2 n
        }% B5 B1 R( @; x, y, q" W& J

8 q% g# D3 G: r        return (maxsize);
; N6 f9 S2 ]4 Y% S}) F; g' P/ c; G0 M* e
int dram_init(void)) n# z& E2 M7 ]  Q# N1 G" E
{  Y- n, \3 T* @# ]/ q6 Q
        /* dram_init must store complete ramsize in gd->ram_size */
/ |* m9 l- G5 w; r7 F        gd->ram_size = get_ram_size(. W+ ?6 |# l; i! C% a8 r
                        (void *)CONFIG_SYS_SDRAM_BASE,% @3 L( I- n) o- w' z# y/ L% S
                        CONFIG_MAX_RAM_BANK_SIZE);
' o1 c+ x, ]9 {1 d        return 0;
# O( h0 S% B. w1 T) \9 B}
# L3 G+ t. E8 H% m  V8 d/ c2 N( I9 ~; B: V5 j

7 ~/ m8 m, }! E. H! `" y2 C8 D5 g- k3 E. p+ J
8 C0 O" e+ f8 I! h  z( }; x# T% a
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!/ @% i. ]) r( @0 s; |- G
3 b' Y5 B2 T; ]+ c

- d2 \% Z$ y) l

! J4 {4 L2 J. J/ Q




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