At this point, a basic linker file is done. Isn’t it so easy?
Extra 1: Custom section
For those who have read this far with patience, Pi Ziheng must give a big reward. The previous part is about how to deal with the system default segment, so is it possible to customize the segment in the code? Imagine that you have such a requirement, you need to open a 1KB updateable data area in your application, you want to specify this data area to the address range of 0x18000 - 0x183ff, you need to define a 4-byte read-only config block constant in the application to point to the first address of this updateable data area (this config block will only be updated by an external debugger or bootloader), how to do it?
// In the C file
/////////////////////////////////////////////////////
// Use the @ operator to specify the variable myConfigBlock[4] to be placed in the custom .myBuffer section
const uint8_t myConfigBlock[4] @ ".myBuffer" = {0x00, 0x01, 0x02, 0x03};
// Linker file
/////////////////////////////////////////////////////
// Customize the specified mySection_region and put .myBuffer into this region
define region mySection_region = mem:[from 0x0x18000 to 0x183ff];
place at start of mySection_region { readonly section .myBuffer };
The above has achieved the goal of putting constants in the code into a custom segment? So how do you put functions in the code into a custom segment? Read on
// In the C file
/////////////////////////////////////////////////////
// Use #pragma location to specify the function myFunction() to be placed in the custom .myTask section
#pragma location = ".myTask"
void myFunction(void)
{
__NOP();
}
// Linker file
/////////////////////////////////////////////////////
// Put .myTask into mySection_region
place in mySection_region { readonly section .myTask };
It seems that the work is done. There is one last thing to note. If myConfigBlock is not referenced in the code, the IDE may ignore this variable when linking (IDE thinks it is useless, so it optimizes it). So how can I force the IDE to link myConfigBlock? IAR has left a backdoor. In the Keep symbols input box in options->Linker->Input tab, fill in the object name you want to force link (note that it is the object name in the code, not the custom segment name in the linker file).
Note: For more details about the extra content, please refer to the Pragma directives section in the IAR SystemsEmbedded Workbench xxxarmdocEWARM_DevelopmentGuide.ENU.pdf document in the IAR software installation directory.
Previous article:Boost download, installation, compilation, configuration and usage guide (including Windows, Linux and ARM Linux)
Next article:Pi Ziheng Embedded: ARM Cortex-M Core (5) - Instruction Set
Recommended ReadingLatest update time:2024-11-16 13:32
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Application of state machine principle in control program design.pdf
- The board has been mailed, please check the courier number in the post~
- Crazy Shell AI open source drone timer (LED flight status light, indicator light flashing)
- How to debug a custom Flash loader in IAR development environment?
- I can't find any information about these two chips.
- [Project source code] Determine the correspondence between the dedicated clock input pin of the FPGA and the PLL
- MCU + I2C communication response signal is abnormal
- 【NUCLEO-L552ZE Review】- 7 : EXTI - One unexpected thing after another
- Key scanning program based on FPGA
- Issues that should be paid attention to when drawing PCB diagrams from the perspective of welding