Inconsistent vector table on Nucleo with STM32L4R5
I have a project, created with STMCubeIDE 1.6.1, for a Nucleo STM32L4R5 board. I experience issues with the vector table not being always the correct one, depending on some influence I'm not quite sure about. Let me explain.
The project has a few peripherals and FreeRTOS enabled. I used the default generated main.c and added some calls in the default task function. In no way or shape did I edit the generated code (HAL, etc), apart from adding some functions to the previously mentioned default task function. When adding too 'much' code (I think this is the trigger), and programming the device with STMCubeIDE (i.e. debug/run), the device would get stuck in HAL_Init() when the HAL tick timer interrupt would fire. I found out that the vector table was populated with pointers to system memory (0x1fffxxxx), causing the MCU to get stuck in an infinite loop there. It should be noted that the vector table in the binary/map compilation output was absolutely correct w.r.t. the IRQ function pointers, they weren't pointing to system memory and were in fact pointing to the entries of the IRQ functions I expected.
If I commented out a bit of my code in the default task function, it suddenly would work again. The vector table would get populated with the expected IRQ function pointers and the MCU wouldn't hang in HAL_Init() anymore. This was confirmed by reading out the vector table located at address 0x0 with the ST-link debugger on the board.
Furthermore, if I used a binary that would get stuck, I noticed that upon disconnecting and reconnecting the ST-link USB cable and providing a hard reset (Nucleo reset button), the MCU wouldn't get stuck (as indicated by the UART output in the default task and the led blinking task).
Last thing I noticed was, contrary to other Nucleo boards I have, if I power up the Nucleo board with the STM32L4R5, the MCU will not start executing its program until I hit the reset button.
I'm not sure why it is doing what I'm seeing. It prevents me from using the debugger, so I'd like to find a sollution to this incorrect vector table issue, so I can debug again. I sadly lack a second L4R5 Nucleo board to exclude the possiblity of a defective board. Couldn't really find other questions that had the same problem, or if I did find something that was similar (i.e. getting stuck in HAL_init/system memory), they lacked tracing it back to the vector table.
So in short: has anybody experienced the vector table getting 'corrupted' (probably just plain wrong one) when using the debugger/st-link and how to resolve it? Output binary/map file was, everything seems fine. Post disconnect and hard reset it doesn't get stuck anymore.