Embedded relay protector protection module loading method
By writing data information and relocation information in the uboot and sloader stages, the problem of multi-module relay protection equipment not being loaded in time when dynamic loading is solved, and the rapid loading and safe operation of the protection module are realized.
Patent Information
- Application Number
- CN202310974408.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-02
- Publication Date
- 2025-02-14
AI Technical Summary
When a multi-module relay protection device adopts dynamic loading, timely loading cannot be achieved, resulting in the protection module being unable to load correctly, affecting the safe operation of the device.
In the uboot stage, data information is written to the custom data segment of the sloader module. In the sloader stage, data information of uboot, its own data information and relocation information of each protection module are written to the custom data segment of the platform module. The module obtains relocation information through its own custom data segments to complete the loading of the protection module.
By positioning and loading the codes of each protection module, the rapid and timely loading of multiple protection modules is achieved, ensuring the safe operation of embedded protection devices.
Smart Images

Figure CN119440651A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a protection module loading method of an embedded relay protector, and belongs to the field of processor loading. Background Art
[0002] With the promotion of digital substation technology, embedded devices have developed rapidly. Embedded relay protection equipment is usually divided into multiple modules according to function, such as platform module, human-machine module, driver module, gateway module, protection module, etc. For each module, independent development is performed to generate its own independent target file. There is an entry module in these modules. The memory space of each module is statically allocated. The entry module loads it into its own static space through the target file name. The static allocation method is as follows: Figure 1 As shown, in order to reduce costs and increase efficiency, it is sometimes necessary to put multiple protection modules on a CPU board to run. When multiple modules adopt the existing static loading mode of protection modules, the memory address of each module is fixed and cannot be reasonably allocated. If a large memory is required when loading a module, the current memory is small. At this time, the module cannot be loaded, and the safe operation of the relay protection device is not utilized. When multiple modules adopt the method of dynamically dividing memory, the address of each protection module changes dynamically. At this time, the external module cannot interact with each protection module, and the module loading cannot be completed successfully in time. Summary of the invention
[0003] The purpose of the present invention is to provide a protection module loading method for an embedded relay protector, so as to solve the problem that timely loading cannot be achieved when a multi-module relay protection device adopts a dynamic loading mode.
[0004] To achieve the above object, the solution of the present invention includes:
[0005] A method for loading a protection module of an embedded relay protector of the present invention comprises the following steps:
[0006] 1) In the uboot stage, when uboot loads the custom data segment of the sloader module, the data information of uboot is written into the custom data segment of the sloader module;
[0007] 2) In the sloader stage, the sloader module obtains the uboot data information in its own custom data segment. When sloader loads the custom data segment of the platform module, it writes the uboot data information, its own data information and the relocation information of each protection module into the custom data segment of the platform module;
[0008] 3) In the platform stage, the platform module obtains its own custom data segment, and obtains the relocation information of each protection module loaded in the sloader stage through its own custom data segment, queries and links the code of each protection module according to the relocation information, and completes the loading of the protection module.
[0009] Beneficial effect: The embedded relay protector protection module loading method of the present invention mainly targets multiple protection modules in the protection device, locates the running parts of multiple dynamically loaded modules, and quickly obtains the target code of each module. First, it is necessary to create custom data segments in the sloader module and the platform module respectively, and write the uboot data information in the custom data segment of the sloader module in the uboot stage, and write the uboot data information, sloader data information and the relocation information of each protection module in the custom data segment of the platform module in the sloader stage, store the location information of each protection module in the platform module, and query the code of each module through the platform module, so as to complete the loading of multiple protection modules in the embedded protection device in time.
[0010] Furthermore, the data format of the custom data segment is .cfgparam.
[0011] Furthermore, the relocation information includes address information and names of each protection module.
[0012] Beneficial effect: The relocation information includes the base address information and name of each protection module, and the loaded protection module can be quickly located through the base address and name.
[0013] Furthermore, before the platform module obtains its own custom data segment, it obtains the starting address of its own allocatable dynamic memory and performs memory initialization processing on the dynamic memory, wherein the starting address is the address at which the protection module is loaded.
[0014] Beneficial effect: The protection module is loaded during the initialization phase, and the starting address is the address at which the protection module is loaded. The address of the protection module is static. If dynamic loading is not performed, the address is exactly the same. Even if multiple protection modules are loaded, only a single module runs. Only when dynamically loaded to different addresses can the requirements for multi-module operation be met.
[0015] Furthermore, the platform module obtains the starting address of its own allocatable dynamic memory through the weak link function.
[0016] Furthermore, during the sloader stage, the name, address information and size of each module are obtained through the boot.cfg file to complete the relocation of each module.
[0017] Furthermore, the data information written by uboot includes a CRC checksum of uboot and a version number of uboot.
[0018] Furthermore, the self-information written by sloader includes sloader version number and crc information.
[0019] Beneficial effect: By obtaining the uboot and sloader version information, it can be known whether the first and second level boot programs of this version support the relocation of multiple application modules. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a schematic diagram of a static memory allocation method in the prior art;
[0021] Figure 2 is a schematic diagram of relocation function definition in an embodiment of the present invention;
[0022] Figure 3 is a schematic diagram of relocation information processing in an embodiment of the present invention;
[0023] Figure 4 It is a flow chart of relocation information transmission in an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The present invention will be further described in detail below in conjunction with the accompanying drawings.
[0025] Embedded relay protection device protection module loading method embodiment:
[0026] like Figure 4 The embedded relay protection device protection module loading method shown in the figure is for a relay protection device with multiple protection modules. By creating custom data segments in the sloader module and the platform module respectively, data is written into the custom data segment of the sloader module in the uboot stage, and the relocation information of each protection module is written into the custom data segment of the platform module in the sloader stage. The platform module obtains the relocation information of each protection module loaded in the sloader stage through its own custom data segment, and completes the positioning of the protection module. The specific implementation is as follows:
[0027] Before relocating and loading the protection module, the relocation loading conditions must be met, that is, the loaded protection module must include program functions that support the relocation function. Taking the "Sourcery CodeBench for ARM Embedded IDE" tool as an example, how to generate a target file that supports the relocation function, the compilation project options need to be set as follows:
[0028] First, add the -fPIC–pie options in both compilation and linking, and add the -nostartfiles option in linking, which is not required for entry modules. Secondly, add the -nostartfiles option for relocation information linking, which is not required for entry modules. Add the exit() function definition in the csgnu_eabi_rtl.c file, such as Figure 2 As shown, the protection module can be relocated according to the newly added function.
[0029] 1) Create custom data segments in the sloader module and the platform module respectively. In the uboot stage, when uboot loads the custom data segment of the sloader module, the data information of each module is written into the custom data segment of the sloader module.
[0030] First, the method of this embodiment involves three program loading stages: uboot, sloader and initialization stage (the entry template of the initialization stage is the platform module, and the initialization stage in this embodiment is also called the platform stage). Among them, uboot is the first-level boot program (first-level loader), sloader is the second-level boot program (second-level loader), the first program loaded by the second-level boot program, and other functional modules and application modules are loaded in the platform program. First, it is necessary to create a custom data segment in the sloader module and the platform module respectively.
[0031] The data format of the custom data segment is .cfgparam, that is, a custom data segment with the same name (.cfgparam data segment) is created in both the sloader module and the platform module.
[0032] like Figure 3 As shown in the figure, in the uboot stage, when the uboot information needs to guide (load) sloader, that is, when uboot loads the custom data segment of the sloader module, the uboot version number, CRC and other information are written into the custom data segment according to the set data structure (.cfgparam data segment). In order to ensure the consistency of the uboot version number, the uboot version number, CRC and other information are written into the custom data segment for version information comparison.
[0033] 2) In the sloader stage, sloader obtains the uboot data information in its own custom data segment. When sloader loads the custom data segment of the platform module, it writes the uboot data information, its own data information and the relocation information of each protection module into the custom data segment of the platform module.
[0034] When sloader loads the custom data segment of the platform module, the information written into the custom data segment of the platform module includes the data information of uboot, its own data information and the relocation information of each protection module. Among them, the data information of sloader includes the version number and crc checksum of sloader, and the relocation information of each protection module includes the description and corresponding address of each loading module. In the sloader stage, the name and size of each module are obtained through the boot.cfg file to complete the relocation of each module. Similarly, the version number and crc checksum of sloader can be used for version information comparison.
[0035] 3) In the platform stage, the platform module obtains the data information in its own custom data segment, obtains the relocation information of each protection module loaded in the sloader stage through its own custom data segment, queries and links the code of each protection module according to the relocation information, and completes the loading of the protection module.
[0036] When the platform module obtains its own custom data segment, it can obtain the information loaded by uboot, sloader and each protection module. The version information of uboot and sloader can be used to know whether the first and second level boot programs of this version support the relocation of multiple application modules.
[0037] The platform module obtains the starting address of the dynamic memory that can be allocated by the platform module through the weak link function provided by the operating system; and initializes the memory pool at the starting address. The platform module obtains the relocation information such as the loading address and size of each module loaded by sloader through its own custom data segment (.cfgparam data segment). The platform module uses the relocation information to query and link the code of each module to complete the loading of each module. The protection module is loaded during the initialization phase. The purpose of obtaining the starting address is to know the starting address of the loadable module. The address where each protection module is loaded is called the starting address of this module. The address length is the size of each module and is 512-byte aligned.
[0038] Supports multiple modules running after copying the protection module; load the protection module in the initialization phase, the starting address is the address of the protection module loading, the address of the protection module is static, if no dynamic loading is performed, the address is exactly the same, even if multiple protection modules are loaded, only a single module is running; only when dynamically loaded to different addresses can the requirements for multiple modules running be met. Each relay protection device online monitoring tool uses the relocation information in the same way. The following takes the "Device Debug Analyzer Tool" as an example to introduce the use of relocation information by the relay protection device online monitoring tool.
[0039] Currently, the "Device Debug Analyzer" tool cannot automatically locate the base address and other information of the dynamically loaded module, resulting in the need to manually modify the corresponding configuration file when using the dynamically loaded module.
[0040] By using the address information of each module carried by the custom data segment of the platform module, the RPC module in the platform module can assist the "Device Debug Analyzer" tool to automatically obtain the base address of the dynamically loaded module, and no manual configuration is required. The specific plan is as follows:
[0041] First, the RPC module in the platform module adds the interactive instruction RPC_READ_MODULE_BASE (0x04) to obtain the base address of the specified module. When the tool sends the RPC_READ_MODULE_BASE instruction, it carries the module name information. Secondly, after the RPC module receives the request instruction for the module base address, it traverses the module information obtained by the platform module by parsing the .cfgparam data segment according to the module name in the request data. If the module name exists, it returns the corresponding address to the device debugging analyzer, otherwise it returns failure. Finally, the tool sends the RPC_READ_PARA instruction. After receiving the instruction, the RPC module returns information such as the memory size end, address space base address, address space size, and FPGA data width to the device debugging analyzer.
Claims
1. A method for loading a protection module of an embedded relay protector, characterized in that: The following steps are involved: 1) Create custom data segments in the sloader module and the platform module respectively. In the uboot stage, when uboot loads the custom data segment of the sloader module, the data information of uboot is written into the custom data segment of the sloader module; 2) In the sloader stage, the sloader module obtains the uboot data information in its own custom data segment. When sloader loads the custom data segment of the platform module, it writes the uboot data information, its own data information and the relocation information of each protection module into the custom data segment of the platform module; 3) In the platform stage, the platform module obtains the data information in its own custom data segment, obtains the relocation information of each protection module loaded in the sloader stage through its own custom data segment, queries and links the code of each protection module according to the relocation information, and completes the loading of the protection module.
2. The embedded relay protection device protection module loading method according to claim 1, characterized in that: The data format of the custom data segment is .cfgparam.
3. The embedded relay protection device protection module loading method according to claim 1, characterized in that: The relocation information includes the address information and name of each protection module.
4. The embedded relay protection device protection module loading method according to claim 2, characterized in that: Before the platform module obtains its own custom data segment, it obtains the starting address of its own allocatable dynamic memory and performs memory initialization processing on the dynamic memory. The starting address is the address at which the protection module is loaded.
5. The embedded relay protection device protection module loading method according to claim 4, characterized in that: The platform module obtains the starting address of its own allocatable dynamic memory through the weak link function.
6. The embedded relay protection device protection module loading method according to claim 3, characterized in that: During the sloader stage, the name, address information and size of each module are obtained through the boot.cfg file to complete the relocation of each module.
7. The embedded relay protection device protection module loading method according to claim 1, characterized in that: The data information written by uboot includes the CRC checksum and version number of uboot.
8. The embedded relay protection device protection module loading method according to claim 1, characterized in that: The self-information written by sloader includes the sloader version number and the CRC check information of sloade.