A method for recovering from abnormal states of a serial memory and quickly entering the target mode.

By sending a specific timing sequence to force the serial memory to exit XIP mode, resetting the state machine and encoding the target mode, the mode recognition problem of SPI NorFlash in the event of NVCR abnormality is solved, and fast and reliable mode recovery is achieved.

CN123068341APending Publication Date: 2026-11-10HUNAN RONGCHUANG MICROELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611598101.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-15
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

When the NVCR value is abnormal, SPI NorFlash cannot recognize the host's instructions, causing it to enter an unknown mode. Existing solutions are cumbersome and time-consuming, and cannot effectively restore it to the specified mode.

Method used

The serial memory is forced to exit XIP mode by sending a specific timing sequence from the host, the internal state machine is reset and set to standard SPI mode, and the target working mode is uniquely encoded by the number of odd clock pulses.

Benefits of technology

It directly solves the instruction blind spot problem in XIP mode, bypasses the influence of non-volatile configuration registers, quickly restores to the target mode, simplifies the configuration process, and shortens the recovery time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123068341A_ABST
    Figure CN123068341A_ABST
Patent Text Reader

Abstract

This application relates to a method for recovering from abnormal states of a serial memory and quickly entering a target mode. The method includes: a first operation, in which the host sends a first timing sequence to the serial memory to forcibly exit the Immediately Executable (XIP) mode; a second operation, after the first operation is completed, sending a second timing sequence to forcibly reset the internal state machine and set it to standard serial peripheral interface mode; and a third operation, after the second operation is completed, sending a third timing sequence containing an odd number of clock pulses to automatically configure the target operating mode by counting the number of clock pulses. This method can reliably restore the chip to a known basic mode and quickly configure it to the target mode regardless of the chip's current state, achieving highly reliable and efficient forced reset and rapid configuration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of semiconductor memory technology, and in particular to a method for recovering from abnormal states of a serial memory and quickly entering a target mode. Background Technology

[0002] Serial Peripheral Interface (SPI) NorFlash is widely used in embedded systems. The SPI protocol has evolved from the initial standard SPI mode to multiplexed SPI modes, introducing Double Data Rate (DTR) mode and Execute in Place (XIP) mode to improve data transmission efficiency. Instructions have been expanded from a three-address mode to a four-address mode to increase the addressing space. Modern SPI NorFlash modes are configured through its configuration registers, which are divided into volatile configuration registers and non-volatile configuration registers (NVCRs). After an SPI NorFlash reset, the configuration in the NVCR is loaded as the initial operating mode. Modifications to the volatile configuration registers by the host immediately apply to the specified operating mode.

[0003] However, this flexible mode configuration mechanism brings serious problems. When the NVCR value is abnormal, even after a hard reset or power-on reset, the chip will still load an unknown configuration and enter an unknown mode after restarting. There are several reasons for abnormal NVCR values, such as abnormal interruption of the write NVCR operation or the NVCR bit being flipped.

[0004] When SPI NorFlash is in unknown mode, it will not correctly recognize commands sent by the master according to the established mode protocol. For example, in XIP mode, it will not parse commands sent by the master; in slave standard SPI mode, it will not recognize Quad SPI timing sent by the master; and in slave STR mode, it will not recognize DTR mode timing sent by the master.

[0005] Existing solutions, such as attempting to "wake up" the chip by traversing all possible mode combinations, are cumbersome and time-consuming; conventional resets are ineffective when the NVCR is damaged. Therefore, there is an urgent need for a reliable method that can force the chip back to a specified mode. Summary of the Invention

[0006] Therefore, it is necessary to propose a method for recovering from abnormal states of a serial memory and quickly entering the target mode, addressing the aforementioned technical problems. The method includes: First operation: The host sends a first timing sequence to the serial memory. The first timing sequence is used to force the serial memory to exit XIP mode. Second operation: After the first operation is completed, the host sends a second timing sequence to the serial memory. The second timing sequence is used to force a reset of the internal state machine of the serial memory and set the communication mode of the serial memory to the standard serial peripheral interface mode. The third operation: After the second operation is completed, the host sends a third timing sequence to the serial memory. The third timing sequence contains N clock pulses. The number of clock pulses is used to uniquely encode a set of target operating modes. The serial memory automatically configures itself to the target operating mode by counting the number of clock pulses.

