嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
1 G: B, f/ N8 H4 z核心板2:DDR2 256M Byte   NAND FLASH 8G bit
2 p. v, P. f( E1 |7 s, s这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
" X+ e$ L1 A, i9 K* k4 m
! D6 S6 R- k: s$ j6 H- b. M+ y是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?! A; S9 @& A% `' J
% ]4 |/ n2 n) i# r& i8 |' ?( [

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:0 O! w5 g8 S3 {& c3 p* \
/*9 q, b; A% n7 u  t8 U; n
* Check memory range for valid RAM. A simple memory test determines
' u0 \; x$ C. ^1 {+ J# }* the actually available RAM size between addresses `base' and
  X  L' S' z( n. X) V# N! @5 ~8 K8 d* `base + maxsize'./ [# h+ S& C* o4 p2 b4 C/ H1 k1 w
*/( ~4 r; D% l  ]  d7 O0 h9 M
long get_ram_size(long *base, long maxsize), E+ x! L1 A; C9 Y2 Z
{
/ r7 a0 l" A( T1 y1 y" S        volatile long *addr;
" n) y5 D! K- `& j0 L- H3 W        long           save[32];
+ I6 v. w' N; G& u0 d        long           cnt;" H, q7 l% I; j/ X
        long           val;& M' q3 H8 V1 e7 [! X, V4 _" n1 Q
        long           size;: g# l8 w7 F. ?2 I3 Q/ `
        int            i = 0;( z9 U( u6 @9 s. q# y5 {2 I! R

7 g( j8 ?6 t: b        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {! M0 q! \% x( x5 f6 S0 L; s
                addr = base + cnt;        /* pointer arith! */2 b4 J  ]7 M' L: e
                sync ();' i2 F( l- i% k
                save[i++] = *addr;
1 Y3 y. {9 \4 E- a                sync ();9 V& w) Q& U6 J1 {3 m
                *addr = ~cnt;
" M, m7 c# S, ~& c: \4 j8 k6 [* c        }
8 |! I* L! e$ h7 w: S0 \: |$ o. t2 n8 _
: _2 \: A* j0 I5 N5 |% _        addr = base;
4 [! Z+ X1 N: d0 A$ t& Z, z        sync ();
5 Q4 d& E; [! g7 ?7 u: W        save = *addr;& Q* g2 V% v) s
        sync ();7 S; Y  F+ h" J2 J% d; K! \: T
        *addr = 0;
7 z# Z. h' b; {; x1 V9 D" n+ ~7 x! a: W$ O' z5 g5 y) ^
        sync ();  i/ n8 _3 w) S5 t, S: p$ I
        if ((val = *addr) != 0) {
! E7 L5 \" w, D  @# e                /* Restore the original data before leaving the function.
  F% [: }2 t& Q$ n% Y% j3 S                 */- e7 [( `- w; e0 U$ y
                sync ();
, k$ {8 a# U4 C$ S! v                *addr = save;! D, B& L1 p3 Y+ i; W
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {" g! P7 Q1 [- Q2 i
                        addr  = base + cnt;* }- `+ t; n2 u& p9 P/ v
                        sync ();7 m% D6 K+ a; e, p+ u
                        *addr = save[--i];# Y' b" P1 s  _1 i. f5 j. g6 v
                }
3 A3 V% @# X9 S8 n! T  u                return (0);
+ @% M7 N" J# }9 M  {        }
% G% J! d% v% {1 A/ \1 r% w. f) F& |# r9 h* Z
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {1 b+ @" ^1 X8 [3 K
                addr = base + cnt;        /* pointer arith! */
6 l: Y& I& {7 ^8 Q; \3 e                val = *addr;
4 p' S7 b3 K$ l5 @) E9 ]2 R                *addr = save[--i];
7 k+ v# K' w/ d' I+ j$ k                if (val != ~cnt) {- N4 _  y- W6 ^3 z6 E( |  T
                        size = cnt * sizeof (long);* z: `( Z1 \& l0 J7 g  q
                        /* Restore the original data before leaving the function.& c8 _/ e6 L* b. l9 }" G' k* s
                         */
2 M" a4 }; b  {$ L                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 ~$ c, @1 `: r/ x7 _9 ]: I, j                                addr  = base + cnt;1 Y& k5 l5 Y' [* a5 H6 Y) m7 ]
                                *addr = save[--i];: s5 K* `; o4 C4 H
                        }$ x# ]# V: t1 b/ p' R# c4 L7 ?3 f
                        return (size);9 x% J& }" W& C8 c# M
                }: J' N4 D! _9 o: f; B
        }/ G% ]' V& r2 L% f7 j; J0 C5 l

3 u5 D* Z# K4 U+ n/ A        return (maxsize);2 o8 B( A  H7 N) M: S! |/ S
}3 Z4 O6 \: s; q- T6 {4 v
int dram_init(void)
: \: E' g' e4 Y( O0 P{$ V, f, k, _! R) U5 b5 Q
        /* dram_init must store complete ramsize in gd->ram_size */) i% p/ n  E& E) d8 G
        gd->ram_size = get_ram_size(
8 C" T7 B* ]$ O. Y! c% _                        (void *)CONFIG_SYS_SDRAM_BASE,) F. A, P/ A& [
                        CONFIG_MAX_RAM_BANK_SIZE);+ C8 ?% A/ w; V: d  c1 m
        return 0;! n) y  x' ]3 a/ N
}
; l% M7 _2 V9 p
& _& a" b. X" d
8 I' V6 \& `0 O, [0 @
: a$ }/ A- p& U8 ^- l7 U6 L- W, c3 {4 D$ Y/ h- N# O1 e$ ?
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!1 m) x# s8 s; [+ N
8 Y, E' C4 K" N- \; w

/ N$ L6 Q' k) z6 A$ K  l( Q0 S
* w( y7 y. t* p% ?, u) b% ]% G" y1 v





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