嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
" T7 z  I9 N" M% Q/ j8 r核心板2:DDR2 256M Byte   NAND FLASH 8G bit, Y6 P+ {) a8 N& T  e* L
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?/ r5 R+ d$ R: I' `" `

) w) _" W7 a( ?* Z是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
" K+ a: k# L# H8 [9 B. e1 X  h, E! S) U2 ]

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:/ ]5 I# R+ c$ J
/*+ A- o6 ?" E8 u6 R: K6 A' j# ?4 `
* Check memory range for valid RAM. A simple memory test determines
  U* U3 \# Y/ [  C4 s; q: J  I* the actually available RAM size between addresses `base' and' }* q: `5 O9 K: O* W+ S
* `base + maxsize'.* B: Z, W1 ]! v
*/& q1 z* l) r$ Z$ D* Q9 M. w. B
long get_ram_size(long *base, long maxsize)
, d3 T" U# K' }9 l$ y  O{# Z6 \# \, V" @1 \
        volatile long *addr;
0 c& k& D4 H) |% L3 H        long           save[32];
" o- z3 f- k' B        long           cnt;
( B+ L# B1 V- [$ u; [        long           val;
) X* {' Z9 h2 V6 ~7 R& U        long           size;
( O2 j! y$ u# Y. ^* m        int            i = 0;0 M" ^% [  ~& i
2 ~! B' z8 a9 g7 X9 W' U
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
- p1 D& x  y$ s                addr = base + cnt;        /* pointer arith! */$ R$ E7 @6 ^' g/ }  |
                sync ();: x9 t- ~5 V5 }9 a4 F
                save[i++] = *addr;
5 }+ h4 a, x+ u& f                sync ();
0 O& C3 N7 p* p8 O- m- t                *addr = ~cnt;
4 f- l" N* {" [( P$ |4 ^        }3 o2 Q$ }3 N* D1 n

7 A$ d. e& P; Y) R& k: M3 F        addr = base;
4 J, J7 m; Q( L5 Q4 g( [/ Z8 p        sync ();
$ l  _- _7 Z# U$ R3 e        save = *addr;
$ M  c1 h; n- \. c3 y* X& R        sync ();
- Q! e5 n* r+ ]8 H6 T: m4 Z- z- u        *addr = 0;; f1 z5 K) R. O8 b/ C' h* B

! Y! s. a  q7 K% F        sync ();, \, u5 D* T1 Y
        if ((val = *addr) != 0) {
8 Z" b: m+ ^0 I  l8 {- @8 u                /* Restore the original data before leaving the function.
1 s8 u/ ~- W9 m7 r1 V                 */
% n& F+ J2 U! K# @& M                sync ();5 V! i( v* m- d5 B- e# W; J
                *addr = save;
; g, c; a% E/ k8 W5 G& E. S8 x                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
  s. E; q/ S* ]0 {                        addr  = base + cnt;
( }' {  _8 @: u0 B                        sync ();
% `2 h7 D0 G- k                        *addr = save[--i];
+ Z# A. d& g7 J5 n, E, ?3 E& x                }9 K) o% |; `# h" o3 L
                return (0);
3 P2 [9 I6 Q' t9 x& u2 J        }& @, T4 H9 V" x1 f" i' {

: ~4 P) z1 O: |" a, V/ V        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {* R+ Z4 M* P0 m$ t7 |1 A8 A: C
                addr = base + cnt;        /* pointer arith! */: j: h* o7 U! U2 V9 \2 @
                val = *addr;
  c& @! H2 b* Z8 Q* ]7 Q8 F                *addr = save[--i];
* [' Y! y; K- a* z% G  d* Y                if (val != ~cnt) {1 ]8 }) ?( [' x5 T. |9 a
                        size = cnt * sizeof (long);
4 W: s/ P! h" @" {$ A; N                        /* Restore the original data before leaving the function.  M9 b/ i5 r, u
                         */' V2 [2 W5 [( c% n$ k% e
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {5 A5 l  Y0 E8 B
                                addr  = base + cnt;9 K2 z/ |) d' L1 g1 o! _. _0 ^) g
                                *addr = save[--i];: e5 Q9 P  N. H) X. e. {8 ?
                        }6 q3 Z& |" V0 r- O/ K* C, l3 k
                        return (size);
: v1 Z+ r& {6 }# C- q: Q$ n                }
% {6 Y6 [, r1 ~% |        }8 @2 M- D) w0 ]3 B

, \7 e# o- P! ?  E  N) U2 J( \        return (maxsize);0 \3 a; j$ r+ d+ m( c# B
}! P$ I/ u! A7 b, r3 C/ n
int dram_init(void)
/ e: |* _: }" f0 l( _( e{
: `. o' _  T* ^5 f! T- o        /* dram_init must store complete ramsize in gd->ram_size */
* }; U, `1 f+ A8 d( f: j        gd->ram_size = get_ram_size(1 W9 W" t& t* H6 i. v
                        (void *)CONFIG_SYS_SDRAM_BASE,+ `: n* s8 S: S8 A" A% q
                        CONFIG_MAX_RAM_BANK_SIZE);
, l; D" B+ Q( @  f$ u# }! Y9 k        return 0;$ f7 _0 N' E: W$ M) o! ?8 L; W
}. u# [  M! H, z8 Y

! x" Z% q4 e4 G7 n8 ^; g2 X9 U
' B5 q" c5 T% ?3 ^1 [: |# H; {4 b4 `# z) c6 v6 b4 }

1 Y3 g7 m7 U; U: j, J) r# BFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
! u" Z/ J& y* x0 ~! B3 h
1 p) s; V% v" n/ S4 B: O! y/ a
0 Y+ t2 I( `. M7 x
0 L( ]; z; J* L) F) F5 M% A9 `





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