2024-10-21 12:33 AM - edited 2024-10-21 12:35 AM
Hi,
I am using STM32CubeIDE and an ST-LINK V2 to program a custom board that runs off an STM32WB10cc chip. After flashing the program onto the board, the board resets and the program runs as expected, including a BLE. However, if I then unplug the board and power it on again, the program behaves unusually. The general program logic is as expected, including the Bluetooth stack, but it seems as though some of the program's data has become corrupted. To be specific: the project includes a ~14kb chunk of data (defined as array of const uint8_t) which is used to program an ICM-20948 via I2C at runtime. Once the transfer is done, the STM32WB10cc is able to read data generated by the program on the other chip, which is processed and then set as the value of a BLE characteristic. This works properly when freshly flashed, but when the board is powered off and powered on the data read from the other chip becomes jumbled, which I know to be the case because what should be four doubles that form a valid normalized quaternion are instead occasionally NaNs or numbers with a magnitude greater than 1.
This is confusing to me, because if the program were getting corrupted, I wouldn't expect it to work entirely as expected except for some values being changed. The program does not appear to be corrupted, since the flash memory before and after power cycling are identical according to STM32CubeProgrammer. This makes me believe that some data is not being committed to flash memory. Indeed, I can't find byte sequences from the ~14k blob in the flash memory via CubeProgrammer.
Several years ago, I had a similar issue with an STM32 board that had an extremely simple program which wrote moving text to an LCD over I2C. After power cycling the text would would still move in the pattern I had instructed, but the characters were wrong, suggesting the string now pointed at random memory.
Does anyone know what causes this? Do I need to tell STM32CubeIDE to treat my program's variables a certain way? Do I need to set certain option bits? Have I designed some part of the board wrong?