bootutil: use flash_area_get_sectors()

The flash map API has added a new routine, flash_area_get_sectors().
Use that instead of flash_area_to_sectors(), which is now deprecated.

This exposed a bug in boot_swap_sectors() (a large sz would still lead
to copying past the end of the area, including the trailer); fix it.

This also exposed a bug in split_go(). Calling boot_read_sectors()
there makes a potentially invalid assumption, namely:

      (loader_slot == FLASH_AREA_IMAGE_0 &&
       split_slot == FLASH_AREA_IMAGE_1)

We make this slightly better by making sure that loader_slot and
split_slot in split_go() get placed into boot_data at indices
mynewt-core currently sets LOADER_SLOT and SPLIT_SLOT to, but a real
fix is left to future work.

This patch also frees up about 650B of RAM, since struct flash_sector
is smaller than struct flash_area.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
1 file changed
tree: 4c1ae5f74a3b544aee93f7a263a63e1feb2626bc
  1. apps/
  2. boot/
  3. doc/
  4. imgtool/
  5. scripts/
  6. sim/
  7. .gitignore
  8. .travis.yml
  9. build_boot.sh
  10. Makefile
  11. project.yml
  12. README-zephyr.rst
  13. README.md
  14. repository.yml
  15. root-ec-p256.pem
  16. root-rsa-2048.pem
  17. sign.sh
README.md

mcuboot

Overview

MCUBoot is a secure bootloader for 32-bit MCUs. The goal of MCUBoot is to define a common infrastructure for the bootloader, system flash layout on microcontroller systems, and to provide a secure bootloader that enables easy software upgrade.

MCUboot is operating system and hardware independent, and relies on hardware porting layers from the operating system it works with. Currently mcuboot works with both the Apache Mynewt, and Zephyr operating systems, but more ports are planned in the future.

Roadmap

The MCUBoot project was originally taken from the Apache Mynewt operating system, which had secure boot and software upgrade functionality instrinsic to it. Currently development is heads down on a first release of MCUboot that works across both the Zephyr operating system and Apache Mynewt operating system.

For more information on what's being planned, and worked on, please visit:

https://runtimeco.atlassian.net/projects/MCUB/summary

Browsing

Information and documentation on the bootloader is stored within the source, and on confluence:

https://runtimeco.atlassian.net/wiki/discover/all-updates

For more information in the source, here are some pointers:

  • boot/bootutil: The core of the bootloader itself.
  • boot/boot_serial: Support for serial upgrade within the bootloader itself.
  • boot/zephyr: Port of the bootloader to Zephyr
  • imgtool: A tool to securely sign firmware images for booting by mcuboot.
  • sim: A bootloader simulator for testing and regression

Joining

Developers welcome! To join in the discussion, please join the developer mailing list:

http://lists.runtime.co/mailman/listinfo/dev-mcuboot_lists.runtime.co