嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit# s2 M8 B$ g+ N' X, w' j
核心板2:DDR2 256M Byte   NAND FLASH 8G bit  n9 @: h+ c" b0 Q6 w
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?* n' q- C* m4 B, F/ `, z% D

* m% q, Z1 A3 P, E$ F! _是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
" e; V/ `7 ^0 I% u& K1 B' [' S. T6 U5 r1 @, D8 T* _7 p6 f6 ?6 T: `7 c

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
5 l& y( ?8 A3 \! r; e/*
& F2 K5 @4 N6 k# Y8 B* Check memory range for valid RAM. A simple memory test determines" R0 I+ w) {2 L# [- D3 g7 A- W* n) J
* the actually available RAM size between addresses `base' and9 A1 G) O6 \+ {
* `base + maxsize'.5 {' d% q4 }# r1 L$ p
*/9 w1 u+ P' ^. P# v3 A
long get_ram_size(long *base, long maxsize)
2 m/ m3 _3 ?$ p6 |{, x$ }& \9 c$ [0 g  y) ~- D' O
        volatile long *addr;
  L2 b2 @0 O- i7 j0 M4 K5 z        long           save[32];! y; M/ `9 x2 G- C0 ?8 G
        long           cnt;
. v+ e. E1 _" a7 s/ c& `        long           val;, _" v, ^- \" U
        long           size;
" h% `  h0 T9 d7 E; O( p        int            i = 0;$ g. ^+ F" A8 U2 h; V7 _

/ q; U: v! O1 i' y& _# t1 K! T8 {        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
0 T& I. Z, E- N% Y4 C                addr = base + cnt;        /* pointer arith! */
6 Q; @, ?7 Z4 ]' Q8 e5 O                sync ();+ V0 r  D, Q, m) y7 l$ K: |* `
                save[i++] = *addr;
* J( C& I8 k6 q2 |9 n                sync ();" T4 w4 w6 n' `
                *addr = ~cnt;
4 l6 Y4 g) X! A* |: _9 c9 R        }! q$ \# U/ g2 @" C2 G! d2 O

7 S5 y/ o* j* L" ?3 k1 c. [" j        addr = base;
) l$ M" r! B6 |3 M  U        sync ();/ ~; m" @. t2 R6 ~6 p: e# q
        save = *addr;
! o( J% T0 i" O0 S9 Q$ ^& }, e4 [        sync ();
5 q/ \+ J  W# r( [7 ~/ K        *addr = 0;
7 Z& D, j1 f  w+ Z3 p2 j1 ^" v1 U+ D$ c9 b# |- _
        sync ();+ \# p! N# t$ [1 W2 q% X; m" }% D% e
        if ((val = *addr) != 0) {
; A& y7 K  @& ~3 X) l! a+ {, n                /* Restore the original data before leaving the function.& b; X( I# v4 \9 V0 j- _9 J2 x
                 */2 e! A4 |& O1 i8 L- Y
                sync ();" d4 q, B( b- k
                *addr = save;
6 V) ~- t2 _- c' z2 A                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {, a: p4 W0 N' D8 u8 b% [% Q
                        addr  = base + cnt;6 o' ]4 g* q1 z& u; v3 ^+ T3 i
                        sync ();
) \. N7 v, m/ V5 E8 o; g                        *addr = save[--i];
) T7 ~4 [# n% R  I: j' F& @: s                }, ]7 U! U3 L* T! x; N
                return (0);
. n5 @! [- d  b        }
* Q# G& ~% L" i- x/ g9 w8 }9 M' g! m/ {% }! K9 ^
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" g; l, E& K0 {* n                addr = base + cnt;        /* pointer arith! */
" X  ?0 y. c: C2 v8 T! M                val = *addr;- Q  Y& r: ?3 b
                *addr = save[--i];+ _6 U9 ]- U# y0 _0 E
                if (val != ~cnt) {) X" r* }) T/ D& e
                        size = cnt * sizeof (long);
9 l3 g8 v8 c" R4 T) F6 A                        /* Restore the original data before leaving the function.# H8 z' J+ G4 R0 G; M. J
                         */; s' Z7 f# T5 y* {
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {2 f" l4 i1 H' X6 g
                                addr  = base + cnt;* w$ q1 B) ^) ]: U; d
                                *addr = save[--i];% z( y  r$ n( c- y& K+ C
                        }8 w4 u: i8 ]7 u' n  K, [5 @. Z
                        return (size);0 k) N3 R; j* `7 [. _* O8 Y' ]
                }
+ N6 d! h( f; f) Q        }# F; h5 q7 W( M' j) U) ]; J/ E: u. F

' F% O6 X. A3 Q        return (maxsize);2 c/ b" |  ~3 V! \3 W/ |( N% n
}
1 Q% G4 T. O6 Z& d' Z4 D8 ]int dram_init(void)7 u* _. h5 j/ ^3 M( d0 P4 [
{
- d+ Y( S& U0 h/ F5 J        /* dram_init must store complete ramsize in gd->ram_size */
; s$ Z. C# ?. y) q- h! y        gd->ram_size = get_ram_size(! k/ t# l" `( `" [4 s+ y
                        (void *)CONFIG_SYS_SDRAM_BASE,3 |, H- S- F/ k) O; `2 `! [
                        CONFIG_MAX_RAM_BANK_SIZE);  s& ^! R7 f/ f) y, L, |! v
        return 0;
0 h; D7 U5 j6 q* U* r* `* _5 b}2 N0 s1 l# B! j  Z3 \0 ]

. e" I& P0 o/ ~8 O  ]6 u% K$ f2 R# A0 F$ x2 \# T- G' X
+ e6 `0 b) _  B4 b+ B& {
/ E) K6 ?1 ~# C1 r* d/ i8 H8 J
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!9 G0 C* a1 u1 ?1 y4 Z) [2 ~
/ {2 M+ I& l( D; J$ d" F
* D4 q1 ]1 Q# F/ y' q

2 r+ K8 p$ l6 p! T) z) G( ?( P




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