A method and system for mounting files and running image firmware on an external QSPI Flash.

By combining the LITTLEFS file system and XIP method with the SWD download protocol and burning algorithm, the problem that external Flash file systems cannot simultaneously mount the file system and run image firmware is solved, achieving efficient, secure, and stable operation of the file system and image firmware.

CN117251408BActive Publication Date: 2026-06-02ZHEJIANG LIERDA INTERNET OF THINGS TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG LIERDA INTERNET OF THINGS TECH
Filing Date
2023-05-06
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing external flash file systems cannot simultaneously mount the file system and run the image firmware, resulting in instability, low efficiency, and poor security, thus hindering their widespread commercial use.

Method used

Using the LITTLEFS file system and XIP method, the image firmware upgrade is detected through the SWD download protocol interface. Combined with the burning algorithm and error branch handling, the file system can be mounted and the image firmware can be run.

Benefits of technology

It achieves high reliability, good security, high integration, stable operation, improved efficiency, and simple design in the file system and image firmware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117251408B_ABST
    Figure CN117251408B_ABST
Patent Text Reader

Abstract

The application discloses a kind of external QSPI Flash mounting file and the method and system of running image firmware, method includes: initialization QSPI Flash, mount file system, run image firmware, judge whether there is upgrade image firmware occurs, wherein, file system is LITTLEFS file system, image firmware is based on XIP method;System includes: processor and the QSPI Flash connected with processor, wherein, processor and QSPI Flash are connected by six-line QSPI circuit interface.The beneficial effects of the present application are that the file system and the image firmware can be mounted and run simultaneously, enriching the embedded firmware and file existence form;Using 6-line QSPI Flash+memory mapping access improves the rate, and is more efficient;Using authentication method, it is not easy to be disturbed, and is more secure;Built-in error branch processing unit, more stable operation;Processor+QSPI Flash system integration is high, and the design is simple.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage systems, and in particular to a method and system for mounting files and running image firmware on an external QSPI Flash. Background Technology

[0002] With the rapid development of the Internet of Things (IoT), the types of IoT products and applications are increasing. Using a cellular module alone (with limited built-in Flash space) cannot fully support a complete industry application. For example, in OpenCPU development, if it needs to support offline text-to-speech (TTS) and over-the-air (FOTA) upgrades, as well as the essential IoT mainstream HTTPS, MQTTS, and FTPS communication protocols, and reserve space as required by the customer, the built-in Flash space will be insufficient. The solution to this problem of limited built-in Flash space in current OpenCPU-based industry applications is to reduce costs and increase efficiency. This can be achieved by either streamlining some functions and optimizing code space, or by using external Flash. External QSPI (Quad Serial Peripheral Interface) Flash, which mounts a file system and runs a firmware image, can greatly enrich embedded firmware and file distribution, increase device firmware capacity and speed up file access, and optimize memory consumption. It is widely applicable to scenarios where the chip's built-in Flash space is limited. However, the industry currently does not support mounting a file system and running a firmware image simultaneously on external Flash. Even if it were supported, there are still problems such as instability (abnormal crashes), low efficiency (Flash read / write timeouts), and insecurity (susceptibility to interference) that need to be addressed, preventing its commercialization.

[0003] Chinese patent document CN102880553B, published on September 16, 2015, discloses a read / write method for an off-chip FLASH file system based on an MCU. It adds a logical translation layer between the off-chip FLASH file system and the FLASH driver layer. This logical translation layer divides a physical sector into several regions of equal size to the logical sector and assigns them serial numbers. By performing a conversion between logical sectors and physical addresses, it solves the problem of inconsistency between the logical sector and the actual physical sector size, thereby enabling the file system to read and write FLASH physical sectors.

[0004] The disadvantages of the above-mentioned off-chip FLASH file system read / write method are: it simply implements file system read / write operations on Flash, but it uses a logic translation layer method. Although it occupies less RAM resources in the MCU, it is unstable and relatively inefficient, easily interfered with, and it only implements simple file system read / write, and cannot run image firmware. Summary of the Invention

[0005] The purpose of this invention is to solve the problem that existing external Flash file systems cannot simultaneously mount the file system and run image firmware. It provides a method and system for mounting files and running image firmware on an external QSPI Flash, which can simultaneously mount the file system and run image firmware. It has the advantages of high reliability, good security, high integration and simple design and development, thus improving the customer experience.

