嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit$ d, J3 v, _# a' G! _% }4 D7 M; h
核心板2:DDR2 256M Byte   NAND FLASH 8G bit. H1 C0 Q: W5 f2 V
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?% P. L6 K" V+ K

+ A( q- a  r9 L8 C' N8 c. c$ C是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?* z' \8 q, N' Z; L8 d+ X6 e
! e6 v6 b' z9 S8 L3 U

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:$ X8 P* w4 j0 _& K7 m
/*1 K, r+ u3 x* m( W$ c' [
* Check memory range for valid RAM. A simple memory test determines
/ r1 r! o5 o. l6 j" a' I5 _* the actually available RAM size between addresses `base' and
6 R1 O+ N$ I* o) R$ a1 {: P7 f* `base + maxsize'.4 D' ~. z% D, Y+ M  N' B
*/
+ ~8 i6 `0 X( |9 y* Mlong get_ram_size(long *base, long maxsize)
: i% u/ o- Q; _) K: p- A{
; V+ t5 X: c7 v4 t7 T- b5 W' p        volatile long *addr;
) E4 l6 p, w  \7 q* ]% S        long           save[32];/ l5 f- f/ Q" @( m; f
        long           cnt;
3 X/ a; T5 ~1 p9 ^& Y+ _        long           val;+ Y' ?! V. W- }. H
        long           size;( R% V- N2 K8 i) n
        int            i = 0;1 W( \! h; @& z4 n/ x, T
) W* A' n5 N3 @) l( ^2 Y( \
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
" Q4 I8 t2 |! M0 N! G, ~+ S5 C* L                addr = base + cnt;        /* pointer arith! */
+ }8 j% U0 e" C% ~% t9 s/ R' y                sync ();
' g- d0 }% j7 s: u. X. c& H                save[i++] = *addr;: L" n; B8 S( O* O2 L
                sync ();
, r6 I9 U3 Z( X  s' ^! `! g                *addr = ~cnt;
$ j1 w5 d# z2 E1 t: F/ n2 E% X8 P        }
) r9 G0 p6 z5 d$ }& T8 X  Y, Q, S6 F) J
        addr = base;7 m, i8 G" ]: K8 |
        sync ();
9 E0 \. I$ }% q        save = *addr;
/ ^' e6 L0 \, }        sync ();
0 n  ?8 [" Y7 v! ^' [        *addr = 0;. \3 U  Z+ s5 {
( c" e7 i1 w9 T" R: ?) B' R
        sync ();2 l  o4 l" `' a0 x) S* s1 A8 F
        if ((val = *addr) != 0) {
6 E6 v  C, q4 b& J( C  G' \7 T+ Q                /* Restore the original data before leaving the function.% _& g3 j# y- H) e5 i; G( M
                 */
' C! v0 `: u9 I5 o! w9 P8 Z4 A                sync ();
, R4 p/ v% s3 s3 o# P# K4 `7 V                *addr = save;
2 W! e( L; R/ v& R0 A6 b                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {1 I! w  j7 z% q& Q
                        addr  = base + cnt;% {/ ]" P$ i6 D4 h# j. m/ e5 u4 \
                        sync ();) }; ]0 u% s6 Z: U) N
                        *addr = save[--i];
# p5 Y7 e7 x( z" G) ~: E' u                }
: |% W/ L( ]% G; D; J' d                return (0);7 L' F# ]* b- T( b
        }9 _, }0 a+ ~# ~! u! M
+ X8 |4 g+ }+ k% `1 Q- ]
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {# b* a& ?/ y7 p$ y! g6 c1 B
                addr = base + cnt;        /* pointer arith! */
$ Q# U. C/ ?* M/ I1 q                val = *addr;
2 {  @8 J. c* `( b+ i                *addr = save[--i];" |  _0 L) y: B: W2 ]$ U" a
                if (val != ~cnt) {
0 H# @$ s  c" K3 t                        size = cnt * sizeof (long);) X) ~2 t0 k  w9 X
                        /* Restore the original data before leaving the function.3 p4 p( K4 j# g2 _# C& l& s
                         */
" T/ Y, E: ~0 _. {' E/ |: M$ \. L  W                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
( G# r+ C( s  R+ e5 N                                addr  = base + cnt;
* u& w8 @7 E( {) A8 d  o7 b) D                                *addr = save[--i];3 Q$ L7 E, ~+ N. ~$ c6 {2 z( M
                        }
* z/ o2 Z+ |# q- q                        return (size);
# `3 A9 @9 g2 v# W7 H. [, i                }' g2 s) Y) S; a; Y0 ^1 p1 _
        }
1 ^5 v9 ~; m+ Z1 S' M7 e, K  u% x1 Q7 C3 [: X, n
        return (maxsize);
. b; ^# @( R' [) I- Q8 \+ `: U}
( ~( F' P! e% U1 N' @0 b' `, Jint dram_init(void)
2 D2 x, I; ?& @8 U6 P' Q{
) s6 |% ^# D: Z" k" i        /* dram_init must store complete ramsize in gd->ram_size */
$ `# p: B9 Q, S5 \  ?2 G# K6 e# t' Z        gd->ram_size = get_ram_size(. I  m; x' S) u( K- \  ^- I# W
                        (void *)CONFIG_SYS_SDRAM_BASE,4 G- i$ g2 h( P) \/ C, f
                        CONFIG_MAX_RAM_BANK_SIZE);( w: J5 r0 E0 \& G4 Y
        return 0;
( F+ ?) a2 n! }) ^' F}
8 s6 z% K1 X9 y1 v" g1 B" A0 n9 M, [) G" g, v8 v0 K5 l2 ~

" A6 [) X3 c& w8 M6 q" k
2 {. H, t9 q5 ~/ [/ O0 L2 ~( E- I2 |6 Z
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!5 l8 ~, V8 o) J4 b$ A4 X3 E$ l2 M8 ]
* s2 \6 l8 `9 @& F

2 u5 c" E' Y3 V+ p
# Z: P3 X: B  T' X





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