当前位置:首页 > 嵌入式培训 > 嵌入式学习 > 讲师博文 > exynos4412内存分析

exynos4412内存分析 时间:2018-08-16      来源:未知

学生在进行开发时,经常对内存这块有疑问,下面将使用exynos4412芯片的华清开发板(fs4412)为例作为讲解。

使用到的手册如下:

FS4412_CoreBoard_V2.pdf

FS4412-DevBoard-V5.pdf

SEC_Exynos4412_Users Manual_Ver.1.00.00.pdf

简述

exynos4412存储分下面几块:

iROM:启动镜像区,存放三星预置的程序,也叫bl0

iRAM :内部内存区,加载通过OM选择后的启动程序,通常加载bl1、bl2

SMC:静态内存区,Static Read Only Memory Controller ,通常用于映射外部总线上设备,如网卡等,该区域被分为4个bank,每个16M(对应硬件手册xm0开头的)

SFR:特殊功能寄存器区,通常用于映射SOC内部设备,如GPIO等

DMC:动态内存区,就是我们通常意义上的内存。

ps:动态内存(由于动态内存本身不供电,需要不断供电刷新,保存数据,所以叫动态内存)(对应硬件手册xm1和xm2开头的)

硬件原理(SMC)

Exynos4412中有1个独立的SMC,分为4个bank

没有行地址和列地址,整个芯片可用内存大小:2^8bit=256/16=16Byte

外部设备片选时,只能选0或者1.

硬件原理(DMC)

Exynos4412中有两个独立的DRAM控制器,分别叫DMC0和DMC1,可以接2组不同的DDR内存。DMC0和DMC1分别支持大1.5GB的DRAM,它们都支持DDR2/DDR3和LPDDR2等,512 Mb, 1 Gb, 2 Gb, 4 Gb and 8 Gbit的内存设备,支持16/32bit的位宽。DRAM0 对应的地址是0x4000_0000~0xAFFF_FFF共1.5GB,DRAM1 对应的地址是0xA000_000~0x0000_0000共1.5GB。

4412的1GB的DRAM是由4片大小为256M*16的DDR3芯片组合而成(查看芯片型号可以得到)

芯片型号:K4B4G1646B-HYXX

第一位: K表示内存

第二位:4表示falsh类型 DRAM

第三位:B表示DDR3

第4~5位. Density(注:实际单位应该是bit,而不是Byte),我们的是4Gbit=4G/16(数据位)=256MByte

第6~7位. organization:数据线引脚个数,我们的是16

分析完成,开发板上共有4片这样的内存芯片,总容量就是256M*4=1G

这四片DDR 芯片被分成了两两一组,组成32位数据,四片都是挂接到DMC0处

总图如下:

分解图如下(只列了一半):

从上两图可以看出,这四片DDR 芯片被分成了两两一组,组成32位数据,四片都是挂接到DMC0处,如下:

· 左边一片16位,右边16位,组成32位数据

· 全部芯片片选挂到CS0:

· bank线数:

3路线(BA0-BA2),有2^3组合,也就是一个芯片上,bank有8个

· 地址线

地址线数:15(A0-A14)

ps:一个芯片内存大支持:2^(bank线数+地址线)=2^33=8Gbit/16=512MByte

· 行列地址线

nRAS,nCAS:复用地址线行和列选择,同一时刻只能有一种地址线使用(不是行就是列),我们的板子上芯片有256M(2^28),28-3(bank)-15(行地址)=10(列地址)

· 寻址流程

这个操作顺序是,先片选,CS拉低,然后,当RAS拉低时,表示传过的是行地址,是A0-A14,15位;当CAS拉低时,表示传过来的是列地址,是A0-A9,列地址多的几位是预留的用来扩展内存,一个芯片内存多可以扩展到512M。

内存划分多个bank原因

由于DDR是不自备充电电路的,所以,每隔一段时间,内存控制器就会刷新一次电路,也就是要充一次电,如果只有一个Bank,那么结果就是在某一时刻,要么都充电,要么都不充电。

像上面这样分成了8个Bank,当我对000充电的时候,我还可以在010或是剩下的别的Bank中读取数据,这样就减小了等待的时间,不用说当电路刷新时,不能读取数据了。

exynos板子上,每个bank大小= 256M/8=32M(1个芯片上有2^3个bank)

内存计算方法

SDRAM容量计算

计算可寻址单元的数量(32位)

地址线数(管脚数):11(A0-A10)

bank线数:2(BA0-BA1) 可以组合出2^2个 bank

大行线数=211(例如地址线的编号,11个管脚线,组合有211种)

大列线数=211(例如地址线的编号,11个管脚线,组合有211种)

一个bank中总单元数=211x 211

芯片中总单元数=(bank个数)×(一个bank中总单元数)

= 22 x 211 x 211

= 224

备注:

因为行线与列线上传输的数据是经过编码(组合方式)的,而不是直接的行号和列号,

也就是说每个bank里有213 个行和 29 个列,并非只有13行和9列。

所以要寻址的单元在第(2行线数据 )行,第( 2列线数据)列。

例如bank0,行线数据是0 0000 0010 0000,列线数据是0 0000 1000,

意思是要获取行32,列8的单元的数据,而不是行5,列3的数据。

如果行线数据是 0 0010 1101 0110,列线数据是0 0011 1010,意思是获取行726,列58的单元的数据。

例如一个32MB的SDRAM芯片中有4个Logic-bank(逻辑bank),位宽16bit(即每个单元是16bits),地址线13条,大行线数13,大列线数9。计算得:

一个bank的单元数= 213 x 29= 4194304(即4M)。

芯片总单元数=4Banks × 4M units = 16M units 。

芯片总位数=16M units × 16bits/per_unit = 256M bits 。

芯片总字节数=256M bits/8 = 32M Bytes 。

内存初始化流程

在三星提供的数据手册《SEC_Exynos4412_Users Manual_Ver.1.00.00》的第1046页提供给了一段关于LPDDR2-S4的初始化步骤,LPDDR2表示低功耗DDR2,DDR3的初始化过程应和这个一样,我们就按这个过程来初始化DDR3

初始化流程,如手册中 18.3.1 LPDDR2-S4 描述:

18.3.1 LPDDR2-S4

Use the sequence given here to initialize LPDDR2 devices. Unlessspecified otherwise, these steps are

mandatory. Note that the memory CK/CKn must be less than or equal to50 MHz before you initialize the

LPDDR2-S4 device.

1. DMC must assert and holdCKE to a logic low level to provide stable power for memory device and thenapply

stable clock.

2. Set thePhyControl0.ctrl_start_point and PhyControl0.ctrl_inc bit-fields to a correctvalue according to clock

frequency. Set the PhyControl0.ctrl_dll_on bit-field to"1" to activate the PHY DLL.

3. DQS cleaning: Set thePhyControl1.ctrl_shiftc and PhyControl1.ctrl_offsetc bit-fields to theappropriate value

according to clock frequency, board delay, and memory tDQSCKparameter.

4. Set thePhyControl0.ctrl_start bit-field to "1".

5. Set the ConControl. Atthis moment, an auto-refresh counter should be disabled.

6. Set the MemControl. Atthis moment, all power down modes should be disabled.

7. Set the MemConfig0register. When there are two external memory chips, set the MemConfig1register.

8. Set the PrechConfig andPwrdnConfig registers.

9. Set the TimingAref,TimingRow, TimingData, and TimingPower registers according to memory AC

parameters.

10. Set the QosControl0 to 15and QosConfig0 to 15 registers when a certain bus master requires QoS scheme.

11. Wait for thePhyStatus0.ctrl_locked bit-fields to change to "1". Verify whetherPHY DLL is locked.

PHY DLL compensates the changes of delay amount that pressure,volume, and temperature variation

causes during memory operation. Therefore, you should not power offPHY DLL for reliable operation.

It can be in power-off mode except when it runs at low frequency.When you use the power-off mode,

set the PhyControl0.ctrl_force bit-field to the correct valueaccording to the PhyStatus0.ctrl_lock_value[9:2]

