嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit/ n* x/ u5 i+ O
核心板2:DDR2 256M Byte   NAND FLASH 8G bit5 J! l/ f8 m  k; M; G) }1 `
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?3 y3 C3 e6 X4 {4 P

( w0 f7 }: J' y8 W* q; \" t9 M0 c& f是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?% t; x' R4 }, ?0 w5 t* O
3 }+ P5 R( D7 J1 U

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:1 D" k' M6 J) w, u1 @$ y6 D
/*# ^8 Q# _* S' y. C$ Q! c9 p* A% @
* Check memory range for valid RAM. A simple memory test determines
2 b5 f: F* ^$ v* a* the actually available RAM size between addresses `base' and
- w) i3 E. M1 e/ g! L, U" P* `base + maxsize'.& z, o3 }  A  U3 M+ o6 m5 e
*/
6 E  j) p' R: U5 Llong get_ram_size(long *base, long maxsize)
8 z' K" k0 A6 {9 s) U# E' C- J{
# m4 P5 t* {* a+ h4 q# ?" t        volatile long *addr;% |) v, v+ O- w
        long           save[32];2 ]7 R) ]& X5 w7 @$ y1 |
        long           cnt;8 |/ @* F) n) s9 y/ B) \" r
        long           val;' M% T6 q+ ~$ K' C. A! ], \" T: P
        long           size;
; ?, _2 ?5 u- Z- [+ p        int            i = 0;
$ t( }8 Q% ~' Q$ T1 T! P" m' N" z+ j3 y
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
1 e+ Z' D- v0 p                addr = base + cnt;        /* pointer arith! */
! X0 I9 O& t0 V) b$ z/ j                sync ();
% g4 U- i& x7 I& C$ a8 L- z                save[i++] = *addr;
+ q& F1 U! R0 Y) w+ j                sync ();% {1 e5 b( {; O; a$ T4 C/ u6 o
                *addr = ~cnt;
( m2 y. S- R' b0 U- q+ P        }
( \# E  ~/ T# J& \8 Z
- _9 V( ?5 c1 o: A6 p$ i2 ?        addr = base;& q4 R2 ~4 {; N( v
        sync ();* y+ A3 L5 i1 {, M
        save = *addr;% r- R+ ]5 f; o) M5 s0 T7 q9 g
        sync ();0 Y) X5 W" T) D  W7 c  @
        *addr = 0;. K" ^0 h* O  k0 w) _
* A; f0 P! \: m& K
        sync ();; D3 A. ]. M. j. r. M& q2 w/ Y
        if ((val = *addr) != 0) {4 a! A0 K' r+ |# y
                /* Restore the original data before leaving the function.
3 A( `" w! u' h8 P                 */) m4 @% b: z; j3 u* U7 ^: ?4 T# a2 W
                sync ();
* f# j4 k( \8 U- `2 m5 \( z5 Z                *addr = save;
- k* r2 d' p' |. g) L! K6 D) ~                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
/ W$ C  R# `+ {                        addr  = base + cnt;: D8 `% L  B: G3 K4 \8 L& _! P% }
                        sync ();& B6 v* Q0 q) A$ b2 A
                        *addr = save[--i];' d/ Q3 E$ T3 K3 s( Q6 k1 e, Q
                }
. h0 J8 i, R6 V3 R                return (0);
, h7 R4 }7 ^" k  [' C9 ?8 \3 \        }# D8 |' b) [0 N4 d) N7 \

; B9 Z5 q' U$ m        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
8 Y# ^! F% V1 d4 W: C! _                addr = base + cnt;        /* pointer arith! */
" c' k8 d5 s6 z; p                val = *addr;
" x* Q0 T. k# _/ @3 ]- Z+ V                *addr = save[--i];
0 w4 l2 C6 L6 C                if (val != ~cnt) {
5 K) L; x8 i3 T* l                        size = cnt * sizeof (long);
: Y: }0 C. L- C, W" p                        /* Restore the original data before leaving the function./ R$ J( t, d7 U& i, \
                         */) T, A5 M. k; F; t, ?  L* T
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {* K! J( `( ^5 s9 r' q6 S) @
                                addr  = base + cnt;
* o6 j, s# K* O! W                                *addr = save[--i];
& ]& l3 F/ I* e" H8 I( `                        }
9 O+ {/ r$ x7 L: r  @: A& L  a                        return (size);9 O2 G+ l9 Y: q5 h3 f2 s
                }
$ N7 a1 n1 O2 ]. `3 l        }1 y/ @  l. K# Y5 f) w# G
" t! `$ x  g# F0 P) l. e- q
        return (maxsize);$ {" A: [. E- ]6 {
}( t) p3 ]4 ]( u+ F
int dram_init(void)
, G- w3 Z+ T7 s/ V% d5 n1 h{% F$ |% i: n/ ?" F
        /* dram_init must store complete ramsize in gd->ram_size */; ~2 x7 q& Z& v: q& J
        gd->ram_size = get_ram_size(
3 P" `8 h7 k) o# G( D+ `. k                        (void *)CONFIG_SYS_SDRAM_BASE,  W% q& x1 M# V( w$ l
                        CONFIG_MAX_RAM_BANK_SIZE);
+ ?8 S2 @# B" A! E3 A  d- ^. J        return 0;
0 W8 p9 W; Q1 d5 N% p( ^}& |/ @& u2 ?4 q; j% q
5 p9 N: s1 ^! v- y
3 k7 i* t4 o" b5 `6 }* p% Q
1 o7 g2 R( _% h6 v, y

/ f, G0 @$ @! y0 O$ W' AFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!% m# B3 d  z- |. @

+ T# A, x) a4 ~8 v* V& e4 t, ]) s0 h" P; [1 T. z# F

# y2 R! x1 Z) A3 L) l




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