嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
7 a7 a9 Z1 _# t核心板2:DDR2 256M Byte   NAND FLASH 8G bit
" M$ j) q( b# [1 j这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?3 C6 w5 r% C/ G. U+ H
, J" a9 }" }0 `: `* Z
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?  x2 v3 [/ s3 o. S# [

1 x8 h( A+ q! W# R
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
! z; c( b9 _: O" A$ a: e" G9 V/*
: R+ }% E2 B: U( K4 k! w- C* Check memory range for valid RAM. A simple memory test determines
9 T" v$ b4 A6 N, s* the actually available RAM size between addresses `base' and1 I7 \' |! y$ Z" F2 c
* `base + maxsize'.
3 |2 B7 T% s' u% \! Q. h9 x/ @*/
/ E  y- u. F! s9 v5 U( Q" _long get_ram_size(long *base, long maxsize)
+ g1 Y4 u  ^# r{' H) s) A) h6 K) {: x
        volatile long *addr;, G# U+ t0 E2 n! \. g; y* U
        long           save[32];
5 N: s' f6 i  S1 j        long           cnt;
& ], v" H1 M- y" H, i* L        long           val;
2 I- L4 l+ w/ E9 G& l# I        long           size;
3 {( h: I4 y' {# K" p' t) K. M: T9 l        int            i = 0;
. g  r2 b$ M' b: p9 b3 ]' z
" |! F- ?9 q% E" Y" N        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {% z( G& Z  u/ |7 P* _' a
                addr = base + cnt;        /* pointer arith! */
! k# g+ I! X$ A6 x9 [                sync ();* J2 }9 l* m8 ]; z# D- `
                save[i++] = *addr;
* ^/ v1 E, Q" o3 [3 {/ J3 s                sync ();  W! o" M  y% @. D; ~. E6 n
                *addr = ~cnt;# ^7 v- Q" r6 h, j
        }
/ e2 d9 ]: V/ `1 m3 h3 P! d
7 {: C) r4 }6 `" o7 Y        addr = base;
, O4 ]1 K: s/ ~6 U+ ^        sync ();3 {$ K1 e! h) I9 R
        save = *addr;
6 E. ^; K4 L7 H2 x6 j1 U        sync ();. u2 A4 m8 t: q2 y! \5 h9 ?
        *addr = 0;
; i' I8 W3 B% s+ z
9 C% J) `5 n' c& r2 T! ]        sync ();, U) r4 b) o8 ^9 H: n
        if ((val = *addr) != 0) {/ c7 b) s8 b! S7 E% w
                /* Restore the original data before leaving the function.
% m0 @: @8 x, ^- |& i                 */* T: x: s% K, W8 W8 E8 J$ d
                sync ();( x  p/ Q" q4 B( z/ l
                *addr = save;9 j2 B! {0 c8 f# e& {" a. v+ L0 G
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {% n1 X' C1 @$ P) o/ V
                        addr  = base + cnt;/ P% Q1 _! t! C- H' [$ h
                        sync ();
: ], I% f* T% |3 n                        *addr = save[--i];7 y0 ~# D: T% A: _) o" _
                }
9 l! ^& \. A; A/ |" M1 y                return (0);
' u1 l' {4 {( C' O' g        }. |9 Q1 X& w/ n% }" {% g, a
# v" S$ V5 n. E( D! u8 M( \0 |6 u
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& A: v# t+ o. V/ U0 O# I; Q) n4 ?: r% \                addr = base + cnt;        /* pointer arith! */  r# c) G& ?! e: o
                val = *addr;# B+ l' n! M. }4 D5 o
                *addr = save[--i];4 ?' o# s+ s8 ?8 N
                if (val != ~cnt) {. O4 H+ R" z" C' O
                        size = cnt * sizeof (long);, t, w( C4 z, W- ]3 A
                        /* Restore the original data before leaving the function.
! q8 ~7 t5 M" t0 F; \                         */
6 |7 N" W# ?  u) m' D, l' R' t( l                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
2 _8 f0 d; t- U- J: q% r                                addr  = base + cnt;
0 Z: x1 J5 Y1 @$ T9 _7 p                                *addr = save[--i];
! H: e  Y! i$ H/ W5 G1 H                        }- [% j$ o, I: N' V$ \& x
                        return (size);
6 n2 J7 \; M/ \7 @                }- j. Y! {6 |1 e2 w8 J
        }
9 G; W; D$ w* T8 O$ W
+ \( V( v( C$ B  r) Q0 s) A6 T        return (maxsize);
& j. {, A  H  o}9 K4 w3 S) M, F) e% \: E
int dram_init(void)
( A& M2 i7 Z- }5 M{, B2 t0 h' ?& p$ I
        /* dram_init must store complete ramsize in gd->ram_size */
5 l" {0 j' P( l  ~! L8 ^) z        gd->ram_size = get_ram_size(
1 F( h* u) y( Q0 _" ~                        (void *)CONFIG_SYS_SDRAM_BASE,. e7 G) K( ~1 f9 [: d; k( j% i
                        CONFIG_MAX_RAM_BANK_SIZE);9 S" y! A/ k& W2 A, D( ]# L
        return 0;% e2 }4 U% D. j( W0 Z  ?8 ]0 F7 `; k
}4 w4 G, V) Z( B0 I
* L" Z0 Y' o0 {2 t: H' ?  @4 T
1 s7 M+ o+ M# O6 ^: f6 B& ?' A
# {$ X+ W4 {; p: n/ f

1 i1 g7 Y$ Q1 S; m% UFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
  j; h+ \9 z+ @/ ?4 m/ ]! s; Z: a( z* D, w( w; m; C

! |# ~& j( t: A; {2 c6 ^) G

9 Y* l  Y6 n9 |' ?2 X2 O




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