Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModusToolbox: Error on boot_set_pending due to flash alignment problem #3

Open
ncmiller opened this issue Sep 30, 2022 · 3 comments
Open

Comments

@ncmiller
Copy link
Contributor

ncmiller commented Sep 30, 2022

  • SDK Version: v0.1.0
  • Target OS/Platform: Modus Toolbox
  • Hardware Target: CY8CPROTO-062-4343W
  • Host OS: Ubuntu 22.04.1 LTS

Current Behavior

When running the Golioth example project and testing firmware update, there is an error reported after the image is downloaded:

boot_set_pending failed, error -1

From https://github.com/golioth/golioth-firmware-sdk/blob/main/port/modus_toolbox/fw_update_mcuboot.c#L105.

Digging into MCUboot (v1.8.1-cypress tag), it appears that it's failing to write the image trailer due to a flash alignment problem:

https://github.com/mcu-tools/mcuboot/blob/v1.8.1-cypress/boot/bootutil/src/bootutil_public.c#L348-L355

From what I can tell, this is the same issue as reported here:

mcu-tools/mcuboot#713

The firmware update proceeds normally, despite the error using strategy MCUBOOT_OVERWRITE_ONLY. However, it prevents other desirable strategies such as MCUBOOT_SWAP_USING_SCRATCH from working since the image trailers cannot be written.

Expected Behavior

The error should not happen. MCUboot needs to support the 512-byte alignment restriction of the PSOC6 board so that image trailers can be written.

Steps to Reproduce

Attempt a device firmware update with Golioth, and you will see boot_set_pending failed, error -1 after downloading the image.

Logs, Additional Data

N/A

@ddka22
Copy link

ddka22 commented Oct 6, 2022

There are three types of swap modes supported in MCUboot - scratch, move, and using a status partition. Only swap mode using status partition can be used with PSoC™ 6 MCU devices because of the hardware restriction of the large minimum flash write/erase size. The MCUboot library is designed with the minimum flash to write/erase size to be 8 bytes or less. This is to ensure that data is not lost when writing to the flash sector status so that it is a single-cycle operation ensuring the robustness of the application.

Because PSoC™ 6 MCU devices have a large minimum flash write/erase size, swap using status partition has been implemented. Using this algorithm, a separate area in the internal flash is used to store swap status values and the image trailer data such as the swap size and info, boot image magic value, and the image ok field.

See https://github.com/Infineon/mtb-example-psoc6-mcuboot-basic for more details.

@ncmiller
Copy link
Contributor Author

ncmiller commented Oct 6, 2022

Thanks for the info @ddka22.

I originally tried to use the "swap using status" algorithm (following the Infineon examples), but it didn't work as I expected it to -after a new image was downloaded and flashed, after reboot the bootloader did not detect that a new image was ready. This is a separate issue which I haven't gotten to the bottom of, which prompted me to switch to the MCUBOOT_OVERWRITE_ONLY algorithm, which works (despite the innocuous boot_set_pending failure).

I will leave this issue open for now, until a point when it's either resolved or I switch to the "swap using status" algorithm (assuming I can work through the issues I was seeing).

@ddka22
Copy link

ddka22 commented Oct 6, 2022

I will try to reproduce the issue from my side. Will keep you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants