嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
. U. J9 g, N5 w核心板2:DDR2 256M Byte   NAND FLASH 8G bit- I6 `. ~. F# j
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
. }: O7 U" ]0 C2 y$ F0 B; t. N6 Q4 c4 v% p
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?) C: a2 M6 F: P- A, ]$ c

: T$ A, ]( R' ]
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:$ K$ g' `) E2 Z% \
/*
1 M9 W8 k9 V$ D0 Y$ Q+ g) V* Check memory range for valid RAM. A simple memory test determines
& A$ D+ V, O! j9 E6 O* the actually available RAM size between addresses `base' and$ i; W$ o& P/ G9 `4 q1 Z
* `base + maxsize'.
6 U( [& X" z0 W2 G3 y*/. K( V. r6 W  b# D: k
long get_ram_size(long *base, long maxsize)
7 i/ B- h0 y& w/ S2 C- v{  c4 ?4 d! o: y' w; Q7 ]* s' z
        volatile long *addr;- z3 o5 V5 B* q: {' L2 [" c
        long           save[32];
$ |4 [' z8 L2 ]3 L; U$ J        long           cnt;! i! T0 j& ]. Y9 c$ j" x9 O
        long           val;& L/ f9 k2 U0 J, T2 H$ \
        long           size;
# d; |. D$ L) K* ^* n7 X- M        int            i = 0;
8 g1 D. {# ^  Z4 u8 x: z$ |" }( ^6 Z  Y( X, X, K  v
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
4 C$ [( p) L: \0 q( c                addr = base + cnt;        /* pointer arith! */
7 k9 ^7 N  X% b: d  Z$ P* h                sync ();: w6 l  k1 h  l: d$ E
                save[i++] = *addr;8 b) P# U% C; p$ a! ]
                sync ();7 d( P; s( Y7 I
                *addr = ~cnt;
% ~* A& R1 }6 m( ^8 U% `" z        }& l/ l. n0 F: g5 |
" Y) H  q% T+ A, z9 |
        addr = base;# T0 I1 F9 T) r
        sync ();4 U1 |7 K) q: ]7 }; ]7 {
        save = *addr;
0 u* u& s+ p/ Z  w        sync ();
7 M  [! `; H0 a        *addr = 0;
  t" r4 ?" w/ F) V- x! h
2 w& O. W2 ]2 m4 L9 M7 `  `        sync ();9 C: z2 x0 C1 p' Z. R8 H) J
        if ((val = *addr) != 0) {8 C9 s( I% H0 A( f/ z" p
                /* Restore the original data before leaving the function.
4 T! Z0 m1 u+ x$ u6 q8 \( \7 I7 F                 */8 o  t; o# u2 n7 t. J
                sync ();" M' c8 p3 J6 E. E8 Z
                *addr = save;
8 `$ F' @$ B+ z+ l% ^- S                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
( u+ n$ I; y% J5 X& S$ ]& v( o. M                        addr  = base + cnt;
2 e3 s7 q& l! k4 D* P' h. X9 b                        sync ();
+ L  `, ^9 k8 @9 }& F6 ?                        *addr = save[--i];; C/ m* _, _3 G9 T* A: g* X0 Y1 d: ~
                }- f* d- t+ h) U
                return (0);
+ `  o- r2 C+ t        }
& o7 [' A: `5 d
0 T; a) N7 F6 E5 `3 p/ Z. z4 a        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {+ U# ~2 g- G2 V& U
                addr = base + cnt;        /* pointer arith! */
$ M, B% `" p) F3 {; d& x% D                val = *addr;
7 b9 O% A9 Z6 H0 e/ k$ K                *addr = save[--i];
; u6 L: N8 g) X# ^& d, f; {- N                if (val != ~cnt) {  i3 r3 I8 y5 }0 o# V! R8 Z  T
                        size = cnt * sizeof (long);
8 X+ i6 N: n# U% B                        /* Restore the original data before leaving the function./ c9 [: `1 p- i7 c
                         */
8 v. u- S% ?/ V! I# V. u8 P- k# H1 l                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
5 F9 U8 n  F! ?5 R5 i6 e5 `' u1 i                                addr  = base + cnt;
+ E7 q5 J4 B% C* ~% d# r5 K9 {8 a                                *addr = save[--i];2 @7 p$ V0 }6 ~; F4 A' E+ Q- m* C
                        }! Q, u0 C5 g# a6 H6 X
                        return (size);/ r4 j3 I" O) C/ W- \
                }
! F* r& w. i9 b# @( X% ?        }
" W0 J& O6 @9 G6 ]% M- L: K- C
        return (maxsize);8 P2 \" f% K! o+ {6 ^0 |! z
}+ u% `4 Y5 d; M" S. L) X
int dram_init(void)' P/ Q$ e# E/ G% i* n$ g' G: v
{
) s* _# A5 k* V& s! v' Z# D        /* dram_init must store complete ramsize in gd->ram_size */5 Y8 }; p& @* r
        gd->ram_size = get_ram_size(0 L  `4 {. W, k, n* B" ^
                        (void *)CONFIG_SYS_SDRAM_BASE,
. J$ S( f9 U8 e! ?                        CONFIG_MAX_RAM_BANK_SIZE);, K8 K; k8 y6 q9 `7 b6 g6 C
        return 0;
, g3 l9 u0 Z( r( f, c}# O" A1 e$ G# n. [7 x
) c+ B2 v2 T! ^/ F. D/ G& d; J
" u, I; y& \. i- Z2 s
! t* S. v& U) P  I$ z
) m* w7 D" Z* a' U
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
. T% o* k* K/ j$ E% v$ V4 v$ S: S6 X- X$ C
1 L! X! f) A3 D4 m+ N: G' `! I

5 p9 c, m$ S1 [9 f, ]4 D9 s9 B




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