Fixed it by looking for the function address in the ROM table manually and not using the SDK function since it seems to crash or work different when having enabled FreeRTOS in the project.
I guess the SDK changes the way it uses the watchdog or threads and mutex when you include FreeRTOS library and simply the function from the SDK to perform the rom_explicit_buy() crashes if FreeRTOS is not initialized yet (?). Maybe someone can explain in more detail what is really going on.
**The interrupts disable maybe are not needed
This worked for me and correctly removed the TBYB flag in my secure OTA update on my secure pico after a FLASH_UPDATE in case someone faces the same issue.
I guess the SDK changes the way it uses the watchdog or threads and mutex when you include FreeRTOS library and simply the function from the SDK to perform the rom_explicit_buy() crashes if FreeRTOS is not initialized yet (?). Maybe someone can explain in more detail what is really going on.
Code:
static __attribute__((aligned(16))) uint8_t workarea[4 * 1024];typedef int (*rom_explicit_buy_fn)(uint8_t *buf, uint32_t len);void *func_address = rom_func_lookup(rom_table_code('E', 'B'));rom_explicit_buy_fn buy_func = (rom_explicit_buy_fn)func_address;uint32_t ints = save_and_disable_interrupts();int ret = buy_func(workarea, sizeof(workarea));restore_interrupts(ints);This worked for me and correctly removed the TBYB flag in my secure OTA update on my secure pico after a FLASH_UPDATE in case someone faces the same issue.
Statistics: Posted by vicenspb9 — Sun Dec 14, 2025 11:18 pm