Flash capacity upgrading method, device, computer readable storage medium and system

CN122985223APending Publication Date: 2026-10-27SHENZHEN LUXPOWER TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611181378.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-05
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

在这种情况下,常规解决方案为新建 GD 专属工程,两套代码并行维护,申请人在研究中发现,这一实现方式导致研发、版本管理成本极高

Benefits of technology

[0011]在一种可能的实现方式中,所述正式版本整合包的升级方式为外部 Flash 升级或透传升级。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985223A_ABST
    Figure CN122985223A_ABST
Patent Text Reader

Abstract

The application discloses a flash capacity expansion upgrading method, equipment, computer readable storage medium and system, wherein the method is applied to equipment capable of carrying different capacity flash chips; the flash chip comprises a first chip with a first capacity or a second chip with a second capacity, the second capacity being greater than the first capacity; the first chip and the second chip each correspond to the same number of chip pins and the same pin definition; the method can comprise the following steps: obtaining a capacity expansion upgrading request initiated by a user for an old version application program; in response to the capacity expansion upgrading request, starting and running a first Bootloader, reading the total capacity of the flash chip through the first Bootloader calling a chip identification program, and identifying the flash chip as the first chip or the second chip; if the flash chip is identified as the second chip, the first Bootloader jumps to a second Bootloader, receives a transition version integration package through the second Bootloader and performs burning; after the burning is completed, the second Bootloader jumps to a transition application program to run. By implementing the application, compatible capacity expansion of a large-capacity flash chip can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage technology, specifically to a method, device, computer-readable storage medium, and system for flash memory capacity expansion and upgrade. Background Technology

[0002] The GD32F305VET6 and STM32F107VCT6 chips have directly interchangeable hardware pins. Initially, they shared a single application program (APP) code, forcibly limiting the GD chip program to a 256K partition, leaving the remaining half of the GD chip's Flash hardware resources idle for extended periods. However, as the APP code size continued to grow with product iterations, the 256K space became insufficient to support new business functions. In this situation, the conventional solution was to create a dedicated GD project and maintain both sets of code in parallel. The applicant found in their research that this approach resulted in extremely high R&D and version management costs. Therefore, how to efficiently and conveniently achieve parallel management and maintenance of the two sets of code is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0003] This application discloses a method, device, computer-readable storage medium, and system for flash memory capacity expansion and upgrade, which can realize compatible capacity expansion of large-capacity flash chips.

[0004] In a first aspect, this application discloses a Flash memory capacity expansion and upgrade method, which is applied to a device capable of carrying Flash chips of different capacities; the Flash chip includes a first chip with a first capacity or a second chip with a second capacity, wherein the second capacity is greater than the first capacity; the first chip and the second chip each have the same number of chip pins and the same pin definitions; the method includes: Get user requests for expansion and upgrades for older versions of applications; In response to the capacity expansion and upgrade request, the first-level bootloader is started and run. The first-level bootloader calls the chip identification program to read the total capacity of the Flash chip and identifies the Flash chip as the first chip or the second chip. If the chip is identified as the second chip, the first-level bootloader jumps to the second-level bootloader, which receives the transitional version integration package and performs the flashing process. The transitional version integration package contains a transitional application and the official second-level bootloader. During the secondary bootloader burning process, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is opened between the storage partition of the primary bootloader and the storage partition of the application, so that the storage partition of the primary bootloader, the storage partition of the secondary bootloader, and the storage partition of the application form a continuous storage space, and a transition compatibility flag is written at a preset flag address. After the flashing process is complete, the secondary bootloader jumps to the transition application to run.

[0005] Implementing this embodiment, the total capacity of the Flash chip is identified through a primary bootloader, classifying the Flash chip as either a first chip or a second chip. If the Flash chip is identified as a second chip, a transitional version integration package is received and programmed through a secondary bootloader. During programming, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is created between the storage partition of the primary bootloader and the storage partition of the application, forming a contiguous storage space. A transition compatibility flag is written to a preset flag address, achieving compatible expansion of the large-capacity Flash chip. In this implementation, storage resources can be expanded without replacing the device hardware.