[0006] The technical solution adopted by this invention to solve the above-mentioned technical problems is as follows: Firstly, a method for mounting files and running image firmware on an external QSPI Flash, comprising the following steps: initializing the QSPI Flash; mounting the file system; running the image firmware; detecting whether the image firmware has been upgraded; wherein the file system is a LITTLEFS file system, the image firmware is based on the XIP method, and the method detects whether an image firmware upgrade has occurred through the SWD download protocol interface; if an image firmware upgrade has occurred, the burning algorithm is executed; otherwise, the external XIP image firmware is run directly. If the burning is successful, the ROM flag is set, and the external bootloader is entered to restart and run the new App system application firmware.

[0007] Using the technical solution described in the first aspect, it is first necessary to initialize the QSPI Flash, then port the LITTLEFS file system into the QSPI Flash. After the porting is completed, the XIP local program is executed. After running, the SWD protocol interface is used to check if an upgrade image firmware has occurred. If no upgrade is detected, the external XIP image firmware is run directly, which can simultaneously mount the file system and run the image firmware. Otherwise, the burning algorithm is executed. After the burning is completed, the new App system application firmware is restarted and run, which can simultaneously mount the file system and run the image firmware.

[0008] In the first aspect, preferably, mounting the file system includes: creating a LITTLEFS task; configuring the QSPIFlash device; initializing the LITTLEFS component; and performing operations on the files in the LITTLEFS component; wherein the LITTLEFS task is executed in the FreeRTOS multi-tasking real-time operating system. If initializing the LITTLEFS component fails, parameter formatting is performed once, and a remount attempt is made. If the remount is successful, the process proceeds to the next step; otherwise, the entire process exits. Remounting is a process of remounting the file system using the system's default parameters. The error branch handling unit allows for the resolution of system errors and other anomalies, improving the overall system stability.

[0009] In the first aspect, preferably, running the image firmware includes: booting into the external bootloader; initializing the external QSPI Flash device; configuring the QSPI data transmission mode; determining whether the ROM flag indicates boot or transfer and performing corresponding processing; remapping the interrupt vector table after entering the App; and initializing CPU resource parameters and peripherals. The XIP running image firmware requires both the bootloader firmware and the App system application firmware. Configuring the QSPI data transmission mode is primarily for efficient coordination with real-time memory mapping access, transmitting data via four wires, addresses via four wires, and instructions via a single wire within four clock cycles. Remapping the interrupt vector table after entering the App is necessary because the App system application firmware also has interrupt response requirements, which need to be configured beforehand; otherwise, system crashes or other abnormal phenomena may occur. Thus, using memory mapping access improves speed and efficiency, and remapping the interrupt vector table enhances the overall system stability.

[0010] In the first aspect, preferably, the programming algorithm comprises two layers: an upper programming algorithm layer containing the programming process, and a lower peripheral driver layer, primarily a QSPI interface driver. The programming algorithm layer mainly consists of seven functions: Init, UnInit, BlankCheck, EraseChip, EraseSector, ProgramPage, and Verify, corresponding to initializing external Flash, deinitializing external Flash, blank checking, full-chip erasure, sector erasure, page programming, and programming authentication, respectively. The lower peripheral driver layer primarily uses a QSPI six-wire driver interface, with common interfaces including sector erasure, chip erasure, page programming, data read / write, and vendor ID reading. When upgrading the image firmware, the programming algorithm can program new App system application firmware, resulting in more stable operation.

[0011] In the first aspect, preferably, creating a LITTLEFS task includes: defining the required parameters in the task; configuring the QSPI Flash device includes: calling the QSPI initialization interface for initialization, and upon successful initialization, reading the vendor ID of the QSPI Flash; initializing the LITTLEFS component includes: mounting it to the external physical Flash according to the file system configuration parameters. The required parameters defined in the task include task stack space and priority, etc.; initialization in the QSPI Flash device configuration involves clock source, pin, and register mode configuration, etc. This ensures compatibility between the LITTLEFS file system and the QSPI Flash device, which is a prerequisite for the normal operation of the LITTLEFS file system. Parameter settings ensure greater system stability, and reading the vendor ID is for verification, ensuring system security.

