嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit* _1 h* p$ g7 ?) e8 O/ d5 T
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
; s$ g8 g5 Q3 }0 ?- P  V这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
, r1 Q! m% m; n, [% h; \
* b4 R1 e; y  n9 p是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?. a+ [# A' ~) N  U$ r

8 k& Q  K) Z) Q% A1 H) X% h
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:5 t% C5 t4 N9 [
/*
+ V' U) M9 P4 U# b( b) V8 Y- P) T* Check memory range for valid RAM. A simple memory test determines
. L& R# b$ O+ n- L" Z* the actually available RAM size between addresses `base' and
6 U$ ?& J: _  F1 y* `base + maxsize'.
$ `/ q& @! l+ G, ^2 C/ O: }*/. W3 y* C9 c) }4 a
long get_ram_size(long *base, long maxsize)3 Q2 Q& q/ r0 ?; @0 H: Y2 s, h8 y
{% K6 C/ G" `: ^7 ~# |1 R& W
        volatile long *addr;
  ^& l& E4 w2 u! C  f7 a) f        long           save[32];
2 V( G4 W. p  M2 E8 j2 K2 D        long           cnt;
: g" ?5 J" `) g5 \9 W- J) g, G7 s        long           val;0 t* l7 a. j, V4 n% g3 u
        long           size;. o8 U, d# i1 Y
        int            i = 0;* L6 S% [4 I3 n

0 y: G, ~3 W( k3 e2 R        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {. |: \  q$ }+ I* Q7 H' E! }# y# s
                addr = base + cnt;        /* pointer arith! */( Y- ?9 m3 w. N9 b% s
                sync ();: A( W5 q. L( {. h- G3 U2 L
                save[i++] = *addr;
# J' ]5 E9 t9 z! N                sync ();
/ W9 U9 J$ T% A. K2 \8 o( T# r                *addr = ~cnt;2 b( F" `6 E/ q1 O* V5 U
        }
: k4 J: F( S) u" H, x5 Q% }% T4 @; J1 S: B% r6 t8 z5 f
        addr = base;' o! ~' g; o! ^( I' b* z
        sync ();
) i  P4 ?1 Z" ?% e        save = *addr;; O4 {+ y- S! w/ N) j
        sync ();' w( z; @# m& A1 I4 j) b" e* n" _
        *addr = 0;7 p( _4 g2 R1 K3 ^5 V! \% ], z

) q- Z* K& H5 y5 ~) r) j7 E        sync ();
& _9 G9 |( G. \* \/ y& x4 i        if ((val = *addr) != 0) {$ x, x: C; Q8 V! h) Z& z& ~
                /* Restore the original data before leaving the function.
9 A/ B& f, [% [3 r7 z, Z                 */7 z/ o5 B( G) |7 \  \' b
                sync ();6 U/ R% \7 j  h& m! z
                *addr = save;6 i! E( q3 D+ i- j1 b1 W
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
2 E7 c, }4 c; y  i                        addr  = base + cnt;+ J4 H" f1 A1 t+ E1 H; c
                        sync ();3 |5 ~4 h+ B) ?& [
                        *addr = save[--i];
* @  P2 N2 n# T7 I2 U6 e+ g                }
& q( h8 I: h0 X7 ~2 |! L                return (0);
+ X9 @! [) E: [: g) x- B# l        }
5 a9 c3 w+ x2 `
* y% k1 t% _1 U) @        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {/ k& x+ q# Z& s3 b
                addr = base + cnt;        /* pointer arith! */
) g# K9 \' y) h" S                val = *addr;
* D8 P: r% b6 r                *addr = save[--i];7 t* v# i* Q6 G6 U: Q
                if (val != ~cnt) {
7 R# R/ o* F* t' h0 U                        size = cnt * sizeof (long);
# F4 [& S2 _/ T+ A                        /* Restore the original data before leaving the function.
* x# A' ]# j6 Y% }+ `  Q                         */" |4 I$ E1 P: c1 t6 d1 i$ c
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {" r  u( e& R+ K
                                addr  = base + cnt;
9 Z1 \1 t: Y5 c  Q+ H1 K  B' G                                *addr = save[--i];2 e  w/ v) c, _6 Q+ I: r% i) s
                        }. b# |- T, o  K1 G# o+ [
                        return (size);0 r4 A! P. @- i4 s. X' `) D
                }( c7 r' v* N0 a2 v
        }
3 E8 S4 l! `: M' Z! u4 x, H) `% O: e. O1 M/ e9 f: \+ d* ?
        return (maxsize);
1 S! |/ z+ c6 e$ }! \}  w( v  l. U; D$ n" e, p) L
int dram_init(void)' n2 T( _: W3 Y  [  s, `
{
! @1 l4 y+ K- M6 g$ Y) n        /* dram_init must store complete ramsize in gd->ram_size */  \8 C' W" x& B, J1 L: I
        gd->ram_size = get_ram_size(! z" u; H4 Z8 p% A; L- }/ _& y+ i2 i
                        (void *)CONFIG_SYS_SDRAM_BASE,
4 F, k! [# q6 k, F                        CONFIG_MAX_RAM_BANK_SIZE);
4 ^7 G2 O9 a$ `7 ?        return 0;
3 P: t+ s1 Z, c; T2 m7 V}0 ]% S' h4 A3 M8 R2 ~6 }# M" Y
$ e- F  J8 y# j  [  ]$ d# ~
- Z1 M7 N" ?6 D6 Z$ _

6 X& h- A# I: _: [) U4 o, B/ x  Y  m0 O7 f1 x" S
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
" z- \( g. M) g4 X$ Y
, T- r; I4 b; p' C! ?9 h# L; _: ^1 E, k/ p% K3 N, C& ]. r
$ E4 w6 o$ b( P/ d# q% _6 [3 G





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