[0006] Secondly, this application discloses a Flash memory expansion and upgrade device, comprising: The storage module is equipped with Flash chips of different capacities, wherein the Flash chip includes a first chip with a first capacity or a second chip with a second capacity, the second capacity being greater than the first capacity; The communication module is used to receive upgrade requests from users for older versions of applications. The processing module integrates a primary bootloader and a secondary bootloader, and is configured to perform the following operations: In response to the capacity expansion and upgrade request, the first-level bootloader is started and run. The first-level bootloader calls the chip identification program to read the total capacity of the Flash chip and identifies the Flash chip as the first chip or the second chip. If the chip is identified as the second chip, the first-level bootloader is controlled to jump to the second-level bootloader. The second-level bootloader receives the transition version integration package and performs the flashing. The transition version integration package contains a transition application and the official second-level bootloader. During the secondary bootloader burning process, the memory address partition reconstruction is performed on the storage module. An independent secondary bootloader storage partition is opened between the storage partition of the primary bootloader and the storage partition of the application, so that the storage partition of the primary bootloader, the storage partition of the secondary bootloader, and the storage partition of the application form a continuous storage space, and a transition compatibility flag is written at a preset flag address. After the burning process is complete, the secondary bootloader is controlled to jump to the transition application for execution.

[0007] Thirdly, this application discloses a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method described in any of the first aspects above.

[0008] Fourthly, this application discloses a Flash memory expansion and upgrade system, comprising: Terminal devices are equipped with Flash chips of different capacities and integrate a primary bootloader and a secondary bootloader to initiate application expansion and upgrade requests; The server is used to send an application transition version integration package to the terminal device in response to the expansion and upgrade request. The terminal device is further configured to, when the Flash chip is identified as a second chip, switch the primary bootloader to the secondary bootloader, receive the transition version integration package through the secondary bootloader, and perform the burning process; wherein, the transition version integration package includes a transition application and the official secondary bootloader; During the secondary bootloader programming process, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is created between the storage partition of the primary bootloader and the storage partition of the application, so that the storage partitions of the primary bootloader, the secondary bootloader, and the application form a contiguous storage space. A transition compatibility flag is written at a preset flag address. After programming is completed, the secondary bootloader jumps to the transition application to run.

[0009] In one possible implementation, the transition application initiates a formal expansion and upgrade request, waking up the secondary bootloader; The secondary bootloader downloads the official version integration package and performs the flashing. The official version integration package includes an expansion application adapted to the second capacity and the official secondary bootloader. During the burning process, the secondary bootloader erases the preset upgrade mode flag and updates the transition compatibility flag to the expansion flag; Based on the expansion flag, a secondary partitioning reconstruction is performed on the Flash chip to release all the storage space of the second chip; After the burning process is complete, the system will redirect to the expanded application partition to run the expanded application.

[0010] By implementing the embodiments of this application, a two-step design of "transitional upgrade - formal expansion" is adopted to avoid application compatibility issues caused by direct expansion. During the programming process, the transitional compatibility flag is updated to the expansion flag, thereby enabling secondary partitioning and reconstruction of the Flash chip based on the expansion flag, releasing all the storage space of the second chip. The expansion flag ensures accurate identification of the storage status during subsequent system startup.

[0011] In one possible implementation, the upgrade method for the official version integration package is external Flash upgrade or pass-through upgrade.

[0012] Implementing the embodiments of this application provides diverse upgrade paths to adapt to different use cases (such as offline upgrades and online remote upgrades), thereby improving the practicality and adaptability of the method.

[0013] In one possible implementation, the method further includes: If the chip is identified as the first chip, no capacity expansion or upgrade will be performed.

[0014] By implementing the embodiments of this application, the processing logic of small-capacity Flash chips is clarified, invalid upgrade operations are avoided, system resource consumption is reduced, and the execution efficiency of the method is ensured.

[0015] In one possible implementation, before each booting of the transitional version integration package or the official version integration package, the secondary bootloader first backs up the user configuration data of the entire machine.

[0016] Implementing the embodiments of this application can prevent data loss or corruption during the upgrade process, improve the reliability of the upgrade process and user experience, and reduce upgrade risks.

[0017] In one possible implementation, the device equipped with the second chip only supports forward expansion upgrades and prohibits rollback from a version adapted to the second capacity to a version adapted to the first capacity; the device equipped with the first chip can only maintain existing functions based on the first capacity and does not support adding new functions that occupy more storage space than the first capacity.

[0018] By implementing the embodiments of this application, system crashes caused by rollback upgrades or the addition of overcapacity features are avoided through version compatibility restrictions, thus ensuring the stability of device operation.

[0019] In one possible implementation, the first chip is a 256k STM32F107VCT6 chip, and the second chip is a 512k GD32F305VET6 chip.

[0020] In one possible implementation, the address range of each storage partition is set as follows: The address range of the first-level bootloader storage partition is 0x8000000 to 0x800C7FF, and the storage space size is 50KB; The address range of the secondary bootloader storage partition is 0x800D000 to 0x800FFFF, the storage space size is 14KB, and it is located between the primary bootloader storage partition and the application storage partition; The application storage partition starts at address 0x8010000 and occupies the remaining storage space of the Flash chip from address 0x8010000 to the end; address 0x803F7F8 is a preset flag address. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the background art, the accompanying drawings used in the embodiments of this application or the background art will be described below.

[0022] Figure 1 A schematic diagram of the architecture of a Flash capacity expansion and upgrade system provided in this application embodiment; Figure 2a A flowchart illustrating a Flash memory expansion and upgrade method provided in this application embodiment; Figure 2b A flowchart illustrating a formal capacity expansion method provided in this application embodiment; Figure 3 A flowchart illustrating an upgrade encryption method provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a Flash capacity expansion and upgrade device provided in an embodiment of this application. Detailed Implementation

[0023] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0024] First, let's introduce the differences between the GD32F305VET6 chip (hereinafter referred to as GD chip) and the STM32F107VCT6 chip involved in this application, mainly including: (1) Flash read / write mechanism GD32F305VET6: 512KB multi-sector memory, with erase / write granularity and address mapping table completely different from STM32F107VCT6; the total Flash capacity can be read from the register.

[0025] STM32F107VCT6: The hardware maximum capacity is only 256KB, and the capacity register returns a fixed 256K, which cannot be expanded.

[0026] (2) Startup mechanism Both are hardware compatible with the boot pins, but their system clock trees and PLL configuration logic are different. In the early days, in order to be compatible with shared code, the GD chip application program (APP) was forced to run in the 256K address range, wasting half of the Flash capacity.

[0027] (3) Firmware partitioning and upgrade logic The STM32F107VCT6 has a hardware limit of 256K and no room for expansion; GD natively has 512K, but the underlying Boot1 of existing devices has not been partitioned or offset.

[0028] Secondly, let's take a closer look at the hierarchical relationship between the first-level Bootloader, the second-level Bootloader, and the application (APP): 1. Initiate relationships sequentially After the device is powered on, the first-level bootloader (Boot1) runs first. After the first-level bootloader completes chip identification and flag bit judgment, it jumps to the second-level bootloader (Boot2). After the second-level bootloader completes partition parsing and firmware verification, it jumps to run the application (APP).

[0029] 2. Location relationship of Flash physical storage partitions The chip's Flash storage space is divided into the following partitions from low to high addresses: a primary Bootloader independent partition, a secondary Bootloader independent partition, an application (APP) partition, and a flag storage partition. The primary Bootloader partition is fixed at the starting address of the Flash memory and cannot be erased, written, or modified. The secondary Bootloader partition is located between the primary Bootloader partition and the APP partition and can be updated remotely. The APP partition is the storage area for business applications and supports address offset expansion and remapping.

[0030] 3. Functional division of labor and subordinate relationships: 1) Level 1 Boot1 (bottom startup layer): Only performs basic scheduling, does not touch the APP, does not modify partitions, only executes: power-on initialization, identifies GD / STM chip Flash capacity, reads upgrade flag, jumps to Level 2 Boot; does not participate in APP erase / write, Flash space expansion, firmware encryption verification.

[0031] 2) Secondary Boot2 (Intermediate Transitional Management Layer): As the intermediate bridge between Boot1 and APP, it undertakes all complex operations, receives upgrade instructions issued by Boot1, and is responsible for APP partition address offset, Flash expansion and remapping, APP firmware erasure and burning, upgrade package encryption and verification, and user data backup; it receives instructions from the primary Boot level and controls the APP running space and version updates.

[0032] 3) APP (Business Execution Layer): It only carries the device business functions, has no underlying partitioning or expansion control capabilities, and stores the device business logic code. It relies on the Flash space allocated by the secondary Bootloader to run; it can only initiate upgrade requests and cannot modify the Flash partition or expansion flag bit itself.

[0033] To better understand this solution, the following section describes the network architecture to which this solution can be applied. Please refer to [link / reference]. Figure 1 , Figure 1This is a schematic diagram of the architecture of a Flash memory expansion and upgrade system provided in an embodiment of this application. Figure 1 As shown, the architecture of the Flash expansion and upgrade system includes multiple terminal devices and a server. In practice, the server can communicate with multiple terminal devices via wired or wireless communication links. Wireless communication links include Wi-Fi, Bluetooth, LoRa, or 4G / 5G communication links, etc. In practical applications, terminal devices are equipped with Flash chips of different capacities, integrating a primary bootloader and a secondary bootloader. They initiate an application expansion and upgrade request to the server. Upon receiving the request, the server sends an application transition version integration package to the terminal device. The terminal device, upon receiving the application transition version integration package and recognizing the Flash chip as the secondary chip, controls the primary bootloader to jump to the secondary bootloader. The secondary bootloader receives the transition version integration package and performs the burning process. This transition version integration package contains a transitional application and the official secondary bootloader. During the secondary bootloader burning process, the memory address partitioning of the storage module is reconstructed. An independent secondary bootloader storage partition is created between the primary bootloader's storage partition and the application's storage partition, forming a contiguous storage space. A transition compatibility flag is written to a preset flag address. After burning is complete, the secondary bootloader is controlled to jump to the transitional application for execution. For the server, it can record the upgrade status of the terminal device, which includes one of the following: no upgrade, transitional upgrade completed, or formal expansion completed.

[0034] exist Figure 1 In the system architecture shown, the server can be any user-accessible device, including but not limited to mobile phones, tablets, personal digital assistants (PDAs), mobile internet devices (MIDs), and other similar devices.

[0035] Terminal devices can include, but are not limited to, mobile phones, tablets, personal digital assistants (PDAs), mobile internet devices (MIDs), and other devices that users can use.

[0036] It should be noted that, in this embodiment, no capacity expansion upgrade is performed on the first chip. Specifically, not performing a capacity expansion upgrade means that Flash capacity expansion is not performed, but application upgrades can be performed. Specifically, if it is determined that the version number of the old application is not the latest stable version number at the current time, the old application is upgraded to the application corresponding to the latest stable version number. For example, if the terminal device is running application version V1.0 at the first time point, and the terminal device receives a capacity expansion upgrade request from the user for application version V1.0, and the device identifies the chip as the first chip, no Flash capacity expansion is performed. Simultaneously, it further determines whether the version number of the old application (i.e., application version V1.0) is the latest stable version number at the current time point. If it is determined that the version number of the old application is less than the latest stable version number at the current time point, application version V1.0 is upgraded to application version V2.0. Here, the second time point is a time point later than the first time point.

[0037] It should be noted that for the first chip, if the application size corresponding to the latest stable version number at the current point in time exceeds the first chip's capacity, the application upgrade will not be performed.

[0038] In this embodiment, the second chip can undergo a capacity expansion upgrade. Specifically, the capacity expansion upgrade refers to expanding the Flash capacity and upgrading the application. The Flash capacity expansion includes reconstructing the memory address partitions of the second chip, creating an independent secondary Bootloader storage partition between the primary Bootloader's storage partition and the application's storage partition, thus forming a contiguous storage space. After flashing, the secondary Bootloader jumps to the transitional application. Upon receiving a formal capacity expansion upgrade request, the secondary Bootloader is awakened; it downloads the official version integration package and performs flashing. After flashing, it jumps to the expanded application partition to run the expanded application. It is understood that the expanded application has the following characteristics: firstly, it adapts to the second capacity; secondly, the expanded application is the application corresponding to the latest stable version number at the current time. It is understood that after expanding the Flash capacity, this process does not need to be repeated. Meanwhile, application upgrades can be performed multiple times subsequently.

[0039] by Figure 1The network architecture shown is used as an example to illustrate a Flash capacity expansion and upgrade method disclosed in this application. This method is applied to devices capable of carrying Flash chips of different capacities. The Flash chip includes a first chip with a first capacity or a second chip with a second capacity, where the second capacity is greater than the first capacity. Furthermore, the first chip and the second chip each have the same number of pins and the same pin definitions, thus allowing them to share a single set of application code. Please refer to [link to relevant documentation]. Figure 2a , Figure 2a This is a flowchart illustrating a Flash memory expansion and upgrade method provided in an embodiment of this application. The method may include, but is not limited to, the following steps: Step S201: Obtain the expansion and upgrade request initiated by the user for the old version of the application; In this embodiment, an older version of an application refers to a non-latest released version of a computer executable program that was publicly released by its development entity (such as a software development company or technical R&D team) through legal distribution channels (such as app stores or official websites) before the current time point. Its version number is lower than the latest stable version number or the officially promoted version number of the application at the current time point. For example, the application version at the first time point is V1.0; the application version at the second time point is V2.0, where the second time point is a point in time later than the first time point.

[0040] For example, the terminal device is running application version V1.0 at the first time point. The terminal device receives a capacity expansion and upgrade request initiated by the user for application version V1.0. The capacity expansion and upgrade request aims to expand the capacity of the Flash chip and upgrade application version V1.0 to application version V2.0.

[0041] Step S202: In response to the capacity expansion and upgrade request, start and run the first-level bootloader, and use the first-level bootloader to call the chip identification program to read the total capacity of the Flash chip and identify the Flash chip as the first chip or the second chip.

[0042] In this embodiment of the application, the first chip is an STM32F107VCT6 chip with a capacity of 256k, and the second chip is a GD32F305VET6 chip with a capacity of 512k.

[0043] Step S203: If the chip is identified as the second chip, proceed to step S204; if the chip is identified as the first chip, proceed to step S205. Step S204: The primary bootloader jumps to the secondary bootloader, which receives the transitional version integration package and performs the burning process. The transitional version integration package contains a transitional application and the official secondary bootloader. During the secondary bootloader burning process, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is created between the storage partition of the primary bootloader and the storage partition of the application, so that the storage partitions of the primary bootloader, the secondary bootloader, and the application form a contiguous storage space. A transition compatibility flag is written to a preset flag address. After the burning is completed, the secondary bootloader jumps to the transitional application to run.

[0044] In the specific implementation, before memory partition reconstruction, the address ranges of each storage partition are set as follows: the address range of the first-level Bootloader storage partition is 0x8000000 to 0x800C7FF, and the storage space size is 50KB; the starting address of the application storage partition is 0x800C800. After memory partition reconstruction, the address ranges of each storage partition are set as follows: the address range of the first-level Bootloader storage partition is 0x8000000 to 0x800C7FF, and the storage space size is 50KB; the address range of the second-level Bootloader storage partition is 0x800C800 to 0x800FFFF, and the storage space size is 14KB, set between the first-level Bootloader storage partition and the application storage partition; the starting address of the application storage partition is 0x8010000, occupying the remaining storage space of the Flash chip from 0x8010000 to the end; address 0x803F7F8 is the preset flag address.

[0045] In practice, during the process of burning the transitional version integration package, the preset flag address is written into the transition compatibility flag (INFM). This completes the burning of the transitional version integration package.

[0046] Step S205: If the chip is identified as the first chip, the capacity expansion and upgrade will not be performed.

[0047] Implementing this embodiment, the total capacity of the Flash chip is identified by a primary bootloader, classifying it as either a first chip or a second chip. If the Flash chip is identified as a second chip, a transitional version integration package is received and programmed via a secondary bootloader. During programming, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is created between the primary bootloader's storage partition and the application's storage partition, forming a contiguous storage space. A transition compatibility flag is written to a preset flag address, achieving compatible expansion of the large-capacity Flash chip. In this implementation, storage resources can be expanded without replacing the device hardware. Furthermore, the processing logic for small-capacity Flash chips is clearly defined, avoiding unnecessary upgrade operations, reducing system resource consumption, and ensuring the efficiency of the method.

[0048] like Figure 2b As shown, this application discloses a specific implementation of formal capacity expansion, which may further include the following steps after the aforementioned step S205: Step S206: The transitional application initiates a formal expansion and upgrade request, waking up the secondary bootloader; Step S207: The secondary bootloader downloads the official version integration package and performs the flashing. The official version integration package includes an expanded application adapted to the second capacity and the official secondary bootloader. During the flashing process, the secondary bootloader erases the preset upgrade method flag and updates the transition compatibility flag to the expanded capacity flag. Based on the expanded capacity flag, the flash chip is re-partitioned and reconstructed to release all the storage space of the second chip. After the flashing is completed, it jumps to the expanded application partition to run the expanded application.

[0049] For example, during the programming process, the secondary bootloader erases the preset upgrade mode flags 0x8031800 and 0x8031804, and updates the INFM transition compatibility flag at address 0x803F7F8 to the 512K expansion flag. This allows for a secondary partitioning and reconstruction of the Flash chip based on the expansion flag, freeing up all the storage space of the second chip. After programming is complete, the system jumps to the expanded application partition to run the expanded application.

[0050] In this embodiment, the upgrade method for the official version integration package is either external Flash upgrade or transparent transmission upgrade. This approach provides diverse upgrade paths, adapting to different use cases (such as offline upgrades and online remote upgrades), thus improving the practicality and adaptability of the method.

[0051] Implementing the embodiments of this application, through a two-step design of "transitional upgrade - formal expansion," avoids application compatibility issues caused by direct expansion. During the programming process, the transitional compatibility flag is updated to the expansion flag, thereby enabling secondary partitioning and reconstruction of the Flash chip based on the expansion flag, releasing all storage space of the second chip. The expansion flag ensures accurate identification of the storage status during subsequent system startup.

[0052] It should be noted that in the above embodiments, before each boot from the transitional version integration package or the official version integration package, the secondary bootloader first backs up the user configuration data of the entire machine. This method prevents data loss or corruption during the upgrade process, improves the reliability of the upgrade process and user experience, and reduces upgrade risks.

[0053] It should also be noted that devices equipped with the second chip only support forward capacity expansion upgrades and are prohibited from rolling back from a version adapted to the second capacity to a version adapted to the first capacity. Devices equipped with the first chip can only maintain existing functions based on the first capacity and do not support adding functions that occupy more storage space than the first capacity. In this way, through version compatibility restrictions, system crashes caused by rollback upgrades or the addition of functions exceeding the capacity are avoided, ensuring the stability of device operation.

[0054] It should also be noted that both the transitional version and the official version of the integrated package support three upgrade modes: upgrading the secondary bootloader separately, upgrading the application separately, and upgrading the secondary bootloader and the application as a whole package.

[0055] It should also be noted that after completing the two-step upgrade and expansion described in this application, the subsequent upgrade should preferably be an upgrade of the integrated package file to avoid program loss due to power failure during the upgrade.

[0056] by Figure 1 For an example of the Flash expansion and upgrade system architecture shown below, please refer to [link / reference]. Figure 3 , Figure 3 A specific implementation of upgraded encryption is disclosed, which may include, but is not limited to, the following steps: Step S301: After receiving the expansion and upgrade request, the server synchronously performs encryption signing and lossless compression processing on the integrated firmware containing the secondary bootloader and application to generate an integrated upgrade package. Step S302: The server sends an encrypted and compressed integrated upgrade package to the terminal device; Step S303: The terminal device receives the encrypted and compressed integrated upgrade package. The primary bootloader receives the integrated upgrade package and only acts as a data relay, forwarding the upgrade package to the secondary bootloader. The secondary bootloader independently performs key validity verification. If the key does not match, the secondary bootloader directly discards the upgrade package, blocking external malicious firmware from being written to Flash. Step S304: After verification, the secondary bootloader locally decompresses the upgrade package, completes Flash partition erasure and writing, expansion address remapping, and firmware burning.

[0057] In this implementation, encryption verification, firmware decompression, and expansion partition scheduling are all isolated and executed in the second-level bootloader, while the first-level bootloader is only responsible for forwarding upgrade packages, thus achieving layered isolation of the underlying startup logic, expansion logic, and security upgrade logic.

[0058] It should be noted that for instructions on how to perform Flash partition erasure and rewriting, address remapping for expansion, and firmware burning, please refer to the above technical descriptions; further details will not be provided here.

[0059] To better understand the technical solutions described in this application, embodiments of this application disclose a Flash memory expansion and upgrade device, such as... Figure 4 As shown, it may include: Storage module 401 is equipped with Flash chips of different capacities. The Flash chips include a first chip with a first capacity or a second chip with a second capacity, wherein the second capacity is greater than the first capacity. The first chip and the second chip each have the same number of chip pins and the pin definitions are the same. The communication module 402 is used to receive expansion and upgrade requests initiated by users for older versions of applications; Processing module 403 integrates a primary bootloader and a secondary bootloader, and is configured to perform the following operations: In response to the capacity expansion and upgrade request, the primary bootloader is started and runs. The primary bootloader retrieves the total capacity of the Flash chip through a chip identification program, identifying the Flash chip as either the first chip or the second chip. If identified as the second chip, the primary bootloader jumps to the secondary bootloader, which receives and executes a transitional version integration package. This transitional version integration package includes a transitional application and the official secondary bootloader. During the secondary bootloader's programming process, memory address partitioning is reconstructed on the storage module. An independent secondary bootloader storage partition is created between the primary bootloader's storage partition and the application's storage partition, forming a contiguous storage space. A transition compatibility flag is written to a preset flag address. After programming is complete, the secondary bootloader jumps to the transitional application for execution.