[0012] In the first aspect, preferably, booting into the external bootloader includes configuring basic CPU parameters. The corresponding processing is as follows: if it is for startup, it jumps to the external image's base address and starts the App system application; if it is for transfer, it copies the App image backup area, sets the ROM flag, and restarts. The basic CPU parameters mainly configure the main clock source and interrupt source, and the QSPI Flash vendor ID is also read during the initialization of the external QSPI Flash device. The corresponding processing is to better correspond to the function; if copying is required, a restart is performed after copying. The entire function is stable and also more secure.

[0013] In the first aspect, preferably, if the burning algorithm is successful, it will set the ROM flag and enter the external bootloader to restart and run the new App system application firmware; if the burning fails, it will enter a waiting state; if the file system mounting step fails, it will exit the entire process; if the image firmware running step fails, it will also enter a waiting state. To prevent system instability, when an abnormal situation occurs, the error branch processing unit will be executed first. If the error branch processing also fails, it will enter a waiting state to prevent unexpected situations such as system crashes from causing inoperability, thus ensuring system stability.

[0014] The second aspect: A system for mounting files and running image firmware on an external QSPI Flash, applying the method of the first aspect above, includes: a processor, and a QSPI Flash connected to the processor; wherein the processor and the QSPI Flash are connected via a six-wire QSPI circuit interface. The QSPI Flash has six wires, requiring six wires: SCLK, CS, SIO0, SIO1, SIO2, and SIO3.

[0015] Using the technical solution in the second aspect mentioned above, the six-wire QSPI Flash needs to be initialized first, the processor needs to be connected to the six-wire QSPI Flash, then the device driver code needs to be written, then the file system needs to be ported, then the QSPI Flash needs to be partitioned, and then the XIP local program needs to be executed to allow the processor to decode and process the instructions.

[0016] In the second aspect, as a preferred option, the QSPI Flash is divided into several partitions, with the partition space divided according to the minimum page size. Specifically, the entire QSPI Flash space is divided into six partitions based on the minimum page size: Bootloader boot area, configuration information area, image runtime area, file system area, configuration information backup area, and image backup area. This reasonable regional division of the QSPI Flash maximizes its utilization, resulting in high integration and a simple design.

[0017] In the second aspect, as a preferred option, the partitions of the QSPI Flash can be resized. Typically, the file system area and the image backup area need adjustment, which can be reasonably adjusted according to the functional requirements, resulting in more efficient and well-functioning systems.

[0018] This invention discloses a method and system for mounting files and running image firmware on an external QSPI Flash. After connecting the processor to a six-wire QSPI Flash, the LITTLEFS file system is ported, the QSPI Flash is partitioned, and then the XIP local program is executed. After execution, the SWD download protocol interface is used to detect whether an upgrade image firmware has occurred. If no download is detected, the external XIP image firmware is run directly; otherwise, the burning algorithm is executed to download the image firmware. After burning is completed, the new App system application firmware is restarted and run. The processor can then simultaneously mount the file system and run the image firmware.

[0019] The beneficial effects of this invention are that it can simultaneously mount the file system and run the image firmware, enriching the forms of embedded firmware and file existence; it adopts 6-wire QSPI Flash + memory mapping access to improve speed and efficiency; it adopts an authentication method, making it less susceptible to interference and more secure; it has a built-in error branch handling unit, making operation more stable; and it has high system integration of processor + QSPI Flash and simple design.

[0020] Features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, combined with features in other embodiments, or substituted for features in other embodiments. It should be emphasized that the term "comprising / including" as used herein refers to the presence of a feature, integral, step, or component, but does not exclude the presence or addition of one or more other features, integrals, steps, or components. Attached Figure Description

[0021] Figure 1 This is a connection diagram of a system for mounting external QSPI Flash files and running image firmware according to the present invention;

[0022] Figure 2 This is a timing diagram of a system for mounting external QSPI Flash files and running image firmware according to the present invention;

[0023] Figure 3 This invention relates to a partition table for an external QSPI Flash mount file and a system for running image firmware.

[0024] Figure 4This is an internal wiring diagram of the ARM Cortex of a system for mounting external QSPI Flash files and running image firmware according to the present invention;

[0025] Figure 5 This is a flowchart illustrating a method for mounting files and running image firmware on an external QSPI Flash according to the present invention.

[0026] Figure 6 This is a schematic diagram of the process of mounting a file system as described in the method of mounting files and running image firmware of an external QSPI Flash according to the present invention;

[0027] Figure 7 This is a schematic diagram illustrating the process of running the image firmware and detecting whether the image firmware has been upgraded, as described in the method of mounting files and running image firmware for an external QSPI Flash according to the present invention.

[0028] Figure 8 This is a structural block diagram of the burning algorithm described in the method for mounting files and running image firmware of an external QSPI Flash according to the present invention. Detailed Implementation

[0029] The specific implementation of the technical solution of the present invention will be further described below through examples and in conjunction with the accompanying drawings.

[0030] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0031] Example 1:

[0032] exist Figures 1 to 4 In Embodiment 1 shown, the present invention provides a technical solution: a system for mounting files and running image firmware on an external QSPI Flash, comprising: a processor, and a QSPI Flash connected to the processor; wherein the processor and the QSPI Flash are connected via a six-wire QSPI circuit interface. The QSPI Flash has six wires, requiring six wires: SCLK, CS, SIO0, SIO1, SIO2, and SIO3.

[0033] In this embodiment, the system hardware connection diagram is as follows: Figure 1 As shown in the diagram. The main controller uses an ARM Cortex processor, and the peripherals use a P25Q64 Flash device with a capacity of 8MB. The internal wiring diagram of the ARM Cortex is shown below. Figure 4 As shown, the ARM controller connects via a 6-wire QSPI interface and primarily performs memory access and external Flash read / write operations. The read / write timing diagram is shown below. Figure 2 As shown, the system image firmware is stored in external Flash memory. During P25Q64 Flash initialization, the clock source, pin configuration, and register mode configuration all need to be initialized.

[0034] In this embodiment, the external Flash partition is as follows: Figure 3 As shown, the entire P25Q64 space is divided into six partitions based on the minimum page size (4KB). These are: Bootloader boot partition (20KB), configuration information partition (4KB), image runtime partition (1MB), file system partition (288KB, adjustable), configuration information backup partition (4KB), and image backup partition (6852KB, adjustable). The file system partition and image backup partition are the largest and are both adjustable. They can be adjusted according to the needs of the functions required, making the system more functional and efficient.

[0035] The workflow of the system for mounting files and running image firmware on an external QSPI Flash as described in the above embodiments is as follows: First, the six-wire P25Q64 Flash needs to be initialized, and the ARM Cortex processor is connected to the six-wire QSPI Flash. Then, device driver code needs to be written, followed by porting the file system. Then, the P25Q64 Flash is partitioned, and then the XIP local program is executed, which allows the processor to decode and process the instructions. The whole process is simple, the system structure is simple and highly integrated, and it can simultaneously mount the file system and run the image firmware.

[0036] Example 2:

[0037] exist Figures 5 to 8 In Embodiment 2 shown, the present invention provides a technical solution: a method for mounting files and running image firmware on an external QSPI Flash, applied to the system in Embodiment 1 above, including the following steps: initializing QSPI Flash; mounting a file system; running image firmware; detecting whether the image firmware has been upgraded; wherein, the file system is a LITTLEFS file system, and the image firmware is based on the XIP method; the determination of whether an image firmware upgrade has occurred is made through the SWD download protocol interface. If the detection is negative, the external XIP image firmware is run directly; if the detection is positive, the burning algorithm is executed. If the burning is successful, the ROM flag is set, and the external bootloader is entered to restart and run the new App system application firmware.

[0038] Figure 5This is a flowchart illustrating a method for mounting files and running image firmware on an external QSPI Flash according to the present invention. It details the specific process of mounting files and running image firmware using this method, providing a specific explanation of how to perform the mounting and running of the image firmware. Figure 5 The flowchart shown includes the following steps.

[0039] Step S100: Initialize the QSPI Flash. In this embodiment, the QSPI Flash used is a P25Q64 Flash, which requires six lines: SCLK (Synchronous Clock), CS (Chip Select), SIO0 (Serial Data Input Output 0), SIO1 (Serial Data Input Output 1), SIO2 (Serial Data Input Output 2), and SIO3 (Serial Data Input Output 3).

[0040] Step S110: Mount the file system. In this embodiment, the file system used is the LITTLEFS file system. The principle of mounting the LITTLEFS file system is to virtualize a metadata block on a real physical sector. This metadata block records the storage directory, block information, file information, and data linked lists. It is the core data structure of LITTLEFS, and subsequent file creation, opening, and deletion operations will all involve the metadata block. After the file system is mounted, step S120 can be executed.

