mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-19 20:48:22 +00:00
This commit adds NuttX based bootloader with the support for image update and recovery if not confirmed. The algorithm utilizes three flash partitions: primary (image runs from this area), secondary and tertiary. Secondary and tertiary areas are used for update upload and recovery. The update is performed by simple copy from update area to primary area with recovery being created in recovery area if not already present. Once image is confirmed by the user, the image in update area is confirmed as well, update area becomes recovery area and vice versa. This means the recovery is always present (except for the first update) and subsequent updates just copy image from update to primary. This makes the update significantly faster and more considerable to flash wear while keeping the recovery/revert possibility. A header (aligned to flash's erase size) must be added to the beginning of the image. Python script nximage.py can be used to prepend this header to built binary. The algorithm also uses one erase page at the end of a partition (partition, not image!) to store flags used to indicate image confirm status and to detect update/recovery partitions. Any program uploading update image to the update partition has to erase this page for the boot to work correctly! The algorithm implementation is based on a patch initially developed for MCUboot project but rejected by the project's maintainers https://github.com/mcu-tools/mcuboot/pull/1902 Signed-off-by: Michal Lenc <michallenc@seznam.cz>
88 lines
2.7 KiB
Text
88 lines
2.7 KiB
Text
#
|
|
# For a description of the syntax of this configuration file,
|
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
|
#
|
|
|
|
menuconfig BOOT_NXBOOT
|
|
bool "NuttX bootloader"
|
|
default n
|
|
select BCH
|
|
---help---
|
|
Enable support for the minimal NuttX based bootloader.
|
|
|
|
if BOOT_NXBOOT
|
|
|
|
config NXBOOT_PRIMARY_SLOT_PATH
|
|
string "Application firmware primary image slot path"
|
|
default "/dev/ota0"
|
|
---help---
|
|
The path to the application firmware image primary slot character
|
|
device driver. The image runs from this location.
|
|
Default: /dev/ota0
|
|
|
|
config NXBOOT_SECONDARY_SLOT_PATH
|
|
string "Application firmware secondary image slot path"
|
|
default "/dev/ota1"
|
|
---help---
|
|
The path to the application firmware image primary slot character
|
|
device driver. This is either update or recovery slot.
|
|
Default: /dev/ota1
|
|
|
|
config NXBOOT_TERTIARY_SLOT_PATH
|
|
string "Application firmware tertiary image slot path"
|
|
default "/dev/ota2"
|
|
---help---
|
|
The path to the application firmware image primary slot character
|
|
device driver. This is either update or recovery slot.
|
|
Default: /dev/ota2
|
|
|
|
config NXBOOT_HEADER_SIZE
|
|
hex "Application firmware image header size"
|
|
default 0x200
|
|
---help---
|
|
Note that this size should be aligned with the program memory write
|
|
page size!
|
|
|
|
config NXBOOT_BOOTLOADER
|
|
bool "Build nxboot bootloader application"
|
|
default n
|
|
select BOARDCTL
|
|
select BOARDCTL_BOOT_IMAGE
|
|
---help---
|
|
This option builds and links a bootloader application. This application
|
|
should be an entry function for NuttX. It checks for possible update/
|
|
revert operation, performs it and boot the correct image.
|
|
|
|
if NXBOOT_BOOTLOADER
|
|
|
|
config NXBOOT_SWRESET_ONLY
|
|
bool "Perform update/revert only on SW reset"
|
|
default n
|
|
select BOARDCTL_RESET_CAUSE
|
|
---help---
|
|
This option ensures the update/revert is performed only for following
|
|
reset causes:
|
|
BOARDIOC_RESETCAUSE_CPU_SOFT: software reset
|
|
BOARDIOC_RESETCAUSE_CPU_RWDT: watchdog error
|
|
BOARDIOC_RESETCAUSE_PIN: reset button
|
|
|
|
This way the board can keep its image (even if not confirmed) during
|
|
for example power shutdown and perform update/revent only if expected
|
|
based on user/maintainer input.
|
|
|
|
config NXBOOT_PREVENT_DOWNGRADE
|
|
bool "Perform update only for newer version"
|
|
default n
|
|
---help---
|
|
NXboot uses Semantic Version 2.0.0 (without build metadata). By default
|
|
the update is performed for every version that doesn't match the
|
|
currently running one. If NXBOOT_PREVENT_DOWNGRADE selected, update is
|
|
performed only for newer versions (according to Semantic Version
|
|
preference rules).
|
|
|
|
WARNING: NXboot currently implementes preferences only for
|
|
MAJOR.MINOR.PATCH and ignores prerelease.
|
|
|
|
endif # NXBOOT_BOOTLOADER
|
|
|
|
endif # BOOT_NXBOOT
|