[0060] In one possible implementation, the communication module 402 is further configured to: receive a formal capacity expansion and upgrade request; The processing module 403 is also configured to perform the following operations: Wake up the secondary bootloader; The secondary bootloader downloads the official version integration package and performs the flashing. The official version integration package includes an expansion application adapted to the second capacity and the official secondary bootloader. During the burning process, the secondary bootloader erases the preset upgrade mode flag and updates the transition compatibility flag to the expansion flag; Based on the expansion flag, a secondary partitioning reconstruction is performed on the Flash chip to release all the storage space of the second chip; After the burning process is complete, the system will redirect to the expanded application partition to run the expanded application.

[0061] In one possible implementation, the upgrade method for the official version integration package is external Flash upgrade or pass-through upgrade.

[0062] In one possible implementation, the communication module 402 is further configured to: If the chip is identified as the first chip, the upgrade process is terminated, and the old version of the application continues to run.

[0063] In one possible implementation, before each booting of the transitional version integration package or the official version integration package, the secondary bootloader first backs up the user configuration data of the entire machine.

[0064] In one possible implementation, the device equipped with the second chip only supports forward expansion upgrades and prohibits rollback from a version adapted to the second capacity to a version adapted to the first capacity; the device equipped with the first chip can only maintain existing functions based on the first capacity and does not support adding new functions that occupy more storage space than the first capacity.

[0065] In one possible implementation, the first chip is a 256k STM32F107VCT6 chip, and the second chip is a 512k GD32F305VET6 chip.

[0066] In one possible implementation, the address range of each storage partition is set as follows: The address range of the first-level bootloader storage partition is 0x8000000 to 0x800C7FF, and the storage space size is 50KB; The address range of the secondary bootloader storage partition is 0x800D000 to 0x800FFFF, the storage space size is 14KB, and it is located between the primary bootloader storage partition and the application storage partition; The application storage partition starts at address 0x8010000 and occupies the remaining storage space of the Flash chip from address 0x8010000 to the end. Address 0x803F7F8 is the default flag address.

[0067] Implementing this embodiment, the total capacity of the Flash chip is identified through a primary bootloader, classifying the Flash chip as either a first or second chip. If the Flash chip is identified as a second chip, a transitional version integration package is received and programmed through a secondary bootloader. During programming, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is created between the storage partition of the primary bootloader and the storage partition of the application, forming a contiguous storage space. A transition compatibility flag is written to a preset flag address, achieving compatible expansion of the large-capacity Flash chip. In this implementation, storage resources can be expanded without replacing the device hardware. Furthermore, the processing logic for small-capacity Flash chips is clearly defined, avoiding invalid upgrade operations, reducing system resource consumption, and ensuring the execution efficiency of the method.

[0068] This application also provides another computer storage medium for storing the above-mentioned... Figure 1 The computer software instructions used by the server include programs designed for executing the methods described in the embodiments above. By executing the stored program, Flash memory expansion and upgrades can be achieved.

[0069] This application embodiment also provides a computer storage medium for storing the above-described 2a, Figure 2b The computer software instructions used by the terminal device shown include a program designed to execute the methods described in the embodiments above. Flash memory expansion and upgrades can be achieved by executing the stored program.

[0070] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0071] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0072] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0073] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0074] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

[0075] 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.

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

Claims

1. A method for expanding and upgrading Flash memory, characterized in that, The method is applied to devices that can carry Flash chips of different capacities; the Flash chip includes a first chip with a first capacity or a second chip with a second capacity, wherein the second capacity is greater than the first capacity. The first chip and the second chip each have the same number of pins and the same pin definitions; the method includes: Get user requests for expansion and upgrades for older versions of applications; In response to the capacity expansion and upgrade request, the first-level bootloader is started and run. The first-level bootloader calls the chip identification program to read the total capacity of the Flash chip and identifies the Flash chip as the first chip or the second chip. If the chip is identified as the second chip, the first-level bootloader jumps to the second-level bootloader, which receives the transitional version integration package and performs the flashing process. The transitional version integration package contains a transitional application and the official second-level bootloader. During the secondary bootloader burning process, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is opened between the storage partition of the primary bootloader and the storage partition of the application, so that the storage partition of the primary bootloader, the storage partition of the secondary bootloader, and the storage partition of the application form a continuous storage space, and a transition compatibility flag is written at a preset flag address. After the flashing process is complete, the secondary bootloader jumps to the transition application to run.

