DFU Upgrade of Thing91X/NRF5340 Not Working

I’m encountering an issue while attempting to perform a DFU (Device Firmware Update) on my Thing91X/NRF5340 device. Despite successfully sending the firmware image and following the necessary steps, the device doesn’t switch to the new firmware after a reset. Instead, it continues to run the old version. Here’s a detailed breakdown of the problem and my troubleshooting efforts:

Error Description

  1. Flash Area ID 2 Error: During the DFU process, an error message appears regarding the flash area ID 2. The message reads:

    mcumgr_img_grp: Failed to open flash area ID 2: -2

    This indicates an issue with accessing or writing to the specified flash area.

  2. Magic Value Issue: The logs also show that the magic value for the flash area is unset or incorrect. This is critical because the magic value is used to validate the firmware image. If it’s not set correctly, the device won’t recognize the new firmware as valid.

  3. Firmware Not Swapping: Despite the DFU process completing without apparent errors, the device doesn’t switch to the new firmware. The logs show that the nsib_swap_run() function executes without errors, but the device reboots to the old firmware.

Configuration Details

  • CONFIG_UPDATEABLE_IMAGE_NUMBER: Set to 3 in the application configuration, but 2 in mcuboot.
  • CONFIG_BOOT_IMG_HASH_ALG_SHA256: Enabled for firmware validation.
  • CONFIG_BOOT_SWAP_USING_MOVE: Enabled, which means the firmware swap should use the move method.

Troubleshooting Steps

  1. Flash Area Configuration: Verified that the flash areas are correctly configured in the linker script. The flash area ID 2 should correspond to the secondary firmware slot.
  2. Magic Value Check: Ensured that the magic value is correctly set for the flash areas. The magic value should be set to 0x86518483 for the primary image and 0x6919b47e for the secondary image.
  3. DFU Process: Retried the DFU process multiple times to rule out transient issues. The same error persists.
  4. Log Analysis: Reviewed the logs to identify any additional clues. The logs indicate that the firmware image is accepted, but the swap process fails.
  5. Bootloader Logs: Checked the bootloader logs for any errors during the firmware validation and swap process. No additional errors were found.

Potential Causes

  1. Mismatched Image Number: The discrepancy between CONFIG_UPDATEABLE_IMAGE_NUMBER in the application and mcuboot might be causing the issue. Mcuboot expects a different number of images than what is configured in the application.
  2. Flash Area Corruption: The flash area ID 2 might be corrupted or inaccessible. This could prevent the firmware from being written or validated.
  3. DFU Tool Configuration: The DFU tool might not be correctly configured to handle the flash areas or firmware validation.
  4. Firmware Image Integrity: The firmware image might be corrupted or incomplete, leading to validation failures.

Next Steps

  1. Check Configuration Settings: Ensure that CONFIG_UPDATEABLE_IMAGE_NUMBER matches between the application and mcuboot. If they don’t match, update the configuration to use the same value.
  2. Flash Area Verification: Use a tool like nrfjprog to verify the contents of flash area ID 2. Check if the firmware image is correctly written and if the magic value is set.
  3. DFU Tool Settings: Review the DFU tool configuration to ensure that it’s correctly targeting the flash areas and handling the firmware validation.
  4. Firmware Image Integrity: Verify the integrity of the firmware image using a checksum or hash. Ensure that the image is correctly signed and formatted.
  5. Reset and Retry: After making any changes, reset the device and retry the DFU process. Monitor the logs closely for any errors or warnings.

Conclusion

This issue is preventing me from successfully updating the firmware on my Thing91X/NRF5340 device. I need to resolve this to ensure that the device runs the latest firmware and benefits from any bug fixes or new features. I’m hoping that by adjusting the configuration settings and verifying the flash areas, I can get the DFU process working as expected.

Any insights or suggestions from the community would be greatly appreciated!

Best regards,
[Your Name]