嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
: N+ B, b: N# ~! N% T核心板2:DDR2 256M Byte   NAND FLASH 8G bit6 I2 u9 a1 Q4 ]4 I- t' V
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?: D1 N5 J& p* a) N" B
9 F$ E8 y/ D9 U' v' c
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
/ N& U$ U8 [% S. u+ d2 b! g2 a
" x* }* R$ U) r3 h$ i1 E2 m. B
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:, o$ b1 C: }  F% @* X
/*+ c& S+ j" j. C6 ~5 |
* Check memory range for valid RAM. A simple memory test determines
  \. k0 l0 `* W& M* the actually available RAM size between addresses `base' and
$ k8 Z+ i, P7 Y: p* `base + maxsize'.
  ~1 p- D2 H3 R) g1 ~, |1 M*/
; l" ^5 `" X7 b; E$ e1 nlong get_ram_size(long *base, long maxsize)
' T& O* \! h0 r  V4 w* D; [2 t0 o$ ?{# J7 E" y% i5 x3 {
        volatile long *addr;
4 q7 E6 \; j( R( M        long           save[32];
8 \: k% M; t) _        long           cnt;! e% C% h* e  a& n, T) {3 g
        long           val;# n+ Q9 t7 B* c
        long           size;
7 ^. U1 j$ Y1 X! W1 d; O# s& ]        int            i = 0;
+ }  i' r6 ^2 M: Y( G- f. g. R; H( t- j! w
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
. d* T) `$ M" y. M8 [2 X# ?                addr = base + cnt;        /* pointer arith! */
6 O0 ]" @( S  C                sync ();7 l- h6 y5 `# H$ X
                save[i++] = *addr;! b/ S  N4 P% j
                sync ();( U( l) l' F- D
                *addr = ~cnt;
* E" q+ e0 ?' w6 A1 X; o        }0 z- L4 m7 E3 N4 v

$ z$ @& t; o6 R/ F$ ]0 W* Z' \# u        addr = base;
0 A$ @  Q4 v- ~        sync ();
- k3 a9 ^7 L# K6 l        save = *addr;
5 `  v+ D" U/ w6 q0 H        sync ();) ]! }; {% i4 m+ h: _  K' s
        *addr = 0;* g6 I; ~) P! S- Y* v/ o

% ~0 P6 u* m1 ~3 ]        sync ();: Q! h. ]$ S, I5 e4 q. `9 i0 |
        if ((val = *addr) != 0) {
2 l7 ~$ o$ A1 W" I1 {8 y                /* Restore the original data before leaving the function.
* @" [: |. ?) _' u                 */
$ G; U4 e' w9 ]( A                sync ();
) y; P8 S3 h" W# c                *addr = save;
  z2 z% O9 C$ V& P8 ?, D                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {# T: E" s4 {" d/ @3 o
                        addr  = base + cnt;3 P) R- S4 ]- x/ g
                        sync ();
& l+ {# I4 a2 x) ]- l                        *addr = save[--i];" X" d* ?: F0 U. I0 f
                }  Y& O$ l# h, }2 ]
                return (0);
3 {" I# g7 D& J; F        }0 }6 J: {, z3 q# F  P* j) f

# ], N' R- E- {6 z) ]( {        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 P: k6 A% `7 t9 {7 y- ]% @4 X( n                addr = base + cnt;        /* pointer arith! */7 y1 W& M3 A6 w
                val = *addr;3 I! M4 i# y: ]' w  {* m! p
                *addr = save[--i];
% \, L+ u- u" V0 S- _4 G                if (val != ~cnt) {
/ f, G: Q, {. Y# W: b( g7 Z5 j                        size = cnt * sizeof (long);
) F9 \. G+ ]* Y/ [0 L                        /* Restore the original data before leaving the function.% a% t, n3 M, y
                         */
/ k, f, h  o" E3 _# z5 A- S, u                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {8 D# |. |+ q3 X2 v; _3 j+ [
                                addr  = base + cnt;
' Q/ O3 y2 P* X9 V6 K* j9 x+ r                                *addr = save[--i];; L6 X: d/ z* u
                        }: j. o; @7 K4 a7 k
                        return (size);9 s( ?4 `, K! X  T
                }
- k& ?# J5 z( K9 l5 p, P# E        }
6 j) G; V+ X  t* C7 h3 b
; K& z! h* ]2 u6 C$ h* A' D" h        return (maxsize);4 L; X4 ^1 A% E: a4 G, J+ R& v
}
  G. V) P+ j/ h- `2 P; D$ Q4 Wint dram_init(void)& l. \. B+ e' x: G# [2 I0 K3 ]
{  U8 z6 ?9 w% L/ g
        /* dram_init must store complete ramsize in gd->ram_size */
  `+ Y: S) i+ m        gd->ram_size = get_ram_size(
% h  F2 x+ I' B& @+ `; O                        (void *)CONFIG_SYS_SDRAM_BASE,
; F: d8 L7 o# ~; R/ P; E                        CONFIG_MAX_RAM_BANK_SIZE);
7 y* B% A& ^* o2 o1 W        return 0;7 L/ n# Y9 E9 s
}
1 _" b; u% @, a' c3 i4 B4 y5 b1 p9 y( W5 x! o
, P! p+ y% T+ W$ o* ^& C6 f
. [, ]' j; M4 E" U5 s- Y. G1 F

( S: F- y1 l8 e4 _5 L/ A( \FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
" K8 b% \+ ?9 V& X0 I) B) s: @& S' _! J& A1 e/ K$ A
  }1 ?, j! n! r% I/ b3 W

6 L) J" U7 y7 ]* n, {




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