嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit( _  k% h8 U% N
核心板2:DDR2 256M Byte   NAND FLASH 8G bit" N9 h' l( o2 L9 B% E0 X
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?. H* A: E. j' N) B8 Z( Q9 f/ u
& A$ g; I. Q) k6 `: f# S. y
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
% S  l3 z& M3 C8 C7 u/ N3 n: R. y) ~# X

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
' N% E% O2 M- A7 N/*- p# [, `7 a3 S; k, b( e( {
* Check memory range for valid RAM. A simple memory test determines
- w6 t, k; d% X( r+ O, L9 |8 c2 X! o* the actually available RAM size between addresses `base' and" j, V/ Y" g. u
* `base + maxsize'.. S* g3 B! X; X
*/
' s8 h: y5 J/ R8 u4 M) K  N4 ~: Vlong get_ram_size(long *base, long maxsize)2 F( I; s4 f( r3 n# g6 a
{6 M7 A& f/ h( T  h
        volatile long *addr;
2 f& l. m( l* k' U* K        long           save[32];  w! G  s" ^; d" w; ^: p1 t) X
        long           cnt;
: c3 y% d% t. P" T$ C( ?        long           val;
) \! z* I8 p% a9 h: g        long           size;
# i& t& n; M7 c" [* \. ^        int            i = 0;& @3 O, k* Q  r/ Q; i
8 C, Z' T+ K# x
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
, b3 l! v9 u6 C, w1 y                addr = base + cnt;        /* pointer arith! */* H& X; j! D9 o, S. \2 E
                sync ();# K/ Z" v  q; [
                save[i++] = *addr;# V% k: m) ?0 B6 a/ Q
                sync ();+ ~9 D" d. B% A5 `
                *addr = ~cnt;
5 B  @3 r! |: |0 u        }
5 k0 Z- B9 f( c- l$ ?( O6 v( m$ v" X+ p  x9 [1 Q- b) q- }# a
        addr = base;3 }- U) P* f0 \2 d5 B# V" X
        sync ();1 d  V% y7 t2 p$ h5 Q. \3 I" L
        save = *addr;& Z  U9 k4 m- ]7 n3 t
        sync ();
! B, g$ v  k8 T2 e8 u' r/ |/ \& v% h        *addr = 0;, Z' l% F; G2 N) W9 }
) A1 \& _3 Z* T4 W# S1 T- M7 l1 p% y
        sync ();
3 C* |- @% d3 x/ \        if ((val = *addr) != 0) {( {8 o5 r: r6 |7 A$ Q2 E4 J
                /* Restore the original data before leaving the function.5 j, S4 |# g: {5 v5 [0 ?
                 *// Y9 w1 w1 F+ h2 U6 K& d5 L
                sync ();
8 v! q$ G; k8 s* i$ ~% P                *addr = save;# M/ I0 C% z. v  i" F
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
9 z/ }9 A: H, B# r# H" v5 `4 R                        addr  = base + cnt;6 y% k6 x+ [* J2 r$ q7 c. F
                        sync ();
9 s3 y7 Q" R9 q* ]3 j                        *addr = save[--i];
- R' G3 C, K* x- e3 g% q/ ?                }
- [- \  B, N; p$ }5 e5 Q; ~6 e) ?                return (0);
9 r3 }/ o! Q1 n( C1 R! C2 i1 Y        }! G8 z- ~$ h- D( w$ t$ E  t
1 D; D( P+ h0 O% ?
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
' k: u, u& W* z, }) ?                addr = base + cnt;        /* pointer arith! */
  _1 Y( m0 S% p( O                val = *addr;
. u2 ]% A, y2 \( a6 n                *addr = save[--i];, a2 q4 f1 Q, l! l9 c
                if (val != ~cnt) {. S5 p" w* B" h3 m
                        size = cnt * sizeof (long);
2 x; |% b! x+ ]+ [                        /* Restore the original data before leaving the function.- m2 h4 w, s0 A: Q) r7 F6 w
                         */
  o7 ^* c; O% w' J# @' G! f                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( E2 d7 a4 n% y$ R( ^                                addr  = base + cnt;
0 O. x/ O/ X, F3 p3 C+ T$ M+ ]                                *addr = save[--i];  }' ~9 g& y& s8 |# @
                        }' A" B# f4 I3 o: z: H9 a: g
                        return (size);; f3 `6 g) s& \" {# n
                }. @- a  g7 S. q: N( p
        }9 ?) Q4 B$ T; P: a) _' i
3 A% ]2 Z+ f8 y& J1 V) S
        return (maxsize);2 _9 s* L8 |* n+ z
}
0 o: o4 i; m. d* m6 ~int dram_init(void)
+ g+ e. d3 r$ ^" S{
* P, h; }& h5 M: u6 z9 Y$ f        /* dram_init must store complete ramsize in gd->ram_size */6 E) T* v5 q& \5 M
        gd->ram_size = get_ram_size(  ^0 x2 Z* u: t; a
                        (void *)CONFIG_SYS_SDRAM_BASE,# a4 u; W& s' x2 x$ b( ^
                        CONFIG_MAX_RAM_BANK_SIZE);
0 ^6 y2 x* c' ^* d        return 0;5 X5 B0 n% ^5 q4 H( Y
}
6 V# W8 e: W( Z8 s0 {
  }4 \7 k- v4 ?) b* V0 m/ ^1 r/ s* F" R& |& X7 ~( a
( G* \/ H3 J4 J0 ]' }, _8 N. l

# b6 Y; x! H1 `FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
; C/ p/ L1 G& a: G
* c0 H1 b: |5 x# h! c9 e0 i8 g7 h- n, ~0 K( Y6 K4 ?8 v' g
: _( a  D1 V  y& w, H





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