嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
6 U* T8 x. |, {8 }  \; s核心板2:DDR2 256M Byte   NAND FLASH 8G bit5 q5 i# y3 F3 p. E4 A( z
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
* z/ e* z8 m5 e/ h! h( N% {4 G, |
" ~( |* ]7 P0 j1 _& q: f: R3 A  ]是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?+ N+ f+ ]5 G7 T3 ]% ]

$ p  @* w5 P, a# _) w; j# A" n8 F
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
0 z3 B3 }5 I$ |$ m# F$ a/*
. {7 i% ?5 i& O. d" L1 k; Z* e3 T* Check memory range for valid RAM. A simple memory test determines
1 }$ o- r: e) ]* the actually available RAM size between addresses `base' and
' A; c0 O9 R  Y* `base + maxsize'.
: [9 q; ^, E( q* _( \*/9 C- M2 c6 Z" E
long get_ram_size(long *base, long maxsize)
7 ~- W. q2 Z2 f( J5 r{: b. N3 Z9 p5 h
        volatile long *addr;3 S# v6 T. q1 W- [& X. b* m
        long           save[32];/ u8 y$ ?* V) R4 B6 S. I
        long           cnt;$ e" \$ u0 o5 {5 @
        long           val;- z3 S# B* u: g
        long           size;
& P7 s" p. R" [# W% K; ?9 N        int            i = 0;. [) W0 U# D. R- C" m: W1 k7 }
+ t$ }+ ?, R: N; Y7 I4 w
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
0 Q6 ?; r4 y& _$ Z                addr = base + cnt;        /* pointer arith! */
. @+ l( s* e$ W1 I- b) T) S: N  T                sync ();
# n. S1 L: I4 p6 o                save[i++] = *addr;' I1 j6 z7 M3 y% @/ E5 n
                sync ();$ g2 t# i' b8 i4 B
                *addr = ~cnt;. L  X8 r; x( Q% p7 i) ~/ L
        }
4 C/ W' n; W; `. ]( {, E+ n  R! B- r2 R+ _7 Q8 y
        addr = base;
1 ^( |4 |# y) D; B4 o2 P        sync ();
4 R! x6 ]/ n- Z        save = *addr;3 \* e1 I1 F, a
        sync ();
& S2 j4 O0 k) T! e8 m: q        *addr = 0;1 g; Z  N: X7 M" L+ y7 ^
% ]6 t8 R9 O8 E0 v  @, N* w& `
        sync ();' u5 J3 m9 P/ B* s. @* e6 g( c
        if ((val = *addr) != 0) {
! b. u2 w+ l0 V9 ?! v: f  ~                /* Restore the original data before leaving the function.
$ }) ?9 F8 e0 b5 k- @                 */5 ]% ~: r9 [; A' o7 S/ s  ^
                sync ();! r, O8 @2 r2 K+ g
                *addr = save;; E6 A# y" M8 N$ a7 y6 q
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {: X8 ^1 ^3 l* L" `) P4 f& q. B
                        addr  = base + cnt;
' t& G; }; L0 g2 u                        sync ();
* O4 c, c3 z9 z+ P& |0 |) M: t                        *addr = save[--i];* [, Y+ @% I' A9 _
                }
0 E0 T! Y# L/ x7 J; v                return (0);
4 |8 e, D5 L4 T( b8 e# p3 J# N        }
1 Q$ T0 @4 b1 M$ e; x. G& R1 u: x  n9 A
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {0 s6 n/ `) r9 u# R% q. I
                addr = base + cnt;        /* pointer arith! */
3 f5 k6 t3 ?/ O1 }6 N( R                val = *addr;
7 }% l. ]9 k+ k" w- J* F0 Z                *addr = save[--i];
0 d% {6 w! Z2 [0 I+ Y                if (val != ~cnt) {5 A) N' m! D. E( {: R4 d# L
                        size = cnt * sizeof (long);
# a) l) u& y3 l8 j  X) v                        /* Restore the original data before leaving the function.
( s( p: i) u# N5 }                         */! p+ J% I; _7 q& c+ w) X
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {( F6 G6 \' x& t6 ^- N3 q# W9 \
                                addr  = base + cnt;& c1 F7 V) g1 K4 S) c# f
                                *addr = save[--i];
) p* X; F+ Z1 d/ Y3 u                        }
5 R. k2 p0 A) t0 U6 f1 u; h                        return (size);; }; t$ T" W+ i  h3 @% ~' s5 R+ l
                }- q) h4 l0 b7 }
        }9 M8 L  h/ @" C" I( g

' @" g6 ]$ @1 V        return (maxsize);
6 D1 f* P% o. V3 t}7 ~  c- n5 T4 y% Y, U: e) [
int dram_init(void)4 e9 ?" U5 c5 k# ?; O4 e
{
  [  [! q  a9 M1 t        /* dram_init must store complete ramsize in gd->ram_size */, W5 t9 g3 p1 t" T0 g' s& f
        gd->ram_size = get_ram_size(
5 l7 n# B' X) d& d& ?3 |                        (void *)CONFIG_SYS_SDRAM_BASE,
% `  }9 {! J7 L! {# q# B5 g                        CONFIG_MAX_RAM_BANK_SIZE);
# t% R$ v7 ^7 A% P) m        return 0;
( C4 G9 r4 D3 r/ |. a  Y" z! m+ e}
2 d1 j3 q! ^( w7 r' V3 G
# F: N$ s$ j$ ^# }7 ?# m* ~' I/ |7 C8 |4 M
4 C! ^3 t; O  H# L0 E: t
! x9 O! e8 D0 R3 ^8 H% [/ W- F
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!# _# B" M7 Y8 W$ w" h" ]1 {! [7 K; e
7 x) y2 Z2 v1 W0 [3 e

% R, x' M( m; |# v. r& ~

" }2 l& f- Y, ?: |




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