Access code function loading method and device, storage medium and equipment
By writing sct scattered loading files and loading access code functions in embedded compilers, the compatibility issue of access code function loading functions in sct type scattered loading file compilers is solved, achieving wider applicability and resource recycling.
Patent Information
- Application Number
- CN202411515594.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-14
AI Technical Summary
The existing access code function loading function cannot work properly in embedded compilers that use the sct type to scatter load files, resulting in compatibility issues when selecting a compiler.
By writing a sct scatter loading file, define the starting address and size of the target free ROM space and the target free RAM space, load the access code function into the target free ROM space, and copy it to the target free RAM space when the code is run, Execute the rewritten task and uninstall it when completed to achieve resource recycling.
The access code function is extended to make it suitable not only for compilers with icf type scattered loading files, but also works normally in compilers with scat type scattered loading files, improving scope of application and maturity.
Smart Images

Figure CN119440663A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an access code function loading method, device, storage medium and equipment. Background Art
[0002] The AC access code function is a function that performs the flash area erase and write function. And the access code function usually requires the compiler to cooperate in the loading process.
[0003] The existing access code function loading functions are all implemented by a single embedded compiler represented by IAR that uses icf type scattered loading files. Although a complete scattered loading file writing implementation method can be formed under this compiler, with the development and update of embedded compilers, the types of available compilers are more extensive, for example, embedded compilers represented by Keil that use sct type scattered loading files, etc. This makes the choices of chip manufacturers more diverse, but when chip manufacturers choose embedded compilers such as Keil that use sct type scattered loading files to adapt chips, they cannot implement the loading of access code functions. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to provide an access code function loading method, device, storage medium and equipment, which can realize the loading of the access code function by an embedded compiler using an sct type distributed loading file, thereby effectively expanding the loading method of the access code function and improving its scope of application.
[0005] The present application embodiment provides an access code function loading method, including:
[0006] Writing an sct scatter loading file; the sct scatter loading file defines the starting address and size of the target free ROM space and the target free RAM space;
[0007] Loading the access code function into the target free ROM space to access the access code function through the start address of the target free ROM space;
[0008] Copying the data in the target free ROM space storing the access code function to the target free RAM space;
[0009] By running the access code function in the target free RAM space, the erase task corresponding to the erase request suspended by the user is executed, and when the task is completed, the access code function in the target free RAM space is uninstalled to realize resource recovery.
[0010] In a possible implementation, the step of writing the sct scatter-loading file in response to a user-suspended erase request includes:
[0011] Determine a starting address and size of a block of free ROM space as the initial free ROM space; the size of the initial free ROM space is not less than the size of the space occupied by the access code function;
[0012] Determine a starting address and size of a free RAM space as a target free RAM space; the size of the target free RAM space is consistent with the size of the initial free ROM space;
[0013] A space area is selected in the ROM as the target free ROM space, and the starting address of the target space area is set to the starting address of the initial free ROM space, and the size of the target space area is set to the size of the initial free ROM space, so as to store the access code function in the target free ROM space area.
[0014] In a possible implementation, loading the access code function into the target free ROM space includes:
[0015] After writing the sct scattered loading file, the sct scattered loading file is used to compile the code and load the access code function into the target free ROM space to generate a corresponding map file; wherein the map file describes the loading position of the access code function in the target free ROM space and the related information of the access code function stored in the space.
[0016] In a possible implementation, the relevant information of the access code function includes a data description of the access code function, an occupied space size, and an end position.
[0017] In a possible implementation, after executing the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, the method further includes:
[0018] If the erase task corresponding to the erase request suspended by the user is not completed and the task has not timed out, the callback function is executed to complete a loop processing process, and continue to determine whether the erase task corresponding to the erase request suspended by the user is completed and whether the task has timed out;
[0019] If the erase task corresponding to the erase request suspended by the user has not been completed and the task has not timed out, the callback function will continue to be executed to complete the next loop processing process, and so on, until the erase task corresponding to the erase request suspended by the user is completed or the task times out, the loop will end and the subsequent process will continue.
[0020] In a possible implementation, after executing the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, the method further includes:
[0021] After completing the erase task corresponding to the erase request suspended by the user, check whether there are tasks corresponding to other suspended erase requests that need to be continued; if so, continue to execute tasks corresponding to other erase requests by running the access code function until the tasks corresponding to all existing erase requests are completed, and then uninstall the access code function in the target free RAM space to realize resource recovery.
[0022] The embodiment of the present application also provides an access code function loading device, the device comprising:
[0023] A writing unit, used for writing an sct scatter-loading file; the sct scatter-loading file defines the starting address and size of the target free ROM space and the target free RAM space;
[0024] A loading unit, configured to load an access code function into the target free ROM space, so as to access the access code function through a starting address of the target free ROM space;
[0025] A copy unit, used for copying the data in the target free ROM space storing the access code function to the target free RAM space;
[0026] The unloading unit is used to execute the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, and when the task is completed, the access code function in the target free RAM space is unloaded to realize resource recovery.
[0027] In a possible implementation, the writing unit includes:
[0028] The first determination subunit is used to determine the starting address and size of a block of free ROM space as the initial free ROM space; the size of the initial free ROM space is not less than the size of the space occupied by the access code function;
[0029] The second determination subunit is used to determine the starting address and size of a free RAM space as a target free RAM space; the size of the target free RAM space is consistent with the size of the initial free ROM space;
[0030] The setting subunit is used to select a space area in the ROM as a target free ROM space, and set the starting address of the target space area to the starting address of the initial free ROM space, and set the size of the target space area to the size of the initial free ROM space, so as to store the access code function in the target free ROM space area.
[0031] In a possible implementation, the loading unit is specifically used for:
[0032] After writing the sct scattered loading file, the sct scattered loading file is used to compile the code and load the access code function into the target free ROM space to generate a corresponding map file; wherein the map file describes the loading position of the access code function in the target free ROM space and the related information of the access code function stored in the space.
[0033] In a possible implementation, the relevant information of the access code function includes a data description of the access code function, an occupied space size, and an end position.
[0034] In a possible implementation, the device further includes:
[0035] The first execution unit is used to execute the callback function if the erase task corresponding to the erase request suspended by the user is not completed and the task has not timed out, complete a loop processing process, and continue to determine whether the erase task corresponding to the erase request suspended by the user is completed and whether the task has timed out;
[0036] The second execution unit is used to continue executing the callback function and complete the next loop processing process if the erase task corresponding to the erase request suspended by the user has not been completed and the task has not timed out, and so on, until the erase task corresponding to the erase request suspended by the user is completed or the task times out, ending the loop and continuing to execute subsequent processes.
[0037] In a possible implementation, the device further includes:
[0038] The third execution unit is used to detect whether there are tasks corresponding to other pending erase requests that need to be continued to be executed after completing the erase task corresponding to the erase request suspended by the user; if so, continue to execute the tasks corresponding to other erase requests by running the access code function until the tasks corresponding to all existing erase requests are completed, and then unload the access code function in the target free RAM space to realize resource recovery.
[0039] The embodiment of the present application also provides an access code function loading device, including: a processor, a memory, and a system bus;
[0040] The processor and the memory are connected via the system bus;
[0041] The memory is used to store one or more programs, and the one or more programs include instructions. When the instructions are executed by the processor, the processor executes any one of the implementations of the access code function loading method.
[0042] The embodiment of the present application further provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes any one of the implementations of the access code function loading method described above.
[0043] The embodiment of the present application further provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes any one of the implementations of the access code function loading method described above.
[0044] The embodiment of the present application provides an access code function loading method, device, storage medium and equipment, firstly, write an sct scattered loading file; wherein, the starting address of the target free ROM space and the target free RAM space is defined in the sct scattered loading file, then, load the access code function into the target free ROM space, so as to access the access code function through the starting address of the target free ROM space; then, copy the data in the target free ROM space storing the access code function to the target free RAM space; then, by running the access code function in the target free RAM space, the erase task corresponding to the erase request suspended by the user can be executed, and when the task is completed, the access code function in the target free RAM space can be unloaded to realize resource recovery. It can be seen that, since the present application writes the content of the sct scattered loading file, the access code function loading function can be used normally in the compiler using the sct type scattered loading file, thereby effectively expanding the loading method of the access code function and improving its scope of application. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1 A flowchart of an access code function loading method provided in an embodiment of the present application;
[0047] Figure 2A schematic diagram of a process of cyclically executing a callback function provided in an embodiment of the present application;
[0048] Figure 3 The overall process diagram of access code function loading provided in the embodiment of the present application;
[0049] Figure 4 A schematic diagram of the composition of an access code function loading device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] Normally, the program code is stored in the PFlash (Program Flash) sector. When the code is performing an erase or write task, the current sector content cannot be accessed, that is, the code instructions stored in the current sector cannot be obtained.
[0051] To solve this problem, the access code function is currently used as an independent erase and write function execution function, which is stored separately in the Fls_Ac.c file of the Flash. When the program is running, it will be loaded into the random access memory (RAM) space for erase or write function implementation. Specifically, the access code function will be loaded into the RAM space before the erase or write command is executed, and the corresponding command will be read in the RAM space to perform the erase and write operation. After the execution is completed, the access code function will be unloaded from the RAM space, that is, the corresponding RAM space will be released, and the erase and write task will be completed.
[0052] It should be noted that the existing access code function requires the cooperation of the compiler during the loading process. The compiler will load the scattered loading file during the compilation process, which defines the specific ROM and RAM space usage methods. Specifically, first, it is necessary to declare a free read-only memory (ROM) space in the file, which is used to automatically load the access code function into the partially controllable area when the program is running. Then, it is also necessary to declare a free RAM space, which is used to copy the access code function stored in the ROM area to the RAM space for the execution of the erase and write function when the program is running.
[0053] However, the existing access code function loading functions are all implemented by a single embedded compiler represented by IAR that uses icf type scattered loading files. Although a complete scattered loading file writing implementation method can be formed under this compiler, there is no mature access code function loading implementation method for embedded compilers such as Keil that use sct type scattered loading files. With the development and update of embedded compilers, the types of available compilers are more extensive, and the choices of chip manufacturers are more diverse. When a chip manufacturer specifies that its chip is adapted to a certain compiler implementation, the modification items for the embedded compiler will become a fixed specification. However, this specification has not yet been implemented for the loading method of the access code function in embedded compilers that use sct type scattered loading files.
[0054] In order to solve the above defects, the present application provides an access code function loading method, firstly, write an sct scatter loading file; wherein, the sct scatter loading file defines the starting addresses of the target free ROM space and the target free RAM space, then, load the access code function into the target free ROM space, so as to access the access code function through the starting address of the target free ROM space; then, copy the data in the target free ROM space storing the access code function to the target free RAM space; and then, by running the access code function in the target free RAM space, execute the erase task corresponding to the erase request suspended by the user, and when the task is completed, unload the access code function in the target free RAM space to realize resource recovery. It can be seen that, since the present application writes the content of the sct scatter loading file, the access code function loading function can be used normally in the compiler using the sct type scatter loading file, thereby effectively expanding the loading method of the access code function and improving its scope of application.
[0055] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0056] First embodiment
[0057] See also Figure 1 , is a flow chart of an access code function loading method provided in this embodiment, the method comprising the following steps:
[0058] S101: Write an sct scatter-loading file; wherein the sct scatter-loading file defines the starting address and size of the target free ROM space and the target free RAM space.
[0059] It should be noted that, in the existing access code function loading method, it is usually implemented by relying on a single embedded compiler represented by IAR that uses an icf type scatter loading file, and the description of the access code function in the icf type scatter loading file is relatively complex. For this reason, an embedded compiler represented by Keil that uses an sct type scatter loading file came into being, and the access code function part in the sct type scatter loading file can achieve the same function through a simple description.
[0060] Specifically, in order to be able to use the access code function loading function normally in the compiler using the sct type scattered loading file, firstly, the content of the sct scattered loading file is written to realize the loading of the access code function by executing the subsequent steps S102-S104, wherein the sct scattered loading file defines the starting address and size of the target free ROM space (referring to the ROM space used to store the access code function when the code is compiled) and the target free RAM space (referring to the RAM space used to store the access code function when the code is running). An optional implementation method is that the implementation process of this step S101 may include the following steps AC:
[0061] Step A: Determine the starting address and size of a block of free ROM space as the initial free ROM space; wherein the size of the initial free ROM space is not less than the size of the space occupied by the access code function.
[0062] It should be noted that the Automotive Open System Architecture (AUTOSAR) standard specifies the use of the access code function, that is, to copy the access code function from ROM to RAM during the code running phase, and then implement operations such as loading and unloading. However, the specific copy address and space size are determined by the scatter loading file, and different compilers use different scatter loading files. Therefore, in order to be able to use the access code function loading function normally in a compiler that uses an sct type scatter loading file, it is necessary to complete the writing of the sct type scatter loading file during the code writing phase.
[0063] Moreover, when writing the sct scattered loading file, you can first define a macro of the starting address of a piece of free ROM space, and then define a macro of the size of the free ROM space, and the size of this part of the space can at least store the access code function, so that after determining the starting address and size of this part of the free ROM space, it can be used as the initial free ROM space to execute subsequent steps BC. It can be understood that the size of the initial free ROM space is not less than the size of the space occupied by the access code function.
[0064] Step B: Determine the starting address and size of a free RAM space as the target free RAM space; wherein the size of the target free RAM space is consistent with the size of the initial free ROM space.
[0065] In this implementation, first, a macro of the starting address of a piece of free RAM space can be defined, and then a macro of the size of the free RAM space can be defined, and the size of this part of the space is consistent with the size of the initial free ROM space defined in step A. Therefore, after determining the starting address and size of this part of the free ROM space, it can be used as the target free RAM space to execute the subsequent step S103, and the size of the target free RAM space is consistent with the size of the initial free ROM space.
[0066] It should be noted that the present application does not limit the starting address and size of the initial free ROM space and the target free RAM space, which can be set according to actual conditions and empirical values. For example, the size of the initial free ROM space and the target free RAM space can be set to 200 bytes.
[0067] Step C: Select a space area in the ROM as the target free ROM space, and set the starting address of the target space area to the starting address of the initial free ROM space, and set the size of the target space area to the size of the initial free ROM space, so as to store the access code function in the target free ROM space area.
[0068] In the present implementation, after determining the starting address and size of the initial free ROM space through step A, a space area can be further selected in the ROM as the target free ROM space, and the starting address of the target space area can be set to the starting address of the initial free ROM space, and the size of the target space area can be set to the size of the initial free ROM space, so that the access code function can be stored in the target free ROM space area to execute the subsequent step S102.
[0069] Among them, for the target free ROM space, its internal description can be as the data segment content of the access code function under the fls_ac.o compilation file.
[0070] S102: Load the access code function into the target free ROM space, so as to access the access code function through the start address of the target free ROM space.
[0071] In this embodiment, when writing the sct scattered loading file through step S101, after defining the starting address and size of the target free ROM space, the sct scattered loading file can be further used to compile the code and load the access code function into the target free ROM space to generate a corresponding map file, and facilitate access to the access code function through the starting address of the target free ROM space.
[0072] The map file describes the loading location of the access code function in the target free ROM space (i.e., the starting address of the target space area), as well as the relevant information of the access code function stored in the space. In addition, the present application does not limit the specific content of the relevant information of the access code function stored in the space, which can be set according to actual conditions and experience values. For example, the relevant information of the access code function may include but is not limited to the data description of the access code function, the size of the space occupied, and the end position.
[0073] An optional implementation method is that the relevant information loading of the access code function can be implemented in the development board during the code burning stage.
[0074] S103: Copy the data in the target free ROM space storing the access code function to the target free RAM space.
[0075] In this embodiment, when writing the sct scattered loading file through step S101, the starting address and size of the target free RAM space are defined, and after the access code function is loaded into the target free ROM space through step S102, when the code is running, before executing the erase task corresponding to the user's suspended erase request, all data in the target free ROM space storing the access code function can be copied to the target free RAM space. Through this process, the access code function can be copied and moved to execute the subsequent step S104.
[0076] S104: executing the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, and uninstalling the access code function in the target free RAM space when the task is completed, so as to realize resource recovery.
[0077] In this embodiment, after the data in the target free ROM space storing the access code function is copied to the target free RAM space through step S103, the erase task corresponding to the erase request suspended by the user can be executed by running the access code function in the target free RAM space, and when the task is completed, the access code function in the target free RAM space can be uninstalled to realize the recovery of system resources.
[0078] Specifically, an optional implementation method is, after executing the erase task corresponding to the user's suspended erase request by running the access code function in the target free RAM space, if the erase task corresponding to the user's suspended erase request is not completed within a preset time (the specific value is not limited, and can be set according to actual conditions and experience values, such as 500 milliseconds, etc.) and the task has not timed out, execute the callback function to complete a loop processing process, and continue to determine whether the erase task corresponding to the user's suspended erase request is completed and whether the task has timed out; if the erase task corresponding to the user's suspended erase request is still not completed and the task has not timed out, continue to execute the callback function to complete the next loop processing process, and so on, until the erase task corresponding to the user's suspended erase request is completed or the task times out, end the loop and continue to execute subsequent processes.
[0079] Among them, this application does not limit the specific content of the callback function, which can be set according to actual conditions and experience values. For example, it can default to an empty implementation and then connect to the basic software layer (Basic Software, BSW) layer or user layer of the automotive open system architecture (Autosar) through an interface to implement specific functions.
[0080] In this implementation, if Figure 2 As shown, when the access code function starts running, the erase task is first started in a preset manner, and the start method is not limited. For example, the erase task can be started by setting a register, and then it is determined whether the erase task is completed. If so, some error information generated during the task execution (such as error notification information, warning information, etc.) is cleared; if not, the callback function is executed in a loop until the erase task corresponding to the user's suspended erase request is completed or the task times out, and then some error information generated during the task execution is cleared. Then, after the access code function is finished running, the access code function in the target free RAM space can be unloaded to realize system resource recovery.
[0081] Another optional implementation method is, after executing the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, it is possible to further detect whether there are other tasks corresponding to the suspended erase requests that need to continue to be executed; if so, continue to execute the tasks corresponding to the other erase requests by running the access code function until all the tasks corresponding to the existing erase requests are completed (that is, after the current write-erase task is completed and there are no suspended write-erase tasks that need to continue to be executed), then uninstall the access code function in the target free RAM space to realize system resource recovery.
[0082] Among them, it should be noted that the erase task can be suspended by the user at any time. If the operation data is too long, it may be divided into multiple tasks for execution. For example, if the operation data is 8 bytes of data, it can be completed using a 1-cycle erase task, but if the operation data is 1 kilobyte of data, it may be necessary to execute a 10-cycle erase task. Therefore, after the current erase task is completed, there may be the next erase task. At this time, there is no need to unload the access code function, but continue to run the access code function to execute the remaining erase tasks until all tasks corresponding to the existing erase requests are completed. Then, the access code function in the target free RAM space is unloaded to realize system resource recovery.
[0083] In this way, by executing the above steps S101-S104, the whole process from loading to unloading of the access code function can be realized in all embedded compilers that use .sct type distributed loading files, represented by Keil embedded compiler. After the unloading step of the access code function, the system can continue to judge the task status and return the result, and then it will be in a state of waiting for the next task to arrive. If the next task is a write or erase task, the above steps S101-S104 will be repeated to realize the loading and unloading functions of the access code function. On the contrary, if the next task does not involve a write or erase command, the loading and unloading process of the access code function will not be involved.
[0084] To facilitate understanding of the access code function loading method provided by the present application, the present application also provides an overall process diagram of access code function loading, such as Figure 3As shown, first, you can write a sct type of scattered loading file. The specific writing process is: Step 1, define the starting position and size of a ROM space; Step 2, define the starting position and size of a RAM space, and ensure that its space size is consistent with the ROM space size defined in Step 1; Step 3, define an area on the ROM, and the starting position of the area is the starting position of the ROM space defined in Step 1, and the space size is consistent with the ROM space size defined in Step 1. This area is used to store the access code function. Then compile the code and load the access code function into the pre-opened ROM space. Then, when the code is running, if it is determined that an erase task is suspended, the access code function is copied from the ROM space to the pre-opened RAM space for executing the erase task, and after the corresponding task is executed, the access code function is unloaded from the RAM space. Then, after it is determined that all erase tasks are completed, the operation process ends. If not completed, the aforementioned steps are re-executed to execute other erase tasks until all erase tasks are completed, and the operation process ends.
[0085] In this way, the loading method of the access code function can be effectively expanded so that it can be loaded not only in embedded compilers that use icf type distributed loading files, but also in embedded compilers that use .sct distributed loading files, such as the Keil embedded compiler. It has a wider adaptation area, provides chip manufacturers with more possibilities for compiler selection, and makes the loading method of the access code function more mature.
[0086] In summary, the access code function loading method provided by the present embodiment firstly writes the sct scatter loading file; wherein the sct scatter loading file defines the starting addresses of the target free ROM space and the target free RAM space, and then loads the access code function into the target free ROM space to access the access code function through the starting address of the target free ROM space; then, the data in the target free ROM space storing the access code function is copied to the target free RAM space; and then, the erase task corresponding to the erase request suspended by the user can be executed by running the access code function in the target free RAM space, and when the task is completed, the access code function in the target free RAM space is unloaded to realize resource recovery. It can be seen that, since the present application writes the content of the sct scatter loading file, the access code function loading function can be used normally in the compiler using the sct type scatter loading file, thereby effectively expanding the loading method of the access code function and improving its scope of application.
[0087] Second embodiment
[0088] This embodiment will introduce an access code function loading device. For related content, please refer to the above method embodiment.
[0089] See also Figure 4 , is a schematic diagram of the composition of an access code function loading device provided in this embodiment, the device 400 includes:
[0090] A writing unit 401 is used to write an sct scatter-loading file; the sct scatter-loading file defines the starting address and size of the target free ROM space and the target free RAM space;
[0091] A loading unit 402, configured to load the access code function into the target free ROM space, so as to access the access code function through the start address of the target free ROM space;
[0092] A copy unit 403, used to copy the data in the target free ROM space storing the access code function to the target free RAM space;
[0093] The unloading unit 404 is used to execute the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, and to unload the access code function in the target free RAM space when the task is completed to realize resource recovery.
[0094] In an implementation of this embodiment, the writing unit 401 includes:
[0095] The first determination subunit is used to determine the starting address and size of a block of free ROM space as the initial free ROM space; the size of the initial free ROM space is not less than the size of the space occupied by the access code function;
[0096] The second determination subunit is used to determine the starting address and size of a free RAM space as a target free RAM space; the size of the target free RAM space is consistent with the size of the initial free ROM space;
[0097] The setting subunit is used to select a space area in the ROM as a target free ROM space, and set the starting address of the target space area to the starting address of the initial free ROM space, and set the size of the target space area to the size of the initial free ROM space, so as to store the access code function in the target free ROM space area.
[0098] In an implementation of this embodiment, the loading unit 402 is specifically used for:
[0099] After writing the sct scattered loading file, the sct scattered loading file is used to compile the code and load the access code function into the target free ROM space to generate a corresponding map file; wherein the map file describes the loading position of the access code function in the target free ROM space and the related information of the access code function stored in the space.
[0100] In an implementation of this embodiment, the relevant information of the access code function includes a data description of the access code function, an occupied space size, and an end position.
[0101] In an implementation of this embodiment, the device further includes:
[0102] The first execution unit is used to execute the callback function if the erase task corresponding to the erase request suspended by the user is not completed and the task has not timed out, complete a loop processing process, and continue to determine whether the erase task corresponding to the erase request suspended by the user is completed and whether the task has timed out;
[0103] The second execution unit is used to continue executing the callback function and complete the next loop processing process if the erase task corresponding to the erase request suspended by the user has not been completed and the task has not timed out, and so on, until the erase task corresponding to the erase request suspended by the user is completed or the task times out, ending the loop and continuing to execute subsequent processes.
[0104] In an implementation of this embodiment, the device further includes:
[0105] The third execution unit is used to detect whether there are tasks corresponding to other pending erase requests that need to be continued to be executed after completing the erase task corresponding to the erase request suspended by the user; if so, continue to execute the tasks corresponding to other erase requests by running the access code function until the tasks corresponding to all existing erase requests are completed, and then unload the access code function in the target free RAM space to realize resource recovery.
[0106] Furthermore, the embodiment of the present application also provides an access code function loading device, including: a processor, a memory, and a system bus;
[0107] The processor and the memory are connected via the system bus;
[0108] The memory is used to store one or more programs, and the one or more programs include instructions. When the instructions are executed by the processor, the processor executes any one of the implementation methods of the access code function loading method.
[0109] Furthermore, an embodiment of the present application also provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes any one of the implementation methods of the access code function loading method described above.
[0110] Furthermore, an embodiment of the present application also provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes any one of the implementation methods of the access code function loading method.
[0111] It can be known from the description of the above implementation mode that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling a computer device (which can be a personal computer, a server, or a network communication device such as a media gateway, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0112] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0113] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0114] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for loading an access code function, characterized in that: include: Write sct scatter loading file; The starting address and size of the target free ROM space and the target free RAM space are defined in the sct scatter loading file; Loading the access code function into the target free ROM space to access the access code function through the start address of the target free ROM space; Copying the data in the target free ROM space storing the access code function to the target free RAM space; By running the access code function in the target free RAM space, the erase task corresponding to the erase request suspended by the user is executed, and when the task is completed, the access code function in the target free RAM space is uninstalled to realize resource recovery.
2. The method according to claim 1, characterized in that The writing of the sct scattered loading file includes: Determine a starting address and size of a block of free ROM space as the initial free ROM space; the size of the initial free ROM space is not less than the size of the space occupied by the access code function; Determine a starting address and size of a free RAM space as a target free RAM space; the size of the target free RAM space is consistent with the size of the initial free ROM space; A space area is selected in the ROM as the target free ROM space, and the starting address of the target space area is set to the starting address of the initial free ROM space, and the size of the target space area is set to the size of the initial free ROM space, so as to store the access code function in the target free ROM space area.
3. The method according to claim 1, characterized in that The step of loading the access code function into the target free ROM space comprises: After writing the sct scattered loading file, the sct scattered loading file is used to compile the code, and the access code function is loaded into the target free ROM space to generate a corresponding map file; wherein the map file describes the loading position of the access code function in the target free ROM space, and the related information of the access code function stored in the space.
4. The method according to claim 3, characterized in that The relevant information of the access code function includes the data description, the occupied space size and the end position of the access code function.
5. The method according to claim 1, characterized in that After executing the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, the method further includes: If the erase task corresponding to the erase request suspended by the user is not completed and the task has not timed out, the callback function is executed to complete a loop processing process, and continue to determine whether the erase task corresponding to the erase request suspended by the user is completed and whether the task has timed out; If the erase task corresponding to the erase request suspended by the user has not been completed and the task has not timed out, the callback function will continue to be executed to complete the next loop processing process, and so on, until the erase task corresponding to the erase request suspended by the user is completed or the task times out, the loop will end and the subsequent process will continue.
6. The method according to claim 1, characterized in that After executing the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, the method further includes: After completing the erase task corresponding to the erase request suspended by the user, check whether there are tasks corresponding to other suspended erase requests that need to be continued; if so, continue to execute tasks corresponding to other erase requests by running the access code function until the tasks corresponding to all existing erase requests are completed, and then uninstall the access code function in the target free RAM space to realize resource recovery.
7. An access code function loading device, characterized in that: include: Writing unit, used to write sct scattered loading files; The starting address and size of the target free ROM space and the target free RAM space are defined in the sct scatter loading file; A loading unit, configured to load an access code function into the target free ROM space, so as to access the access code function through a starting address of the target free ROM space; A copy unit, used for copying the data in the target free ROM space storing the access code function to the target free RAM space; The unloading unit is used to execute the erase task corresponding to the erase request suspended by the user by running the access code function in the target free RAM space, and when the task is completed, the access code function in the target free RAM space is unloaded to realize resource recovery.
8. The device according to claim 7, characterized in that The writing unit comprises: The first determination subunit is used to determine the starting address and size of a block of free ROM space as the initial free ROM space; the size of the initial free ROM space is not less than the size of the space occupied by the access code function; The second determination subunit is used to determine the starting address and size of a free RAM space as a target free RAM space; the size of the target free RAM space is consistent with the size of the initial free ROM space; The setting subunit is used to select a space area in the ROM as a target free ROM space, and set the starting address of the target space area to the starting address of the initial free ROM space, and set the size of the target space area to the size of the initial free ROM space, so as to store the access code function in the target free ROM space area.
9. An access code function loading device, characterized in that: include: Processor, memory, system bus; The processor and the memory are connected via the system bus; The memory is used to store one or more programs, wherein the one or more programs include instructions, and when the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 6.