Fix flash decoder assert
An assert is triggered if you attempt load a DAPLink interface image
while in interface mode or a DAPLink bootloader image while in
bootloader mode due to unhandled cases in the flash decoder. This
patch adds logic to handle these cases so an assert does not occur.
@@ -112,8 +112,6 @@ error_t flash_decoder_get_flash(flash_decoder_type_t type, uint32_t addr, bool a
if (addr_valid && (DAPLINK_ROM_IF_START != addr)) {
// Address is wrong so display error message
status = ERROR_FD_INTF_UPDT_ADDR_WRONG;
- flash_start_local = 0;
- flash_intf_local = 0;
} else {
// Setup for update
flash_start_local = DAPLINK_ROM_IF_START;
@@ -123,14 +121,14 @@ error_t flash_decoder_get_flash(flash_decoder_type_t type, uint32_t addr, bool a
// "Target" update in this case would be a 3rd party interface application
flash_start_local = DAPLINK_ROM_IF_START;
flash_intf_local = flash_intf_iap_protected;
+ } else {
+ status = ERROR_FD_UNSUPPORTED_UPDATE;
}
} else if (daplink_is_interface()) {
if (FLASH_DECODER_TYPE_BOOTLOADER == type) {
if (addr_valid && (DAPLINK_ROM_BL_START != addr)) {
// Address is wrong so display error message
status = ERROR_FD_BL_UPDT_ADDR_WRONG;
- flash_start_local = 0;
- flash_intf_local = 0;
} else {
// Setup for update
flash_start_local = DAPLINK_ROM_BL_START;
@@ -139,6 +137,8 @@ error_t flash_decoder_get_flash(flash_decoder_type_t type, uint32_t addr, bool a
} else if (FLASH_DECODER_TYPE_TARGET == type) {
flash_start_local = target_device.flash_start;
flash_intf_local = flash_intf_target;
+ } else {
+ status = ERROR_FD_UNSUPPORTED_UPDATE;
}
} else {
status = ERROR_FD_UNSUPPORTED_UPDATE;
