嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
. e7 |- A( T' i, n4 ~' B核心板2:DDR2 256M Byte   NAND FLASH 8G bit
3 F! K/ K" G! I$ y- e' I% x这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 K- p3 n7 f4 v) f. j+ D" V( t: t: J* i3 E/ v
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
7 n* I: k$ p- Y. j2 I
$ m: I- G0 C3 q
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
/ @4 Z1 b" |! Y. W" ^; y5 y/*9 G- F- {2 W) i. ?8 ?
* Check memory range for valid RAM. A simple memory test determines$ ]' h' M( T, u
* the actually available RAM size between addresses `base' and$ r/ N$ J! E( ^2 s+ L4 L  X
* `base + maxsize'.8 t) P8 D7 e2 f! [( M
*/
2 _; q! v) B( e/ S3 ?long get_ram_size(long *base, long maxsize)' V. D6 o. r: C7 F4 O6 h9 T
{
1 N& X2 p- n" u- I5 d7 z        volatile long *addr;. G) y" |* ?# c0 k
        long           save[32];1 _+ i! N* b- W# A7 M
        long           cnt;  y4 }# _- i+ f
        long           val;
. o! w2 r+ n6 V( J+ l, \! Y        long           size;
8 c, D* c6 r/ A0 E3 f. X: v        int            i = 0;
9 t4 T, H8 F5 U
5 h  |  ?. o" U9 ^8 P9 j        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
3 c5 D; A: u/ w# q  c1 m+ ^                addr = base + cnt;        /* pointer arith! */( w" ?' K0 F7 F5 x/ z5 d
                sync ();# s& D, [  `* h. R" J# h; D
                save[i++] = *addr;
  p2 C4 }, {- ]% s                sync ();9 `' E' K! [3 g# T1 O6 W# h
                *addr = ~cnt;4 b7 {) {, e% e, O2 t
        }
& V2 M, @0 a* w; _7 W- Z4 e$ C6 r+ Y% R3 H4 Q- ~4 w: M0 I
        addr = base;
5 _! h- R4 P% g, i) w        sync ();
6 b! ]  ~+ r8 r4 }7 y, _" B& W5 s) j        save = *addr;* `$ s7 l5 i; `
        sync ();
$ Z* T) [4 q: m/ Q1 @2 c        *addr = 0;
+ g: I6 N( w9 D1 m' S" [$ L6 J+ ~$ f
        sync ();
# j9 Q  N( L5 K        if ((val = *addr) != 0) {
" D1 `9 ?8 d; D9 D$ E$ n1 c3 R                /* Restore the original data before leaving the function.+ Q8 Y# P1 ]2 m& H8 ~; g  {
                 */
/ q) I$ }. w7 e9 K4 ^7 x% V                sync ();' n4 w5 Y# a6 `! ]
                *addr = save;
3 h9 ^  F! l- ~# H/ h" b8 Y. z                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {8 c. e5 A% S$ E: x0 B5 O7 P
                        addr  = base + cnt;/ i  N3 |# M% I& d; P$ U5 A7 z
                        sync ();
/ ?1 A/ s/ h  k9 ?9 k                        *addr = save[--i];
* c/ `' S, \2 Q8 b2 ~                }  S6 ^+ g, z* l9 G5 Z# Q
                return (0);
5 ^& ?  g2 V  B0 ~: [4 }4 |4 b2 J        }
* p; _6 J! R- m
; H. m' y* y. p# a- \% `        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {" d1 B7 X/ m8 C5 f
                addr = base + cnt;        /* pointer arith! */- v+ ?: B# Z" H" }! ^- ?8 ]
                val = *addr;( A- W/ L6 E4 [6 S9 l$ y' L
                *addr = save[--i];
) ~7 x+ ]% s; N                if (val != ~cnt) {
& K1 j9 i' F5 O7 C7 S. N! r# L                        size = cnt * sizeof (long);
4 D. c' Q4 I  [1 s' U                        /* Restore the original data before leaving the function.
" C" b3 A1 e' @2 i                         */& Z5 j$ d0 j( T( d3 t7 t1 L( X
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {8 H7 v# e' l, I% P1 j
                                addr  = base + cnt;
8 E8 g  `% B0 E& ~6 _% V                                *addr = save[--i];
5 ~3 ^9 Z9 [9 M                        }
2 B/ E" T' l5 p                        return (size);
1 ]2 k* w) I9 I9 J                }" `. \4 x* X- [9 w8 K
        }! Z' @9 P+ |' W

6 q& v& i. z5 W( V: m        return (maxsize);
. B8 H( e  h. W6 I" |/ |}2 {* l+ |! D8 C
int dram_init(void)
+ r5 ~2 l+ }2 L7 X+ z{: h4 Z* X% v/ L! t5 L( `
        /* dram_init must store complete ramsize in gd->ram_size */
# _' {' V/ x  Y3 |7 o5 z: b        gd->ram_size = get_ram_size(
% Z! A7 b; R! k                        (void *)CONFIG_SYS_SDRAM_BASE,  ]2 b* Z! X1 Q( m
                        CONFIG_MAX_RAM_BANK_SIZE);0 t. q3 c% l  W! ~
        return 0;
& i' Z, }2 S+ G}# m4 ~9 ~6 T: ~0 e7 Q9 j

( R1 Q1 q; b) l) b+ V& U
# n2 m7 J/ ~5 l0 n- z9 o7 X% P2 V" N# y, r- O6 D: _9 J; f
" i, I* I) }, q# N0 ^
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
- q1 G6 x1 n- H5 w6 o5 m. ?8 p9 I
0 H; d4 E3 h. b0 j" X
/ ~0 P0 k6 q: I% g& c" u9 M





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