The program creates the C source file containing the exception vectors, startup routine and dummy exception handler.
The startup module is generated based on the MCU-specific header file, usually supplied by the MCU vendor.
The exception names are taken from the definition of enum type defining the MCU-specific xxx_IRQn constants.
The resulting startup_xxx.c
file is compatible with gcc-arm-embedded and follows the section naming convention used by ST Microelectronics' STM32CubeIDE in the linker script files generated by it. Compared to the assembly startup, the C startup file is more compact and easier to read and modify.
The program accepts three options influencing its operation:
-i
option causes the definition of interrupt handlers for NVIC interrupts not defined in the MCU header files. This allows for using these interrupts for software-triggered event handlers. The ISRs have the names containing the IRQ number, like IRQ12_IRQHandler
.
-n IRQns
sets the non-standard number of available NVIC interrupt handlers. IRQns
is the number of NVIC interrupts to be defined. The option may be used to reduce or increase the number of defined interrupt vectors. Setting it to 0 allows for creating vector table containing only core exception vectors.
-s
option forces the output of commonly used, shortened names of core exception handlers, like SVC_Handler
, instead of names taken from IRQn names, like SVCall_Handler
.
Example:
h2cstartup -s stm32f401xc.h
creates startup_stm32f401xc.c
file, which may replace the startup_stm32f401xx.s
file originally created by STM32CubeIDE.
The motivation behind creating the code was to get rid of the assembly startup file and to make it convenient to use the NVIC interrupts non-defined in the given MCU for software-generated event handling.