2. The method according to claim 1, characterized in that, The method further includes: The transition application initiates a formal expansion and upgrade request, waking up the secondary bootloader; The secondary bootloader downloads the official version integration package and performs the flashing. The official version integration package includes an expansion application adapted to the second capacity and the official secondary bootloader. During the burning process, the secondary bootloader erases the preset upgrade mode flag and updates the transition compatibility flag to the expansion flag; Based on the expansion flag, a secondary partitioning reconstruction is performed on the Flash chip to release all the storage space of the second chip; After the burning process is complete, the system will redirect to the expanded application partition to run the expanded application.

3. The method according to claim 2, characterized in that, The upgrade method for the official version integration package is external Flash upgrade or transparent transmission upgrade.

4. The method according to claim 2, characterized in that, The method further includes: If the chip is identified as the first chip, no capacity expansion or upgrade will be performed.

5. The method according to claim 1, characterized in that, Before each booting of the transitional version integration package or the official version integration package, the secondary bootloader first backs up the user configuration data of the entire machine.

6. The method according to claim 1, characterized in that, Devices equipped with the second chip only support forward capacity expansion upgrades and are prohibited from rolling back from a version adapted to the second capacity to a version adapted to the first capacity; Devices equipped with the first chip can only maintain existing functions based on the first capacity and do not support adding new functions that occupy more storage space than the first capacity.

7. The method according to any one of claims 1-6, characterized in that, The first chip is a 256k STM32F107VCT6 chip, and the second chip is a 512k GD32F305VET6 chip.

8. The method according to any one of claims 1-6, characterized in that, The address ranges for each storage partition are set as follows: The address range of the first-level bootloader storage partition is 0x8000000 to 0x800C7FF, and the storage space size is 50KB; The address range of the secondary bootloader storage partition is 0x800D000 to 0x800FFFF, the storage space size is 14KB, and it is located between the primary bootloader storage partition and the application storage partition; The application storage partition starts at address 0x8010000 and occupies the remaining storage space of the Flash chip from address 0x8010000 to the end. Address 0x803F7F8 is the default flag address.

9. A Flash memory expansion and upgrade device, characterized in that, include: The storage module is equipped with Flash chips of different capacities, wherein the Flash chip includes a first chip with a first capacity or a second chip with a second capacity, the second capacity being greater than the first capacity; The communication module is used to receive upgrade requests from users for older versions of applications. The processing module integrates a primary bootloader and a secondary bootloader, and is configured to perform the following operations: In response to the capacity expansion and upgrade request, the first-level bootloader is started and run. The first-level bootloader calls the chip identification program to read the total capacity of the Flash chip and identifies the Flash chip as the first chip or the second chip. If the chip is identified as the second chip, the first-level bootloader is controlled to jump to the second-level bootloader. The second-level bootloader receives the transition version integration package and performs the flashing. The transition version integration package contains a transition application and the official second-level bootloader. During the secondary bootloader burning process, the memory address partition reconstruction is performed on the storage module. An independent secondary bootloader storage partition is opened between the storage partition of the primary bootloader and the storage partition of the application, so that the storage partition of the primary bootloader, the storage partition of the secondary bootloader, and the storage partition of the application form a continuous storage space, and a transition compatibility flag is written at a preset flag address. After the burning process is complete, the secondary bootloader is controlled to jump to the transition application for execution.

10. A computer-readable storage medium, characterized in that, The computer storage medium stores a computer program, the computer program including program instructions, which, when executed by a processor, cause the processor to perform the method as described in any one of claims 1-8.

11. A Flash memory expansion and upgrade system, characterized in that, include: Terminal devices are equipped with Flash chips of different capacities and integrate a primary bootloader and a secondary bootloader to initiate application expansion and upgrade requests; The server is used to send an application transition version integration package to the terminal device in response to the expansion and upgrade request. The terminal device is further configured to, when the Flash chip is identified as a second chip, switch the primary bootloader to the secondary bootloader, receive the transition version integration package through the secondary bootloader, and perform the burning process; wherein, the transition version integration package includes a transition application and the official secondary bootloader; During the secondary bootloader programming process, the memory address partitioning of the Flash chip is reconstructed. An independent secondary bootloader storage partition is created between the storage partition of the primary bootloader and the storage partition of the application, so that the storage partitions of the primary bootloader, the secondary bootloader, and the application form a contiguous storage space. A transition compatibility flag is written at a preset flag address. After programming is completed, the secondary bootloader jumps to the transition application to run.

12. The system according to claim 11, characterized in that, The server is configured as follows: Record the upgrade status of the terminal device, wherein the upgrade status of the terminal device includes one of: not upgraded, transitional upgrade completed, and formal expansion completed.