diff --git a/README.md b/README.md index 723e8f2a6..8cc43b6f8 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ 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 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. RIOT is currently supported as a boot target with a complete port planned. @@ -28,16 +28,21 @@ Instructions for different operating systems can be found here: ## Roadmap -The issues being planned and worked on are tracked on Jira. To participate -please visit: +The issues being planned and worked on are tracked using GitHub issues. To +participate please visit: -https://runtimeco.atlassian.net/projects/MCUB/summary +[MCUBoot GitHub Issues](https://github.com/runtimeco/mcuboot/issues) + +~~Issues were previously tracked on [MCUboot JIRA](https://runtimeco.atlassian.net/projects/MCUB/summary) +, but it is now deprecated.~~ ## Browsing -Information and documentation on the bootloader is stored within the source, and on confluence: +Information and documentation on the bootloader are stored within the source. -https://runtimeco.atlassian.net/wiki/discover/all-updates +~~It was previously also documented on confluence: +[MCUBoot Confluence](https://runtimeco.atlassian.net/wiki/discover/all-updates) +however, it is now deprecated and not currently maintained~~ For more information in the source, here are some pointers: diff --git a/boot/bootutil/src/image_rsa.c b/boot/bootutil/src/image_rsa.c index 7a9ca1565..0534c1291 100644 --- a/boot/bootutil/src/image_rsa.c +++ b/boot/bootutil/src/image_rsa.c @@ -27,6 +27,7 @@ #include "mbedtls/rsa.h" #include "mbedtls/asn1.h" +#include "mbedtls/version.h" #include "bootutil_priv.h" @@ -89,9 +90,18 @@ bootutil_parse_rsakey(mbedtls_rsa_context *ctx, uint8_t **p, uint8_t *end) return -4; } - if ((rc = mbedtls_rsa_check_pubkey(ctx)) != 0) { + /* The mbedtls version is more than 2.6.1 */ +#if MBEDTLS_VERSION_NUMBER > 0x02060100 + rc = mbedtls_rsa_import(ctx, &ctx->N, NULL, NULL, NULL, &ctx->E); + if (rc != 0) { return -5; } +#endif + + rc = mbedtls_rsa_check_pubkey(ctx); + if (rc != 0) { + return -6; + } ctx->len = mbedtls_mpi_size(&ctx->N); diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig index 3502481d9..49627e001 100644 --- a/boot/zephyr/Kconfig +++ b/boot/zephyr/Kconfig @@ -7,6 +7,11 @@ mainmenu "MCUboot configuration" comment "MCUboot-specific configuration options" +# Hidden option to mark a project as MCUboot +config MCUBOOT + default y + bool + config BOOT_USE_MBEDTLS bool # Hidden option @@ -127,6 +132,23 @@ menuconfig MCUBOOT_SERIAL if MCUBOOT_SERIAL +choice + prompt "Serial device" + default BOOT_SERIAL_UART if !BOARD_NRF52840_PCA10059 + default BOOT_SERIAL_CDC_ACM if BOARD_NRF52840_PCA10059 + +config BOOT_SERIAL_UART + bool "UART" + # SERIAL and UART_INTERRUPT_DRIVEN already selected + +config BOOT_SERIAL_CDC_ACM + bool "CDC ACM" + select USB + select USB_DEVICE_STACK + select USB_CDC_ACM + +endchoice + config BOOT_MAX_LINE_INPUT_LEN int "Maximum command line length" default 512 diff --git a/boot/zephyr/boards/nrf52840_pca10059.conf b/boot/zephyr/boards/nrf52840_pca10059.conf new file mode 100644 index 000000000..bf63bf7f8 --- /dev/null +++ b/boot/zephyr/boards/nrf52840_pca10059.conf @@ -0,0 +1,30 @@ +# Serial +CONFIG_SERIAL=y +CONFIG_UART_NRFX=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_UART_LINE_CTRL=y + +# MCUBoot serial +CONFIG_GPIO=y +CONFIG_MCUBOOT_SERIAL=y +CONFIG_BOOT_SERIAL_CDC_ACM=y +CONFIG_BOOT_SERIAL_DETECT_PORT="GPIO_1" +CONFIG_BOOT_SERIAL_DETECT_PIN=6 + +# RTT console +CONFIG_RTT_CONSOLE=y +CONFIG_USB_UART_CONSOLE=n + +# Required by USB +CONFIG_MULTITHREADING=y + +# USB +CONFIG_USB=y +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_PRODUCT="MCUBOOT" +CONFIG_USB_CDC_ACM=y +CONFIG_USB_COMPOSITE_DEVICE=n +CONFIG_USB_MASS_STORAGE=n + +# Logging +CONFIG_SYS_LOG_DEFAULT_LEVEL=1 diff --git a/boot/zephyr/include/target.h b/boot/zephyr/include/target.h index 00251dfd7..03e90989f 100644 --- a/boot/zephyr/include/target.h +++ b/boot/zephyr/include/target.h @@ -33,7 +33,7 @@ /* * Sanity check the target support. */ -#if !defined(FLASH_DEV_NAME) || \ +#if !defined(DT_FLASH_DEV_NAME) || \ !defined(FLASH_ALIGN) || \ !defined(FLASH_AREA_IMAGE_0_OFFSET) || \ !defined(FLASH_AREA_IMAGE_0_SIZE) || \ diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c index ca30bb5c8..d773dded9 100644 --- a/boot/zephyr/main.c +++ b/boot/zephyr/main.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "target.h" @@ -47,6 +48,8 @@ struct arm_vector_table { uint32_t reset; }; +extern void sys_clock_disable(void); + static void do_boot(struct boot_rsp *rsp) { struct arm_vector_table *vt; @@ -66,6 +69,10 @@ static void do_boot(struct boot_rsp *rsp) rsp->br_hdr->ih_hdr_size); irq_lock(); sys_clock_disable(); +#ifdef CONFIG_BOOT_SERIAL_CDC_ACM + /* Disable the USB to prevent it from firing interrupts */ + usb_disable(); +#endif __set_MSP(vt->msp); ((void (*)(void))vt->reset)(); } @@ -101,8 +108,8 @@ void main(void) os_heap_init(); - if (!flash_device_get_binding(FLASH_DEV_NAME)) { - BOOT_LOG_ERR("Flash device %s not found", FLASH_DEV_NAME); + if (!flash_device_get_binding(DT_FLASH_DEV_NAME)) { + BOOT_LOG_ERR("Flash device %s not found", DT_FLASH_DEV_NAME); while (1) ; } @@ -119,7 +126,7 @@ void main(void) GPIO_DIR_IN | GPIO_PUD_PULL_UP); __ASSERT(rc == 0, "Error of boot detect pin initialization.\n"); - rc = gpio_pin_read(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN, + rc = gpio_pin_read(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN, &detect_value); __ASSERT(rc == 0, "Error of the reading the detect pin.\n"); diff --git a/boot/zephyr/serial_adapter.c b/boot/zephyr/serial_adapter.c index 92aa6c683..fc39f7168 100644 --- a/boot/zephyr/serial_adapter.c +++ b/boot/zephyr/serial_adapter.c @@ -188,7 +188,11 @@ boot_uart_fifo_getline(char **line) static int boot_uart_fifo_init(void) { +#ifdef CONFIG_BOOT_SERIAL_UART uart_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); +#elif CONFIG_BOOT_SERIAL_CDC_ACM + uart_dev = device_get_binding(CONFIG_CDC_ACM_PORT_NAME); +#endif u8_t c; if (!uart_dev) { diff --git a/docs/index.md b/docs/index.md index 8a40238c2..7ba153d70 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,7 +7,7 @@ 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 +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. RIOT is currently supported as a boot @@ -35,16 +35,20 @@ of date. You should use `imgtool.py` instead of these documents. ## Roadmap -The issues being planned and worked on are tracked on Jira. To participate +The issues being planned and worked on are tracked using GitHub issues. To participate please visit: -[MCUboot JIRA](https://runtimeco.atlassian.net/projects/MCUB/summary) +[MCUboot Issues](https://github.com/runtimeco/mcuboot/issues) + +~~Issues were previously tracked on [MCUboot JIRA](https://runtimeco.atlassian.net/projects/MCUB/summary) +, but it is now deprecated.~~ ## Browsing -Information and documentation on the bootloader is stored within the source, and on confluence: +Information and documentation on the bootloader is stored within the source. -[Confluence page](https://runtimeco.atlassian.net/wiki/discover/all-updates) +~~It was previously also documented on confluence: [Confluence page](https://runtimeco.atlassian.net/wiki/discover/all-updates) +, but it is now deprecated and not currently maintained~~ For more information in the source, here are some pointers: