嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
# r' R2 \: l5 Z9 `0 g: L: ]核心板2:DDR2 256M Byte   NAND FLASH 8G bit1 `# C9 ]5 T* ~& }
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?) B1 c" x& U/ S
4 f4 P$ w3 J5 s- [0 Y0 x) f
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
& Q( g9 [6 ^1 k( E" a) }" d0 y! n  E0 J0 j- D4 s

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:  v" g; `* V, \
/*
4 T  c" o% N4 Y, H- {: e  B4 F* Check memory range for valid RAM. A simple memory test determines5 {& a  M7 z- M9 |8 c' w
* the actually available RAM size between addresses `base' and
6 q, g- W* z( D5 K4 N# T4 Z* `base + maxsize'.
* j1 y3 v) m1 ?- _/ s# [/ C, v+ `*/
. \5 K. t. z$ [* l" Y8 X/ |: _; ulong get_ram_size(long *base, long maxsize)" b  f& G0 B9 \$ z5 e  k3 Z, t
{3 O: |. l1 z$ O. p
        volatile long *addr;
' U" P9 h4 M" {% Y% V6 e) g        long           save[32];7 L  \& s- U2 R7 R( z2 h* t
        long           cnt;
- H% B; ]- f) A1 K$ a; u& c. J        long           val;, \3 ?- o" o( |% s
        long           size;
5 ~4 a/ b- c% z( f) z6 X        int            i = 0;$ c3 |$ C% A3 O6 V+ U

4 N9 H- F7 ^" B$ h* V. H) P        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {' @# d$ r6 J/ i5 r& D3 B) u
                addr = base + cnt;        /* pointer arith! */: ~0 K6 W8 W) I9 E4 E$ g/ _3 Z
                sync ();& T, D# }6 Y' Q0 S
                save[i++] = *addr;
( ]3 z( B/ Z8 i6 d                sync ();5 r! ~0 P  F* U$ [
                *addr = ~cnt;
  w, a  A- ^& Y& U        }9 L  N4 t: r, \& ?

7 T$ ^3 v( [5 ?* P        addr = base;, T( `0 a+ w; A! T, ^
        sync ();# s+ I5 P3 |6 Z1 b
        save = *addr;8 W. \! s2 _* L5 L+ H
        sync ();6 s6 y7 a( I+ c3 U: h4 U2 E
        *addr = 0;
& H* a& s8 n+ o6 N8 V
4 x0 g. q6 M6 a$ ~4 V. P, o9 W8 `        sync ();
9 [- q( E. d- `' r( ^/ t) m        if ((val = *addr) != 0) {
3 `) L. |% }, ?                /* Restore the original data before leaving the function.
4 r0 p& m) S  ^! ]! J                 */# \1 _- d% f! b: h! X! S% f( m% d
                sync ();8 \+ ]: t6 I: h7 T+ y1 l% n
                *addr = save;: d, k2 Z, [6 Y5 u
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
- u2 d0 D5 G# f1 o0 V                        addr  = base + cnt;
( V& g" b$ i0 n* g                        sync ();
/ P; B8 Q0 s* p9 W, x; N. y8 O                        *addr = save[--i];9 \9 {9 p3 q, x; A' F& ?
                }
8 ~6 M( K3 A/ u9 ~0 q( j7 O' j                return (0);
. J# r9 o* N( s& D' ]        }
! }; j6 C2 X8 n- \+ [
/ s( F- ^% [$ Y        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; A, t! b8 ^) g% V& @1 Y                addr = base + cnt;        /* pointer arith! */
( H0 m4 b' ^) I) B                val = *addr;( Y' g% q/ a, x# K( e7 N9 M$ x
                *addr = save[--i];3 J! ]1 M# ^/ t/ V' b" F! r3 T- V
                if (val != ~cnt) {
  m, O" Y$ T2 f) ^" ]- P                        size = cnt * sizeof (long);* i7 k; ^8 q4 f
                        /* Restore the original data before leaving the function." r4 M3 y( c: ?. \+ j- n; j
                         */$ g  j+ U4 h- d2 d* }# F
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 P% ~2 R) L1 F7 m" T% k5 [' N                                addr  = base + cnt;
# b- I" `! l0 \                                *addr = save[--i];
! c! t- q% \3 C/ {                        }9 r8 c) D. q* q/ Y& G% a+ B1 W4 z
                        return (size);$ w9 N& T" b$ i& b; }
                }
; }% C% E) }5 h- H$ _- N        }' X- R! t8 g1 K$ F8 _: g6 z; _7 s
8 W3 C5 e$ i  O" Y  x4 [
        return (maxsize);
; y. Q+ x- E! z) `1 F: n, s2 X}' ^) }0 s& x! `: b5 R- m
int dram_init(void)2 x# E- n9 _6 Q9 Q! Q$ Y
{
9 O: B: z0 z8 r( b        /* dram_init must store complete ramsize in gd->ram_size */; ^, m# R# }1 w
        gd->ram_size = get_ram_size(9 n2 m6 ?/ w% _) ?+ `9 h
                        (void *)CONFIG_SYS_SDRAM_BASE,
  w3 ?' Y6 O, k4 e                        CONFIG_MAX_RAM_BANK_SIZE);
: _0 Q( c) L( ]- Z; m4 r        return 0;- |: S) w) ]# }- C) b# W) b
}2 ^5 x9 z# q& ?" s

/ G5 q% G1 f1 R8 \1 s
( t0 Z- n% s7 u# z' H( m% @# G- J3 u4 E# E+ M4 b0 S% |6 i& |3 U
* M* w; i9 |$ @+ s6 P
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
. }' _8 F' T+ r6 _4 R$ }% y; H7 T- U9 C) H; L, q

- j  w5 g' ~% N
" }2 B) w% M5 c/ g1 ]# b& r





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