[0041] Step S120: Start running the image firmware. In this embodiment, the image firmware uses FreeRTOS application firmware. The principle of XIP running the image firmware is that the kernel does not need to copy the program code into memory, but directly boots from the external Flash, i.e., executes locally. The core technology of XIP is real-time memory mapping access, which requires CPU kernel support. After the image firmware is running, proceed to step S130.

[0042] Step S130: Determine whether to upgrade the image firmware. In this embodiment, the SWD download protocol is used to detect whether an image firmware upgrade has occurred. If the result is no, step S140 is executed; if the result is yes, step S131 is executed.

[0043] Step S131: Execute the programming algorithm. In this embodiment, the programming algorithm is to build an offline programming tool that integrates low-level drivers and high-level components. After programming is completed, step S132 will be executed.

[0044] Step S132: Determine whether the burning was successful. In this embodiment, if the burning algorithm is successful, it will set the ROM flag bit and return to step S100 to re-execute and run the new App system application firmware. If the burning fails, it will enter a waiting state, which means it stops running and waits indefinitely.

[0045] Step S140: Run the external XIP image firmware. In this embodiment, running the XIP image firmware requires two firmware components: the Bootloader firmware and the App system application firmware. After the Bootloader firmware completes its execution, the external XIP image firmware can be run. These steps achieve the effect of simultaneously mounting the file system and running the image firmware.

[0046] Figure 6 This is a flowchart illustrating the method for mounting a file system using an external QSPI Flash and running image firmware, as described in this invention. It explains the specific process of mounting the file system and provides a detailed description of how to mount it. Figure 6 The flowchart shown includes the following steps.

[0047] Step S200: Create a LITTLEFS task. In this embodiment, this task will be executed in the freeRTOS multitasking real-time operating system, and the required task stack space and priority parameters are defined in the task.

[0048] Step S210: Determine whether the LITTLEFS task was created successfully. In this example, if the task was created successfully, proceed to step S220; otherwise, exit the entire process.

[0049] Step S220: Configure the QSPI Flash device. In this example, the QSPI Flash used is the P25Q64 Flash. To initialize the P25Q64 Flash device, the QSPI initialization interface will be called first. QSPI initialization involves clock source, pin, and register mode configuration, etc. If QSPI initialization is successful, the vendor ID of the P25Q64 will be read.

[0050] Step S230: Determine whether the QSPI Flash device configuration is successful. In this embodiment, the vendor ID of P25Q64 is read. If the return value is correct (i.e., the vendor ID matches), it is determined that the QSPI Flash device configuration is successful, and step S240 is executed; otherwise, the entire process exits.

[0051] Step S240: Initialize the LITTLEFS component. In this embodiment, the initialization of the LITTLEFS component mainly involves mounting it to the external physical Flash memory according to the file system configuration parameters.

[0052] Step S250: Determine whether the initialization of the LITTLEFS component was successful. In this embodiment, if the initialization is successful, proceed to step S260. If the initialization fails, perform parameter formatting once and attempt to remount. If the second remount is successful, proceed to step S260; otherwise, exit the entire process.

[0053] Step S260 involves file operations for the LITTLEFS component. In this embodiment, this mainly involves creating a file and opening it, followed by step S260.

[0054] Step S270: Write the file. In this embodiment, the file from step S260 above is written, and step S280 is executed after the writing is completed.

[0055] Step S280: Read the file. In this embodiment, the file from step S270 above is read, and step S290 is executed after the reading is completed.

[0056] Step S290: Close the file. In this embodiment, the file from step S280 above is closed. After closing, the entire process of mounting the file system is completed.

[0057] Figure 7 This is a schematic diagram illustrating the process of running the image firmware and detecting whether to upgrade the image firmware, as described in the method of mounting an external QSPI Flash file and running the image firmware according to the present invention. It explains the specific process of running the image firmware and provides a detailed description of how to run the image firmware and detect whether to upgrade the image firmware. Figure 7 The flowchart shown includes the following steps.

[0058] Step S300: Enter the external boot process. In this embodiment, the device boots into the external bootloader area.

[0059] Step S310: Configure CPU clock and interrupt sources. In this embodiment, the basic CPU parameters are configured, mainly the parameters of the master clock source and interrupt sources.

