Application program loading method and related device
By setting the starting address and offset of the second partition in the first partition of external storage and updating these addresses after changes to the image package, the compatibility problem after application upgrades is solved, image package adaptation and efficient loading are achieved, and memory space utilization is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING CO WHEELS TECH CO LTD
- Filing Date
- 2024-10-31
- Publication Date
- 2026-05-01
AI Technical Summary
In the existing technology, because the starting address and offset of the partition are fixed in the external storage, the image package cannot be adapted to the upgraded application when the application is upgraded, causing compatibility problems.
A first partition is set up in external memory to store the starting address and offset of each second partition. These addresses and offsets are updated after the image package changes. The image package is read and copied to internal memory by the bootloader. The updated second partition stores the changed image package.
The application compatibility issue was resolved, image package adaptation and efficient loading were achieved, the workload of updating the bootloader was reduced, and memory space utilization was improved.
Smart Images

Figure CN121957705A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of application loading technology, and in particular to an application loading method and related apparatus. Background Technology
[0002] Because many chips have limited internal storage space, external memory (such as flash memory) is often used to increase storage capacity. External memory can be used not only to store data, but also to store application image packages.
[0003] Currently, application image packages stored in external memory need to be loaded into the chip's internal memory before execution. Existing technology pre-defines multiple partitions in the external memory to store the bootloader and various parts of the image package separately.
[0004] However, the starting address and offset of each partition are fixed in the existing technology. When the application is upgraded, the parts of the image package may change. This causes the partitions that are pre-set in the existing technology to no longer be compatible with the parts of the image package of the upgraded application, resulting in application compatibility problems. Summary of the Invention
[0005] In view of the above problems, this application provides an application loading method and related apparatus to solve the application compatibility problem. The specific solution is as follows:
[0006] The first aspect of this application provides an application loading method applied to a chip, the chip being electrically connected to an external memory, the external memory having a first partition and at least one second partition, the first partition being used to store the starting address and offset of each of the second partitions, the second partition being used to store an image package of a target application, and after the image package is changed, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package;
[0007] The application loading method includes:
[0008] The initial boot program within the chip starts the bootloader in the chip's internal memory;
[0009] The bootloader reads the starting address and offset of each of the second partitions stored in the first partition, and copies the image package in each of the second partitions to the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
[0010] In one optional implementation of the first aspect, copying the image package in each of the second partitions to the internal memory includes: copying the image package in each of the second partitions to each of the third partitions corresponding to the second partitions, wherein each of the third partitions is located in the internal memory;
[0011] The first partition is specifically used to store a mapping table, which stores the correspondence between the second partition and the third partition. The mapping table also stores the starting address and offset of each second partition and the starting address and offset of each third partition.
[0012] In an optional implementation of the first aspect, after the bootloader reads the starting address and offset of each of the second partitions stored in the first partition, the application loading method further includes:
[0013] The bootloader performs a verification calculation on the starting address and offset of each of the second partitions stored in the first partition based on a preset verification calculation method, obtains the verification calculation result, compares the verification calculation result with the preset calculation result stored in the first partition, and if they match, then executes the step: copying the image package in each of the second partitions to the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
[0014] In an optional implementation of the first aspect, the external memory includes a fourth partition for storing the bootloader. Before starting the bootloader in the chip's internal memory, the application loading method further includes:
[0015] The initial boot program within the chip copies the bootloader from the fourth partition to the fifth partition of the internal memory, and the initial boot program completes the initialization of the bootloader in the fifth partition.
[0016] In an alternative implementation of the first aspect, after copying the image package from each of the second partitions to the internal storage, the application loading method further includes:
[0017] The target application is run, and the fifth partition is set up as a storage area for storing at least one other type of data besides the bootloader after the target application is run.
[0018] A second aspect of this application provides a chip electrically connected to an external memory. The external memory has a first partition and at least one second partition. The first partition is used to store the starting address and offset of each of the second partitions. The second partition is used to store an image package of a target application. After the image package changes, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package.
[0019] When the chip executes its internal initial startup program, it performs the following: starts the bootloader program in the chip's internal memory;
[0020] When the chip executes the bootloader, it reads the starting address and offset of each of the second partitions stored in the first partition, and copies the image package in each of the second partitions to the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
[0021] In an alternative implementation of the second aspect, the external memory includes a fourth partition for storing the bootloader.
[0022] When the chip executes its internal initial startup program, it also performs the following: before starting the bootloader in the chip's internal memory, it copies the bootloader in the fourth partition to the fifth partition of the internal memory, thereby completing the initialization of the bootloader in the fifth partition.
[0023] When the chip executes the bootloader, it also performs the following: after copying the image package in each of the second partitions into the internal memory, it runs the target application, and the fifth partition is set as a storage area for storing at least one other data besides the bootloader after the target application runs.
[0024] A third aspect of this application provides an external memory electrically connected to a chip. The external memory is provided with a first partition and at least one second partition. The first partition is used to store the starting address and offset of each of the second partitions. The second partition is used to store an image package of a target application. After the image package changes, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package.
[0025] After the bootloader in the chip's internal memory is started by the chip's initial boot program, it performs the following: reads the starting address and offset of each of the second partitions stored in the first partition, and copies the image package in each of the second partitions into the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
[0026] A fourth aspect of this application provides a circuit comprising: an external memory and any of the chips provided in the second aspect, the chip being electrically connected to the external memory, the external memory having a first partition and at least one second partition, the first partition being used to store the starting address and offset of each of the second partitions, the second partitions being used to store an image package of a target application, wherein after the image package is changed, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package.
[0027] The fifth aspect of this application provides a computer program product, including computer-readable instructions that, when executed on a chip, cause the chip to implement the application loading method described in the first aspect or any implementation thereof.
[0028] By employing the above technical solution, the application loading method and related apparatus provided in this application establish a first partition in external memory for storing the start addresses and offsets of each second partition. If the target application changes (e.g., due to an upgrade), causing a change in the target application's image package, the start address and offset of the second partition containing the changed image package are updated, and the updated second partition can store the changed image package. The application loading method of this application can read the start addresses and offsets of each second partition stored in the first partition, and copy the data in each second partition to internal memory based on these start addresses and offsets. Thus, this application solves the application compatibility problem. Attached Figure Description
[0029] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0030] Figure 1 This application provides a schematic diagram illustrating the connection between a chip and an external memory in an embodiment of the present application.
[0031] Figure 2 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application;
[0032] Figure 3 A schematic diagram of the partitioning of the external memory provided in the embodiments of this application;
[0033] Figure 4 A flowchart illustrating an application loading method provided in an embodiment of this application;
[0034] Figure 5 A flowchart illustrating another application loading method provided in this application embodiment;
[0035] Figure 6 A flowchart illustrating yet another application loading method provided in this application embodiment;
[0036] Figure 7 A schematic diagram of the partitioning of internal and external memory provided for embodiments of this application;
[0037] Figure 8 A schematic diagram of the internal memory partitioning provided in an embodiment of this application;
[0038] Figure 9 This is a flowchart illustrating another application loading method provided in an embodiment of this application.
[0039] Figure label:
[0040] 001 - Chip; 003 - Internal memory; 002 - External memory;
[0041] 110 - Radio Frequency Unit; 120 - Memory; 130 - Input Unit; 140 - Display Unit; 150 - Camera; 160 - Audio Circuit; 161 - Speaker; 162 - Microphone; 163 - Headphone Jack; 170 - Processor; 180 - External Interface; 190 - Power Supply;
[0042] 0021 - First partition; 0022 - Second partition. Detailed Implementation
[0043] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0044] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0045] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0046] This application can be applied to the field of application loading. The following will introduce the application scenarios of chip connection to external memory as an example.
[0047] like Figure 1 As shown, chip 001 includes internal memory 003, which is electrically connected to external memory 002. Optionally, the external memory 002 in this application can be any type of erasable programmable memory whose data is retained after power loss, including but not limited to: flash memory, electrically erasable programmable read-only memory (EEPROM), etc. Flash memory is a form of electronically erasable programmable read-only memory that allows for multiple erasures or writes during operation. Flash memory includes two types: NOR flash memory and NAND flash memory. In one optional implementation, the external memory 002 of this application can be a NOR flash memory based on the Serial Peripheral Interface (SPI), abbreviated as SPI-NorFlash; the external memory 002 of this application can also be a NOR flash memory based on the Expanded Serial Peripheral Interface (xSPI), abbreviated as xSPI-NorFlash.
[0048] Optionally, this application can be applied to embedded systems.
[0049] The internal memory 003 in this application can be any type of random access memory (RAM), such as static random access memory (SRAM), dynamic random access memory (DRAM), etc.
[0050] It should be noted that, Figure 1 The chip 001 shown is for illustrative purposes only and does not imply that the chip is composed of a single electronic device. Those skilled in the art will understand that chip 001 can be composed of multiple electronic devices, including internal memory 003.
[0051] like Figure 1 As shown, by attaching the external memory 002 to the chip 001, the capacity of the chip 001 can be easily expanded. When the external memory 002 contains the image package of the target application, the image package of the target application needs to be loaded into the internal memory 003 so that the target application can run or can run efficiently.
[0052] As will be understood by those skilled in the art, loading is the process of loading the data or resources required by an application from external memory into the chip's internal memory so that the application can use that data or resources.
[0053] Figure 1 The chip 001 shown can be a processor in a terminal or a processor in a server.
[0054] The product form of the terminal will be described next;
[0055] The terminal in this application embodiment can be a mobile phone, tablet computer, wearable device, in-vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc., and this application embodiment does not impose any limitations on it. Among them, the in-vehicle device can be an electronic control unit (ECU).
[0056] Figure 2 A schematic diagram of one possible hardware architecture for the terminal is shown.
[0057] refer to Figure 2As shown, the terminal may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), a headphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190, and other components. Those skilled in the art will understand that... Figure 2 These are merely examples of terminals or multi-functional devices and do not constitute a limitation on terminals or multi-functional devices. They may include more or fewer components than shown in the illustration, or combine certain components, or use different components.
[0058] The input unit 130 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the portable multi-functional device. Specifically, the input unit 130 may include a touchscreen 131 (optional) and / or other input devices 132. The touchscreen 131 can collect touch operations performed by the user on or near it (such as operations performed by the user using fingers, knuckles, styluses, or any suitable object on or near the touchscreen), and drive the corresponding connection devices according to a pre-set program. The touchscreen can detect the user's touch actions, convert the touch actions into touch signals and send them to the processor 170, and can receive and execute commands sent by the processor 170; the touch signal includes at least touch point coordinate information. The touchscreen 131 can provide an input interface and an output interface between the terminal and the user. In addition, various types of touchscreens, such as resistive, capacitive, infrared, and surface acoustic wave, can be used to implement the touchscreen. Besides the touchscreen 131, the input unit 130 may also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0059] Among them, the input device 132 can receive input data, etc.
[0060] The display unit 140 can be used to display information input by the user or information provided to the user, various menus of the terminal, interactive interfaces, file display, and / or playback of any multimedia file. In this embodiment, the display unit 140 can be used to display the file management interface of external storage, the interface displayed after running the target application, etc.
[0061] The memory 120 can be used to store instructions and data. The memory 120 may primarily include an instruction storage area and a data storage area. The data storage area can store various types of data, such as multimedia files and text. The instruction storage area can store software units such as operating systems, applications, and instructions required for at least one function, or subsets or extended sets thereof. It may also include non-volatile random access memory. It provides the processor 170 with hardware, software, and data resources for managing the computing device, supporting control software and applications. It is also used for storing multimedia files, as well as storing running programs and applications.
[0062] The memory 120 can be used in this application Figure 1 The external memory 002 is shown. In another alternative embodiment, this memory 120 is related to the present application. Figure 1 The external memory 002 shown can also be a different type of memory. For example, when the terminal is an ECU, the ECU has internal RAM and ROM. The RAM inside the ECU is the ECU's internal memory. Figure 2 The memory 120 shown. At this time, the external memory of this application is a memory other than the ECU. For example, if the external memory of this application is a flash memory USB flash drive, the application loading method of this application can be implemented by inserting the USB flash drive into the USB interface electrically connected to the ECU.
[0063] The processor 170 is the control center of the terminal, connecting various parts of the terminal through various interfaces and lines. It executes instructions stored in the memory 120 and calls data stored in the memory 120 to perform various functions and process data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory can be implemented on a single chip; in some embodiments, they can also be implemented on separate chips. The processor 170 can also be used to generate corresponding operation control signals, send them to the corresponding components of the computing device, read and process data in the software, especially read and process data and programs in the memory 120, so that the various functional modules therein perform corresponding functions, thereby controlling the corresponding components to act according to the instructions.
[0064] The processor 170 can be used in this application. Figure 1 The chip shown is 001.
[0065] The memory 120 can be used to store the software code of the initial boot program (BootROM), and the processor 170 can execute the steps of the application loading method of this application, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve the corresponding functions.
[0066] The radio frequency unit 110 (optional) can be used for receiving and transmitting signals during information transmission or calls. For example, it can receive downlink information from the base station and process it for the processor 170; additionally, it can transmit uplink data to the base station. Typically, the RF circuit includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the radio frequency unit 110 can also communicate wirelessly with network devices and other devices. This wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0067] In this embodiment of the application, the radio frequency unit 110 can send data to the server and receive the processing results sent by the server.
[0068] It should be understood that the radio frequency unit 110 is optional and can be replaced with other communication interfaces, such as a network port.
[0069] The terminal also includes a power supply 190 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0070] The terminal also includes an external interface 180, which can be a standard Micro USB interface or a multi-pin connector, which can be used to connect the terminal to other devices for communication or to connect a charger to charge the terminal.
[0071] Although not shown, the terminal may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with various functions, etc., which will not be elaborated here. Some or all of the methods described below can be applied to, for example... Figure 2 In the terminal shown.
[0072] The application loading method of this application embodiment will be described in detail below with reference to the accompanying drawings.
[0073] This application provides an embodiment of an application loading method, which is applied to... Figure 1 The chip 001 shown is as follows: Figure 1 As shown, chip 001 is electrically connected to external memory 002. Figure 3 As shown, the external memory 002 is provided with a first partition 0021 and at least one second partition 0022. The first partition 0021 is used to store the starting address and offset of each second partition 0022. The second partition 0022 is used to store the image package of the target application. After the image package changes, the starting address and offset of the second partition 0022 where the changed image package is located are updated so that the updated second partition 022 stores the changed image package.
[0074] In one optional embodiment, the external memory 002 may consist only of a first partition 0021 and each of the second partitions 0022, that is, the first partition 0021 and each of the second partitions 0022 together constitute the entire storage area of the external memory 002. In another optional embodiment, in addition to the first partition 0021 and each of the second partitions 0022, the external memory 002 may also have other storage areas.
[0075] Since this application specifically sets up a first partition 0021 for storing the starting address and offset of each second partition, if the target application changes (such as an upgrade) and the target application image package changes, the starting address and offset of each second partition stored in the first partition 0021 can be updated according to the changed image package.
[0076] The following example demonstrates a process for updating the starting address and offset of each second partition when the image package changes:
[0077] After the target application's image package changes, the upgrade push script updates the starting address and offset of the second partition where the changed image package is located based on the changed image package, and pushes the updated starting address and offset of the second partition along with the changed image package as the upgrade file.
[0078] Specifically, the upgrade push script can utilize Over-the-Air (OTA) technology to push the upgrade file to the network-side device, thereby controlling the target application to perform a remote upgrade. The chip can obtain the upgrade file sent by the network-side device through a communication unit (such as an RF unit) and save it to external memory 002. This updates the starting address and offset of each second partition to the first partition.
[0079] In one optional implementation, the first partition and each of the second partitions are arranged sequentially in external memory 002.
[0080] Reference Figure 4 , Figure 4 This is a flowchart illustrating an application loading method provided in an embodiment of this application, as shown below. Figure 4 As shown in the figure, an application loading method provided in this application embodiment may include steps 401 to 402, which are described in detail below.
[0081] 401. The initial boot program within the chip starts the bootloader in the chip's internal memory.
[0082] The initial boot program (Bootrom) is a string of code embedded in the chip. It is the first string of code executed when the chip is powered on or reset. Step 401 can be executed when the chip is powered on or reset. In another alternative implementation, step 401 can also begin execution after the external memory is electrically connected to the chip.
[0083] The bootloader runs before the system kernel. It can initialize hardware devices and establish a memory space mapping, thereby bringing the system's hardware and software environment to a suitable state.
[0084] In one alternative implementation, the bootloader may be stored in the external memory, and the bootloader in the internal memory may be copied from the external memory to the internal memory, or it may be copied from another location to the internal memory.
[0085] Optionally, the bootloader in internal memory can be located in a partition of internal memory. This application does not limit the starting address and offset of this partition. For example, the starting address of the partition can be the starting address of the internal memory.
[0086] 402. The bootloader reads the starting address and offset of each second partition stored in the first partition, and copies the image package in each second partition to the internal memory according to the starting address and offset of each second partition stored in the first partition.
[0087] Since the first partition stores the starting address and offset of each second partition, the bootloader can determine the address range of each second partition based on its starting address and offset, and then copy the data in each second partition sequentially or in parallel into the internal memory. Optionally, the internal memory may have a third partition corresponding to at least one second partition, and the bootloader can copy the data in at least one second partition into the corresponding third partition. The offsets of the corresponding second and third partitions can be the same or different.
[0088] After copying the data from the second partition to the internal storage, the target application can start running, thus achieving application loading in this application.
[0089] The application loading method of this application sets up a first partition in external storage to store the start addresses and offsets of each second partition. If the target application changes (such as through an upgrade), causing a change in the target application's image package, the start address and offset of the second partition containing the changed image package are updated, and the updated second partition can store the changed image package. The application loading method of this application can read the start addresses and offsets of each second partition stored in the first partition, and copy the data in each second partition to internal storage based on these start addresses and offsets. In this way, this application solves the application compatibility problem.
[0090] Meanwhile, storing the starting addresses and offsets of each second partition in a dedicated partition facilitates management and updates without affecting data in other partitions. For example, when a fourth partition is set up in the external storage to store the bootloader, changes to the data in the first partition (i.e., the starting addresses and offsets of each second partition stored in the first partition) will not affect the bootloader in the fourth partition. Thus, when the target application's image package changes, there is no need to update the bootloader in the fourth partition, reducing workload.
[0091] In another alternative implementation, a fourth partition is provided in the external storage, which is used to store the bootloader, such as... Figure 5 As shown, before step 401, Figure 4 The application loading method shown also includes:
[0092] 400. The initial boot program inside the chip copies the bootloader in the fourth partition to the fifth partition of the internal memory. The initial boot program completes the initialization of the bootloader in the fifth partition.
[0093] Since the data stored in the chip's internal memory may be lost upon power failure, this application can set up a fourth partition in external memory to store the bootloader. Before executing steps 401 and 402, the initial boot program within the chip can first copy the bootloader from the fourth partition to the fifth partition of the internal memory, and then the initial boot program completes the initialization of the bootloader in the fifth partition. After initialization is complete, the initial boot program within the chip can start the bootloader in the chip's internal memory.
[0094] The initialization of the bootloader mentioned above may include the initialization of the bootloader's runtime environment. By initializing the runtime environment, the bootloader can run in a suitable environment.
[0095] The initialization of the aforementioned bootloader may include the initialization of the chip kernel.
[0096] Optionally, the starting address of the fourth partition can be the starting address of external memory 002, such as address 0x00000000. In this way, after chip 001 is powered on, when reading data from external memory 002, it will first read the bootloader stored in the fourth partition, thereby executing step 400.
[0097] In another alternative implementation, such as Figure 6 As shown, after step 402, the application loading method further includes:
[0098] 403. Run the target application. After the target application runs, the fifth partition is set up as a storage area for storing at least one other type of data besides the bootloader.
[0099] After copying the data from each of the second partitions to internal memory, the target application can run, and the bootloader in the fifth partition is no longer needed for processing. Therefore, this application can set the fifth partition as a storage area for storing at least one other type of data besides the bootloader, thus achieving time-sharing multiplexing of the fifth partition and effectively improving the space utilization of internal memory.
[0100] Optionally, the other data mentioned above can be data generated during the target application's runtime, or it can be state data when the target application is abnormally interrupted, such as: memory data, register status, stack pointer, memory management information, etc., at the time of the abnormal interruption. The state data when the target application is abnormally interrupted can be data stored in a coredump file.
[0101] In another alternative implementation, Figure 4Step 402, which involves copying the image packages from each of the second partitions to the internal storage, may specifically include:
[0102] The image packages in each second partition are copied to the corresponding third partitions, which are located in the internal storage.
[0103] The first partition is specifically used to store the mapping table, which stores the correspondence between the second and third partitions. The mapping table also stores the starting address and offset of each second partition and the starting address and offset of each third partition.
[0104] The second and third partitions can have a one-to-one correspondence or a non-one-to-one correspondence. The offsets of the corresponding second and third partitions can be the same or different.
[0105] Optionally, the bootloader may also create a runtime data partition in internal memory, which is used to store data generated during the bootloader's execution and / or the target application's execution. Of course, the bootloader may also create other partitions, which are not limited in this application.
[0106] The following example illustrates the partitioning of external and internal memory.
[0107] Figure 7 A schematic diagram of the partitioning of external and internal memory provided in this application is shown below. Figure 7 As shown, the external storage includes: a bootloader partition, a configuration parameter partition, an application code partition, a calibration data partition, and a diagnostic data partition. The internal storage includes: a bootloader partition, an application code partition, a calibration data partition, a diagnostic data partition, a data partition, and a reserved partition.
[0108] The external storage partition is designated as the fourth partition, the configuration parameter partition as the first partition, and the program execution code partition and calibration data partition as two second partitions. The diagnostic data partition in external storage may contain no data or may contain Decentralized Identity (DID). The DID is used to identify specific information, such as diagnostic data and critical information. This application can copy the data from the diagnostic data partition in external storage to internal storage and establish a diagnostic data partition in internal storage. Diagnostic data and critical information generated during the target application's execution can then be stored corresponding to the DIDs in the diagnostic data partition in internal storage.
[0109] Optionally, the first partition is also used to store the starting address and offset of the diagnostic data partition in the external memory. The bootloader reads the starting address and offset of the diagnostic data partition stored in the first partition and copies the data of the diagnostic data partition to the internal memory according to the starting address and offset of the diagnostic data partition.
[0110] The boot partition in internal memory is the fifth partition, while the program execution code partition and the calibration data partition in internal memory are two third partitions. The mapping table stores the correspondence between each partition in internal memory and each partition in external memory. The mapping table also stores the starting address and offset of each partition in internal memory and each partition in external memory.
[0111] The following table 1 illustrates one possible function of the above partitions:
[0112] Table 1, Partition Description Table
[0113] Partition Name describe Boot partition Store the bootloader code Configuration parameter partition Store the mapping table of each partition. Program execution code partition Store the target application's runtime code Calibrate data partitions Store the calibration data of the target application Diagnostic data partitioning Store diagnostic data and key information Running data partitions Store data generated during code runtime Reserved partition Reserved area
[0114] Figure 7 The internal memory partitioning shown is the partitioning configuration before the target application runs. After the target application runs, the internal memory partitioning configuration can be as follows: Figure 8 As shown. Comparison Figure 7 and Figure 8 It can be seen that after the target application runs, Figure 7 The boot partition of the internal memory is modified into an exception data partition, which is used for state data when the target application is abnormally interrupted, thus realizing time-sharing multiplexing of the partition.
[0115] Reference Figure 9 , Figure 9 A flowchart illustrating another application loading method provided in this application embodiment is shown below. Figure 9 As shown in the embodiment of this application, an application loading method may include steps 901 to 905, which are described in detail below.
[0116] 901. The initial boot program within the chip starts the bootloader in the chip's internal memory.
[0117] Step 901 and Figure 4 The steps in step 401 are the same as those shown, and will not be repeated here.
[0118] 902. The bootloader reads the starting address and offset of each of the second partitions stored in the first partition.
[0119] Step 902 and Figure 4 The process of the bootloader reading the starting address and offset of each second partition stored in the first partition in step 402 is the same and will not be described again.
[0120] 903. The bootloader performs verification calculations on the starting address and offset of each second partition stored in the first partition based on a preset verification calculation method, and obtains the verification calculation results.
[0121] The above-mentioned preset verification calculation method can be any calculation method with data integrity or data consistency verification function, such as Cyclic Redundancy Check (CRC) algorithm or checksum algorithm.
[0122] 904. Compare the verification calculation result with the preset calculation result stored in the first partition. If they match, proceed to step 905.
[0123] In one implementation, the preset calculation results stored in the first partition include the preset calculation results of each second partition. This application can perform verification calculations on the starting address and offset of each second partition separately to obtain the verification calculation result for each second partition, and then compare the verification calculation results of the same second partition with the preset calculation results. If the comparison results of all second partitions are consistent, step 905 is then executed. If the comparison results of at least one second partition are inconsistent, a prompt message indicating that the data stored in the first partition is incomplete can be output.
[0124] In one implementation, the preset calculation result stored in the first partition is the overall preset calculation result for all second partitions. This application can perform verification calculations on the starting address and offset of all second partitions to obtain the overall verification calculation result for all second partitions, and then compare the overall verification calculation result with the overall preset calculation result. If they match, step 905 is executed. If they do not match, a prompt message indicating that the data stored in the first partition is incomplete is output.
[0125] Optionally, the preset calculation results can be stored at the end of the first partition. The preset calculation results can be obtained by pre-calculating the starting addresses and offsets of each second partition stored within the first partition based on a preset verification calculation method. If the verification calculation result matches the preset calculation result stored in the first partition, it indicates that the starting addresses and offsets of each second partition stored in the first partition are complete / consistent. If the verification calculation result matches the preset calculation result stored in the first partition, then executing step 905 ensures the integrity / consistency of the target application image package copied to internal storage.
[0126] 905. Based on the starting address and offset of each second partition stored in the first partition, copy the image package in each second partition to the internal storage.
[0127] Step 905 and Figure 4 The process of copying the data in each third partition to the internal memory according to the starting address and offset of each third partition stored in the second partition in step 402 is the same and will not be described again.
[0128] The above describes an application loading method provided by an embodiment of this application. The following will describe the chip that executes the above application loading method.
[0129] Please combine Figure 1 and Figure 3 Chip 001 is electrically connected to external memory 002. External memory 002 is provided with a first partition 0021 and at least one second partition 0022. The first partition 0021 is used to store the starting address and offset of each second partition 0022. The second partition 0022 is used to store the image package of the target application. After the image package changes, the starting address and offset of the second partition 0022 where the changed image package is located are updated so that the updated second partition 0022 stores the changed image package.
[0130] When chip 001 executes its internal initial startup program, it starts the bootloader program in the chip's internal memory.
[0131] When chip 001 executes the bootloader in the fourth partition, it reads the starting address and offset of each second partition stored in the first partition, and copies the image package in each second partition to the internal memory according to the starting address and offset of each second partition stored in the first partition.
[0132] Optionally, when chip 001 executes the bootloader in the fourth partition, it copies the image packages in each of the second partitions to the internal memory. Specifically, when chip 001 executes the bootloader in the fourth partition, it copies the image packages in each of the second partitions to the corresponding third partitions, and each third partition is located in the internal memory.
[0133] The first partition is specifically used to store the mapping table, which stores the correspondence between the second and third partitions. The mapping table also stores the starting address and offset of each second partition and the starting address and offset of each third partition.
[0134] Optionally, when the chip executes the bootloader, it also performs the following: after reading the starting address and offset of each second partition stored in the first partition, it performs a verification calculation on the starting address and offset of each second partition stored in the first partition based on a preset verification calculation method, obtains the verification calculation result, compares the verification calculation result with the preset calculation result stored in the first partition, and if they match, copies the image package in each second partition to the internal memory according to the starting address and offset of each second partition stored in the first partition.
[0135] Optionally, a fourth partition is provided in the external memory. The fourth partition is used to store the bootloader. When the chip executes the internal initial boot program, it also implements the following: before starting the bootloader in the chip's internal memory, the bootloader in the fourth partition is copied to the fifth partition of the internal memory. The initial boot program completes the initialization of the bootloader in the fifth partition.
[0136] Optionally, when the chip executes the bootloader, it also implements the following: after copying the image packages in each of the second partitions into the internal memory, the target application is run, and the fifth partition is set up as a storage area for storing at least one other data besides the bootloader after the target application runs.
[0137] The chip provided in this application can read the updated starting addresses and offsets of each of the second partitions stored in the first partition, and copy the data in each of the second partitions to the internal memory according to the starting addresses and offsets of each of the second partitions stored in the first partition. In this way, this application solves the application compatibility problem.
[0138] This application embodiment also provides an external memory, which is electrically connected to the chip. The external memory is provided with a first partition and at least one second partition. The first partition is used to store the starting address and offset of each second partition. The second partition is used to store the image package of the target application. After the image package changes, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package.
[0139] After the bootloader in the chip's internal memory is started by the chip's initial boot program, it performs the following: reads the starting address and offset of each second partition stored in the first partition, and copies the image package in each second partition to the internal memory according to the starting address and offset of each second partition stored in the first partition.
[0140] This application embodiment also provides a circuit, including: an external memory and a chip provided in this application embodiment. The chip is electrically connected to the external memory. The external memory is provided with a first partition and at least one second partition. The first partition is used to store the starting address and offset of each second partition. The second partition is used to store the image package of the target application. After the image package changes, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package.
[0141] This application also provides a computer program product, including computer-readable instructions, which, when executed on a chip, cause the chip to implement any of the application loading methods provided in this application.
[0142] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0143] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0144] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0145] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. An application loading method, characterized in that, The chip is electrically connected to an external memory, which has a first partition and at least one second partition. The first partition is used to store the starting address and offset of each second partition, and the second partition is used to store the image package of the target application. After the image package changes, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package. The application loading method includes: The initial boot program within the chip starts the bootloader in the chip's internal memory; The bootloader reads the starting address and offset of each of the second partitions stored in the first partition, and copies the image package in each of the second partitions to the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
2. The application loading method according to claim 1, characterized in that, The step of copying the image package in each of the second partitions to the internal memory includes: copying the image package in each of the second partitions to each of the third partitions corresponding to the second partitions, wherein each of the third partitions is located in the internal memory; The first partition is specifically used to store a mapping table, which stores the correspondence between the second partition and the third partition. The mapping table also stores the starting address and offset of each second partition and the starting address and offset of each third partition.
3. The application loading method according to claim 1, characterized in that, After the bootloader reads the starting address and offset of each of the second partitions stored in the first partition, the application loading method further includes: The bootloader performs a verification calculation on the starting address and offset of each of the second partitions stored in the first partition based on a preset verification calculation method, obtains the verification calculation result, compares the verification calculation result with the preset calculation result stored in the first partition, and if they match, then executes the step: copying the image package in each of the second partitions to the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
4. The application loading method according to claim 1, characterized in that, The external memory has a fourth partition for storing the bootloader. Before starting the bootloader in the chip's internal memory, the application loading method further includes: The initial boot program within the chip copies the bootloader from the fourth partition to the fifth partition of the internal memory, and the initial boot program completes the initialization of the bootloader in the fifth partition.
5. The application loading method according to claim 4, characterized in that, After copying the image package from each of the second partitions to the internal storage, the application loading method further includes: The target application is run, and the fifth partition is set up as a storage area for storing at least one other type of data besides the bootloader after the target application is run.
6. A chip, characterized in that, The chip is electrically connected to an external memory, which has a first partition and at least one second partition. The first partition is used to store the starting address and offset of each second partition, and the second partition is used to store the image package of the target application. After the image package changes, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package. When the chip executes its internal initial startup program, it performs the following: starts the bootloader program in the chip's internal memory; When the chip executes the bootloader, it reads the starting address and offset of each of the second partitions stored in the first partition, and copies the image package in each of the second partitions to the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
7. The chip according to claim 6, characterized in that, The external storage device has a fourth partition, which is used to store the bootloader program. When the chip executes its internal initial startup program, it also performs the following: before starting the bootloader in the chip's internal memory, it copies the bootloader in the fourth partition to the fifth partition of the internal memory, thereby completing the initialization of the bootloader in the fifth partition. When the chip executes the bootloader, it also performs the following: after copying the image package in each of the second partitions into the internal memory, it runs the target application, and the fifth partition is set as a storage area for storing at least one other data besides the bootloader after the target application runs.
8. An external memory, characterized in that, The external memory is electrically connected to the chip. The external memory is provided with a first partition and at least one second partition. The first partition is used to store the starting address and offset of each second partition. The second partition is used to store the image package of the target application. After the image package changes, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package. After the bootloader in the chip's internal memory is started by the chip's initial boot program, it performs the following: reads the starting address and offset of each of the second partitions stored in the first partition, and copies the image package in each of the second partitions into the internal memory according to the starting address and offset of each of the second partitions stored in the first partition.
9. A circuit, characterized in that, include: An external memory and the chip according to claim 6 or 7, wherein the chip is electrically connected to the external memory, the external memory is provided with a first partition and at least one second partition, the first partition is used to store the starting address and offset of each of the second partitions, the second partition is used to store the image package of the target application, and after the image package is changed, the starting address and offset of the second partition where the changed image package is located are updated so that the updated second partition stores the changed image package.
10. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on a chip, cause the chip to implement the application loading method as described in any one of claims 1 to 5.