[0007] The advantages of the above-mentioned method for recovering from abnormal states of a serial memory and quickly entering the target mode are as follows: In the first operation, the host sends the first timing sequence to the serial memory to force exit XIP mode. This method directly eliminates the most troublesome obstacle of the chip being in the instruction blind zone, so that all subsequent operations can be correctly parsed by the chip, thus solving the technical problem that regular instructions cannot be sent in XIP mode.

[0008] The second operation sends a second timing sequence to force a reset of the internal state machine and set it to standard SPI mode after the first operation is completed. This means that the reset instruction does not depend on the chip's current busy flag, thus enabling it to bypass programming or erase the dead state of the state machine. At the same time, this operation bypasses the SPI interface protocol and directly sets the working mode to standard SPI basic mode, exiting the unexpected working mode and avoiding loading configuration from potentially abnormal registers. The third operation, following the completion of the second operation, sends a third timing sequence containing an odd number of clock pulses. The target operating mode is uniquely encoded by the number of pulses and automatically configured by the chip. This method compresses the complex configuration process, which originally required multiple register writes, into a single timing sequence, significantly reducing recovery time. This application can handle various complex fault scenarios such as configuration register bit flips, configuration register corruption, and state machine freezes, forcibly recovering from any unknown state and quickly configuring to the target mode. Furthermore, the host only needs to implement a simple timing generator to complete all operations, without requiring complex protocol stack support. Attached Figure Description

[0009] Figure 1 This is a flowchart illustrating a method for recovering from an abnormal state of a serial memory and quickly entering a target mode in one embodiment. Figure 2 This is a flowchart illustrating the first and second operations in one embodiment; Figure 3 This is a flowchart illustrating the third operation in one embodiment; Figure 4 This is a logic block diagram of the chip's internal components used to implement the method in another embodiment; Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0010] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0011] In one embodiment, such as Figure 1 As shown, a method for recovering from an abnormal state of a serial memory and quickly entering a target mode is provided, including the following steps: Step 102, First operation: The host sends a first timing sequence to the serial memory. The first timing sequence is used to force the serial memory to exit XIP mode.

[0012] Step 104, Second operation: After the first operation is completed, the host sends a second timing sequence to the serial memory. The second timing sequence is used to force a reset of the internal state machine of the serial memory and set the communication mode of the serial memory to the standard serial peripheral interface mode.

[0013] Step 106, Third Operation: After the second operation is completed, the host sends a third timing sequence to the serial memory. The third timing sequence contains N clock pulses. The number of clock pulses is used to uniquely encode a set of target operating modes. The serial memory automatically configures itself to the target operating mode by counting the number of odd-numbered clock pulses.

[0014] In one embodiment, the first timing sequence includes: the host pulls the CS# pin low, pulls all DQ pins high, then sends a first preset number of clock pulses to the SCLK pin, and finally pulls the CS# pin high; The second timing sequence includes: the host pulls the CS# pin low, pulls all DQ pins high, then sends a second preset number of clock pulses to the SCLK pin, and finally pulls the CS# pin high; The third timing sequence includes: the host pulls the CS# pin low, pulls the DQ0 and DQ3 pins high, then sends a third preset number of clock pulses to the SCLK pin, and finally pulls the CS# pin high.

[0015] In one embodiment, such as Figure 2 As shown, both the first and second preset quantities are even numbers.

[0016] Specifically, the first preset quantity and the second preset quantity can be selected as 64 as the specific implementation value, which satisfies both the requirement of covering the Xb bits of XIP and the number of clock cycles as an integer multiple of the byte, making it convenient for the host to generate.

[0017] In one embodiment, such as Figure 3 As shown, in the third operation, the host pulls DQ3 and DQ0 high before sending the third timing sequence.

[0018] Specifically, DQ3 is used as the HOLD# or RESET# function pin in some SPI modes. Pulling DQ3 high can prevent these functions from being triggered accidentally, which is an important prerequisite for ensuring the reliable execution of the third operation.