[0060] Step S320: Initialize the external QSPI Flash device. In this embodiment, the QSPI Flash used is P25Q64 Flash. To initialize the P25Q64 Flash device, the QSPI initialization interface is first called. QSPI initialization involves clock source, pin, and register mode configuration, etc. If QSPI initialization is successful, the vendor ID of P25Q64 will be read.

[0061] Step S330: Determine whether the initialization of the external QSPI Flash device was successful. In this embodiment, the vendor ID of P25Q64 is read. If the return value is correct (i.e., the vendor ID matches), it is determined that the initialization of the external QSPI Flash device was successful, and step S340 is executed; otherwise, the system enters a waiting state.

[0062] Step S340: Configure the QSPI data transmission mode. In this embodiment, to efficiently coordinate with real-time memory mapping access, the transmission mode is four-wire data transmission, four-wire address transmission, and single-wire instruction transmission within four clock cycles.

[0063] Step S350: Determine if the ROM flag is set to boot. In this embodiment, if it is set to boot, jump to the off-chip image runtime base address, i.e., start the App system application, i.e., execute step S360; otherwise, if it is set to transfer, copy the App image backup area, i.e., execute step S351.

[0064] Step S351: Move the App image backup area. In this embodiment, when it is determined that the ROM flag is not bootable, the App image backup area is moved, and then step S352 is executed.

[0065] Step S352: Determine whether the transfer of the App image backup area was successful. In this embodiment, if the transfer of the App image backup area is successful, then step S353 is executed; if the transfer of the App image backup area fails, then a waiting state is entered.

[0066] Step S353: Set the ROM flag to start. In this embodiment, after successfully transferring the App image backup area, the ROM flag is set to start, and then the process returns to step S300 to be executed again, thus completing the transfer process.

[0067] Step S360: Jump to App and start it. In this embodiment, in step S350, if it is determined that the ROM flag is booted, jump to the off-chip image running base address and start the App system application. After booting, proceed to step S370.

[0068] Step S370: Remap the interrupt vector. In this embodiment, because the App system application firmware also has requirements such as interrupt response, it is necessary to remap the interrupt vector; otherwise, abnormal phenomena such as system crashes may occur.

[0069] Step S380: Configure CPU clock source and interrupt source. In this embodiment, the CPU resource parameters and peripherals are initialized, mainly including the configuration of clock source, interrupt source, etc.

[0070] Step S390: Determine whether to upgrade the image firmware. In this embodiment, the SWD download protocol interface is used to determine whether an image firmware upgrade has occurred. If the detection result is no, the external XIP image firmware is run directly, i.e., step S400 is executed directly; if the detection result is yes, the burning algorithm is executed, i.e., step S391 is executed.

[0071] Step S391: Execute the programming algorithm. In this embodiment, the programming algorithm is to build an offline programming tool that integrates low-level drivers and high-level components. After programming is completed, step S392 will be executed.

[0072] Step S392: Determine whether the programming algorithm was executed successfully. In this embodiment, if programming is successful, the ROM flag will be set, i.e., step S393 will be executed; otherwise, if programming fails, the system will enter a waiting state.

[0073] Step S393: Set the ROM flag to "Transfer". In this embodiment, after successful programming, the ROM flag is set to "Transfer", and then step S394 is executed.

[0074] Step S394: Reboot into external boot. In this embodiment, after the ROM flag is set, the system will enter the external bootloader to reboot and run the new App system application firmware, and then return to step S300 to re-execute the transfer process.

[0075] Step S400: Run the XIP image firmware. The above steps achieve the effect of running the image firmware.

[0076] Figure 8 This is a structural block diagram of the burning algorithm described in the method for mounting files and running image firmware of an external QSPI Flash according to the present invention, and it introduces the burning algorithm used in this embodiment. For example... Figure 8 The block diagram shown illustrates the programming algorithm, which aims to build an offline programming tool that integrates low-level drivers and high-level components.

[0077] In this embodiment, as Figure 8 As shown, the upper layer is the programming algorithm layer, which contains the programming process. The main functions of the programming algorithm layer are Init, UnInit, BlankCheck, EraseChip, EraseSector, ProgramPage, and Verify, corresponding to the following seven modules: initializing external Flash, deinitializing external Flash, blank check, full erase, sector erase, page programming, and programming authentication, respectively.

