嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
4 Q! Q! {; W; H! X+ l( O1 |核心板2:DDR2 256M Byte   NAND FLASH 8G bit+ s1 ~( L4 d: o% c* s4 ?7 y- ~
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?6 w9 ?; `  |; F6 l
& I7 l) M9 C( h. K! N1 b9 S
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
6 ~1 w+ K/ \. M8 w
0 d  c# q% ?, L# M
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:' L$ L5 ~/ H7 K4 n) D
/*( R5 R8 _% w) i  Y( |/ E( z
* Check memory range for valid RAM. A simple memory test determines
5 ?* I* I3 }( a; t* \* the actually available RAM size between addresses `base' and
& J5 c& F6 p$ g- d) ^3 G* `base + maxsize'., @: F1 z% s: K. `' [: l! `2 Q% h
*/
3 o6 Z% b( z, b5 _3 b+ r8 ?long get_ram_size(long *base, long maxsize). l3 v- h* \1 @4 i
{
% W" q7 D0 t/ X' d7 y        volatile long *addr;
8 |' ]. Z6 h1 [) H$ r        long           save[32];, F2 f% j  R# d' O, U. n' a: i" T
        long           cnt;
. h8 T2 ]5 n' Y4 k7 ~2 ]        long           val;7 p% P3 v9 `& r. H( `
        long           size;3 I/ D5 N2 v, B; t& M0 A& d
        int            i = 0;
- R) v) o3 [/ S. @7 W* N/ H, _
, v: n/ k& y  W0 F& ]1 w        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
# R; X' k* s; W+ g& g! E                addr = base + cnt;        /* pointer arith! */
8 S. J- T9 ]( {" a# W+ z% h                sync ();8 |" O( e/ b. f8 A
                save[i++] = *addr;; a, s) S( g4 r3 r
                sync ();4 B1 N0 J7 X7 h2 Z, x5 B2 H
                *addr = ~cnt;
/ C- q3 r. q( G# ?3 s/ e* r+ X' l        }' @) D1 K+ c5 b8 G

4 V; ~. Q. K- l. g+ T/ Q& }2 G        addr = base;
: v" O" k7 j3 F% T5 j- |        sync ();
; |. T. ~: `0 U# ^0 q/ J! {: U        save = *addr;
1 a. D) I5 {! V        sync ();
0 C0 l" V& j$ x& W8 K        *addr = 0;
0 L7 R9 l( g3 F5 I2 Z& v( c2 P) @" L0 m
        sync ();
2 z; `; f! H" f; i+ }$ h7 J$ W- y        if ((val = *addr) != 0) {7 c# B" |6 y8 B
                /* Restore the original data before leaving the function.
0 P( Z! F6 R% J" u' u' G) Y                 */' }( a- a# ]" O# V( |
                sync ();
' O0 X1 Q3 H7 U" o9 k                *addr = save;8 ?0 s* d- O) `+ h
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
" a1 \3 [4 k  D( Z: y7 j                        addr  = base + cnt;
2 f$ ], P  N8 H9 U. |+ r! E/ h                        sync ();& N, z; u/ j7 b4 H( }
                        *addr = save[--i];
+ ~! R1 ]: O+ O2 U                }
  D' J2 F8 z' Z! \$ V                return (0);
1 B1 x" K7 }7 G. W" L        }
" ~2 w6 Y! s# V/ N/ ^2 B5 V; @+ m6 F$ i# D. i2 Z3 P
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ D. h7 x0 z! z( ]& f                addr = base + cnt;        /* pointer arith! *// ?: z% `& L) {1 T7 u( _
                val = *addr;& Q) ^2 p) O5 h/ D8 V0 Y
                *addr = save[--i];
" H9 ?4 u. _# W4 z                if (val != ~cnt) {7 W  c$ y4 e# @) \. w% `6 h9 x" k
                        size = cnt * sizeof (long);5 }$ N# a  Y. `; D$ I" Z. T+ u
                        /* Restore the original data before leaving the function.
/ z6 ~3 [2 P  d! q$ K8 l                         */
5 c# A3 \  f# w, H, F                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {% f% d- m8 @& d
                                addr  = base + cnt;
6 o# ?5 m! j' `1 f  W# O2 P                                *addr = save[--i];1 Q7 ?2 v. \5 H2 b/ a& M
                        }7 T. F! X& b0 y# S! n) ?) U
                        return (size);
$ k6 _: J. w7 {- a; R                }
# l8 p! S' j+ M! K        }
; M" G4 [3 o8 b: \, m. Q
- c3 B1 @6 d$ |. u. p9 S9 g* J        return (maxsize);  d% R6 p( r6 d! w* \- R3 P% \
}& }' Z, V! D" K& I, w
int dram_init(void)
$ Z. E8 o0 {2 M{1 m* ~& G5 E1 y* e  b! }% F3 J
        /* dram_init must store complete ramsize in gd->ram_size */# b& S3 E$ ~- L) S# P! P
        gd->ram_size = get_ram_size($ Q" P) S2 j, }
                        (void *)CONFIG_SYS_SDRAM_BASE,* T5 J+ j2 U3 l! v
                        CONFIG_MAX_RAM_BANK_SIZE);
- C# Q. M& v0 ^( @        return 0;
9 Q' S+ ~' `" }4 x- r. T3 Y7 m}
6 u- w! k- B5 W! A8 d4 r3 }0 G4 P3 `6 t
; S/ u( d  b% x9 F, R: s& {4 r

, o! z; }  v$ t  f% M: X  t7 N9 o  N+ L. I5 L8 M  }
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
; z6 F8 r% k5 I- P5 A0 m+ ?. K- y$ a% d2 W& i) p) [
/ @) e- S. I( O, u0 ?) D2 H

5 K; M8 M5 E  m# z+ [9 l- Q$ `4 J




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