[0019] There is a preset mapping relationship between the number of odd-numbered clock pulses and the target operating mode. The mapping relationship includes at least the following: The first odd number corresponds to: 3-byte address, standard serial peripheral interface, and single data rate mode; The second odd number corresponds to: 3-byte address, standard serial peripheral interface, and double data rate mode; The third odd number corresponds to: 3-byte address, dual-channel serial peripheral interface, and single data rate mode; The fourth odd number corresponds to: 3-byte address, dual-channel serial peripheral interface, and double data rate mode; The fifth odd number corresponds to: 3-byte address, four serial peripheral interfaces, and single data rate mode; The sixth odd number corresponds to: 3-byte address, four serial peripheral interfaces, and double data rate mode; The seventh odd number corresponds to: 3-byte address, XIP mode, standard serial peripheral interface, and single data rate mode; The eighth odd number corresponds to: 4-byte address, standard serial peripheral interface, and single data rate mode; Among them, the number of time sequences mapped to each working mode is different from each other.

[0020] Specifically, through this mapping table, the chip can uniquely determine the target mode combination based on the number of odd clock pulses received. This mechanism compresses the traditional multi-step register configuration process into a single timing sequence, greatly improving configuration efficiency. The mapping relationship can be extended to more modes according to actual needs, such as eight-channel SPI, different empty cycle lengths, etc.

[0021] In one embodiment, the number of odd numbers in the preset mapping relationship is 9 for the first odd number, 11 for the second odd number, 13 for the third odd number, 15 for the fourth odd number, 17 for the fifth odd number, 19 for the sixth odd number, 21 for the seventh odd number, and 33 for the eighth odd number.

[0022] Specifically, the choice of these odd numbers ensures sufficient spacing (at least 2) between the mode codes, allowing for reliable differentiation by the clock counter. 33 corresponds to the 4-byte address mode, maintaining a clear distinction from the 3-byte address modes such as 21. Other unlisted odd numbers (23, 25, 27, 29, 31, etc.) can be further extended to map to more combinations; for example, 23 corresponds to 3-byte address + XIP + standard SPI + DTR, 25 corresponds to 3-byte address + XIP + DualSPI + STR, etc., until all required mode combinations are covered.

[0023] In one embodiment, the second timing sequence is recognized by the serial memory, independent of the serial memory's internal busy flag, and can directly reset the internal state machine and volatile configuration register when the busy flag is valid, without initialization configuration.

[0024] Specifically, the second timing sequence is recognized by the serial memory as a high-priority reset and set instruction. The execution of this instruction does not depend on the internal busy flag of the serial memory. It can directly reset the internal state machine and set it to the standard serial peripheral interface mode when the busy flag is valid.

[0025] Traditional soft reset instructions (66h+99h) typically require waiting for the busy bit to be cleared before taking effect. However, the second timing sequence in this method has a higher priority and can bypass the busy state of the programming or erasing state machine, directly resetting all internal state machines.

[0026] In one embodiment, after a conventional soft reset operation is completed, the operating mode of the serial memory is set by a non-volatile configuration register. However, after the second operation in this method is completed, the operating mode of the serial memory is directly set by the second timing sequence, and is not affected by the non-volatile configuration register.

[0027] Specifically, a conventional reset operation often reloads the configuration in the NVCR. If the NVCR is damaged due to a single-event upset, the chip will still be in error mode after the reset. The forced reset instruction in this method directly sets the chip to the basic mode of standard SPI+STR+3-byte address, completely bypassing the NVCR and exiting the unexpected operating mode.

[0028] like Figure 4 As shown, the technical solution of this application will be described in detail with reference to a specific embodiment.

[0029] An embedded system based on SPI NorFlash unexpectedly enters XIP mode during operation, and its internal programming state machine hangs in a busy state. At this time, the host cannot communicate with the chip via any regular instructions. The recovery process is as follows: First, the first operation is performed: the host controls the Flash's CS# pin to pull low, sets all data lines DQ0-DQ3 to output high, then the host sends 64 clock pulses to the SCLK pin, and finally pulls the CS# pin high. This operation forces the SpinorFlash to exit XIP mode.

[0030] Next, the second operation is performed: the host repeats the same operation as above: pulls the CS# pin low, outputs a high level on DQ0-DQ3 pins, then sends 64 clock pulses to the SCLK pin, and finally pulls the CS# pin high. At this time, the SPI NorFlash internal logic recognizes this sequence as a forced reset instruction, immediately resets all its internal state machines, and simultaneously forces the communication interface to be configured as the standard SPI+STR+3-byte address mode.

