嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
* o( a  U# R' x( h1 c! V0 _* m: S核心板2:DDR2 256M Byte   NAND FLASH 8G bit' b8 f: n& M4 m
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
4 F/ g# `9 H' k+ w' y" G! M- T5 [  ]) K' g4 J9 a
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
( D9 D; {! N2 Y' c* F7 M6 h( J  Z) i- e4 D' T+ \. P/ k

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:1 }7 x2 m! }3 H+ W1 u" |
/*
( t- A' K* G6 R. J; M: O: {6 F6 a* Check memory range for valid RAM. A simple memory test determines! H1 I" |' z' U9 D
* the actually available RAM size between addresses `base' and  f; `2 w5 z& _  C! L0 E
* `base + maxsize'.# C; J' W8 R4 G5 @6 X( b- F
*/: c1 M$ T3 [9 x/ w' D
long get_ram_size(long *base, long maxsize)1 F8 B; L$ h. R3 k4 [8 ]+ g
{
# }& ?" g" v" J2 ?1 {2 O1 j3 y        volatile long *addr;; S: R. s* E+ ]* ^& W  ^
        long           save[32];8 r& \5 a$ I* {% h2 A* F3 o
        long           cnt;- m2 O3 f" `% o3 m* }% B
        long           val;
+ ?/ ~2 q" p( Y- L        long           size;; V1 w+ [) h: G0 b7 H
        int            i = 0;4 c5 W8 ^: S( B3 X7 D" U
* d/ C, w8 S. Q' R
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {) ]) H" ~3 g7 W7 m9 C0 {
                addr = base + cnt;        /* pointer arith! */
! F: W( R/ m8 \, E. H2 [                sync ();
/ u) H: w% l+ m: A                save[i++] = *addr;
3 ~; a/ S/ d* [                sync ();
1 E& q+ \1 {: w1 ~" i9 A& Q. n                *addr = ~cnt;3 E. i/ H# v* \1 |& N
        }
. ~* A9 y. u, y, W5 c% [% A, @0 @$ C
& o5 H2 y  n% s( o3 e) Z/ }& P        addr = base;
- k; e% W: Q6 }3 ?5 I: f$ j. K        sync ();  N2 A' A3 K6 x- i- `* X7 X5 O
        save = *addr;# f! [9 P1 ?5 E% f1 n6 [
        sync ();, Z# x3 |( D) x/ C
        *addr = 0;
& C- t* h' @% `" a6 |4 ~# M+ U( v5 n- w0 m$ e7 F) B0 {
        sync ();! C! K! e/ }! I' g$ K. {& ~* }
        if ((val = *addr) != 0) {
3 i$ [' n. }% H3 g                /* Restore the original data before leaving the function.* v' D1 H7 k  |  P$ p: a6 f- Z
                 */  _; g) d4 X5 u) c  M2 w- h; d. W! [
                sync ();
. \  q' }  a' B* [                *addr = save;9 L2 b/ s" ]% f; b+ C
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {& n4 Z9 p- I" H. @
                        addr  = base + cnt;* u" E8 H  L- R3 j
                        sync ();
7 m2 i# ?, i' F" s                        *addr = save[--i];/ w( K: M4 g' T4 Z
                }
3 h' ?! t0 `2 w; m' g9 N9 |; j                return (0);
5 w, e8 F& E, r" q# Z) v        }
: Z: X, T# a9 u9 P3 n7 {: @5 q1 y# M% K5 v
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
7 m& W3 Y2 P" [% f4 s: C' N$ `                addr = base + cnt;        /* pointer arith! */+ Q! E. F5 e7 l
                val = *addr;& x% W8 i6 d% [4 O
                *addr = save[--i];
  C. l+ z8 n9 b, g  q. [$ Q9 L1 J                if (val != ~cnt) {
' O( e1 }* T4 |                        size = cnt * sizeof (long);
7 B) Y4 Q6 H0 h; U7 H                        /* Restore the original data before leaving the function.4 I# e2 P0 O- u- F: b
                         */
! P) d1 T# d$ O$ y# P% k7 r" r( y                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. |1 C# {( ?; [" ]& i7 f) H                                addr  = base + cnt;
6 V) f5 |1 \% v; i# F                                *addr = save[--i];
4 Y8 n1 E/ w2 J3 ?) K: I                        }# H4 D& L8 Z% d
                        return (size);
' ^: E8 Q. ?7 x9 @, Z                }. Q+ E5 \3 Q$ h
        }1 j5 u4 m/ ?0 Z8 G2 T" [# V
0 S0 P# g  j4 W  g0 x
        return (maxsize);1 o. Z* j. P4 J2 b# ?
}. {/ F4 C/ n- U
int dram_init(void)# k3 m' \" s- m; c
{$ K8 H3 F) z, g
        /* dram_init must store complete ramsize in gd->ram_size */
- j* @" U0 l% w, ?: z1 _9 V        gd->ram_size = get_ram_size(# D9 [1 M1 d5 g
                        (void *)CONFIG_SYS_SDRAM_BASE,
0 @/ E9 r9 s( O, ]                        CONFIG_MAX_RAM_BANK_SIZE);
' |5 g% h* S7 N5 }2 r# ]4 E6 B        return 0;
7 p6 _" U6 E; s5 V5 H}2 w0 O- `9 I) h: M
9 O' z$ E/ f; d4 h0 y- c# ^

* @' Y7 ?7 u, t/ L8 r( |# f0 W- |$ _$ x( x/ h) d% ?
1 C* D( k! M/ ]
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!8 _0 D; v% Z8 A  U

$ U* m  O9 p* ?* e5 a
6 b' e: T- b. A4 F( }

* L! D% e* o5 d' ^2 U9 q( `9 B




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