TL138 uboot是怎么区分配置两款核心板的 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4861|回复: 1
打印 上一主题 下一主题

TL138 uboot是怎么区分配置两款核心板的

[复制链接]

14

主题

102

帖子

821

积分

创龙

Rank: 8Rank: 8

积分
821
楼主
发表于 2014-9-11 18:55:41 | 显示全部楼层
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
* e9 \& y) {: R4 D, A2 l/*
, ?0 j3 z9 Q/ y. B& K* Check memory range for valid RAM. A simple memory test determines
* z4 f) v' L/ \* the actually available RAM size between addresses `base' and9 j7 Q6 P, G4 k( M8 z4 H
* `base + maxsize'.8 N4 S" w( }' ~& [, p: B
*/' N/ \7 k7 R, u# H7 u: B
long get_ram_size(long *base, long maxsize)
8 u8 _& _8 W/ i' {1 ~8 K3 C{
/ K# M) x' O& Q        volatile long *addr;
# z1 `( R" r% H+ |& G+ K% J1 H8 h* s        long           save[32];' @5 f8 g+ v, q4 Z5 N
        long           cnt;
' z" s0 t% T# K" [: q        long           val;- a  A% s0 t/ i
        long           size;4 [; j) B# T1 O' I1 N8 t
        int            i = 0;
' p, H0 _5 z# L3 \# x$ N* T5 z: k" u; W7 }2 e5 N) K% k6 q. O. g2 l
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {' p/ R; q( \( s5 M
                addr = base + cnt;        /* pointer arith! */
2 P; L- {% e9 x7 W7 e. t0 ?& E                sync ();: N2 u4 l0 V7 Q
                save[i++] = *addr;+ K. ?! P! y8 @
                sync ();
# G: C+ r6 J7 _8 j! y- f- T                *addr = ~cnt;
, H4 R# d7 r, Q1 T) h  a        }
0 F3 k. J( T2 u+ a8 c- Y3 \0 q; C+ B. ~8 D  [. X9 U: A5 }1 r3 i8 F$ p
        addr = base;" N+ A# d2 {9 _5 W) t% i
        sync ();5 E- g% S* `  Q- t. O% g
        save = *addr;
* g& Y, L% p# @: |9 X- b4 |        sync ();
* r( o/ ~6 v  @$ m% o        *addr = 0;
- y! G9 Y3 I* j( }. Z/ |3 V( _: N3 W7 q
        sync ();* _+ ?: e  l" |" ~" v9 b
        if ((val = *addr) != 0) {, F% c" o/ i8 I7 i: |' q# `
                /* Restore the original data before leaving the function.9 O/ I$ _% G  Q
                 */: I8 ^( U; j9 E0 u6 {8 G0 H
                sync ();
3 e8 n' m- @# H* u! v- g: V                *addr = save;1 t7 @; |* s5 @, t4 G
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
/ `) [  }; [) N8 d. f9 g/ o                        addr  = base + cnt;2 Z0 l  _* `/ s/ }* K5 Z
                        sync ();
1 U, ]/ E9 U8 c9 G2 R& ~                        *addr = save[--i];1 }2 V  h, B( f. T8 v6 U7 F4 `6 w7 O
                }: L, [6 D0 j. a- K
                return (0);
) s, t5 J: z( u* @) \0 a  d; p# B1 H$ \        }
. C8 A& p" [, t3 m1 K9 |9 q6 L# ?& j( q6 P
        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
- h, W, }. M! [                addr = base + cnt;        /* pointer arith! */
8 ^* q8 A( |; Q                val = *addr;( O1 k" s5 d0 W
                *addr = save[--i];& M8 n  P3 L' q% H3 C7 B
                if (val != ~cnt) {; Z7 Y7 v8 z4 s( L9 M+ ?
                        size = cnt * sizeof (long);3 e3 r- l- J* q( I% b$ \9 q
                        /* Restore the original data before leaving the function.' I$ g9 |$ r/ g3 D5 Z' g; [5 j
                         */: @7 G8 o6 x5 R
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {' L- `3 I8 ~! o& a% E6 J
                                addr  = base + cnt;
; q! i& I( F1 K/ Q. R/ J" z                                *addr = save[--i];$ M4 A; o  F0 P* A4 G
                        }
/ i' s8 R! K5 Z5 f" O                        return (size);
9 {) M8 A3 j6 s/ M) h( p  B" S                }
, J2 b: g  w6 N9 N        }# e& B' c8 w3 |5 W* T: |0 L6 A

' w/ d; Q& R# b5 J* T  p" l        return (maxsize);/ t! q! Z1 J: J0 P
}
! b$ u( N# {: H' @5 i8 A. l1 U! jint dram_init(void)
; G' \, f" H5 U& W$ w{
. J/ \3 s: R0 X( w  M8 [        /* dram_init must store complete ramsize in gd->ram_size */
/ f) P0 u4 N" i* G3 s+ N8 l; \% l. u* o        gd->ram_size = get_ram_size(
! ?1 d6 S" ~: t, @8 j$ k+ @* x                        (void *)CONFIG_SYS_SDRAM_BASE,
9 k  u& _! }. _7 D. T                        CONFIG_MAX_RAM_BANK_SIZE);! ^% c% E1 V& W) n6 ~0 w( x; B
        return 0;0 l0 f: C/ s" T, c' s" N; }
}8 D! ]- |: ]  _; u6 T# H0 w9 N
1 f+ u# w2 C) Y+ n& b' T

' ?- G: U% r/ e+ y3 p( G6 U7 R! n1 s' ~5 t  h8 M6 q

8 Z- l* U- U: h5 h# MFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!) ?/ v6 r7 X4 }2 G3 n2 ~
4 w2 D0 h. W; q5 ~3 q* _
, C  a) t. H: @$ d

3 c7 g4 C, h7 Y
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2025-7-2 20:29 , Processed in 0.040692 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表