[0031] Finally, the third operation is performed (assuming a return to QuadSPI+DTR+4-byte address mode is required): The host first sets DQ3 and DQ0 pins to high level, then pulls the CS# pin low, precisely generating 43 clock pulses on the SCLK pin, and finally pulls the CS# pin high. The internal clock counter of the SPI NorFlash detects the 43 pulses and automatically configures it to 4-byte address+QuadSPI+DTR mode according to the preset mapping table. At this point, the SPI NorFlash has exited the abnormal state and entered the target operating mode.

[0032] It should be understood that, although Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0033] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When executed by the processor, the computer program implements a method for recovering from serial memory exceptions and quickly entering a target mode. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0034] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0035] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM, direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM, etc.

[0036] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0037] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these modifications and improvements all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for recovering from an abnormal state of a serial memory and quickly entering a target mode, characterized in that, The method includes: First operation: The host sends a first timing sequence to the serial memory, the first timing sequence being used to force the serial memory to exit XIP mode; Second operation: After the first operation is completed, the host sends a second timing sequence to the serial memory. The second timing sequence is used to force a reset of the internal state machine of the serial memory and set the communication mode of the serial memory to the standard serial peripheral interface mode. Third operation: After the second operation is completed, the host sends a third timing sequence to the serial memory. The third timing sequence contains N clock pulses. The number of clock pulses is used to uniquely encode a set of target operating modes. The serial memory automatically configures itself to the target operating mode by counting the number of clock pulses.

2. The method according to claim 1, characterized in that, The first timing sequence includes: the host pulls the CS# pin low, pulls all DQ pins high, then sends a first preset number of clock pulses to the SCLK pin, and finally pulls the CS# pin high; the second timing sequence includes: the host pulls the CS# pin low, pulls all DQ pins high, then sends a second preset number of clock pulses to the SCLK pin, and finally pulls the CS# pin high; the third timing sequence includes: the host pulls the CS# pin low, pulls the DQ0 and DQ3 pins high, then sends a third preset number of clock pulses to the SCLK pin, and finally pulls the CS# pin high.

3. The method according to claim 2, characterized in that, The first and second preset quantities are both even numbers, and the third preset quantity is an odd number.

4. The method according to claim 1, characterized in that, There is a preset mapping relationship between the number of timing operations in the third operation and the target working mode, and the preset mapping relationship includes at least: The first odd number corresponds to: 3-byte address, standard serial peripheral interface, and single data rate mode; The second odd number corresponds to: 3-byte address, standard serial peripheral interface, and double data rate mode; The third odd number corresponds to: 3-byte address, dual-channel serial peripheral interface, and single data rate mode; The fourth odd number corresponds to: 3-byte address, dual-channel serial peripheral interface, and double data rate mode; The fifth odd number corresponds to: 3-byte address, four serial peripheral interfaces, and single data rate mode; The sixth odd number corresponds to: 3-byte address, four serial peripheral interfaces, and double data rate mode; The seventh odd number corresponds to: 3-byte address, XIP mode, standard serial peripheral interface, and single data rate mode; The eighth odd number corresponds to: 4-byte address, standard serial peripheral interface, and single data rate mode; Among them, the number of time sequences mapped to each working mode is different from each other.

5. The method according to claim 4, characterized in that, In the preset mapping relationship, the number of the first odd number is 9; the number of the second odd number is 11; the number of the third odd number is 13; the number of the fourth odd number is 15; the number of the fifth odd number is 17; the number of the sixth odd number is 19; the number of the seventh odd number is 21; and the number of the eighth odd number is 33. The preset mapping relationship is one-to-one and includes, but is not limited to, these eight types.

6. The method according to claim 1, characterized in that, The second timing sequence is recognized by the serial memory, and does not depend on the internal busy flag of the serial memory. It can directly reset the internal state machine and volatile configuration register when the busy flag is valid, without performing initialization configuration.

7. The method according to claim 1, characterized in that, After the second operation is completed, the operating mode of the serial memory is directly set by the second timing sequence, without loading the initial configuration from the non-volatile configuration register.