嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit+ m& {( A! a3 U9 J3 q' n
核心板2:DDR2 256M Byte   NAND FLASH 8G bit5 V1 z8 I0 a" `& F% E( r
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
2 [9 ?" G: T+ I3 p. C" f6 n/ A2 W  F
0 S0 t' W; _  I8 ]5 T- D3 k8 g) |是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?; f$ A7 v7 K) x# f& o. N
5 F! @3 v$ e) t; l8 z

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
1 e6 f. }. h* I& S0 M, u/*! X- w% r) s7 r7 ~: k. _
* Check memory range for valid RAM. A simple memory test determines
- v: i' p$ N) l/ D* the actually available RAM size between addresses `base' and; I1 m5 o" \. ?0 ]. d
* `base + maxsize'.7 \- y2 |; m0 d8 e& j
*/" X$ F- H* @, }
long get_ram_size(long *base, long maxsize)
' }% @4 f" A. }{! Y  i8 X/ O" q1 `
        volatile long *addr;
+ R! T% f1 y0 e: v. ?4 q3 G        long           save[32];: ?2 _  A; Y8 b8 }
        long           cnt;7 q  e/ ]1 R4 X' N3 e) n- N
        long           val;
  u" x; e/ U( l% p; F+ e- L        long           size;  j. {1 U1 o: H
        int            i = 0;
' I" t$ Q4 r. r: T* p" }1 H$ a9 @$ ?' p: {0 e8 ]" j
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
$ K, D$ c, d4 x: l, }                addr = base + cnt;        /* pointer arith! */# ]  r: Z4 W# Q8 @$ H6 w
                sync ();
# Y/ K( F% `( q- A5 J                save[i++] = *addr;/ z. A  [- O: e$ q& Y4 n0 b& |* N
                sync ();
, O" p2 _. ]; `" {3 e5 B1 F                *addr = ~cnt;3 w1 t" f( J6 r$ ], ^" x1 d
        }
" z7 U! Z. h  K! M1 W6 S2 w, m2 X- t% O$ n9 o1 Z5 M, r
        addr = base;
( m4 |% \) _' [$ }7 c        sync ();
. Z6 X: V  k9 Z( P  @& z        save = *addr;& n( |1 U4 c# R2 C9 g$ @- i
        sync ();
" i& \+ F0 a  O  D2 t        *addr = 0;
% w/ U# w: S6 }5 `  p) Y
; w' ?/ c7 _+ V# x3 ?) U/ b5 X# C. \  O        sync ();3 d( T3 g! Z" ?/ K$ Z+ L# F
        if ((val = *addr) != 0) {
8 t7 i" H* R' B                /* Restore the original data before leaving the function.0 W1 a& e6 g% S, F# A
                 */) }1 ~6 N) _( R$ I0 g  d7 J
                sync ();$ u9 [# M. o* {# w
                *addr = save;
7 i# u9 F- Q; @  a                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
! P" @6 p. P/ l' ?6 u                        addr  = base + cnt;
2 U% z& ]! S* N$ R5 M3 r                        sync ();' r- J9 j3 l2 A7 L
                        *addr = save[--i];5 g( G3 m% V* F) d, D0 v
                }5 E5 A* Z$ t& _/ H/ Y
                return (0);( h- n: W6 w) q6 M: b+ G$ A
        }  F# u$ G& G2 E( s

# `8 H/ K9 q. y2 R1 a8 q( Q        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
0 _+ k0 C/ C, w! T$ Y                addr = base + cnt;        /* pointer arith! */% `9 N( t$ V; y1 ]" p1 t1 ~
                val = *addr;0 \& s4 V! ^' ~1 U
                *addr = save[--i];
3 I; y, D0 c: }% n# \, q( h                if (val != ~cnt) {
5 a# L4 X# C1 j/ i# v                        size = cnt * sizeof (long);
$ Y2 W4 o' ~2 n3 ]                        /* Restore the original data before leaving the function.0 B3 l9 ^0 j; \- b- c* Y
                         */. p6 `; j5 q6 C4 S, u; {
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {4 C5 W: A+ i  d. w# {
                                addr  = base + cnt;
" F( k! Z: e% ^: Z9 f                                *addr = save[--i];5 x" }4 J; p0 t' F& ^
                        }
7 n2 N6 a% b% x7 H5 o2 c/ N                        return (size);: B/ ?& {6 m7 y3 P0 e* p# p+ v( t
                }5 s0 ~  x7 _9 F( U! W
        }
+ Z7 x7 x* P' d! Z2 ^" q* j8 D6 P: i! J1 \+ ^8 j
        return (maxsize);
. J/ B% B" g" y( E2 s/ }% Q}5 l: ~6 T2 E4 K/ P8 B3 u
int dram_init(void)
. d9 _; I- f, A{% k# w( p8 u9 z2 ?, H# ?
        /* dram_init must store complete ramsize in gd->ram_size */
2 w. v$ u6 l# H        gd->ram_size = get_ram_size(
& i& \3 {8 |, v1 t% j* d0 h& |9 d                        (void *)CONFIG_SYS_SDRAM_BASE,
5 p7 E; ^# r5 `                        CONFIG_MAX_RAM_BANK_SIZE);  y% `% B0 t4 |) z1 L! Y5 S% k
        return 0;& R& \3 l2 S. g( o3 E8 q0 I: r" O
}
' z2 [3 M2 h2 L+ X& A$ N7 ~% x8 G- O7 |; n
3 h* W. \: ~3 u: E
: O3 ?% p3 B+ N% z3 E0 w

" b/ f, p. m: E  xFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!- L" J# }4 F; b3 T9 i3 S1 ^1 t! E

5 E5 ^# o4 \* K  M9 I3 S# w3 l: _3 r. x0 Q6 C1 ?( H

. ^8 @, A, R2 z% j; B




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