/* We arrive here after the ROM bootloader finished loading this second stage bootloader from flash. The hardware is mostly uninitialized, flash cache is down and the app CPU is in reset. We do have a stack, so we can do the initialization in C.  */
void __attribute__((noreturn))
/* We arrive here after the ROM bootloader finished loading this second stage bootloader from flash. The hardware is mostly uninitialized, flash cache is down and the app CPU is in reset. We do have a stack, so we can do the initialization in C.  */
void __attribute__((noreturn))
{
    if (bootloader_init() != ESP_OK) {
        bootloader_reset();
    }
    bootloader_state_t bs = { 0 };
    int boot_index = select_partition_number(&bs);
    if (boot_index == INVALID_INDEX) {
        bootloader_reset();
    }
    bootloader_utility_load_boot_image(&bs, boot_index);
}