嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit1 h4 Q# }* A- C
核心板2:DDR2 256M Byte   NAND FLASH 8G bit5 m5 L6 ^( Q' d  h
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?9 k! E0 K% _9 s7 w: @
( @4 [8 K& q1 M5 l: y
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?  k+ Q+ u8 _/ I/ i, p4 _2 W" U  c  s/ f

* C# G4 m2 r$ D' ~) K
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
: c( Y  I5 L" f! k+ Y4 i: S$ \/*
5 ~3 A, w1 O, g. U* Check memory range for valid RAM. A simple memory test determines
5 @6 {$ D- M" @! B. R2 z* the actually available RAM size between addresses `base' and
3 c2 [: u8 M2 W- h* `base + maxsize'.; `  Y( ~( |; h: p9 G# _, R
*/2 ?% t- |) O( d" [; U, g% J+ H
long get_ram_size(long *base, long maxsize)
) O: h$ }9 L3 ^# K( f+ l& l) s{  s+ {3 l! w4 w1 Z/ b: [
        volatile long *addr;+ e* i" n4 q# [8 R$ Y9 m) U
        long           save[32];1 S* V3 h$ C3 Q9 E1 G
        long           cnt;
0 U- c/ p) ?* x$ `        long           val;
4 m  G0 R' m) C9 f1 F6 U& {4 b        long           size;
; ^5 k& \! ?) j( U. K# @: L        int            i = 0;0 d2 A! n# M6 {
$ M+ @: Z' B0 j* C1 J( v, i! ~1 V
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
5 }' t/ m* [3 V1 k1 Q                addr = base + cnt;        /* pointer arith! */
3 g) o! C" e7 s. ^. G                sync ();
' O9 ^; c% e  x1 O9 U& K" [                save[i++] = *addr;8 n; O! U3 O9 z2 V
                sync ();
5 R" T6 o6 D0 }6 ^                *addr = ~cnt;' {7 q7 |- [6 l* O( M) v
        }3 x1 X2 U( C0 V9 ?: Z8 @

6 {( @. ]  j" l, M4 \4 K        addr = base;& g, e  M. x0 B5 U" C3 o' \5 K( M1 x) L7 d
        sync ();$ p+ O! l7 w7 W3 L: u& x3 r! J: c
        save = *addr;- t0 _* d& \: k
        sync ();! M2 k6 T5 ~- {+ F* }. V9 H
        *addr = 0;) K7 o2 u1 w1 D$ D( w7 d" G
6 T& \3 d! e# L& G4 y
        sync ();
* ^8 h# G3 @3 B/ r+ @        if ((val = *addr) != 0) {
3 o1 W/ N/ x( y0 K                /* Restore the original data before leaving the function., [! H5 \3 k. |/ e
                 */
5 a9 ^" D$ s& @# O* v                sync ();
0 b* N8 K* T$ R+ m; S/ t; w5 {: t                *addr = save;
1 B8 r( n) p  Z$ o( J                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {  g' w" T. {. m1 F
                        addr  = base + cnt;
% ^$ I4 W8 r! n7 }$ w. v                        sync ();
4 ?# f9 U) i& J/ X. @2 u# V- [: b                        *addr = save[--i];
" z# G# [- f  x9 w) w                }2 K/ K; ^9 s, p$ A; {
                return (0);
+ z) x6 x6 d6 V        }3 V+ Q  g, n& d6 ?0 Z( k3 x
3 a, L1 D8 J2 d$ S- Z
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {# S9 m: O* ~9 F
                addr = base + cnt;        /* pointer arith! */
8 j8 o! x5 q1 N: M                val = *addr;% @0 g4 N  Q6 }) S
                *addr = save[--i];6 q# d' N2 [, i* k
                if (val != ~cnt) {% r( n8 Z) K9 v* W2 w
                        size = cnt * sizeof (long);4 [: X' a4 Y/ M2 Z  Y
                        /* Restore the original data before leaving the function.
7 ^: l4 V& j- @, u: Q: J                         */
: J2 }) d- t% F8 n1 x0 Q' U1 l                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
  ~6 f+ e$ U8 `                                addr  = base + cnt;0 o# W9 Z: }9 q/ u
                                *addr = save[--i];3 I. k. w' e& J4 z. f1 b* x
                        }" i& [" Q" Q0 \0 D" J' o) {
                        return (size);
4 p4 y8 A: T8 y                }
, J; P1 u5 Y9 U, `) U+ {$ b4 J        }
, L  H9 G( g% O  D2 B* T+ v: d3 I  o9 j$ ^: u
        return (maxsize);
  w2 `( ]- A4 s2 P: ~) v) n}
( d+ E1 J! R# T3 Y/ C; P% {int dram_init(void)
/ _2 x" O0 ]/ n: D+ u6 T# x* M{
0 _, g! W0 J1 k  }. c" ]9 Z        /* dram_init must store complete ramsize in gd->ram_size */
- S2 a& A) H5 P1 Z        gd->ram_size = get_ram_size(
3 k5 E3 J/ B; e6 A. ]                        (void *)CONFIG_SYS_SDRAM_BASE,
* m' ?* S8 J4 D; o7 [1 q! `: Z                        CONFIG_MAX_RAM_BANK_SIZE);
! }+ j; F* i7 B* Y- x        return 0;
& I5 T! m+ V8 G$ c2 h}
4 n' q' }5 H. i; U/ |( |. [* c8 c" k$ t% t4 {4 R$ ?

. Y( y6 T. U+ ?* G3 k3 W& \: n9 B
" d- Y% ~& o- g* X* e8 U  k& X) H. M" Y7 i  [: t  x& L
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
6 Y1 k( x/ Q8 @% q1 w; B6 i4 Y! Y* o' D

# O& }- @6 w4 b- t3 u6 N

2 n2 [* L/ r+ m




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