嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit) c1 i- @5 C! U  \2 H6 [1 V+ B
核心板2:DDR2 256M Byte   NAND FLASH 8G bit
. H) R' [9 q* K3 W这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
* B6 G$ n5 x4 v! e
! _- j) v$ i7 n0 S0 N* ^. P/ E是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?+ U9 u  t3 J) e! n- z

1 y6 _: c8 X! C  c1 `
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
3 S( K" M3 G! M/*: o" f0 E" W! x/ n3 p
* Check memory range for valid RAM. A simple memory test determines6 E% V. _! `- I0 ~0 F# i
* the actually available RAM size between addresses `base' and' V- M! ~: f7 w/ s
* `base + maxsize'.
2 Q2 {; S+ y7 y7 L* }*/
5 l* S* t4 N1 C6 o/ ~3 w' `' m( clong get_ram_size(long *base, long maxsize)
7 p4 I  ~% D- e/ W  q2 k' K- m0 i7 x{- ~7 Y$ Z, q/ N9 Y5 X1 g
        volatile long *addr;- Y7 ?' @% d, p0 K: G  h
        long           save[32];; C# y9 _: R" z) `" y3 D8 E7 P
        long           cnt;9 Z& ]( x! z0 w8 L# Z( p
        long           val;6 }5 J/ h" V5 T( V3 o
        long           size;
- j7 V  a& Q% G" N3 M/ e4 t+ H        int            i = 0;
  ^' _- Y( U9 S' V4 _# N2 ]/ k& Y8 S9 k& n7 y
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {) a5 S4 @# P/ ~7 z# ]3 K7 \0 G
                addr = base + cnt;        /* pointer arith! */
0 S( O. [" \9 r                sync ();; w2 K( x; E, O; k9 c
                save[i++] = *addr;
; y8 p& h# Y, M: C                sync ();
4 ?9 Z5 u/ s" {# {- I                *addr = ~cnt;
6 ~- ^, ^% ], D+ u; m/ O1 i        }) }: _' Q6 \. f3 s8 Y

- g1 E* N2 M: J6 `& g8 u        addr = base;8 H5 v6 O6 ]) m. B
        sync ();# r' I5 Z3 \% a3 v
        save = *addr;6 E) W. `  g) {0 l* P
        sync ();# ]( b0 W# x6 w* N2 N  n, Z# a" R8 X; b
        *addr = 0;  T1 Z* H, T7 u7 [+ f1 d

0 x. r# J5 M9 n. r7 U; E7 {        sync ();
; L" p8 p: j/ c* n: Y' a        if ((val = *addr) != 0) {  M  Y6 |6 c0 Y
                /* Restore the original data before leaving the function.
; o  \% D( N1 p9 c) f4 y                 */
5 n. T( K7 U( `# O- {; \                sync ();- o; {# Q! m0 v9 A
                *addr = save;
5 \+ @' k3 `$ A# ]. [; D                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
; C* s, J9 ~( l* Z  [/ C                        addr  = base + cnt;
  W- h% c* q5 {) m6 A/ |: X, ]                        sync ();
7 l, C# o, X& _- D# b) [$ b4 _2 v                        *addr = save[--i];
7 a2 g* Y3 r5 l9 U# U                }- C; s/ n3 M* {- \9 x4 ~& J+ G7 b
                return (0);
8 O  f1 t) G* F+ y; _# A! w( M        }
# \. q' k' G: v: _) `) O! t3 A- n
7 X3 L. `8 X5 Q1 W        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {6 c; [5 H: a+ }0 B, J! }. K
                addr = base + cnt;        /* pointer arith! */! t. A% s0 Q7 N0 d0 U
                val = *addr;: y2 i0 t; o& b5 v) o
                *addr = save[--i];; M/ o  m0 V) h1 a9 c
                if (val != ~cnt) {: n. e, j4 U% _% ^
                        size = cnt * sizeof (long);
4 d% Z4 B5 n, U* J                        /* Restore the original data before leaving the function.
: c5 s0 a; i+ X$ L* t1 d                         */  D! Z1 n0 m" y/ y3 H% u! g
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {. U% N8 A, d6 |1 r
                                addr  = base + cnt;
& E& t; x  X) ?. }- [9 @' o3 _5 `% v                                *addr = save[--i];( ^: z5 Z! A% u: I# v" e
                        }
) n1 c, ]  p' u0 _0 x                        return (size);! C* @5 N& E+ z9 t" z6 g& k
                }- Y/ L+ X* ^: K* R' B9 _
        }, f) c0 {! s4 P) Q7 j+ ?4 L
2 K! Z! h$ o- U5 F" l6 ^  \
        return (maxsize);6 x6 D& [$ @7 c6 U
}
! V# G% _5 V/ }) xint dram_init(void): L& o* t$ x# x9 Q
{
6 v0 G9 J+ g% H# O" M8 n8 I8 h, n        /* dram_init must store complete ramsize in gd->ram_size */8 Y' }* s, R' ~8 z- \( z% A
        gd->ram_size = get_ram_size(
* e* i, P+ C4 \+ @                        (void *)CONFIG_SYS_SDRAM_BASE,. s9 {# \4 D, @. `  Z( [
                        CONFIG_MAX_RAM_BANK_SIZE);; E$ ?5 \% S1 z6 _7 Q) y' Y
        return 0;
& k: M: G0 j$ o}) z1 a# [$ F5 M" Z" |2 n8 k
7 R- }) P# b2 ^! q3 m
. D* E- w9 `% B; |. _* Y7 F2 F

% x1 P+ A! \% G% n" Z8 _  z3 W/ i4 l& A! b4 O  t1 A
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!2 a/ Q: I0 n* n/ k& G  r: P6 c

7 P1 x$ o# o8 l; W$ Q# V( |1 m! {, X7 O
% b: O: C% G7 B) }





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