How to inspect the clock source for RTC?
I have three STM32WB55 applications:
A) is a debugging application that's only ever flashed directly and standalone using the STM32CubeProgrammer CLI.
B) is a bootloader with integrated FUOTA functionality.
C) is my "actual" application. It can be compiled in two configurations: as standalone (which I will refer to as "Ca", as in "C alone"), or to be started by B (referred to as "Cb", as in "C w/ bootloader")
C has a sophisticated debug interface, where I can send commands as bytes via UART and get a reply back via UART. One of those commands is "Echo your current RTC time every 500 milliseconds for 5 seconds" (timing the 500ms is done by FreeRTOS/osDelay).
But the debug command exposes a weird behavior:
Flash and run A, then flash and run B+Cb, and the debug command works as intended. It prints the 10 values in 500ms intervals, and the RTC time progresses by 500ms for every timestamp received.
But then I tell C to launch B in FUOTA mode. I let the update time out, which means nothing is changed about the flashed application binaries, and Cb is started again. When I repeat the debug command, the results are still printed in 500ms intervals (so FreeRTOS ticks are still accurate), but the timestamp only progresses by ~31ms.
So depending on which other application last ran, the RTC seems to be going at the correct speed, or only 1/16th the speed. No combination of flashing Ca, or B+Cb, or stopping/resetting the device fixes this. Only if I flash and run A once, it returns back to normal. Thereafter (as before) flashing and simply launching B+Cb poses no problem.
All that said, I assume that A contains some setup code that configures the RTC in the way C expects and needs in order to function properly, while B has some code that changes that setup, but only the in FUOAT part, not the common launch path itself. And C has incomplete setup code, so unlike A it doesn't change the config according to its needs.
Unfortunately, neither A nor B were developed by me, and B didn't even use CubeMX and therefore it has no clock configuration diagram to look at and compare. A does use CubeMX, but A and C have identical clock configuration diagrams, apart from the RNG bit which C uses but A doesn't (marked red). That's also why I assumed C's clock configuration would be correct, but apparently it isn't.
Clock map A:

Clock map C:

I guess my only chance to find out what A does right and B does "wrong" and C does not do at all would be to look at the code, or certain registers or variables at run time. Can someone point me to the part of the setup code and the variable names that I should check, given the behavior described above?
