嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit( s, }, z0 K+ ]: a
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
4 ^" E* v3 x6 v; F* f$ O这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?: k2 w% d3 m3 w  [

; ?5 N1 ~; U3 M! O2 |& V; q是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?8 x; t( ^& _9 K+ e

. G6 m  d4 w3 ?* q7 U0 q
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
" R* B4 i4 D" Y+ N8 R/*' L7 Q9 j' k+ S3 m9 X  T; Q
* Check memory range for valid RAM. A simple memory test determines# \8 X7 G& r9 Z4 d) [7 ~/ m
* the actually available RAM size between addresses `base' and
; ?5 k# y: |# C' j$ K4 l: y/ O: Q* `base + maxsize'.
8 U+ H! d( x% D" t  L*/
* [3 S) Z" E' Nlong get_ram_size(long *base, long maxsize)
6 g- Z) Y: t: ]6 `. _: H$ p% O{* g- N0 e3 v) N; e/ o
        volatile long *addr;
" S9 f3 Q: o8 Z7 ?# l        long           save[32];
0 w0 [+ l- x- G& V0 [$ p9 f7 A( d        long           cnt;( ^; b/ f* ^* v6 H
        long           val;: ]  N: i8 f) H
        long           size;+ ?. \) o9 P& @* f, ?# D8 y
        int            i = 0;. n& g8 l: d5 A) }9 a8 ^5 L6 p

# M: n% p) y8 E& Y        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
' g: G& X, u6 t: a                addr = base + cnt;        /* pointer arith! */
- a% h8 q* b, U) Z- r                sync ();
6 Y! y4 k; X4 k& V8 k                save[i++] = *addr;0 ?) O5 r8 h+ o* x6 q7 b8 x
                sync ();$ z' A4 R" s6 o' r# f1 k7 |
                *addr = ~cnt;. u2 R0 u+ W$ K( |
        }
, {2 \% ]: @, a
  [+ Q5 X# v5 ^' h3 O, ~3 b% i        addr = base;/ d$ Z5 A  n# |+ @' a: U2 s
        sync ();
% ]2 M3 F4 f$ B* }) Y        save = *addr;2 e% b5 [$ t1 F2 n8 c1 G
        sync ();
* S8 R, Y+ f7 j2 P' ^; T        *addr = 0;
2 a" V6 d  _0 Y& _4 n9 w- @
- a+ m) n! d! s) t: e1 [        sync ();
! ^! Y- ?5 V, ]; s# L; r2 F        if ((val = *addr) != 0) {
% Y# v, ^) M0 Z                /* Restore the original data before leaving the function.( ~$ J7 z: S- S& ~
                 */
7 `. N$ d( E4 t- Z2 w                sync ();
2 P) |! [! j  w0 [) ^8 ?                *addr = save;% q7 R' v: G8 F* X, q1 p1 |
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 R& H& \5 n) i, q3 _7 j                        addr  = base + cnt;8 l0 h6 U7 E! }) Z2 d
                        sync ();
# W* S( V  [" r* M" V: i                        *addr = save[--i];% w$ z% H. }7 V: m8 A! a% M) Q
                }6 ^* W* p0 ]2 e/ H2 J
                return (0);# u$ `. l. q# v' A- N  [8 @" r
        }
& Z. s4 k, r+ D1 Q6 J$ F' T& o4 w8 {5 e8 L9 ?. A
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {$ `) \+ D* }8 h! |9 l, E7 s7 j$ b* l
                addr = base + cnt;        /* pointer arith! */
$ U% O8 t% v" a/ Z; G                val = *addr;5 P) ]: ^  |8 G9 p
                *addr = save[--i];  e7 X" y, P9 b1 J; V. U1 e. e
                if (val != ~cnt) {
  R6 p7 t+ s+ d' [9 T# Z5 a                        size = cnt * sizeof (long);8 b- l9 Y3 u: p( `
                        /* Restore the original data before leaving the function.
) M# }4 L; r% @+ c6 h9 ^                         */
" Y3 E. h: n& @1 M3 R, ?( a3 n                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 p2 O0 N6 x" q                                addr  = base + cnt;( q# d  t( f$ A
                                *addr = save[--i];
9 p' u3 i3 l* V                        }
: x0 @8 J# p: J% _                        return (size);
3 A! u8 h1 b( ]& P5 e                }
3 ~( I0 ~# i6 y1 `( D4 k        }+ r1 f6 K6 W- Y0 D
  V  S: ?; |' X  P) ?
        return (maxsize);
; v5 \) H, y3 R0 ^. j7 }+ \}6 }% X! N1 L6 B# O
int dram_init(void)
8 N) d1 k2 y' F2 C{' N) ~! P# G4 q) F( U' X6 G1 ]
        /* dram_init must store complete ramsize in gd->ram_size */* B, A, M6 d6 ]2 J
        gd->ram_size = get_ram_size(: g  V0 \5 `1 u* @7 E
                        (void *)CONFIG_SYS_SDRAM_BASE,
" ^3 @. ^0 Y8 P                        CONFIG_MAX_RAM_BANK_SIZE);3 ~4 ]' ?4 Q( S/ {& @9 |
        return 0;
. K$ X1 U2 I7 C4 H+ D% r0 K6 J7 d0 V}+ Y4 Y0 _; G) f, y
) e, e! V4 J! h: P8 w8 \' g

* r/ j: G% Z; M* i: O3 ]: y% I' p

' F. K  x* H8 W! o2 a3 A  OFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!" R6 E( c$ t6 Y$ d+ c" Y
; x1 G. ^& ^2 M
2 z4 h- |$ j; I4 u4 Q

1 t) X+ y% q- C' C5 ~4 C1 Q




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