嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit7 j3 |& x8 Z+ u: [* d4 _1 u. z4 O& n
核心板2:DDR2 256M Byte   NAND FLASH 8G bit# `! e! k6 O- X) _
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?. {7 I/ O4 j7 ^! U2 V# C" V4 {

+ k) v/ B; \) Y是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?  ?8 R( U  e* j3 b

9 B" ]" A! x$ D. P
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:) I; q3 b3 y- y, L
/*
4 |5 {  T  |. U: e* Check memory range for valid RAM. A simple memory test determines# v# E, f& S0 b  e! \7 ~
* the actually available RAM size between addresses `base' and
# q) p' g6 v) h6 M9 E3 e* `base + maxsize'.
9 l; y( w" u9 p*/
/ h* U* {. U2 O) l* Y: Olong get_ram_size(long *base, long maxsize)
% u/ l& Z2 {! @{8 Y/ e) ~" @; C% W+ j! M) {
        volatile long *addr;: G9 I2 X* S/ [. i1 v5 e& ]+ ?
        long           save[32];2 N& ?8 v" U% q
        long           cnt;
9 j) P0 d4 D( `& r2 X        long           val;
8 n$ T: U- Y* z: }6 \% R5 A9 V% e        long           size;
4 v" ~! V) v# t3 O4 `        int            i = 0;! e8 \0 \  A( o  `/ K
# e; m( u! D4 x# }
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {% @4 h6 X. p% k9 n( a3 m% _
                addr = base + cnt;        /* pointer arith! */, }" v' r. n) c; W9 G, t, `5 ]" B
                sync ();/ l: @$ B. V' v
                save[i++] = *addr;% g* [5 l  y, n1 i. L6 G/ V" Q8 B
                sync ();
* q: {- j, P- e! y4 O5 o0 V' [                *addr = ~cnt;- E. W! A" \  M+ i( m
        }  F% y7 n% Z! M5 z  |

& R9 n( Y* j+ _+ w5 q9 w9 C        addr = base;: b( U+ S2 N( R% u! q# B' x! p
        sync ();1 |  c* `/ |* `
        save = *addr;
( l; G, X/ @# D, j' Q3 \- |! j" L7 n        sync ();) G  L' }) N, V  G, [* T5 @. y
        *addr = 0;
+ [- ~, Q# k+ w* [# Z' O+ O, T# @9 X' z" R+ ?) _  L
        sync ();: B* ^/ c% c: i; Z. E9 H6 [
        if ((val = *addr) != 0) {
* D+ }9 N0 V) ^. r4 Y                /* Restore the original data before leaving the function.! P2 k: Q* A8 _3 l- b) j
                 */5 f5 G5 E. ^2 Q$ e- ?' b8 L
                sync ();( D" w, _, p3 L0 @: y
                *addr = save;3 S) L$ Y" E5 v8 i. r
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {( a6 C+ T' ~8 J0 ~6 c
                        addr  = base + cnt;
" r9 x2 Y4 C$ G! B- X                        sync ();
6 Q; a+ r. e" l                        *addr = save[--i];
3 @# \$ P" u( P                }
: n0 k5 O) w8 ]8 r9 |                return (0);
" \5 b, J5 n0 |) B& \        }
% q7 r/ w2 J9 U* _8 A: ?: n) a4 }$ i. P# t' r3 q1 U5 S: ]
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
4 _2 r1 B$ f8 ]' s+ x                addr = base + cnt;        /* pointer arith! */$ G. k- \+ U) C1 W4 J! |
                val = *addr;0 O. q( Y+ Y" ~3 g; R- Z# F
                *addr = save[--i];" Z6 J% n7 t; ~" y0 v, V. T
                if (val != ~cnt) {
" H6 u8 S0 R* u, e( }  W                        size = cnt * sizeof (long);5 L: J& I# J8 X; z
                        /* Restore the original data before leaving the function.
+ d# E# S8 W7 N5 q3 h                         */6 x  o/ ^/ m8 q- J$ L0 L2 v) s
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ [  z! M9 G4 \/ x( b
                                addr  = base + cnt;
/ _2 G$ ?6 T4 r9 D/ u$ @$ s/ \                                *addr = save[--i];% O, Y: q9 }/ g0 p( X
                        }; ?7 a! ~8 p: x; @
                        return (size);& Q' f" l8 n7 p( g
                }5 x% D2 \6 |" b! K( e
        }8 `  B$ J: Q* Z' |9 S
0 ?0 G' G' w6 M. e5 H
        return (maxsize);( X$ x1 B1 d1 A+ w& P# U
}
  t; a# \/ G+ ]6 p1 C- o( P, x* Q# aint dram_init(void)2 ?# r+ p1 J$ {
{
( k5 a* ^% j0 B" e" H        /* dram_init must store complete ramsize in gd->ram_size */  E! V+ f$ _; g8 ^2 Y5 b
        gd->ram_size = get_ram_size(/ F4 b2 ~3 }" M7 L+ O
                        (void *)CONFIG_SYS_SDRAM_BASE,8 s/ p- d' \; W- y  ]
                        CONFIG_MAX_RAM_BANK_SIZE);2 B$ b+ ^; J; d3 h4 v# d' W5 a! A
        return 0;; C* m- K3 [1 c8 \( u4 v
}
4 H5 [% a# Y% V! q7 K# {3 a5 s% y8 Q; g$ `2 {# Z* @5 o
. ?; I9 [% K- m* z4 E

6 {8 a$ |  H6 c" [/ a$ c9 J! s9 X+ _! |3 g* Y& C3 Q9 r
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!! A) l* j: w) x! t: T/ Q
+ L9 O0 ]5 ]- B: a9 a+ t3 b/ @/ Q
. s' G% W  A% F: S* w0 T& `& K, w' p

4 H1 t* S: H( K6 D5 G- b2 g4 A




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