The bootloader cannot boot an application immediately after the bootloader has been flashed and reset. This is a (minor) inconvenience when developing the bootloader.
The problem is that flashing leaves the contents of RAM in an unspecified state with the reset cause SYSREQRST. The bootloader only initializes the boot token when the reset cause is PORST and otherwise assumes that it has valid contents. So what happens is that after flashing the bootloader happily checks the value of boot_count field of the boot token, and this field most probably contains some large value left by the flashing. Hence the application boot is aborted due to BOOT_FAILED_TOO_MANY_TIMES.
To solve this, the bootloader should somehow verify that the boot token contents are valid without depending on the reset cause. Perhaps use some (non-zero) magic value in the magic field of the boot token even when not forcing bootloader entry?
The bootloader cannot boot an application immediately after the bootloader has been flashed and reset. This is a (minor) inconvenience when developing the bootloader.
The problem is that flashing leaves the contents of RAM in an unspecified state with the reset cause
SYSREQRST. The bootloader only initializes the boot token when the reset cause isPORSTand otherwise assumes that it has valid contents. So what happens is that after flashing the bootloader happily checks the value ofboot_countfield of the boot token, and this field most probably contains some large value left by the flashing. Hence the application boot is aborted due toBOOT_FAILED_TOO_MANY_TIMES.To solve this, the bootloader should somehow verify that the boot token contents are valid without depending on the reset cause. Perhaps use some (non-zero) magic value in the
magicfield of the boot token even when not forcing bootloader entry?