WO2022227473A1 - Spi access control method and system, and computing device and storage medium - Google Patents
Spi access control method and system, and computing device and storage medium Download PDFInfo
- Publication number
- WO2022227473A1 WO2022227473A1 PCT/CN2021/128632 CN2021128632W WO2022227473A1 WO 2022227473 A1 WO2022227473 A1 WO 2022227473A1 CN 2021128632 W CN2021128632 W CN 2021128632W WO 2022227473 A1 WO2022227473 A1 WO 2022227473A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- access
- spi
- master device
- interval
- slave device
- Prior art date
Links
- 238000003860 storage Methods 0.000 title claims abstract description 89
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000004891 communication Methods 0.000 claims abstract description 18
- 238000013507 mapping Methods 0.000 claims abstract description 5
- 230000004044 response Effects 0.000 claims description 30
- 238000009434 installation Methods 0.000 abstract description 8
- 230000000694 effects Effects 0.000 abstract description 4
- 238000013461 design Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 5
- 230000002093 peripheral effect Effects 0.000 description 4
- 238000002955 isolation Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 230000009977 dual effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/40—Bus structure
- G06F13/4063—Device-to-bus coupling
- G06F13/4068—Electrical coupling
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2213/00—Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F2213/0002—Serial port, e.g. RS232C
Definitions
- the present application relates to the technical field of storage devices, and in particular, to an SPI access control method, system, computing device and storage medium.
- SPI Serial Peripheral Interface, Serial Peripheral Interface
- PCB printed Circuit
- Board printed circuit board
- some SPI master devices will be connected to multiple SPI slave devices.
- the firmware program in one of the SPI slave devices cannot complete the system startup, for example, when the firmware program of the SPI slave device is damaged, Then switch to another SPI slave device to load the new firmware to start the system to meet the needs of use.
- this method requires two SPI slave devices, the cost is high; in addition, there are certain installation restrictions due to the need to reserve space for the installation of multiple SPI slave devices.
- the purpose of the present application is to provide an SPI access control method, system, computing device and storage medium to solve the problems in the prior art that when multiple SPI slave devices need to be used, the cost is relatively high and there are installation restrictions.
- the present invention provides the following technical solutions:
- An SPI access control method which is applied to the access of the SPI slave device by the SPI master device, and the storage space of the SPI slave device is at least divided into two storage sections;
- the SPI access control method includes:
- the SPI master device When the SPI master device requests to access the SPI slave device, intercept the access signal sent by the SPI master device to the SPI slave device; the access signal includes a logical address and a signal source flag;
- the storage interval corresponding to the modified logical address is used as an access interval, so that a communication connection is established between the SPI master device and the access interval.
- each of the storage intervals respectively includes a plurality of physical addresses
- the described setting up communication connection between the SPI master device and the access interval includes:
- the multiple physical addresses are sequentially accessed as access objects, and the access is stopped until the access termination signal sent by the SPI master device to the SPI slave device is intercepted.
- the accessing the multiple physical addresses as access objects in sequence includes:
- the currently accessed physical address is less than or equal to the physical address at the end of the access interval, receive the response information returned by the access object, forward the response information to the SPI master device, and respond to the current access
- the physical address is additionally calculated, and the calculated physical address is used as the next access object to continue accessing.
- the accessing the plurality of physical addresses as access objects further includes:
- the SPI master device when the SPI master device requests to access the SPI slave device, it also includes:
- the present invention also provides an SPI access control system for implementing the SPI access control method described in any of the above, including an SPI master device and an SPI slave device, wherein the storage space of the SPI slave device is at least divided into two storage spaces interval, the SPI master device and the SPI slave device are bridged by a logic device;
- the logic device is used for:
- the SPI master device When the SPI master device requests to access the SPI slave device, intercept the access signal sent by the SPI master device to the SPI slave device; the access signal includes a logical address and a signal source flag;
- the storage section corresponding to the modified logical address is used as an access section, and a communication connection is established between the SPI master device and the access section.
- each of the storage intervals respectively includes a plurality of physical addresses
- the logic device is used to establish a communication connection between the SPI master device and the access interval:
- the multiple physical addresses are successively accessed as access objects, and the access is stopped until the terminating access signal sent by the SPI master device to the SPI slave device is intercepted;
- the accessing the multiple physical addresses as access objects in sequence includes:
- the currently accessed physical address is less than or equal to the physical address at the end of the access interval, receive the response information returned by the access object, forward the response information to the SPI master device, and respond to the current access
- the physical address is additionally calculated, and the calculated physical address is used as the next access object to continue access;
- the logic device is also used to establish a communication connection between the SPI master device and the access interval:
- the present invention also provides a computing device, comprising:
- the processor is configured to call the program instructions stored in the memory, and execute the SPI access control method described in any one of the above according to the obtained program.
- the present invention also provides a computer-readable non-volatile storage medium, comprising computer-readable instructions, when the computer reads and executes the computer-readable instructions, the computer executes the SPI access control described in any of the above method.
- the present invention has the following beneficial effects:
- the present invention monitors the access request from the SPI master device to the SPI slave device, and modifies the logical address in the access request, so that the SPI master device access request can be mapped to one of the various storage areas in the SPI slave device, so as to utilize a single SPI slave device.
- the device achieves the effect of multiple SPI slave devices, which reduces the cost and overcomes the problem of installation limitations.
- Figure 1 is a schematic structural diagram of an SPI Flash packaged with an 8Pin pin
- Fig. 2 is the flow chart of a kind of SPI access control method provided by the present invention.
- Fig. 3 is the flow chart of step S3 in a kind of SPI access control method provided by the present invention.
- Fig. 4 is the flow chart of step S32 in a kind of SPI access control method provided by the present invention.
- Fig. 5 is the flow chart of step S4 in a kind of SPI access control method provided by the present invention.
- FIG. 6 is a schematic structural diagram of a SPI access control system provided by the present invention.
- Figure 7 is the SPI timing diagram of the "Read Data" command in the SPI Flash of Winbond Electronics' model 25Q128FV.
- the core of the present application is to provide an SPI access control method, system, computing device and storage medium, so as to effectively improve automation efficiency and reduce labor cost.
- the SPI master device can access the SPI slave device through the enable of the SPI master device pin/CS (Chip Select).
- the access methods include the following situations:
- the present invention aims to provide an SPI access scheme to overcome the above problems of the prior art.
- SPI Serial Peripheral Interface, Serial Peripheral Interface
- Serial Peripheral Interface is a high-speed, dual full-duplex and synchronous communication bus, which occupies only four lines on the pins of the chip.
- SPI Flash (SPI NOR Flash) has the characteristics of read speed block, byte access, etc. It is usually used to store firmware programs. It is a long-life non-volatile memory that can still maintain all Stored data information; data deletion is not in a single byte, but in a fixed block, and the block size is generally 256KB to 20MB.
- BIOS Basic Input Output System
- BIOS Basic Input Output System
- CPLD Complex Programmable Logic Device
- SOC System on Chip, system-on-chip
- SOC System on Chip, system-on-chip
- ROM Read Only Memory, read-only memory
- ROM Read Only Memory image, read-only memory
- SPI Flash Serial Peripheral Component Interconnect Express
- RAM Random Access Memory, random access memory
- /CS-chip select chip select: After this signal is pulled low, the SPI slave device is selected by the SPI master device and responds to the SPI Master's request.
- CLK-clock (clock) The clock synchronization signal sent by the SPI master device.
- DI-data in (input data) The request data of the SPI master device is serially sent to the SPI slave device on this signal.
- DO-data out The response data of the SPI slave device to the SPI master device's request is serially returned to the SPI master device on this signal.
- an embodiment of the present invention provides an SPI access control method, which is applied to an SPI master device accessing an SPI slave device, and the storage space of the SPI slave device is divided into at least two storage regions.
- the SPI access control method includes:
- the access signal sent by the SPI master device includes a logical address and a signal source flag.
- the SPI master device may include at least two /CS (chip select, chip select) pins for selecting the accessed memory interval, such as /CS0 and /CS1; when requesting access to the SPI slave device, the SPI The master device enables either /CS0 and /CS1 based on the access requirement, so that the access signal sent by the SPI master device to the SPI slave device contains the signal source flag of /CS0 or /CS1, so as to provide the modified logical address in this step. in accordance with.
- /CS chip select, chip select
- mapping relationship between each storage interval in the SPI slave device and different logical addresses is established in advance, so that the storage interval mapped by the logical address modified according to the signal source flag is consistent with the access request of the SPI master device. meets the.
- the access signal from the SPI master device when the access signal from the SPI master device is intercepted, the logical address originally contained in the access signal is modified according to the signal source flag, so that the modified logical address is stored with one of the SPI slave devices.
- the interval has a unique corresponding relationship, so that the access request from the SPI master device to the SPI slave device is mapped to the storage interval corresponding to the modified logical address.
- the SPI master device access request can be mapped to one of the various storage areas in the SPI slave device, so that a single SPI slave device can be used to achieve the effect of multiple SPI slave devices, which reduces the cost and overcomes the existence of installation restrictions.
- the problem is that a single SPI slave device can be used to achieve the effect of multiple SPI slave devices, which reduces the cost and overcomes the existence of installation restrictions.
- a specific program When the system is powered on, a specific program is first executed to determine which firmware (ie, the storage area in the SPI slave device) is used to start the system. For example, the specific program first checks the integrity of the first firmware, and once the check fails, the Boot the system with the second firmware.
- a 16MB SPI slave has twice the capacity of an 8MB SPI slave, but a 16MB SPI slave is still costlier than two 8MB SPI slaves, so it can achieve cost savings.
- space is often the key to restricting the selection of its components; using a single SPI slave device to save space can provide more choices for system layout.
- the current SPI storage devices generally have the ability to read the data in the entire SPI slave device storage space with a single command, for example, when the SPI slave device accepts the "Read (read)" command, it returns the response information one by one starting from the specified address, until Data acquisition stops when all /CS pins of the SPI master are pulled high. Therefore, after the SPI master device obtains the first response information, it can obtain all the data in the storage space of the SPI slave device by extending the clock cycle of the /CS signal.
- each storage area includes a plurality of physical addresses respectively.
- step S3 specifically includes:
- step S32 includes:
- step S322 compare the physical address of current access and the physical address of the last position in the access interval, and judge whether the physical address of the current access is greater than the physical address of the last position in the access interval; if so, execute step S324, if not, execute step S323;
- S323 receive the response information returned by the access object, and forward the response information to the SPI master device; perform additional calculation on the physical address of the current access, and continue to access the calculated physical address as the next access object, and return to step S322;
- S324 Send preset false response information to the SPI master device, so that the SPI master device sends a termination access signal to the SPI slave device.
- the capacity of the storage interval divided by the SPI slave device can be dynamically adjusted according to the actual demand, and has high flexibility.
- the SPI storage device usually also has a chip erase function.
- the SPI master device sends the "Chip Erase (chip erase)" command to the SPI slave device, the data in the entire storage space of the SPI slave device can be erased, including Other storage intervals other than the access interval.
- the storage interval other than the access interval is set to "Protected” (that is, write-protected), and the "Chip Erase” issued to the storage interval " command will not be executed.
- an embodiment of the present invention further provides an SPI access control system, including an SPI master device and an SPI slave device.
- the storage space of the SPI slave device is divided into at least two storage areas, and the SPI master device is divided into two storage areas.
- the device and the SPI slave device are bridged by a logic device.
- the SPI master device is the CPU of the SPI Master (host), the SPI slave device includes SPI ROM and SPI Flash, and the logic device is CPLD (Complex Programmable Logic Device).
- the CPU includes DO pins, DI pins, CLK pins and /CS pins, and the CPU includes at least two types of /CS pins, such as /CS0 and /CS1;
- SPI ROM includes DO pins, DI pins pin, CLK pin and /CS pin.
- the storage space of the SPI ROM divided into two storage sections as an example, and the two storage sections are BIOS0 and BIOS1 respectively.
- the physical addresses included in the storage interval BIOS0 are 0x000000-0x7FFFFF, and the physical addresses included in the storage interval BIOS1 are 0x800000-0xFFFFFF.
- the SPI slave device is not directly connected to the SPI master device, but is bridged through a logic device in the middle.
- the logic device monitors the bridged SPI signal and modifies the DI signal at a specific timing, so as to achieve the purpose of mapping the access request of the SPI master device to the specified SPI slave device storage area.
- the logic device is used for:
- the access signal sent by the SPI master device to the SPI slave device is intercepted; the access signal includes a logical address and a signal source flag.
- the logic device modifies the logical address according to the signal source flag, so that the access request from the SPI master device to the SPI slave device is mapped to the storage area corresponding to the modified logical address.
- Figure 7 is the SPI timing diagram of the "Read Data" command (03h) in the SPI Flash of Winbond Electronics' model 25Q128FV. It can be seen that when the /CS signal is enabled, the data on the DI sampled in the first 8 clock cycles on the CLK signal is the SPI operation command (03h); the data on the DI signal sampled in the next 24 clock cycles is the SPI Flash 24-Bit Address (a total of 24Bit access addresses), the access address has a total capacity of 16MB, which is the aforementioned logical address; the last 8 clock cycles or multiple clock cycles are returned on the DO signal and stored in the SPI Flash address.
- One or more Bytes (byte) data the Bytes data is also the response information.
- the logic device uses the storage area corresponding to the modified logical address as the access area of the SPI master device, so that a communication connection is established between the SPI master device and the access area.
- each storage area includes multiple physical addresses
- the logic device is used to first obtain multiple physical addresses in the access area when establishing a communication connection between the SPI master device and the access area, and then use the first address in the access area.
- the physical address is used as the first access object, the currently accessed physical address is additionally calculated, and the calculated physical address is used as the next access object.
- Access multiple physical addresses as access objects in turn, and stop the access until the access termination signal sent by the SPI master device to the SPI slave device is intercepted.
- the logic device accesses multiple physical addresses as the access objects in sequence
- the first physical address in the access interval is used as the first access object, and additional calculation is performed on the currently accessed physical address, and the calculated physical address is used as The next access object continues to access; compare the physical address currently accessed with the physical address located at the end of the access range.
- the response information returned by the access object is received, and the response information is forwarded to the SPI master device; if the currently accessed physical address is greater than the last position in the access range The physical address sends the preset false response information to the SPI master device, so that the SPI master device sends a termination access signal to the SPI slave device.
- the logic device stops forwarding the response information returned by the current access object to the SPI master device, thereby realizing the isolation effect between the storages in the SPI slave device.
- the logic device first records the first physical address in the current access range. After the SPI slave device returns a response message, the /CS pin signal of the SPI master device is not pulled high, then the logic device adds one to the first physical address. , obtain a new access address, and compare the new access address with the physical address located at the last position in the access range, that is, the maximum address of the access range.
- the logic device will pull up the /CS signal of the SPI slave device to block subsequent accesses.
- the logic device returns a false response message, such as an invalid value of 0xFF; when the SPI master device receives an invalid value of 0xFF, it pulls up the /CS signal on the CPU side and sends a termination access signal to the SPI slave device; Until the /CS signal on the CPU side is pulled low again, the signal of the /CS pin is re-enabled, thereby starting a new round of access from the SPI master to the SPI slave.
- the logic device when the logic device is also used to establish a communication connection between the SPI master device and the access interval, before the SPI master device accesses the access interval, the storage interval other than the access interval in the SPI slave device is set to write immediately. protection status.
- the SPI master device can send the "Chip Erase" command to the SPI Flash to erase all the data in the entire storage space of the SPI slave device, including outside the current access interval storage area. Therefore, logic devices need to block the Chip Erase function to avoid erasing the data in the memory areas that are not accessed.
- the CPLD In order to block the chip erase operation, before the CPU accesses the SPI Flash, the CPLD first initializes the SPI Flash, sets any block in the storage area outside the current access interval to the "Protected” state, and sets the /WP of the SPI Flash side to the "Protected” state. (Write Protect) is pulled low to prevent the Block in this "Protected” state from being reset.
- Writing Protect is pulled low to prevent the Block in this "Protected” state from being reset.
- an embodiment of the present invention further provides a computing device, including:
- the processor is configured to call the program instructions stored in the memory, and execute the SPI access control method provided by the above embodiment according to the obtained program.
- the embodiments of the present invention further provide a computer-readable non-volatile storage medium, including computer-readable instructions, when the computer reads and executes the computer-readable instructions, the computer is made to execute the above embodiments.
- SPI access control method when the computer reads and executes the computer-readable instructions, the computer is made to execute the above embodiments.
- the SPI access control technology provided by the present invention can virtualize a large-capacity SPI storage device into multiple storage devices with smaller capacities and isolated from each other, and has the following advantages:
- the storage area is obtained by dividing the storage space of a single SPI slave device, the division of the storage area can be dynamically adjusted according to requirements, adding more possibilities for flexible system design.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Storage Device Security (AREA)
Abstract
An SPI access control method and system, and a computing device and a storage medium. The SPI access control method comprises: when an SPI master device requests access to an SPI slave device, intercepting an access signal, which is sent by the SPI master device to the SPI slave device, wherein the access signal comprises a logical address and a signal source flag; modifying the logical address according to the signal source flag, and mapping, to a storage extent corresponding to the modified logical address, a request for access to the SPI slave device by the SPI master device; and by taking, as an access extent, the storage extent corresponding to the modified logical address, establishing a communication connection between the SPI master device and the access extent. By means of the present invention, an access request of an SPI master device can be mapped to one of storage extents in an SPI slave device, such that the effect of a plurality of SPI slave devices is achieved by using a single SPI slave device, thereby reducing costs, and also overcoming the problem of installation limitations.
Description
本申请要求于2021年4月29日提交中国专利局、申请号为202110474343.1、发明名称为“一种SPI访问控制方法、系统、计算设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on April 29, 2021 with the application number 202110474343.1 and the invention titled "An SPI access control method, system, computing device and storage medium", the entire contents of which are Incorporated herein by reference.
本申请涉及存储设备技术领域,特别涉及一种SPI访问控制方法、系统、计算设备及存储介质。The present application relates to the technical field of storage devices, and in particular, to an SPI access control method, system, computing device and storage medium.
SPI(Serial Peripheral Interface,串行外设接口)通信总线具有高速、全双工和同步的特质,在芯片的管脚上只占用四根线,能够节约芯片的管脚,同时为PCB(Printed Circuit Board,印制电路板)的布局上节省空间。由于SPI简单易行的优势,在多个领域得以广泛应用,SPI存储设备作为一种常用的数据存储部件,在系统设计中常被用于存储固件程序及其相关的配置数据。SPI (Serial Peripheral Interface, Serial Peripheral Interface) communication bus has the characteristics of high speed, full duplex and synchronization. It only occupies four lines on the pins of the chip, which can save the pins of the chip, and is also a PCB (Printed Circuit). Board, printed circuit board) layout to save space. Due to the advantages of SPI's simplicity and ease of operation, it is widely used in many fields. As a common data storage component, SPI storage devices are often used to store firmware programs and related configuration data in system design.
目前,由于应用场景的需求,一些SPI主设备上会接入多个SPI从设备,当其中一个SPI从设备内的固件程序无法完成系统启动,例如该SPI从设备的固件程序遭到破坏时,则切换到另一个SPI从设备以载入新的固件启动系统,从而以满足使用需求。但由于这种方式需要用到两个SPI从设备,成本较高;此外,由于需要为多个SPI从设备的安装预留空间,因此存在一定的安装限制。At present, due to the requirements of application scenarios, some SPI master devices will be connected to multiple SPI slave devices. When the firmware program in one of the SPI slave devices cannot complete the system startup, for example, when the firmware program of the SPI slave device is damaged, Then switch to another SPI slave device to load the new firmware to start the system to meet the needs of use. However, since this method requires two SPI slave devices, the cost is high; in addition, there are certain installation restrictions due to the need to reserve space for the installation of multiple SPI slave devices.
发明内容SUMMARY OF THE INVENTION
本申请的目的在于提供一种SPI访问控制方法、系统、计算设备及存储介质,解决现有技术中,当需要使用多个SPI从设备时,成本较高且存在安装限制的问题。The purpose of the present application is to provide an SPI access control method, system, computing device and storage medium to solve the problems in the prior art that when multiple SPI slave devices need to be used, the cost is relatively high and there are installation restrictions.
为实现上述目的,本发明提供以下的技术方案:To achieve the above object, the present invention provides the following technical solutions:
一种SPI访问控制方法,应用于SPI主设备对SPI从设备的访问,所述SPI从设备的存储空间至少划分成两个存储区间;An SPI access control method, which is applied to the access of the SPI slave device by the SPI master device, and the storage space of the SPI slave device is at least divided into two storage sections;
所述SPI访问控制方法包括:The SPI access control method includes:
在所述SPI主设备请求访问所述SPI从设备时,截获所述SPI主设备向所述SPI从设备发送的访问信号;所述访问信号包括逻辑地址和信号来源标志;When the SPI master device requests to access the SPI slave device, intercept the access signal sent by the SPI master device to the SPI slave device; the access signal includes a logical address and a signal source flag;
依据所述信号来源标志修改所述逻辑地址,将所述SPI主设备对所述SPI从设备的访问请求,映射至与修改后的逻辑地址对应的存储区间;Modifying the logical address according to the signal source sign, mapping the access request of the SPI master device to the SPI slave device to a storage section corresponding to the modified logical address;
将修改后的逻辑地址对应的存储区间作为访问区间,使所述SPI主设备与所述访问区间之间建立通信连接。The storage interval corresponding to the modified logical address is used as an access interval, so that a communication connection is established between the SPI master device and the access interval.
可选地,每个所述存储区间分别包括多个物理地址;Optionally, each of the storage intervals respectively includes a plurality of physical addresses;
所述使SPI主设备与所述访问区间之间建立通信连接,包括:The described setting up communication connection between the SPI master device and the access interval includes:
获取所述访问区间中的所述多个物理地址;obtaining the plurality of physical addresses in the access interval;
将所述多个物理地址依次作为访问对象进行访问,直至截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止所述访问。The multiple physical addresses are sequentially accessed as access objects, and the access is stopped until the access termination signal sent by the SPI master device to the SPI slave device is intercepted.
可选地,所述将所述多个物理地址依次作为访问对象进行访问,包括:Optionally, the accessing the multiple physical addresses as access objects in sequence includes:
以所述访问区间中位于首位的物理地址作为首个访问对象;Taking the physical address at the first position in the access interval as the first access object;
比较所述当前访问的物理地址和所述访问区间中位于末位的物理地址;Compare the physical address of the current access and the physical address at the last position in the access interval;
若所述当前访问的物理地址小于或等于所述访问区间中位于末位的物理地址,接收所述访问对象返回的应答信息,将所述应答信息转发至所述SPI主设备,并对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一访问对象继续访问。If the currently accessed physical address is less than or equal to the physical address at the end of the access interval, receive the response information returned by the access object, forward the response information to the SPI master device, and respond to the current access The physical address is additionally calculated, and the calculated physical address is used as the next access object to continue accessing.
可选地,所述将所述多个物理地址依次作为访问对象进行访问,还包括:Optionally, the accessing the plurality of physical addresses as access objects in turn, further includes:
若所述当前访问的物理地址大于所述访问区间中位于末位的物理地址,向所述SPI主设备发送预设的虚假应答信息,使所述SPI主设备向所述SPI从设备发送终止访问信号;If the currently accessed physical address is greater than the physical address at the last position in the access interval, send a preset false response message to the SPI master device, so that the SPI master device sends the SPI slave device to terminate the access Signal;
当截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止 将当前访问对象返回的应答信息转发至所述SPI主设备。When intercepting the termination access signal that the SPI master device sends to the SPI slave device, stop forwarding the response information returned by the current access object to the SPI master device.
可选地,在所述SPI主设备请求访问SPI从设备时,还包括:Optionally, when the SPI master device requests to access the SPI slave device, it also includes:
将所述SPI从设备中除所述访问区间之外的存储区间设置为即写保护状态。Setting the storage interval other than the access interval in the SPI slave device to a write-protected state.
本发明还提供了一种SPI访问控制系统,用于实现如上任一项所述的SPI访问控制方法,包括SPI主设备和SPI从设备,所述SPI从设备的存储空间至少划分成两个存储区间,所述SPI主设备与SPI从设备之间通过一逻辑器件桥接;The present invention also provides an SPI access control system for implementing the SPI access control method described in any of the above, including an SPI master device and an SPI slave device, wherein the storage space of the SPI slave device is at least divided into two storage spaces interval, the SPI master device and the SPI slave device are bridged by a logic device;
所述逻辑器件用于:The logic device is used for:
在所述SPI主设备请求访问所述SPI从设备时,截获所述SPI主设备向所述SPI从设备发送的访问信号;所述访问信号包括逻辑地址和信号来源标志;When the SPI master device requests to access the SPI slave device, intercept the access signal sent by the SPI master device to the SPI slave device; the access signal includes a logical address and a signal source flag;
依据所述信号来源标志修改所述逻辑地址,使所述SPI主设备对所述SPI从设备的访问请求,映射至与修改后的逻辑地址对应的存储区间;Modifying the logical address according to the signal source sign, so that the access request of the SPI master device to the SPI slave device is mapped to the storage section corresponding to the modified logical address;
将修改后的逻辑地址对应的存储区间作为访问区间,并使所述SPI主设备与所述访问区间之间建立通信连接。The storage section corresponding to the modified logical address is used as an access section, and a communication connection is established between the SPI master device and the access section.
可选地,每个所述存储区间分别包括多个物理地址;Optionally, each of the storage intervals respectively includes a plurality of physical addresses;
所述逻辑器件用于在使所述SPI主设备与所述访问区间之间建立通信连接时:The logic device is used to establish a communication connection between the SPI master device and the access interval:
获取所述访问区间中的所述多个物理地址;obtaining the plurality of physical addresses in the access interval;
以所述访问区间中位于首位的物理地址作为首个访问对象,对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一个访问对象;Taking the physical address at the first position in the access interval as the first access object, additionally calculate the physical address of the current access, and use the calculated physical address as the next access object;
将所述多个物理地址依次作为访问对象进行访问,直至截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止所述访问;The multiple physical addresses are successively accessed as access objects, and the access is stopped until the terminating access signal sent by the SPI master device to the SPI slave device is intercepted;
所述将所述多个物理地址依次作为访问对象进行访问,包括:The accessing the multiple physical addresses as access objects in sequence includes:
以所述访问区间中位于首位的物理地址作为首个访问对象;Taking the physical address at the first position in the access interval as the first access object;
比较所述当前访问的物理地址和所述访问区间中位于末位的物理地址;Compare the physical address of the current access and the physical address at the last position in the access interval;
若所述当前访问的物理地址小于或等于所述访问区间中位于末位的物 理地址,接收所述访问对象返回的应答信息,将所述应答信息转发至所述SPI主设备,并对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一访问对象继续访问;If the currently accessed physical address is less than or equal to the physical address at the end of the access interval, receive the response information returned by the access object, forward the response information to the SPI master device, and respond to the current access The physical address is additionally calculated, and the calculated physical address is used as the next access object to continue access;
若所述当前访问的物理地址大于所述访问区间中位于末位的物理地址,向所述SPI主设备发送预设的虚假应答信息,使所述SPI主设备向所述SPI从设备发送终止访问信号;If the currently accessed physical address is greater than the physical address at the last position in the access interval, send a preset false response message to the SPI master device, so that the SPI master device sends the SPI slave device to terminate the access Signal;
当截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止将当前访问对象返回的应答信息转发至所述SPI主设备。When intercepting the access termination signal sent by the SPI master device to the SPI slave device, stop forwarding the response information returned by the current access object to the SPI master device.
可选地,所述逻辑器件还用于在所述SPI主设备与所述访问区间之间建立通信连接时:Optionally, the logic device is also used to establish a communication connection between the SPI master device and the access interval:
将所述SPI从设备中除所述访问区间之外的存储区间设置为即写保护状态。Setting the storage interval other than the access interval in the SPI slave device to a write-protected state.
本发明还提供了一种计算设备,包括:The present invention also provides a computing device, comprising:
存储器,用于存储程序指令;memory for storing program instructions;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行如上任一项所述的SPI访问控制方法。The processor is configured to call the program instructions stored in the memory, and execute the SPI access control method described in any one of the above according to the obtained program.
本发明还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行如上任一项所述的SPI访问控制方法。The present invention also provides a computer-readable non-volatile storage medium, comprising computer-readable instructions, when the computer reads and executes the computer-readable instructions, the computer executes the SPI access control described in any of the above method.
与现有技术相比,本发明具有以下有益效果:Compared with the prior art, the present invention has the following beneficial effects:
本发明通过监控SPI主设备向SPI从设备的访问请求,并修改访问请求中的逻辑地址,使得SPI主设备访问请求得以映射至SPI从设备中各个存储区间中的其中一个,以利用单个SPI从设备达到多个SPI从设备的效果,降低成本的同时也克服了存在安装限制的问题。The present invention monitors the access request from the SPI master device to the SPI slave device, and modifies the logical address in the access request, so that the SPI master device access request can be mapped to one of the various storage areas in the SPI slave device, so as to utilize a single SPI slave device. The device achieves the effect of multiple SPI slave devices, which reduces the cost and overcomes the problem of installation limitations.
为了更清楚地说明现有技术和本申请实施例中的技术方案,下面将对现有技术和本申请实施例描述中需要使用的附图作简要的介绍。当然,下面有关本申请实施例的附图描述的仅仅是本申请中的一部分实施例,对于 本领域普通技术人员来说,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图,所获得的其他附图也属于本申请的保护范围。In order to more clearly illustrate the prior art and the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings to be used in the description of the prior art and the embodiments of the present application. Of course, the following drawings related to the embodiments of the present application describe only a part of the embodiments of the present application. For those of ordinary skill in the art, without any creative effort, they can also obtain other embodiments according to the provided drawings. The accompanying drawings and other drawings obtained also belong to the protection scope of the present application.
图1为8Pin脚封装的SPI Flash的结构示意图;Figure 1 is a schematic structural diagram of an SPI Flash packaged with an 8Pin pin;
图2为本发明提供的一种SPI访问控制方法的流程图;Fig. 2 is the flow chart of a kind of SPI access control method provided by the present invention;
图3为本发明提供的一种SPI访问控制方法中步骤S3的流程图;Fig. 3 is the flow chart of step S3 in a kind of SPI access control method provided by the present invention;
图4为本发明提供的一种SPI访问控制方法中步骤S32的流程图;Fig. 4 is the flow chart of step S32 in a kind of SPI access control method provided by the present invention;
图5为本发明提供的一种SPI访问控制方法中步骤S4的流程图;Fig. 5 is the flow chart of step S4 in a kind of SPI access control method provided by the present invention;
图6为本发明提供的一种SPI访问控制系统的结构示意图;6 is a schematic structural diagram of a SPI access control system provided by the present invention;
图7为华邦电子公司型号为25Q128FV的SPI Flash中,“Read Data”命令的SPI时序图。Figure 7 is the SPI timing diagram of the "Read Data" command in the SPI Flash of Winbond Electronics' model 25Q128FV.
本申请的核心在于提供一种SPI访问控制方法、系统、计算设备及存储介质,以便有效地提高自动化效率并降低人力耗费成本。The core of the present application is to provide an SPI access control method, system, computing device and storage medium, so as to effectively improve automation efficiency and reduce labor cost.
为了对本申请实施例中的技术方案进行更加清楚、完整地描述,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行介绍。显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to describe the technical solutions in the embodiments of the present application more clearly and completely, the technical solutions in the embodiments of the present application will be introduced below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
由于应用场景的需求,一些SPI主设备上会接入多个SPI从设备,通过SPI主设备引脚/CS(Chip Select,芯片选择)的使能以实现SPI主设备对SPI从设备的访问。以两个SPI从设备的设计为例,接入方式包括如下情形:Due to the requirements of the application scenario, some SPI master devices will be connected to multiple SPI slave devices, and the SPI master device can access the SPI slave device through the enable of the SPI master device pin/CS (Chip Select). Taking the design of two SPI slave devices as an example, the access methods include the following situations:
同一个SPI主设备上接入两个SPI从设备,并在两个SPI从设备中分别放入系统固件;若其中的一个SPI从设备内的固件程序无法完成系统启动(例如遭到破坏时),则切换到另一个SPI从设备中并载入新的固件启动系统;这种方式需要用到两个SPI从设备,成本较高;此外,由于需要为两个SPI从设备的安装预留空间,因此存在一定的安装限制。Connect two SPI slave devices to the same SPI master device, and put the system firmware into the two SPI slave devices respectively; if the firmware program in one of the SPI slave devices cannot complete the system startup (for example, when it is damaged) , then switch to another SPI slave device and load the new firmware to start the system; this method requires two SPI slave devices, and the cost is high; in addition, due to the need to reserve space for the installation of the two SPI slave devices , so there are certain installation restrictions.
本发明旨在于提供一种SPI访问方案,以克服现有技术的如上问题。The present invention aims to provide an SPI access scheme to overcome the above problems of the prior art.
为便于理解本发明提供的技术方案,在此对本发明所涉及的专业术语进行解释:In order to facilitate the understanding of the technical solutions provided by the present invention, the technical terms involved in the present invention are explained here:
SPI(Serial Peripheral Interface,串行外设接口),是一种高速、双全工且同步的通信总线,在芯片的管脚上只占四根线。SPI (Serial Peripheral Interface, Serial Peripheral Interface) is a high-speed, dual full-duplex and synchronous communication bus, which occupies only four lines on the pins of the chip.
SPI Flash(SPI NOR Flash),具有读速度块,可字节访问等特点,通常用来做固件程序的存储,是一种长寿命的非易失性存储器,在断电情况下仍能保持所存储的数据信息;数据删除不是以单个字节为单位,是以固定区块为单位,区块大小一般为256KB到20MB。SPI Flash (SPI NOR Flash) has the characteristics of read speed block, byte access, etc. It is usually used to store firmware programs. It is a long-life non-volatile memory that can still maintain all Stored data information; data deletion is not in a single byte, but in a fixed block, and the block size is generally 256KB to 20MB.
BIOS(Basic Input Output System),即基本输入/输出系统。BIOS (Basic Input Output System), the basic input/output system.
CPLD(Complex Programmable Logic Device),即复杂可编程逻辑器件。CPLD (Complex Programmable Logic Device), namely complex programmable logic device.
SOC(System on Chip,系统级芯片)厂商一般需要将识别引导介质类型的程序固化到芯片的ROM(Read Only Memory,只读存储器)中,由于ROM是只读的,为了保证对多种类型SPI Flash的兼容,需要引导代码对启动介质进行识别和引导。SOC (System on Chip, system-on-chip) manufacturers generally need to solidify the program that identifies the type of boot medium into the ROM (Read Only Memory, read-only memory) of the chip. Since the ROM is read-only, in order to ensure that various types of SPI Flash compatibility requires boot code to identify and boot the boot medium.
ROM(Read Only Memory image,只读存储器)从SPI Flash搬移启动引导程序至内部RAM(Random Access Memory,随机存取存储器),并跳转至RAM执行启动引导程序,由启动引导程序完成频率配置、板级配置和DDR初始化等,下载并执行操作系统。ROM (Read Only Memory image, read-only memory) moves the bootstrap program from the SPI Flash to the internal RAM (Random Access Memory, random access memory), and jumps to the RAM to execute the bootstrap program, which completes the frequency configuration, Board configuration and DDR initialization, etc., download and execute the operating system.
请参考图1,在此以8Pin脚封装的SPI Flash为例,对其各引脚的功能进行解释:Please refer to Figure 1. Here, the SPI Flash packaged with 8Pin pins is used as an example to explain the functions of its pins:
/CS-chip select(芯片选择):该信号被拉低后,SPI从设备被SPI主设备选中并对SPI Master的请求做出响应。/CS-chip select (chip select): After this signal is pulled low, the SPI slave device is selected by the SPI master device and responds to the SPI Master's request.
CLK-clock(时钟):由SPI主设备送出的时钟同步信号。CLK-clock (clock): The clock synchronization signal sent by the SPI master device.
/WP–write protect(写入保护):该信号被拉低后,SPI从设备的状态和控制寄存器被禁止写入新数据,直到重新上电。/WP–write protect (write protection): After this signal is pulled low, the status and control registers of the SPI slave device are prohibited from writing new data until the power is turned on again.
DI–data in(输入数据):SPI主设备的请求数据在该信号上通过串行方式送入SPI从设备。DI-data in (input data): The request data of the SPI master device is serially sent to the SPI slave device on this signal.
DO–data out(输出数据):SPI从设备对SPI主设备的请求的响应数 据在该信号上通过串行方式返回给SPI主设备。DO-data out (output data): The response data of the SPI slave device to the SPI master device's request is serially returned to the SPI master device on this signal.
请参考图2,本发明实施例提供一种SPI访问控制方法,应用于SPI主设备对SPI从设备的访问,SPI从设备的存储空间至少划分成两个存储区间。Referring to FIG. 2 , an embodiment of the present invention provides an SPI access control method, which is applied to an SPI master device accessing an SPI slave device, and the storage space of the SPI slave device is divided into at least two storage regions.
具体地,在SPI主设备请求访问SPI从设备时,该SPI访问控制方法包括:Specifically, when the SPI master device requests to access the SPI slave device, the SPI access control method includes:
S1、截获SPI主设备向SPI从设备发送的访问信号。S1. Intercept the access signal sent by the SPI master device to the SPI slave device.
具体地,步骤S1中,由SPI主设备发出的访问信号包括逻辑地址和信号来源标志。Specifically, in step S1, the access signal sent by the SPI master device includes a logical address and a signal source flag.
可以理解的是,SPI主设备可以包括至少两个用于选择所访问的存储区间的/CS(chip select,芯片选择)引脚,如/CS0和/CS1;在请求访问SPI从设备时,SPI主设备基于访问需求使能/CS0和/CS1中的任一个,使得SPI主设备向SPI从设备发送的访问信号中包含/CS0或/CS1的信号来源标志,从而为该步骤中修改逻辑地址提供依据。It can be understood that the SPI master device may include at least two /CS (chip select, chip select) pins for selecting the accessed memory interval, such as /CS0 and /CS1; when requesting access to the SPI slave device, the SPI The master device enables either /CS0 and /CS1 based on the access requirement, so that the access signal sent by the SPI master device to the SPI slave device contains the signal source flag of /CS0 or /CS1, so as to provide the modified logical address in this step. in accordance with.
S2、依据信号来源标志修改逻辑地址,将SPI主设备对SPI从设备的访问请求,映射至与修改后的逻辑地址对应的存储区间。S2. Modify the logical address according to the signal source flag, and map the access request of the SPI master device to the SPI slave device to the storage area corresponding to the modified logical address.
可以理解的是,事先建立好SPI从设备中各存储区间与不同的逻辑地址之间的映射关系,使得按照信号来源标志修改后的逻辑地址所映射的存储区间,与SPI主设备的访问请求相符合。It can be understood that the mapping relationship between each storage interval in the SPI slave device and different logical addresses is established in advance, so that the storage interval mapped by the logical address modified according to the signal source flag is consistent with the access request of the SPI master device. meets the.
在该步骤中,当截获到来自SPI主设备的访问信号时,根据该信号来源标志,对访问信号中原本包含的逻辑地址进行修改,使得修改后的逻辑地址与SPI从设备中的其中一个存储区间具有唯一的对应关系,从而将SPI主设备对SPI从设备的访问请求,映射至与修改后的逻辑地址对应的存储区间。In this step, when the access signal from the SPI master device is intercepted, the logical address originally contained in the access signal is modified according to the signal source flag, so that the modified logical address is stored with one of the SPI slave devices. The interval has a unique corresponding relationship, so that the access request from the SPI master device to the SPI slave device is mapped to the storage interval corresponding to the modified logical address.
S3、将修改后的逻辑地址对应的存储区间作为访问区间,使SPI主设备与访问区间之间建立通信连接。S3. Use the storage area corresponding to the modified logical address as the access area, so that a communication connection is established between the SPI master device and the access area.
通过前述步骤,使得SPI主设备访问请求得以映射至SPI从设备中各个存储区间中的其中一个,以利用单个SPI从设备达到多个SPI从设备的 效果,降低成本的同时也克服了存在安装限制的问题。Through the above steps, the SPI master device access request can be mapped to one of the various storage areas in the SPI slave device, so that a single SPI slave device can be used to achieve the effect of multiple SPI slave devices, which reduces the cost and overcomes the existence of installation restrictions. The problem.
当系统上电后,首先执行一段特定程序判断哪一个固件(即SPI从设备中的存储区间)用于启动系统,例如,该特定程序首先校验第一固件的完整性,一旦校验失败则使用第二固件启动系统。When the system is powered on, a specific program is first executed to determine which firmware (ie, the storage area in the SPI slave device) is used to start the system. For example, the specific program first checks the integrity of the first firmware, and once the check fails, the Boot the system with the second firmware.
可以理解的是,一个容量为16MB的SPI从设备,其容量是容量为8MB的SPI从设备的两倍,但16MB的SPI从设备在成本上仍然优于两个8MB的SPI从设备,因此能够达到节约成本的目的。此外,对于一些小板卡型的系统设计,空间往往是制约其部件选型的关键;利用单个SPI从设备节约空间,能够为系统布局提供更多的选择空间。Understandably, a 16MB SPI slave has twice the capacity of an 8MB SPI slave, but a 16MB SPI slave is still costlier than two 8MB SPI slaves, so it can achieve cost savings. In addition, for some small board-type system designs, space is often the key to restricting the selection of its components; using a single SPI slave device to save space can provide more choices for system layout.
可以理解的是,利用软件方式使单个SPI从设备具备双固件功能的设计存在一定的缺陷,具体如下:由于两个系统固件同处于一个SPI从设备中,两个固件之间缺乏隔离保护。在任意一次系统启动中,无论是使用了哪个固件,另一个系统固件都能够被SPI主设备直接访问到,甚至有被擦除的可能,导致可靠性降低。It can be understood that there are certain defects in the design of using software to enable a single SPI slave device to have dual firmware functions. The details are as follows: Since the two system firmwares are in the same SPI slave device, there is a lack of isolation protection between the two firmwares. In any system startup, no matter which firmware is used, another system firmware can be directly accessed by the SPI master device, and may even be erased, resulting in reduced reliability.
由于目前的SPI存储设备普遍具有单指令读取整个SPI从设备存储空间中数据的能力,例如,当SPI从设备在接受“Read(读)”指令后,从指定地址开始逐个返回应答信息,直到SPI主设备的所有/CS引脚信号拉高时才停止数据获取。因此,SPI主设备在获取第一个应答信息后,通过延长/CS信号的时钟周期即可获取到SPI从设备存储空间中的所有数据。Because the current SPI storage devices generally have the ability to read the data in the entire SPI slave device storage space with a single command, for example, when the SPI slave device accepts the "Read (read)" command, it returns the response information one by one starting from the specified address, until Data acquisition stops when all /CS pins of the SPI master are pulled high. Therefore, after the SPI master device obtains the first response information, it can obtain all the data in the storage space of the SPI slave device by extending the clock cycle of the /CS signal.
为了提高SPI从设备的存储空间中各存储区间的隔离性,本实施例中,每个存储区间分别包括多个物理地址。In order to improve the isolation of each storage area in the storage space of the SPI slave device, in this embodiment, each storage area includes a plurality of physical addresses respectively.
请参考图3,基于此,该SPI访问控制方法中,步骤S3具体包括:Please refer to FIG. 3, based on this, in the SPI access control method, step S3 specifically includes:
S31、获取访问区间中的多个物理地址;S31, acquiring multiple physical addresses in the access range;
S32、将多个物理地址依次作为访问对象进行访问,直至截获到SPI主设备向SPI从设备发送的终止访问信号时,停止访问。S32, access multiple physical addresses as access objects in sequence, and stop the access until the access termination signal sent by the SPI master device to the SPI slave device is intercepted.
请参考图4,进一步地,步骤S32包括:Please refer to FIG. 4, further, step S32 includes:
S321、以访问区间中位于首位的物理地址作为首个访问对象;S321, taking the physical address at the first position in the access range as the first access object;
S322、比较当前访问的物理地址和访问区间中位于末位的物理地址,判断当前访问的物理地址是否大于访问区间中位于末位的物理地址;若是, 执行步骤S324,若否,执行步骤S323;S322, compare the physical address of current access and the physical address of the last position in the access interval, and judge whether the physical address of the current access is greater than the physical address of the last position in the access interval; if so, execute step S324, if not, execute step S323;
S323、接收访问对象返回的应答信息,将应答信息转发至SPI主设备;对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一访问对象继续访问,返回步骤S322;S323, receive the response information returned by the access object, and forward the response information to the SPI master device; perform additional calculation on the physical address of the current access, and continue to access the calculated physical address as the next access object, and return to step S322;
S324、向SPI主设备发送预设的虚假应答信息,使SPI主设备向SPI从设备发送终止访问信号。S324: Send preset false response information to the SPI master device, so that the SPI master device sends a termination access signal to the SPI slave device.
S325、当截获到SPI主设备向SPI从设备发送的终止访问信号时,停止将当前访问对象返回的应答信息转发至SPI主设备。S325 , when the access termination signal sent by the SPI master device to the SPI slave device is intercepted, stop forwarding the response information returned by the current access object to the SPI master device.
可以理解的是,利用步骤S321-步骤S325,使得某一时刻只能有一个存储区间被访问到,且对该存储区间的访问操作不对其他区间产生影响。It can be understood that by using steps S321 to S325, only one storage interval can be accessed at a certain time, and the access operation of this storage interval does not affect other intervals.
此外,通过控制所访问的物理地址中的最大值不超过该访问区间中位于末位的物理地址,即,无论SPI主设备访问SPI从设备中划分得到的哪一个存储区间,其访问起始地址始终为0x0,最大访问地址为该存储区间的大小,从而阻止SPI主设备对SPI从设备中除访问区间以外的存储区间进行访问。In addition, by controlling the maximum value of the accessed physical addresses not to exceed the physical address located at the last position in the access interval, that is, no matter which storage interval the SPI master device accesses from the SPI slave device, its access start address It is always 0x0, and the maximum access address is the size of the storage interval, thereby preventing the SPI master device from accessing the storage interval other than the access interval in the SPI slave device.
可以理解的是,SPI从设备中划分所得的存储区间的容量大小可根据实际需求动态调整,具有较高的灵活性。It can be understood that the capacity of the storage interval divided by the SPI slave device can be dynamically adjusted according to the actual demand, and has high flexibility.
进一步地,SPI存储设备通常还具有芯片擦除功能,当SPI主设备向SPI从设备发送“Chip Erase(芯片擦除)”命令,即可擦除SPI从设备的整个存储空间内的数据,包括除访问区间之外的其他存储区间。Further, the SPI storage device usually also has a chip erase function. When the SPI master device sends the "Chip Erase (chip erase)" command to the SPI slave device, the data in the entire storage space of the SPI slave device can be erased, including Other storage intervals other than the access interval.
请参考图5,基于此,在SPI主设备请求访问SPI从设备时,还包括如下步骤:Please refer to Figure 5. Based on this, when the SPI master device requests to access the SPI slave device, the following steps are also included:
S4、将SPI从设备中除访问区间之外的存储区间设置为即写保护状态。S4. Set the storage interval other than the access interval in the SPI slave device to a write-protected state.
具体地,该步骤中,在SPI主设备请求与SPI从设备建立通信连接之前,将除访问区间之外的存储区间设置为“Protected”(即写保护),对该存储区间发出的“Chip Erase”命令将不会被执行。Specifically, in this step, before the SPI master device requests to establish a communication connection with the SPI slave device, the storage interval other than the access interval is set to "Protected" (that is, write-protected), and the "Chip Erase" issued to the storage interval " command will not be executed.
如图6所示,基于前述实施例,本发明实施例还提供了一种SPI访问控制系统,包括SPI主设备和SPI从设备,SPI从设备的存储空间至少划分成两个存储区间,SPI主设备与SPI从设备之间通过一逻辑器件桥接。As shown in FIG. 6 , based on the foregoing embodiment, an embodiment of the present invention further provides an SPI access control system, including an SPI master device and an SPI slave device. The storage space of the SPI slave device is divided into at least two storage areas, and the SPI master device is divided into two storage areas. The device and the SPI slave device are bridged by a logic device.
本实施例中,SPI主设备为SPI Master(主机)的CPU,SPI从设备包括SPI ROM和SPI Flash,逻辑器件为CPLD(Complex Programmable Logic Device,复杂可编程逻辑器件)。其中,CPU包括DO引脚、DI引脚、CLK引脚和/CS引脚,且CPU至少包括两种类型的/CS引脚,如/CS0和/CS1;SPI ROM包括DO引脚、DI引脚、CLK引脚和/CS引脚。In this embodiment, the SPI master device is the CPU of the SPI Master (host), the SPI slave device includes SPI ROM and SPI Flash, and the logic device is CPLD (Complex Programmable Logic Device). Among them, the CPU includes DO pins, DI pins, CLK pins and /CS pins, and the CPU includes at least two types of /CS pins, such as /CS0 and /CS1; SPI ROM includes DO pins, DI pins pin, CLK pin and /CS pin.
进一步地,以SPI ROM的存储空间分为两个存储区间为例,两个存储区间分别为BIOS0和BIOS1。Further, take the storage space of the SPI ROM divided into two storage sections as an example, and the two storage sections are BIOS0 and BIOS1 respectively.
存储区间BIOS0包括的物理地址为0x000000-0x7FFFFF,存储区间BIOS1包括的物理地址为0x800000-0xFFFFFF。The physical addresses included in the storage interval BIOS0 are 0x000000-0x7FFFFF, and the physical addresses included in the storage interval BIOS1 are 0x800000-0xFFFFFF.
本实施例中,SPI从设备不与SPI主设备直连,而是中间通过逻辑器件进行桥接。逻辑器件对桥接的SPI信号进行监控并修改特定时序下的DI信号,从而达成将SPI主设备的访问请求映射到指定的SPI从设备存储区间的目的。In this embodiment, the SPI slave device is not directly connected to the SPI master device, but is bridged through a logic device in the middle. The logic device monitors the bridged SPI signal and modifies the DI signal at a specific timing, so as to achieve the purpose of mapping the access request of the SPI master device to the specified SPI slave device storage area.
本实施例中,逻辑器件用于:In this embodiment, the logic device is used for:
在SPI主设备请求访问SPI从设备时,截获SPI主设备向SPI从设备发送的访问信号;访问信号包括逻辑地址和信号来源标志。逻辑器件依据信号来源标志修改逻辑地址,使SPI主设备对SPI从设备的访问请求,映射至与修改后的逻辑地址对应的存储区间。When the SPI master device requests to access the SPI slave device, the access signal sent by the SPI master device to the SPI slave device is intercepted; the access signal includes a logical address and a signal source flag. The logic device modifies the logical address according to the signal source flag, so that the access request from the SPI master device to the SPI slave device is mapped to the storage area corresponding to the modified logical address.
请参考图7,图7为华邦电子公司型号为25Q128FV的SPI Flash中,“Read Data”命令(03h)的SPI时序图。可见,当/CS信号使能后,CLK信号上的前8个时钟周期采样DI上的数据为SPI操作命令(03h);紧跟其后的24个时钟周期采样DI信号上的数据为SPI Flash的24-Bit Address(共24Bit的访问地址),该访问地址共16MB容量,也即前述的逻辑地址;最后的8个时钟周期或者多个时钟周期在DO信号上返回存放在该SPI Flash地址的一个或者多个Bytes(字节)数据,该Bytes数据也即应答信息。Please refer to Figure 7. Figure 7 is the SPI timing diagram of the "Read Data" command (03h) in the SPI Flash of Winbond Electronics' model 25Q128FV. It can be seen that when the /CS signal is enabled, the data on the DI sampled in the first 8 clock cycles on the CLK signal is the SPI operation command (03h); the data on the DI signal sampled in the next 24 clock cycles is the SPI Flash 24-Bit Address (a total of 24Bit access addresses), the access address has a total capacity of 16MB, which is the aforementioned logical address; the last 8 clock cycles or multiple clock cycles are returned on the DO signal and stored in the SPI Flash address. One or more Bytes (byte) data, the Bytes data is also the response information.
通过对该时序图分析可知,当24-Bit Address中的第23个Bit的电平状态(即/CS信号使能后,在第9个时钟周期内采样DI信号上的电平状态)为低时,对SPI Flash的访问空间为0x000000-0x7FFFFF,即SPI Flash的前半段地址空间;当24-Bit Address中的第bit23为高时,对SPI Flash的访 问空间为0x800000-0xFFFFFF,即SPI ROM的后半段地址空间。以上,通过修改DI信号线上的bit23即可实现将CPU访问映射到不同的区间。Through the analysis of the timing diagram, it can be seen that when the level state of the 23rd Bit in the 24-Bit Address (that is, after the /CS signal is enabled, the level state on the DI signal is sampled in the ninth clock cycle) is low When the SPI Flash access space is 0x000000-0x7FFFFF, that is, the first half of the SPI Flash address space; when the bit23 of the 24-Bit Address is high, the SPI Flash access space is 0x800000-0xFFFFFF, that is, the SPI ROM The second half of the address space. Above, by modifying bit23 on the DI signal line, the CPU access can be mapped to different intervals.
逻辑器件将修改后的逻辑地址对应的存储区间作为SPI主设备的访问区间,使SPI主设备与访问区间之间建立通信连接。The logic device uses the storage area corresponding to the modified logical address as the access area of the SPI master device, so that a communication connection is established between the SPI master device and the access area.
由于每个存储区间分别包括多个物理地址,逻辑器件用于在使SPI主设备与访问区间之间建立通信连接时,首先获取访问区间中的多个物理地址,然后以访问区间中位于首位的物理地址作为首个访问对象,对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一个访问对象。将多个物理地址依次作为访问对象进行访问,直至截获到SPI主设备向SPI从设备发送的终止访问信号时,停止访问。Since each storage area includes multiple physical addresses, the logic device is used to first obtain multiple physical addresses in the access area when establishing a communication connection between the SPI master device and the access area, and then use the first address in the access area. The physical address is used as the first access object, the currently accessed physical address is additionally calculated, and the calculated physical address is used as the next access object. Access multiple physical addresses as access objects in turn, and stop the access until the access termination signal sent by the SPI master device to the SPI slave device is intercepted.
具体地,逻辑器件将多个物理地址依次作为访问对象进行访问时,以访问区间中位于首位的物理地址作为首个访问对象,对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一个访问对象继续访问;比较当前访问的物理地址和访问区间中位于末位的物理地址。Specifically, when the logic device accesses multiple physical addresses as the access objects in sequence, the first physical address in the access interval is used as the first access object, and additional calculation is performed on the currently accessed physical address, and the calculated physical address is used as The next access object continues to access; compare the physical address currently accessed with the physical address located at the end of the access range.
若当前访问的物理地址小于或等于访问区间中位于末位的物理地址,接收访问对象返回的应答信息,将应答信息转发至SPI主设备;若当前访问的物理地址大于访问区间中位于末位的物理地址,向SPI主设备发送预设的虚假应答信息,使SPI主设备向SPI从设备发送终止访问信号。If the currently accessed physical address is less than or equal to the physical address at the end of the access range, the response information returned by the access object is received, and the response information is forwarded to the SPI master device; if the currently accessed physical address is greater than the last position in the access range The physical address sends the preset false response information to the SPI master device, so that the SPI master device sends a termination access signal to the SPI slave device.
当截获到SPI主设备向SPI从设备发送的终止访问信号时,逻辑器件停止将当前访问对象返回的应答信息转发至SPI主设备,从而实现SPI从设备中各存储之间的隔离效果。When the termination access signal sent by the SPI master device to the SPI slave device is intercepted, the logic device stops forwarding the response information returned by the current access object to the SPI master device, thereby realizing the isolation effect between the storages in the SPI slave device.
例如,逻辑器件首先记录当前访问区间中位于首位的物理地址,当SPI从设备返回一个应答信息后,SPI主设备的/CS引脚信号没有被拉高,则逻辑器件将首位的物理地址加一,得到一个新的访问地址,并将该新访问地址与该访问区间中位于末位的物理地址,也即该访问区间的最大地址做比较。For example, the logic device first records the first physical address in the current access range. After the SPI slave device returns a response message, the /CS pin signal of the SPI master device is not pulled high, then the logic device adds one to the first physical address. , obtain a new access address, and compare the new access address with the physical address located at the last position in the access range, that is, the maximum address of the access range.
若新地址大于访问区间的最大地址,则逻辑器件拉高SPI从设备端的/CS信号,阻断后续访问。同时在SPI主设备端,逻辑器件返回一个虚假的应答信息,例如无效值0xFF;当SPI主设备收到无效值0xFF时,拉高 CPU端的/CS信号,并向SPI从设备发送终止访问信号;直到CPU端的/CS信号重新被拉低,使/CS引脚的信号重新使能,从而开始新一轮的SPI主设备对SPI从设备的访问。If the new address is greater than the maximum address of the access range, the logic device will pull up the /CS signal of the SPI slave device to block subsequent accesses. At the same time, on the SPI master side, the logic device returns a false response message, such as an invalid value of 0xFF; when the SPI master device receives an invalid value of 0xFF, it pulls up the /CS signal on the CPU side and sends a termination access signal to the SPI slave device; Until the /CS signal on the CPU side is pulled low again, the signal of the /CS pin is re-enabled, thereby starting a new round of access from the SPI master to the SPI slave.
进一步地,逻辑器件还用于在SPI主设备与访问区间之间建立通信连接时,在SPI主设备对访问区间进行访问之前,将SPI从设备中除访问区间之外的存储区间设置为即写保护状态。Further, when the logic device is also used to establish a communication connection between the SPI master device and the access interval, before the SPI master device accesses the access interval, the storage interval other than the access interval in the SPI slave device is set to write immediately. protection status.
由于SPI Flash还具有Chip Erase(芯片擦除)功能,SPI主设备向SPI Flash发送“Chip Erase”命令即可将SPI从设备中整个存储空间内的数据全部擦除,包括当前的访问区间之外的存储区间。因此,逻辑器件需要阻断Chip Erase功能,以避免未被访问的存储区间中的数据被擦除。Since the SPI Flash also has the Chip Erase function, the SPI master device can send the "Chip Erase" command to the SPI Flash to erase all the data in the entire storage space of the SPI slave device, including outside the current access interval storage area. Therefore, logic devices need to block the Chip Erase function to avoid erasing the data in the memory areas that are not accessed.
具体地,当SPI Flash的某一个Block(块)被设置为“Protected”(即写保护)时,“Chip Erase”命令将不会被执行。Specifically, when a certain Block of the SPI Flash is set to "Protected" (ie write protection), the "Chip Erase" command will not be executed.
为实现阻断芯片擦除操作,CPLD在CPU访问SPI Flash前,首先初始化SPI Flash,将当前访问区间之外的存储区间内的任一Block设置为“Protected”状态,并将SPI Flash端的/WP(Write Protect)拉低,防止该“Protected”状态下的Block被重置。当CPU开始访问SPI Flash时,由于“Protected”状态的Block的存在且属性无法被修改,即使发送了“Chip Erase”命令也会被SPI Flash拒绝执行,从而保护当前非访问射区间的数据安全。In order to block the chip erase operation, before the CPU accesses the SPI Flash, the CPLD first initializes the SPI Flash, sets any block in the storage area outside the current access interval to the "Protected" state, and sets the /WP of the SPI Flash side to the "Protected" state. (Write Protect) is pulled low to prevent the Block in this "Protected" state from being reset. When the CPU starts to access the SPI Flash, due to the existence of the Block in the "Protected" state and the properties cannot be modified, even if the "Chip Erase" command is sent, the SPI Flash will refuse to execute it, thus protecting the data security of the current non-access shot interval.
基于前述实施例,本发明实施例还提供了一种计算设备,包括:Based on the foregoing embodiments, an embodiment of the present invention further provides a computing device, including:
存储器,用于存储程序指令;memory for storing program instructions;
处理器,用于调用存储器中存储的程序指令,按照获得的程序执行如上实施例提供的SPI访问控制方法。The processor is configured to call the program instructions stored in the memory, and execute the SPI access control method provided by the above embodiment according to the obtained program.
基于前述实施例,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行计算机可读指令时,使得计算机执行如上实施例提供的SPI访问控制方法。Based on the foregoing embodiments, the embodiments of the present invention further provide a computer-readable non-volatile storage medium, including computer-readable instructions, when the computer reads and executes the computer-readable instructions, the computer is made to execute the above embodiments. SPI access control method.
综上,本发明提供的SPI访问控制技术,能够将一颗大容量的SPI存储设备虚拟成多个容量较小且彼此之间相互隔离的存储设备,具有如下优势:To sum up, the SPI access control technology provided by the present invention can virtualize a large-capacity SPI storage device into multiple storage devices with smaller capacities and isolated from each other, and has the following advantages:
1)节省成本。在成本上一颗16MB容量的SPI ROM依然较2颗8MB容量的SPI ROM更为便宜,因此单个SPI ROM的设计能够降低成本。1) Save cost. In terms of cost, a 16MB SPI ROM is still cheaper than two 8MB SPI ROMs, so the design of a single SPI ROM can reduce the cost.
2)节省空间。对于一些小板卡型的系统设计,空间往往是制约其部件选型的关键。单颗SPI ROM的设计能够为系统布局提供更多空间选择。2) Save space. For some small board-type system designs, space is often the key to restricting the selection of its components. The design of a single SPI ROM can provide more space options for system layout.
3)有效利用剩余空间。独立使用的单颗SPI ROM在存储数据时往往不能将剩余容量完全用完,造成浪费;若将单颗SPI ROM划分为多个存储空间,则能够有效利用这部分的剩余容量,从而有效利用剩余空间。3) Effective use of the remaining space. A single SPI ROM that is used independently often cannot use up the remaining capacity completely when storing data, resulting in waste; if a single SPI ROM is divided into multiple storage spaces, the remaining capacity of this part can be effectively used, so as to effectively use the remaining capacity. space.
4)增加灵活性。由于存储区间是通过分割单个SPI从设备的存储空间虚得到的,因此能够根据需求动态调整存储区间的划分,为灵活的系统设计增加更多可能。4) Increase flexibility. Since the storage area is obtained by dividing the storage space of a single SPI slave device, the division of the storage area can be dynamically adjusted according to requirements, adding more possibilities for flexible system design.
本申请中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的方法而言,由于其与实施例公开的系统相对应,所以描述的比较简单,相关之处参见系统部分说明即可。The various embodiments in this application are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments may be referred to each other. For the method disclosed in the embodiment, since it corresponds to the system disclosed in the embodiment, the description is relatively simple, and the relevant part can be referred to the description of the system.
还需说明的是,在本申请文件中,诸如“第一”和“第二”之类的关系术语,仅仅用来将一个实体或者操作与另一个实体或者操作区分开来,而不一定要求或者暗示这些实体或者操作之间存在任何这种实际的关系或者顺序。此外,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、系统、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、系统、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、系统、物品或者设备中还存在另外的相同要素。It should also be noted that, in this application document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require Or imply that there is any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, system, article or device comprising a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, system, article or equipment. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, system, article, or device that includes the element.
以上对本申请所提供的技术方案进行了详细介绍。本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的系统及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请权利要求的保护范围内。The technical solutions provided by the present application have been introduced in detail above. The principles and implementations of the present application are described herein by using specific examples, and the descriptions of the above embodiments are only used to help understand the system and its core ideas of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the principles of the present application, several improvements and modifications can also be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims (10)
- 一种SPI访问控制方法,其特征在于,应用于SPI主设备对SPI从设备的访问,所述SPI从设备的存储空间至少划分成两个存储区间;An SPI access control method, characterized in that, it is applied to the access of the SPI slave device by the SPI master device, and the storage space of the SPI slave device is at least divided into two storage sections;所述SPI访问控制方法包括:The SPI access control method includes:在所述SPI主设备请求访问所述SPI从设备时,截获所述SPI主设备向所述SPI从设备发送的访问信号;所述访问信号包括逻辑地址和信号来源标志;When the SPI master device requests to access the SPI slave device, intercept the access signal sent by the SPI master device to the SPI slave device; the access signal includes a logical address and a signal source flag;依据所述信号来源标志修改所述逻辑地址,将所述SPI主设备对所述SPI从设备的访问请求,映射至与修改后的逻辑地址对应的存储区间;Modifying the logical address according to the signal source sign, mapping the access request of the SPI master device to the SPI slave device to a storage section corresponding to the modified logical address;将修改后的逻辑地址对应的存储区间作为访问区间,使所述SPI主设备与所述访问区间之间建立通信连接。The storage interval corresponding to the modified logical address is used as an access interval, so that a communication connection is established between the SPI master device and the access interval.
- 根据权利要求1所述的SPI访问控制方法,其特征在于,每个所述存储区间分别包括多个物理地址;SPI access control method according to claim 1, is characterized in that, each described storage interval comprises a plurality of physical addresses respectively;所述使SPI主设备与所述访问区间之间建立通信连接,包括:The described setting up communication connection between the SPI master device and the access interval includes:获取所述访问区间中的所述多个物理地址;obtaining the plurality of physical addresses in the access interval;将所述多个物理地址依次作为访问对象进行访问,直至截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止所述访问。The multiple physical addresses are sequentially accessed as access objects, and the access is stopped until the access termination signal sent by the SPI master device to the SPI slave device is intercepted.
- 根据权利要求2所述的SPI访问控制方法,其特征在于,所述将所述多个物理地址依次作为访问对象进行访问,包括:The SPI access control method according to claim 2, wherein the accessing the multiple physical addresses as access objects in turn comprises:以所述访问区间中位于首位的物理地址作为首个访问对象;Taking the physical address at the first position in the access interval as the first access object;比较所述当前访问的物理地址和所述访问区间中位于末位的物理地址;Compare the physical address of the current access and the physical address at the last position in the access interval;若所述当前访问的物理地址小于或等于所述访问区间中位于末位的物理地址,接收所述访问对象返回的应答信息,将所述应答信息转发至所述SPI主设备,并对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一访问对象继续访问。If the currently accessed physical address is less than or equal to the physical address at the end of the access interval, receive the response information returned by the access object, forward the response information to the SPI master device, and respond to the current access The physical address is additionally calculated, and the calculated physical address is used as the next access object to continue accessing.
- 根据权利要求3所述的SPI访问控制方法,其特征在于,所述将所述多个物理地址依次作为访问对象进行访问,还包括:The SPI access control method according to claim 3, wherein the accessing the multiple physical addresses as access objects in turn, further comprising:若所述当前访问的物理地址大于所述访问区间中位于末位的物理地 址,向所述SPI主设备发送预设的虚假应答信息,使所述SPI主设备向所述SPI从设备发送终止访问信号;If the currently accessed physical address is greater than the physical address at the last position in the access interval, send a preset false response message to the SPI master device, so that the SPI master device sends the SPI slave device to terminate the access Signal;当截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止将当前访问对象返回的应答信息转发至所述SPI主设备。When intercepting the access termination signal sent by the SPI master device to the SPI slave device, stop forwarding the response information returned by the current access object to the SPI master device.
- 根据权利要求1所述的SPI访问控制方法,其特征在于,在所述SPI主设备请求访问SPI从设备时,还包括:SPI access control method according to claim 1, is characterized in that, when described SPI master device requests to visit SPI slave device, also comprises:将所述SPI从设备中除所述访问区间之外的存储区间设置为即写保护状态。Setting the storage interval other than the access interval in the SPI slave device to a write-protected state.
- 一种SPI访问控制系统,其特征在于,用于实现如权利要求1至5任一项所述的SPI访问控制方法,包括SPI主设备和SPI从设备,所述SPI从设备的存储空间至少划分成两个存储区间,所述SPI主设备与SPI从设备之间通过一逻辑器件桥接;An SPI access control system, characterized in that, for realizing the SPI access control method as described in any one of claims 1 to 5, comprising an SPI master device and an SPI slave device, wherein the storage space of the SPI slave device is at least divided into into two storage sections, the SPI master device and the SPI slave device are bridged by a logic device;所述逻辑器件用于:The logic device is used for:在所述SPI主设备请求访问所述SPI从设备时,截获所述SPI主设备向所述SPI从设备发送的访问信号;所述访问信号包括逻辑地址和信号来源标志;When the SPI master device requests to access the SPI slave device, intercept the access signal sent by the SPI master device to the SPI slave device; the access signal includes a logical address and a signal source flag;依据所述信号来源标志修改所述逻辑地址,使所述SPI主设备对所述SPI从设备的访问请求,映射至与修改后的逻辑地址对应的存储区间;Modifying the logical address according to the signal source sign, so that the access request of the SPI master device to the SPI slave device is mapped to the storage section corresponding to the modified logical address;将修改后的逻辑地址对应的存储区间作为访问区间,并使所述SPI主设备与所述访问区间之间建立通信连接。The storage section corresponding to the modified logical address is used as an access section, and a communication connection is established between the SPI master device and the access section.
- 根据权利要求6所述的SPI访问控制系统,其特征在于,每个所述存储区间分别包括多个物理地址;SPI access control system according to claim 6, is characterized in that, each described storage interval comprises a plurality of physical addresses respectively;所述逻辑器件用于在使所述SPI主设备与所述访问区间之间建立通信连接时:The logic device is used to establish a communication connection between the SPI master device and the access interval:获取所述访问区间中的所述多个物理地址;obtaining the plurality of physical addresses in the access interval;以所述访问区间中位于首位的物理地址作为首个访问对象,对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一个访问对象;Taking the physical address at the first position in the access interval as the first access object, additionally calculate the physical address of the current access, and use the calculated physical address as the next access object;将所述多个物理地址依次作为访问对象进行访问,直至截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止所述访问;The multiple physical addresses are successively accessed as access objects, and the access is stopped until the terminating access signal sent by the SPI master device to the SPI slave device is intercepted;所述将所述多个物理地址依次作为访问对象进行访问,包括:The accessing the multiple physical addresses as access objects in sequence includes:以所述访问区间中位于首位的物理地址作为首个访问对象;Taking the physical address at the first position in the access interval as the first access object;比较所述当前访问的物理地址和所述访问区间中位于末位的物理地址;Compare the physical address of the current access and the physical address at the last position in the access interval;若所述当前访问的物理地址小于或等于所述访问区间中位于末位的物理地址,接收所述访问对象返回的应答信息,将所述应答信息转发至所述SPI主设备,并对当前访问的物理地址进行附加计算,将计算所得的物理地址作为下一访问对象继续访问;If the currently accessed physical address is less than or equal to the physical address at the end of the access interval, receive the response information returned by the access object, forward the response information to the SPI master device, and respond to the current access The physical address is additionally calculated, and the calculated physical address is used as the next access object to continue access;若所述当前访问的物理地址大于所述访问区间中位于末位的物理地址,向所述SPI主设备发送预设的虚假应答信息,使所述SPI主设备向所述SPI从设备发送终止访问信号;If the currently accessed physical address is greater than the physical address at the last position in the access interval, send a preset false response message to the SPI master device, so that the SPI master device sends the SPI slave device to terminate the access Signal;当截获到所述SPI主设备向SPI从设备发送的终止访问信号时,停止将当前访问对象返回的应答信息转发至所述SPI主设备。When intercepting the access termination signal sent by the SPI master device to the SPI slave device, stop forwarding the response information returned by the current access object to the SPI master device.
- 根据权利要求6所述的SPI访问控制系统,其特征在于,所述逻辑器件还用于在所述SPI主设备与所述访问区间之间建立通信连接时:The SPI access control system according to claim 6, wherein the logic device is further used to establish a communication connection between the SPI master device and the access interval:将所述SPI从设备中除所述访问区间之外的存储区间设置为即写保护状态。Setting the storage interval other than the access interval in the SPI slave device to a write-protected state.
- 一种计算设备,其特征在于,包括:A computing device, comprising:存储器,用于存储程序指令;memory for storing program instructions;处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行权利要求1至5任一项所述的SPI访问控制方法。The processor is configured to call the program instructions stored in the memory, and execute the SPI access control method according to any one of claims 1 to 5 according to the obtained program.
- 一种计算机可读非易失性存储介质,其特征在于,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行如权利要求1至5任一项所述的SPI访问控制方法。A computer-readable non-volatile storage medium, characterized by comprising computer-readable instructions, when the computer reads and executes the computer-readable instructions, the computer is made to execute any one of claims 1 to 5. SPI access control method.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110474343.1A CN113127402B (en) | 2021-04-29 | 2021-04-29 | SPI access control method, system, computing device and storage medium |
CN202110474343.1 | 2021-04-29 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022227473A1 true WO2022227473A1 (en) | 2022-11-03 |
Family
ID=76780532
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/128632 WO2022227473A1 (en) | 2021-04-29 | 2021-11-04 | Spi access control method and system, and computing device and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113127402B (en) |
WO (1) | WO2022227473A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116610631A (en) * | 2023-07-21 | 2023-08-18 | 西安智多晶微电子有限公司 | FPGA (field programmable Gate array) starting configuration method supporting multi-SPI Flash access |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113127402B (en) * | 2021-04-29 | 2024-05-14 | 广东湾区智能终端工业设计研究院有限公司 | SPI access control method, system, computing device and storage medium |
CN113775936B (en) * | 2021-08-18 | 2023-10-24 | 国家管网集团大连液化天然气有限公司 | Multi-main acquisition method for LNG receiving station auxiliary system |
CN115576499A (en) * | 2022-11-10 | 2023-01-06 | 广州翼辉信息技术有限公司 | Flash security enhancing method for real-time system access and access thereof |
CN118590344A (en) * | 2024-08-06 | 2024-09-03 | 上海芯炽科技集团有限公司 | Method for accessing all I2C slave devices in A-PHY system |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104461401A (en) * | 2014-12-25 | 2015-03-25 | 珠海煌荣集成电路科技有限公司 | Data reading and writing management method and device for SPI flash memory |
CN105353989A (en) * | 2015-11-19 | 2016-02-24 | 华为技术有限公司 | Stored data access method, related controller, device, mainframe and system |
CN111966611A (en) * | 2020-08-03 | 2020-11-20 | 南京扬贺扬微电子科技有限公司 | SPI flash memory control chip with logic-to-physical address architecture |
CN113127402A (en) * | 2021-04-29 | 2021-07-16 | 广东湾区智能终端工业设计研究院有限公司 | SPI (Serial peripheral interface) access control method, system, computing equipment and storage medium |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4990505B2 (en) * | 2005-04-04 | 2012-08-01 | 株式会社日立製作所 | Storage control device and storage system |
CN100580642C (en) * | 2006-02-28 | 2010-01-13 | 国际商业机器公司 | Universal serial bus storage device and access control method thereof |
JP2010009454A (en) * | 2008-06-30 | 2010-01-14 | Toshiba Corp | Information processing apparatus |
CN102789435B (en) * | 2012-07-02 | 2015-05-06 | 华为技术有限公司 | Serial storage and method and system for dividing storage regions |
KR20150000543A (en) * | 2013-06-24 | 2015-01-05 | 에스케이하이닉스 주식회사 | Semiconductor memory device and memory system including the same |
CN104809420B (en) * | 2014-01-28 | 2018-06-12 | 上海复旦微电子集团股份有限公司 | Device with store function |
US10635596B2 (en) * | 2015-10-02 | 2020-04-28 | Sony Interactive Entertainment Inc. | Information processing device, access controller, information processing method, and computer program for accessing memory having access units of different sizes |
CN105468563B (en) * | 2015-12-28 | 2018-06-01 | 杭州士兰控股有限公司 | SPI slave devices, SPI communication system and SPI communication method |
KR102458918B1 (en) * | 2016-02-24 | 2022-10-25 | 삼성전자주식회사 | Memory device and Memory system |
CN108268380A (en) * | 2016-12-30 | 2018-07-10 | 北京兆易创新科技股份有限公司 | A kind of method and apparatus for reading and writing data |
CN106897635A (en) * | 2017-02-28 | 2017-06-27 | 广东虹勤通讯技术有限公司 | Movable memory equipment and its operating method |
US10929309B2 (en) * | 2017-12-19 | 2021-02-23 | Western Digital Technologies, Inc. | Direct host access to storage device memory space |
-
2021
- 2021-04-29 CN CN202110474343.1A patent/CN113127402B/en active Active
- 2021-11-04 WO PCT/CN2021/128632 patent/WO2022227473A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104461401A (en) * | 2014-12-25 | 2015-03-25 | 珠海煌荣集成电路科技有限公司 | Data reading and writing management method and device for SPI flash memory |
CN105353989A (en) * | 2015-11-19 | 2016-02-24 | 华为技术有限公司 | Stored data access method, related controller, device, mainframe and system |
CN111966611A (en) * | 2020-08-03 | 2020-11-20 | 南京扬贺扬微电子科技有限公司 | SPI flash memory control chip with logic-to-physical address architecture |
CN113127402A (en) * | 2021-04-29 | 2021-07-16 | 广东湾区智能终端工业设计研究院有限公司 | SPI (Serial peripheral interface) access control method, system, computing equipment and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116610631A (en) * | 2023-07-21 | 2023-08-18 | 西安智多晶微电子有限公司 | FPGA (field programmable Gate array) starting configuration method supporting multi-SPI Flash access |
CN116610631B (en) * | 2023-07-21 | 2023-09-26 | 西安智多晶微电子有限公司 | FPGA (field programmable Gate array) starting configuration method supporting multi-SPI Flash access |
Also Published As
Publication number | Publication date |
---|---|
CN113127402B (en) | 2024-05-14 |
CN113127402A (en) | 2021-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022227473A1 (en) | Spi access control method and system, and computing device and storage medium | |
US7657696B2 (en) | Method to detect NAND-flash parameters by hardware automatically | |
RU2442211C2 (en) | Hybrid memory device with a single interface | |
US7296143B2 (en) | Method and system for loading processor boot code from serial flash memory | |
CN114974374B (en) | Serial nand flash memory with on-chip execution capability | |
US5548730A (en) | Intelligent bus bridge for input/output subsystems in a computer system | |
JP5085334B2 (en) | USB / OTG controller | |
CN114020655A (en) | Memory expansion method, device, equipment and storage medium | |
US8037228B2 (en) | Bridge device with page-access based processor interface | |
CN115858431B (en) | Data transmission control method, controller and electronic equipment | |
KR100847968B1 (en) | Dual-port semiconductor memories | |
JPH11167544A (en) | Pcmcia card and programming method thereof | |
JP6710219B2 (en) | DRAM circuit with integrated processor | |
US20020013880A1 (en) | Integrated circuit with flash bridge and autoload | |
EP0595960A4 (en) | Computer workstation expansion chassis | |
US20080010419A1 (en) | System and Method for Issuing Commands | |
CN115203101A (en) | PCIe device and operating method thereof | |
CN106919343A (en) | Perimeter interface circuit and Perimeter memory system | |
US6633927B1 (en) | Device and method to minimize data latency and maximize data throughput using multiple data valid signals | |
CN110795373B (en) | I2C bus-to-parallel bus conversion method, terminal and storage medium | |
US6622244B1 (en) | Booting from a reprogrammable memory on an unconfigured bus by modifying boot device address | |
CN116107697B (en) | Method and system for communication between different operating systems | |
CN110750476B (en) | Bridging method, device, system and medium of SPI bus and parallel bus | |
CN109726149B (en) | Method and device for accessing NAND FLASH through AXI bus | |
CN113010236A (en) | Program execution method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21938935 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 21938935 Country of ref document: EP Kind code of ref document: A1 |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 07.05.2024) |