CN119225831A - CPU implicit initialization method - Google Patents
CPU implicit initialization method Download PDFInfo
- Publication number
- CN119225831A CN119225831A CN202411470757.7A CN202411470757A CN119225831A CN 119225831 A CN119225831 A CN 119225831A CN 202411470757 A CN202411470757 A CN 202411470757A CN 119225831 A CN119225831 A CN 119225831A
- Authority
- CN
- China
- Prior art keywords
- ini
- function
- initialization
- func
- address
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4403—Processor initialisation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/47—Retargetable compilers
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Small-Scale Networks (AREA)
Abstract
The invention discloses a CPU implicit initialization method, which comprises defining an initialization function, outputting an address of the initialization function to an independent section, simultaneously arranging the sections according to a set sequence, mapping an initialization function pointer to a corresponding section, checking mapping information, defining a function ini_start_func for searching a section starting position, defining a function ini_end_func for judging a section ending position, mapping the address of the function ini_start_func to the section ini_fn.0, mapping the address of the ini_end_func to the section ini_fn.z, performing address self-increasing operation, traversing pointer data of a section area, copying pointer data of the section area to funcptrnum, and operating the function in a function addressing mode. The invention outputs the initializing function address to the independent segment through ARMGCC compiler instruction, marks the starting address and the ending address through the null function address, traverses the function between the starting address and the ending address of the operating segment in the main function, and completes the operation work of the initializing function.
Description
Technical Field
The invention belongs to the technical field of computer control, and relates to a CPU implicit initialization method.
Background
The ARM CPU software is initialized by firstly configuring a system clock, wherein a clock system in the ARM CPU is a core of the whole system and provides clock signals for other peripheral equipment and functions. Next, the clocks of the individual peripherals are configured as needed, the normal operation of the peripherals being dependent on the clock signal. GPIO (general purpose input output) is one of the most commonly used peripherals in ARM CPUs for connecting and controlling external devices. Therefore, parameters such as pin mode, output type, and the like of the GPIO need to be properly configured. Interrupts are an important mechanism for STM32 to handle external events. By configuring the interrupt priority and interrupt service routine, it is ensured that the system can quickly respond to external events. In addition to GPIOs and interrupts, other peripherals may need to be configured to meet specific application requirements. After all necessary configurations are completed, the user's application logic begins to run.
Disclosure of Invention
First, the technical problem to be solved
In the process of starting GD32, an on-board peripheral is required to be initialized in a main function, and the initialization functions of different peripheral are usually called sequentially according to the initialization functions of different peripheral, wherein the peripheral initialization functions are called in an APP file, and the initialization functions belong to a bottom layer function, so that the APP program and the bottom layer program are seriously coupled together, and if the bottom layer peripheral interface function is modified and the latter peripheral module is deleted, the application program is required to be correspondingly modified.
(II) technical scheme
In order to solve the technical problems, the invention provides a CPU implicit initialization method, which comprises the following steps:
S1, defining an initialization function by using a typedef key definition function pointer init_func, wherein the shape parameters and the return values of the function pointer are null type void.
The defined initialization functions comprise a network initialization function ini_wlan_fun and an ARINC 1553B bus initialization function, and a command line SHELL initialization function ini_shell_func.
S2, outputting the address of a function to an independent section by using ARMGCC compiler instruction __ attribute __ (section ("name")) and arranging the functions according to the set sequence.
The method comprises the steps of replacing x in a compiler with a segment name priority mode in a macro definition mode, for example, replacing x with an 'ini_fn' rank mode, wherein rank is the rank number 1, 2 and 3, and the like, for example, x parameters are represented by 'ini_fn', '1', 'ini_fn', '2', 'ini_fn', '3', the smaller the numerical value is, the compiler will place the corresponding function at the front position of a segment table.
The S3: ARMGCC compiler instruction __ attribute __ (used) instruction maps the initialization function pointer into the corresponding segment.
Setting a network initialization function ini_wlan_fun as a 1-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.1 ', setting an ARINC 1553B bus initialization function ini_1553b_func as a 2-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.2 ', setting a command line SHELL initialization function ini_shell_func as a 3-level priority, and mapping the command line SHELL_shell_func into a section ini_fn.3 '.
And S4, after compiling is completed, looking up in the map, and looking up mapping information in a map symbol table Image Symbol Table area.
The mapping information includes:
(1) The symbol name network initialization function ini_wlan_fun, the symbol address value of 0x200002c8, the symbol type of Data, the storage size of 4, and the network initialization function mapping on segment ini_fn.1.
(2) The symbol name ARINC 1553B bus initialization function ini_1553b_func, the symbol address value is 0x200002cc, the symbol type is Data, the storage size is 4, and the ARINC 1553B bus initialization function is mapped on the section ini_fn.2.
(3) The symbol name command line SHELL initialization function ini_shell_func, the symbol address value 0x200002d0, the symbol type Data, the memory size 4, and the command line SHELL initialization function map in segment ini_fn.3.
S5, defining a function ini_start_func by using the init_func function pointer definition defined in the step S1, wherein no operation is performed in the function to find the segment start position, and a function ini_end_func is defined to judge the segment end position, and no operation is performed in the function.
S6, mapping the address of the function ini_start_func into a segment 'ini_fn.0', the address of ini_end_func into a segment 'ini_fn.0', and the address of ini_end_func into a segment 'ini_fn.z', using ARMGCC compiler __ attribute __ (section ('name') instruction and __ attribute __ (used) instruction.
And S7, defining a function pointer variable funcptrnum in the step S1, assigning an initial value as an address of the function ini_start_func, performing address self-increasing operation, traversing pointer data of the extracted section area, copying the pointer data to funcptrnum, and operating the function in a function addressing mode.
(III) beneficial effects
According to the CPU implicit initialization method provided by the technical scheme, the initialization function address is output to the independent segment through ARMGCC compiler instructions, the starting address and the ending address are marked through the null function address, and the function between the starting address and the ending address of the operation segment is traversed in the main function, so that the operation work of the initialization function is completed.
Drawings
FIG. 1 is a flow chart of an embodiment of an implicit CPU initialization method.
Detailed Description
To make the objects, contents and advantages of the present invention more apparent, the following detailed description of the present invention will be given with reference to the accompanying drawings and examples.
Referring to fig. 1, the method for implicit initialization of a CPU according to the present embodiment includes the steps of:
S1, defining an initialization function by using a typedef key definition function pointer init_func, wherein the shape parameters and the return values of the function pointer are null type void.
The defined initialization functions comprise a network initialization function ini_wlan_fun and an ARINC 1553B bus initialization function, and a command line SHELL initialization function ini_shell_func.
S2, outputting the address of a function to an independent section by using ARMGCC compiler instruction __ attribute __ (section ("name")) and arranging the functions according to the set sequence.
The method comprises the steps of replacing x in a compiler with a segment name priority mode in a macro definition mode, for example, replacing x with an 'ini_fn' rank mode, wherein rank is the rank number 1, 2 and 3, and the like, for example, x parameters are represented by 'ini_fn', '1', 'ini_fn', '2', 'ini_fn', '3', the smaller the numerical value is, the compiler will place the corresponding function at the front position of a segment table.
The S3: ARMGCC compiler instruction __ attribute __ (used) instruction maps the initialization function pointer into the corresponding segment.
Setting a network initialization function ini_wlan_fun as a 1-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.1 ', setting an ARINC 1553B bus initialization function ini_1553b_func as a 2-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.2 ', setting a command line SHELL initialization function ini_shell_func as a 3-level priority, and mapping the command line SHELL_shell_func into a section ini_fn.3 '.
And S4, after compiling is completed, looking up in the map, and looking up mapping information in a map symbol table Image Symbol Table area.
The mapping information includes:
(1) The symbol name network initialization function ini_wlan_fun, the symbol address value of 0x200002c8, the symbol type of Data, the storage size of 4, and the network initialization function mapping on segment ini_fn.1.
(2) The symbol name ARINC 1553B bus initialization function ini_1553b_func, the symbol address value is 0x200002cc, the symbol type is Data, the storage size is 4, and the ARINC 1553B bus initialization function is mapped on the section ini_fn.2.
(3) The symbol name command line SHELL initialization function ini_shell_func, the symbol address value 0x200002d0, the symbol type Data, the memory size 4, and the command line SHELL initialization function map in segment ini_fn.3.
S5, defining a function ini_start_func by using the init_func function pointer definition defined in the step S1, wherein no operation is performed in the function to find the segment start position, and a function ini_end_func is defined to judge the segment end position, and no operation is performed in the function.
S6, mapping the address of the function ini_start_func into a segment 'ini_fn.0', the address of ini_end_func into a segment 'ini_fn.0', and the address of ini_end_func into a segment 'ini_fn.z', using ARMGCC compiler __ attribute __ (section ('name') instruction and __ attribute __ (used) instruction.
And S7, defining a function pointer variable funcptrnum in the step S1, assigning an initial value as an address of the function ini_start_func, performing address self-increasing operation, traversing pointer data of the extracted section area, copying the pointer data to funcptrnum, and operating the function in a function addressing mode.
The section adds all the initializing functions into the defined input section in advance, and then sequentially takes out the initializing functions in the input section in the main function, so that the system can be initialized on the premise of not modifying the main function.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411470757.7A CN119225831A (en) | 2024-10-21 | 2024-10-21 | CPU implicit initialization method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411470757.7A CN119225831A (en) | 2024-10-21 | 2024-10-21 | CPU implicit initialization method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN119225831A true CN119225831A (en) | 2024-12-31 |
Family
ID=93945128
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202411470757.7A Pending CN119225831A (en) | 2024-10-21 | 2024-10-21 | CPU implicit initialization method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN119225831A (en) |
-
2024
- 2024-10-21 CN CN202411470757.7A patent/CN119225831A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP4560478A1 (en) | Verification system, verification method, electronic device, and storage medium | |
US6338109B1 (en) | Microcontroller development system and applications thereof for development of a universal serial bus microcontroller | |
US6370635B2 (en) | Dual ROM microprogrammable microcontroller and universal serial bus microcontroller development system | |
US9652570B1 (en) | Automatic implementation of a customized system-on-chip | |
CN113849433A (en) | Bus controller execution method and device, bus controller, computer equipment and storage medium | |
US20250077240A1 (en) | Method, system, and device for software and hardware component configuration and content generation | |
JP7420804B2 (en) | Data communication with improved speed modes | |
US20070283260A1 (en) | Human-machine Interface System with Device Bridge and Method for Designing and Operating the Same | |
JP2009181579A (en) | Method, subsystem and system for calling functions | |
US11392406B1 (en) | Alternative interrupt reporting channels for microcontroller access devices | |
CN119225831A (en) | CPU implicit initialization method | |
US12093201B2 (en) | Method, system, and device for software and hardware component configuration and content generation | |
CN117931404A (en) | Multi-application switching method, device, equipment and medium based on FPGA | |
CN117193872A (en) | Chip starting firmware device and method based on symbol table dynamic execution | |
CN117350205A (en) | Verification methods, devices, electronic equipment and storage media for chips | |
KR20250042701A (en) | Reconfigurable neural engine with extensible instruction set architecture | |
CN112949243B (en) | Parameter configuration method and device, computer equipment and storage medium | |
CN112257359B (en) | Debugging method, device, debugging system and storage medium for data waveform | |
CN116088864A (en) | Assembling method, disassembling method, apparatus and storage medium | |
CN112395727B (en) | CAE-based vehicle durability condition creation method and device | |
JP5577619B2 (en) | Logic circuit design device | |
US12039294B2 (en) | Device and method for handling programming language function | |
JPS5856277A (en) | Method and device for information processing | |
JP2001076027A (en) | Method and apparatus for simulation in system desgining stage and storage medium with program stored thereof | |
CN102591820A (en) | IDMA (interleave division multiple access) bus bridge device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |