Background
I have some microcontroller experience (Atmel AVR, PIC18, PIC32), but I'm pretty new in STM32.
I need to maintain/refresh some old project written by another developer who for some reasons can't explain this code. Basically whole project needs to be moved from CooCox to STM32Cube IDE and needs serious refactoring.
I understand practically everything in that project except one thing.
Problem
I have found, that there are some constants in the .isr_vector
section.
- software version
- probably build/release date (2020-05-26)
- serial number (which is overwritten in the .hex file later, before device programming)
Code and details
#define VECTORS __attribute__ ((section (".isr_vector")))
#define VERSION 0x0348
// (...)
#define VERSION_L(VERSION&0xFF)
#define VERSION_H(VERSION>>8)
// (...)
const unsigned char VECTORS FREE3[] = "-------";
const unsigned char VECTORS SERIAL_NUMBER[] = {0xcf,0x93};
const unsigned char VECTORS FREE2[] = "-----";
const unsigned char VECTORS VERSION[] = {VERSION_L, VERSION_H, 0, 0, 20, 0, 5, 0, 26, 0 };
const unsigned char VECTORS NAME[] = " --------------------";
const unsigned char VECTORS FREE1[] = "---";
I have no original linker file for this project, but I believe it was default and generated by CooCox.
I have some hex file which was used in production and I found that 0xCF93 (initial serial number) is here:
I don't understand why this data stored in the interrupt vector table section. It looks pretty smart way to store stuff like this at some "known place" without custom linker script etc.
1. Is this normal / common practise in STM32 programming?
2. How can I be sure that real vector table will be allocated correctly (before these constants)?
"Real vector table" is in startup_stm32f10x_md.c
- autogenerated CMSIS file.