CN101261606A - NOR FLASH Equalization Method Based on Address Mapping - Google Patents
NOR FLASH Equalization Method Based on Address Mapping Download PDFInfo
- Publication number
- CN101261606A CN101261606A CNA2008100355520A CN200810035552A CN101261606A CN 101261606 A CN101261606 A CN 101261606A CN A2008100355520 A CNA2008100355520 A CN A2008100355520A CN 200810035552 A CN200810035552 A CN 200810035552A CN 101261606 A CN101261606 A CN 101261606A
- Authority
- CN
- China
- Prior art keywords
- flash
- address
- code
- time
- program code
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Landscapes
- Techniques For Improving Reliability Of Storages (AREA)
- Read Only Memory (AREA)
Abstract
一种片上系统技术领域的基于地址映射的NOR FLASH均衡方法,首先,将控制器内部的用于程序代码存储的NOR FLASH分为两部分,第一部分存储程序代码,第二部分保存NOR FLASH的状态;然后,在每次从外部向NOR FLASH中加载程序代码时,控制器根据均衡方法确定程序代码写入NOR FLASH中的地址范围,并按照自身的写入方式将代码写入其中,同时以查询方式更新状态信息;最后,在片上系统运行过程中,控制器每次检测到外部读取代码的操作时,并根据状态信息,利用地址映射的方法从内部的NOR FLASH中读取正确的数据并输出。本发明减少了嵌入式系统中NOR FLASH空间的浪费,延长了使用寿命。A NOR FLASH equalization method based on address mapping in the field of system-on-chip technology. First, the NOR FLASH used for program code storage inside the controller is divided into two parts, the first part stores the program code, and the second part saves the state of the NOR FLASH ; Then, each time the program code is loaded into the NOR FLASH from the outside, the controller determines the address range in which the program code is written into the NOR FLASH according to the balance method, and writes the code into it according to its own writing method, and simultaneously queries Finally, during the operation of the system on chip, the controller will read the correct data from the internal NOR FLASH by using the method of address mapping according to the status information each time the controller detects the operation of reading the code from the outside. output. The invention reduces the waste of NOR FLASH space in the embedded system and prolongs the service life.
Description
技术领域technical field
本发明涉及的是一种片上系统技术领域的方法,具体是一种基于地址映射的NOR FLASH(或非式闪存)均衡方法。The present invention relates to a method in the field of system-on-chip technology, in particular to an address mapping-based NOR FLASH (or non-type flash memory) equalization method.
背景技术Background technique
嵌入式系统在电子产品中得到了广泛的应用,而其中用于存储程序代码的设备通常是NOR FLASH。由于NOR FLASH的电气特性,其每一个区块的擦写次数有限,当超过这一限度时,很可能损坏。由于在加载程序时,都是从NOR FLASH的头部开始写入,从而导致NOR FLASH的尾部基本不会用到,浪费了空间。Embedded systems are widely used in electronic products, and the devices used to store program codes are usually NOR FLASH. Due to the electrical characteristics of NOR FLASH, the number of erasing and writing of each block is limited. When this limit is exceeded, it is likely to be damaged. Since the program is loaded from the head of the NOR FLASH, the end of the NOR FLASH is basically not used, wasting space.
经对现有技术的文献检索发现,张原豪等在Annual ACM IEEE DesignAutomation Conference(ACM IEEE设计自动化年度会议)上发表的“EnduranceEnhancement of Flash-Memory Storage Systems:An Efficient Static WearLeveling Design”(闪存存储系统的寿命增强:一种有效的静态磨损均衡)中提出,通过采用“静态磨损均衡”的机制,可以大幅度的提高基于NAND FLASH的文件存储系统的使用寿命。该发明的不足在于:只针对了NAND FLASH,并没有NOR FLASH的均衡方法,而且用于程序代码的存储结构,没有文件系统的存储结构复杂,可以减小开销,并且文章中的方法采用软件实现,不是硬件实现。After searching the literature of the prior art, it was found that "Endurance Enhancement of Flash-Memory Storage Systems: An Efficient Static Wear Leveling Design" published by Zhang Yuanhao et al. at the Annual ACM IEEE DesignAutomation Conference (ACM IEEE Design Automation Annual Conference) Enhancement: An Effective Static Wear Leveling) proposes that by adopting the "static wear leveling" mechanism, the service life of the NAND FLASH-based file storage system can be greatly improved. The disadvantage of this invention is that it is only aimed at NAND FLASH, and there is no equalization method for NOR FLASH, and it is used for the storage structure of program code, which is not as complicated as the storage structure of file system, which can reduce the overhead, and the method in the article is realized by software , not a hardware implementation.
发明内容Contents of the invention
本发明针对上述现有技术中的不足,提出了一种基于地址映射的NOR FLASH均衡方法,使其在应用于嵌入式系统中NOR FLASH程序存储时,避免每次加载程序时都是从NOR FLASH首地址处顺序加载而带来的其后部存储空间的空闲,利用均衡技术,即在后一次加载程序时,先占用前一次加载时没有用到的空间,并利用地址映射技术使得对外的地址空间仍是从首地址开始顺序的,只在NOR FLASH内部实现均衡,增加了利用率,延长了使用寿命。The present invention aims at the deficiencies in the above-mentioned prior art, and proposes a NOR FLASH balancing method based on address mapping, so that when it is applied to the storage of NOR FLASH programs in embedded systems, it avoids loading programs from NOR FLASH each time. For the vacancy of the rear storage space caused by the sequential loading at the first address, use the equalization technology, that is, when the program is loaded the next time, it first occupies the space that was not used in the previous loading, and uses the address mapping technology to make the external address The space is still in order from the first address, and the balance is only realized inside the NOR FLASH, which increases the utilization rate and prolongs the service life.
本发明是通过以下技术方案实现的,本发明包括如下步骤:The present invention is realized through the following technical solutions, and the present invention comprises the following steps:
首先,将控制器内部的用于程序代码存储的NOR FLASH分为两部分,第一部分存储程序代码,第二部分保存NOR FLASH的状态,状态包括NOR FLASH当前存储程序的起始地址、结束地址、运行方式等,未使用时为初始状态;First, the NOR FLASH used for program code storage inside the controller is divided into two parts. The first part stores the program code, and the second part saves the state of NOR FLASH. The state includes the start address, end address, and Operating mode, etc., the initial state when not in use;
然后,在每次从外部向NOR FLASH中加载程序代码时,控制器都要分析NORFLASH的当前状态,并根据均衡方法确定程序代码写入NOR FLASH中的地址范围,按照NOR FLASH自身提供的写入方式将代码写入其中,同时以查询方式更新状态信息;Then, every time the program code is loaded into NOR FLASH from the outside, the controller must analyze the current state of NORFLASH, and determine the address range where the program code is written into NOR FLASH according to the balance method, according to the writing provided by NOR FLASH itself Write the code into it by way of query, and update the status information by way of query;
最后,在片上系统运行过程中,控制器每次检测到外部读取代码的操作时,并根据状态信息,利用地址映射的方法从内部的NOR FLASH中读取正确的数据并输出。Finally, during the operation of the system on chip, every time the controller detects the operation of reading the code from the outside, and according to the status information, it uses the method of address mapping to read the correct data from the internal NOR FLASH and output it.
所述控制器,是指:具有地址映射技术与均衡功能的NOR FLASH控制电路,内部包含一个NOR FLASH,对外接口也与NOR FLASH的对外接口一致,用于增强嵌入式系统中用于程序代码存储的NOR FLASH的使用寿命。The controller refers to: a NOR FLASH control circuit with address mapping technology and equalization function, which contains a NOR FLASH inside, and the external interface is also consistent with the external interface of NOR FLASH, which is used to enhance the storage of program codes in embedded systems The service life of NOR FLASH.
所述NOR FLASH,是指:嵌入式系统中用于装载程序代码的以NOR FLASH为媒介的存储设备。与一般嵌入式系统的外接低速FLASH存储设备不同,NOR FLASH是集成在芯片之内的高速存储设备。The NOR FLASH refers to a storage device using NOR FLASH as a medium for loading program codes in an embedded system. Different from external low-speed FLASH storage devices of general embedded systems, NOR FLASH is a high-speed storage device integrated in the chip.
所述程序代码,是指:在嵌入式系统上电启动时,用于指定其启动行为的指令。The program code refers to an instruction for specifying the startup behavior of the embedded system when it is powered on and started.
所述起始地址,是指:程序的第一条代码存储在NOR FLASH中的物理地址。为了均衡,NOR FLASH中存储代码的连续空间并不是从零地址开始的,而是接着前一次代码存放的空间。但是为了让外部使用者看起来仍然是从零地址开始的,必须保留第一条代码存储的物理地址,以便于做地址映射。The starting address refers to the physical address where the first code of the program is stored in the NOR FLASH. In order to balance, the continuous space for storing code in NOR FLASH does not start from zero address, but follows the space where the previous code was stored. But in order to make it look like the external user is still starting from address zero, the physical address stored in the first code must be reserved for address mapping.
所述结束地址,是指:程序的最后一条代码存储在NOR FLASH中的物理地址,用于下一次加载程序代码时确定起始地址。The end address refers to: the last code of the program is stored in the physical address of NOR FLASH, which is used to determine the starting address when the program code is loaded next time.
所述运行方式,其由用户设定,包括设定使能位、对齐方式、查询的时间间隔,具体为:将使能位置为0表示采用均衡方法与地址映射技术,置为1则表示不采用,即每次都从零地址处加载程序;将对齐方式设为00,表示字节对齐,设为01表示半字对齐,10表示字对齐,11表示双字对齐等,分别可适应8位机、16位机、32位机、64位机;查询的时间间隔,即多少个时钟周期查询一次。The operation mode is set by the user, including setting the enable bit, alignment method, and query time interval, specifically: setting the enable position to 0 indicates that the equalization method and address mapping technology are used, and setting it to 1 indicates that no Use, that is, load the program from zero address each time; set the alignment to 00, which means byte alignment, set to 01, which means half word alignment, 10 means word alignment, 11 means double word alignment, etc., which can be adapted to 8 bits respectively machine, 16-bit machine, 32-bit machine, and 64-bit machine; the query time interval, that is, how many clock cycles to query once.
所述根据均衡方法确定程序代码写入NOR FLASH中的地址范围,具体为:第一次加载程序代码从NOR FLASH的零地址开始顺序存储,其余加载程序代码每次都接着前一次代码的结束地址之后开始顺序存储,并且与对齐方式有关,如果是字节对齐,则从前一次的结束地址之后的第一个地址开始存储;如果是半字对齐,则从前一次的结束地址之后的第一个2的倍数的地址开始存储;如果是字对齐,则从之后的第一个4的倍数地址开始;如果是双字对齐,则从第一个8的倍数地址开始。Described according to the balance method to determine the address range of the program code written in the NOR FLASH, specifically: the first loading program code is sequentially stored from the zero address of the NOR FLASH, and the remaining loading program codes are followed by the end address of the previous code every time Then start sequential storage, and it is related to the alignment. If it is byte-aligned, it will be stored from the first address after the previous end address; if it is half-word aligned, it will be stored from the first 2 after the previous end address. If it is word-aligned, it will start from the address that is a multiple of 4; if it is double-word aligned, it will start from the address that is a multiple of 8.
所述以查询方式更新状态信息,具体为:由于程序代码的加载有突发性,即开始加载到加载完毕会在连续的一段较短的时间内完成,这段时间内会不断的向NOR FLASH发出写入命令,加载完毕后相当长一段时间内均不会写入,根据这个特性,如果在某写入之后的一段设定的时间内没有写入动作,则判断为一次写入完毕,此后,将上一次的结束地址加若干长度单位作为本次的起始地址,长度单位由具体对齐方式决定,将判断一次写入完毕时的写入地址作为本次的结束地址,再用这些新的状态信息覆盖原有的状态信息。The status information is updated in the query mode, specifically: because the loading of the program code is sudden, that is, it will be completed in a short period of time from the beginning of the loading to the completion of the loading, and it will continue to be sent to the NOR FLASH during this period. Issue a write command, and it will not be written for a long time after the loading is completed. According to this feature, if there is no writing action within a set period of time after a certain write, it will be judged that a write has been completed. After that , take the previous end address plus a number of length units as the start address of this time, and the length unit is determined by the specific alignment method, and use the write address when judging the completion of a write as the end address of this time, and then use these new The state information overwrites the original state information.
所述利用地址映射的方法从内部的NOR FLASH中读取正确的数据并输出,具体为:将CPU给出的地址与起始地址相加,所得到的值即为NOR FLASH中对应的物理地址,如果相加所得到的值超过了用于存储代码的第一部分的大小,则将此值减去第一部分的大小。The method of utilizing address mapping reads correct data from the internal NOR FLASH and outputs it, specifically: the address given by the CPU is added to the starting address, and the obtained value is the corresponding physical address in the NOR FLASH , if the added value exceeds the size of the first part used to store the code, subtract the size of the first part from this value.
与现有技术相比,本发明具有如下有益效果:本发明利用很少的时间与空间代价,减少嵌入式系统中NOR FLASH空间的浪费,延长了使用寿命。本发明可以应用于任何大小不超过4GB的NOR FLASH中,并且如果将预留的控制位加以利用,可以衍生出更加丰富的功能。Compared with the prior art, the present invention has the following beneficial effects: the present invention utilizes little time and space cost, reduces the waste of NOR FLASH space in the embedded system, and prolongs the service life. The present invention can be applied to any NOR FLASH whose size does not exceed 4GB, and if the reserved control bits are utilized, more abundant functions can be derived.
具体实施方式Detailed ways
下面对本发明的实施例作详细说明:本实施例在以本发明技术方案为前提下进行实施,给出了详细的实施方式和具体的操作过程,但本发明的保护范围不限于下述的实施例。The embodiments of the present invention are described in detail below: the present embodiment is implemented under the premise of the technical solution of the present invention, and detailed implementation and specific operation process are provided, but the protection scope of the present invention is not limited to the following implementation example.
本实施例中以大小为64K字节(地址范围为0x0000~0xffff)的NOR FLASH为例,数据宽度为4字节(即1个字),本实施例包括如下步骤:In this embodiment, take the NOR FLASH with a size of 64K bytes (the address range is 0x0000~0xffff) as an example, and the data width is 4 bytes (that is, 1 word). This embodiment includes the following steps:
1.首先将NOR FLASH的地址空间分为两部分,第一部分的地址范围是0x0000~0xffef,第二部分是最后16个字节,即最后4个字,地址范围是0xfff0~0xffff。第一部分用于存储程序代码,第二部分的4个字用于存储与均衡和地址映射有关的信息。在未使用过的情况下,所有空间里存储的数据都是0,包括起始地址、结束地址、控制信息等,其中起始地址存储在0xffe0,结束地址存储在0xffe4,余下两个地址0xffe8和0xffec用于存储控制信息。1. First divide the address space of NOR FLASH into two parts, the address range of the first part is 0x0000~0xffef, the second part is the last 16 bytes, that is, the last 4 words, and the address range is 0xfff0~0xffff. The first part is used to store the program code, and the 4 words of the second part are used to store information related to equalization and address mapping. In the case of unused, the data stored in all spaces is 0, including the start address, end address, control information, etc., where the start address is stored in 0xffe0, the end address is stored in 0xffe4, and the remaining two addresses are 0xffe8 and 0xffec is used to store control information.
2.在第一次加载程序代码之前,先向控制信息位写入对齐方式、是否为第一次使用、查询计数周期等信息。当开始向NOR FLASH中加载代码时,控制器判断出为第一次使用,开始向零地址写入代码,此时用于查询的计数器被触发。此后每写入一条代码,都刷新查询计数器,并将结束地址加1。当某次写入后,查询计数器的计数器达到了预设值,则判断加载代码完成,将更新的起始地址与结束地址写回NOR FLASH中,并将控制信息的是否为首次使用位置为否。之后的每一次写入,都根据对齐方式,从结束地址之后的正确地址开始写入。2. Before loading the program code for the first time, write information such as alignment, whether it is the first use, query counting cycle, etc. to the control information bit. When the code is loaded into the NOR FLASH, the controller judges that it is used for the first time, and starts to write the code to the zero address, and the counter used for query is triggered at this time. After that, every time a code is written, the query counter is refreshed, and the end address is increased by 1. When the counter of the query counter reaches the preset value after a certain write, it is judged that the loading code is completed, and the updated start address and end address are written back to the NOR FLASH, and whether the control information is the first use position is set to No . Every subsequent write starts from the correct address after the end address according to the alignment.
3.每次外部读取一条代码时,采用地址映射方法,将外部读取的地址与起始地址相加,所得到的值即为NOR FLASH中对应的物理地址。如果相加所得到的值超过了用于存储代码的第一部分的大小,则将此值减去第一部分的大小,之后根据得出的这个地址在NOR FLASH中读取对应的数据,并将其输出。3. Every time a code is read externally, the address mapping method is used to add the address read externally to the start address, and the obtained value is the corresponding physical address in NOR FLASH. If the value obtained by adding exceeds the size of the first part used to store the code, subtract the value from the size of the first part, and then read the corresponding data in NOR FLASH according to the obtained address, and store it output.
本实施例方法利用很少的时间与空间代价,减少嵌入式系统中NOR FLASH空间的浪费,可以将NOR FLASH的使用寿命延长87%左右。The method of this embodiment utilizes little time and space cost to reduce the waste of NOR FLASH space in the embedded system, and can prolong the service life of NOR FLASH by about 87%.
Claims (5)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2008100355520A CN100535872C (en) | 2008-04-03 | 2008-04-03 | NOR FLASH equalising method based on address mapping |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2008100355520A CN100535872C (en) | 2008-04-03 | 2008-04-03 | NOR FLASH equalising method based on address mapping |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101261606A true CN101261606A (en) | 2008-09-10 |
CN100535872C CN100535872C (en) | 2009-09-02 |
Family
ID=39962071
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2008100355520A Expired - Fee Related CN100535872C (en) | 2008-04-03 | 2008-04-03 | NOR FLASH equalising method based on address mapping |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100535872C (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102789485A (en) * | 2012-06-28 | 2012-11-21 | 用友软件股份有限公司 | Uninterrupted code management device and uninterrupted code management method |
CN107229571A (en) * | 2017-06-08 | 2017-10-03 | 中国电子信息产业集团有限公司第六研究所 | FMMU control method and system in EtherCAT slave stations |
CN107526687A (en) * | 2016-06-16 | 2017-12-29 | 爱思开海力士有限公司 | The accumulator system and its operating method of various configurations |
CN109582370A (en) * | 2018-11-01 | 2019-04-05 | 浙江大华技术股份有限公司 | A kind of starting method and device of NOR FLASH embedded device |
-
2008
- 2008-04-03 CN CNB2008100355520A patent/CN100535872C/en not_active Expired - Fee Related
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102789485A (en) * | 2012-06-28 | 2012-11-21 | 用友软件股份有限公司 | Uninterrupted code management device and uninterrupted code management method |
CN107526687A (en) * | 2016-06-16 | 2017-12-29 | 爱思开海力士有限公司 | The accumulator system and its operating method of various configurations |
CN107229571A (en) * | 2017-06-08 | 2017-10-03 | 中国电子信息产业集团有限公司第六研究所 | FMMU control method and system in EtherCAT slave stations |
CN109582370A (en) * | 2018-11-01 | 2019-04-05 | 浙江大华技术股份有限公司 | A kind of starting method and device of NOR FLASH embedded device |
CN109582370B (en) * | 2018-11-01 | 2022-07-19 | 浙江大华技术股份有限公司 | Starting method and device of NOR FLASH embedded equipment |
Also Published As
Publication number | Publication date |
---|---|
CN100535872C (en) | 2009-09-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9292379B2 (en) | Apparatus and method to manage high capacity storage devices | |
US8595427B1 (en) | Non-volatile block storage module using magnetic random access memory (MRAM) | |
US20130290606A1 (en) | Power management for a system having non-volatile memory | |
TW201329713A (en) | Non-volatile temporary data handling | |
CN109219804B (en) | Nonvolatile memory access method apparatus and system | |
US20040193864A1 (en) | System and method for actively booting a computer system | |
TWI479315B (en) | Memory storage device, memory controller thereof, and method for programming data thereof | |
US10866755B2 (en) | Two stage command buffers to overlap IOMMU map and second tier memory reads | |
TWI657336B (en) | Data storage method for detecting data storage device and its data storage device | |
US20190324912A1 (en) | Cache memory shared by software having different time-sensitivity constraints | |
CN101261606A (en) | NOR FLASH Equalization Method Based on Address Mapping | |
CN107045423B (en) | Memory device and data access method therefor | |
JP5129023B2 (en) | Cache memory device | |
TWI621021B (en) | Data storage method for optimizing data storage device and its data storage device | |
US11734184B2 (en) | Effective avoidance of line cache misses | |
JP2016143422A (en) | Configuring serial devices | |
CN108538332B (en) | NAND gate flash memory reading method | |
US8825912B2 (en) | Dynamic state configuration restore | |
US10236066B2 (en) | Method of managing semiconductor memories, corresponding interface, memory and device | |
WO2019041291A1 (en) | Information writing method and device | |
TWI433165B (en) | Storage apparatus and related data access method | |
TWI742961B (en) | Flash memory system and flash memory device thereof | |
WO2009086692A1 (en) | A processing method for embedded system using nand flash to memorize and start up | |
KR20170114991A (en) | Method for logging using non-volatile memory | |
CN107003960B (en) | Electronic device for blocking interrupt requests |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C17 | Cessation of patent right | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20090902 Termination date: 20120403 |