[0078] In this embodiment, as Figure 8As shown, the bottom layer is the peripheral driver layer, mainly containing the QSPI interface driver algorithm. For the P25Q64 Flash used in this embodiment, common interfaces include sector erase (20H), chip erase (60H), page programming (02H), data read / write (9BH / 9CH), and vendor ID read (9FH). Besides the P25Q64 Flash used in this embodiment, the peripheral driver layer can also be adapted to other QSPI Flash devices.

[0079] The workflow of the method for mounting files and running image firmware on an external QSPI Flash as described in the above embodiments is as follows: First, the P25Q64 Flash needs to be initialized. Then, the LITTLEFS file system is ported into the P25Q64 Flash. After the porting is completed, the XIP local program is executed. After running, the SWD download protocol detection interface is used to detect whether the image firmware needs to be upgraded. If no upgrade is detected, the external XIP image firmware is run directly, so that the file system and image firmware can be mounted and run simultaneously. If an upgrade is detected, the burning algorithm is executed. After burning is completed, the new App system application firmware is restarted and run, so that the file system and image firmware can be mounted and run simultaneously.

[0080] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for mounting files and running image firmware on an external QSPI Flash, characterized in that, Includes the following steps: Initialize the QSPI Flash; port the LITTLEFS file system into the QSPI Flash; after the porting is complete, execute the XIP native program. Mounting the file system: Create a LITTLEFS task; configure the QSPI Flash device; initialize the LITTLEFS component; perform file operations on the LITTLEFS component; Running the image firmware: Power on and enter the external bootloader boot area; initialize the external QSPI Flash device; configure the QSPI data transmission mode; determine whether the ROM flag is for boot or transfer, and perform corresponding processing; remap the interrupt vector table after entering the App; Initialize CPU resource parameters and peripherals; Check if the image firmware has been upgraded; The file system is a LITTLEFS file system, and the image firmware is based on the XIP method; The detection process checks for firmware upgrades. If an upgrade occurs, the burning algorithm is executed; otherwise, the external XIP firmware is run directly.

2. The method for mounting files and running image firmware according to claim 1, characterized in that, The mounted file system includes: the LITTLEFS task is executed in the freeRTOS multitasking real-time operating system.

3. The method for mounting files and running image firmware according to claim 1, characterized in that, The runtime image firmware includes: the XIP runtime image firmware requires the Bootloader boot firmware and the App system application firmware.

4. The method for mounting files and running image firmware according to claim 1, characterized in that, The programming algorithm consists of two layers: the upper layer is the programming algorithm layer, which contains the programming process; the lower layer is the peripheral driver layer, which mainly consists of the QSPI interface driver.

5. The method for mounting files and running image firmware according to claim 2, characterized in that, Creating a LITTLEFS task includes defining the required parameters within the task; The configuration of the QSPI Flash device includes: calling the QSPI initialization interface for initialization; if the initialization is successful, the manufacturer ID of the QSPI Flash will be read. The initialization of the LITTLEFS component includes: mounting it to an external physical Flash memory according to the file system configuration parameters.

6. The method for mounting files and running image firmware according to claim 3, characterized in that, The process of booting into the external bootloader includes: configuring basic CPU parameters; The corresponding processing is as follows: if it is to start, jump to the external image running base address and start the App system application; if it is to transfer, copy the App image backup area, set the ROM flag, and restart.

7. The method for mounting files and running image firmware according to any one of claims 1 to 6, characterized in that, If the programming algorithm successfully programs the firmware, it will set the ROM flag and enter the external bootloader to restart and run the new App system application firmware; if the programming fails, it will enter a waiting state. If the file system mounting step fails, the entire process will exit. If the step of running the image firmware fails, the system will enter a deadlock state.

8. A system for mounting files and running image firmware on an external QSPI Flash, employing the method for mounting files and running image firmware on an external QSPI Flash as described in any one of claims 1-7, characterized in that, include: The processor, and the QSPI Flash connected to the processor; The processor and QSPI Flash are connected via a six-wire QSPI circuit interface.

9. The system for mounting files and running image firmware according to claim 8, characterized in that, The QSPIFlash is divided into several partitions, and the partition space is divided according to the minimum page size.

10. The system for mounting files and running image firmware according to claim 8 or 9, characterized in that, The partitions of the QSPI Flash can be resized.