DelfiSpace / DelfiPQcore

0 stars 1 forks source link

[Bug] Global variables not properly initialized during jump to Different slot #48

Open CasperBroekhuizen opened 4 years ago

CasperBroekhuizen commented 4 years ago

(related to https://github.com/DelfiSpace/DelfiPQcore/issues/43 )

During testing, a bug was found that the value of the SW version number did not change when a different slot was jumped too: image The SWVersion does show up correctly in the print statement. Further tests showed that this is caused by the SWVersion being set in the SWUpdate Service during the initialization of the global variables (before main.cpp). Moving this to the main function is a workaround to make this value set correctly.

However, values set and initialized in SLOT2 before the main function. Are not executed correctly. More investigation shows that this is caused by the entry point of the slot (in the startup file) being _c_int00_noinit. Which skips the function __TI_auto_init which is a function generated by the ARM compiler that handles global initialization (according to https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/422177?-TI-auto-init-and-gcc-questions-for-tms570lc43). This change was initially done due to this specific function taking a long time, tripping the WDT.

Possible solutions might be to make sure all initialization happens in the main function to ensure the functions are run. However, I don't know if values are added to the heap when globals appear in SLOT1/2 that are not present in SLOT0. (I added an integer to slot1/2 but not to 0, which seems to work properly, however initializing a value before the main function is not picked up on. Other solutions might be to extend the external WDT window in order to allow for the __TI_auto_init function to run regularly.