bit-field for fix delay amount. Clear the PhyControl0.ctrl_dll_onbit-field to turn off PHY DLL.

12. Set thePhyControl1.fp_resync bit-field to "1" to update DLL information.

13. Confirm that Clock Enable(CKE) is in a logic low level at least 100ns after power on.

14. Issue a NOP command byusing the DirectCmd register to assert and hold CKE to a logic high level.

15. Wait for a minimum of 200ms.

16. Issue a MRS command byusing the DirectCmd register to reset memory devices and program the operating

parameters.

17. Wait for minimum of 1 μs.

18. Issue a MRR command byusing the DirectCmd register to poll the DAI bit of the MRStatus register.

This is to know whether or not Device Auto-Initialization iscomplete.

19. If there are two externalmemory chips, execute step 14 to 19 for chip1 memory device.

20. Set the ConControl toturn on an auto-refresh counter.

21. Set MemControl registerwhen you require power-down modes.

翻译上面的步骤:

1、DMC功能必须设置,并且要保持CKE为低电平,以便可以提供稳定的电源和时钟给DDR

2、根据时钟频率设置PhyControl0.ctrl_start_point 和PhyControl0.ctrl_inc bit-fields,并且设置PhyControl0.ctrl_dll_on bit-field 为 "1" 已启动PHY DLL。

3、DQS 清除,根据时钟频率、板子延时和芯片的tDQSCK参数设置PhyControl1.ctrl_shiftc 和PhyControl1.ctrl_offsetcbit-fields。

4、设置 PhyControl0.ctrl_start bit-field 为"1"。

5、设置ConControl,此时,不能使能自动刷新计数器(auto-refresh counter )。

6. 设置MemControl,此时,所有的power down模式应关闭。

7、设置MemConfig0 寄存器,当外面有两片存储芯片时,设置MemConfig1寄存器。

8、设置 PrechConfig和 PwrdnConfig寄存器。

9、根据DDR3的 AC参数设置TimingAref, TimingRow, TimingData, 和 TimingPower寄存器。

10、当总线主控者需要QoS时序参数时,设置QosControl0 到15寄存器和QosConfig0 到 15寄存器。

11、等待 PhyStatus0.ctrl_locked bit-fields 变成 "1",以确定 PHY DLL 是否锁定。PHY DLL 可以补偿压力、体积?和温度等环境的变化,因为在芯片工作期间,我们不能关闭了PHY DLL的电源,只有当他在低的时钟频率时才可以切换到Power-off 模式,当我们用power-off 模式,参考PhyStatus0.ctrl_lock_value[9:2]的延时参数来设置PhyControl0.ctrl_forcebit-field,清楚PhyControl0.ctrl_dll_on bit-field来关闭 PHY DLL。

12、设置PhyControl1.fp_resync bit-field 为 "1" 来更新 DLL的设置。

13、确保在电源上电后至少保持Clock Enable (CKE)在低电平100ns。

14、用DirectCmd 寄存器来执行一条NOP指令且保持CKE 为高电平。

15、至少等待200us。

16、发出MRS指令来重新设置存储芯片的操作参数。

17、至少等待1us。

18、用MRR指令来查询MRStatus的寄存器的DAI位,用这们来确定自动初始化过程是否完成。

19、如果外部有别的存储芯片,重复执行14到19步来设置芯片1。

20、设置ConControl来启动auto-refresh counter.

21、当我们要进行power-down模式,设置MemControl寄存器。

按照上边的步骤来设置就可以完成DDR的初始化。

更多exynos4412内存分析问题

Exynos4412特殊功能寄存器的封装

上一篇:arm11开发板适合新手学习吗

下一篇:Linux平台下pci总线驱动

热点文章推荐
华清学员就业榜单
高薪学员经验分享
热点新闻推荐
前台专线:010-82525158 企业培训洽谈专线:010-82525379 院校合作洽谈专线:010-82525379 Copyright © 2004-2022 北京华清远见科技集团有限公司 版权所有 ,京ICP备16055225号-5京公海网安备11010802025203号

回到顶部