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

[DNM] upmerge to upsteram f50054d #4

Merged
merged 8 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:

Expand Down
12 changes: 11 additions & 1 deletion boot/bootutil/src/image_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "mbedtls/rsa.h"
#include "mbedtls/asn1.h"
#include "mbedtls/version.h"

#include "bootutil_priv.h"

Expand Down Expand Up @@ -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);

Expand Down
22 changes: 22 additions & 0 deletions boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions boot/zephyr/boards/nrf52840_pca10059.conf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion boot/zephyr/include/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) || \
Expand Down
13 changes: 10 additions & 3 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <misc/__assert.h>
#include <flash.h>
#include <drivers/system_timer.h>
#include <usb/usb_device.h>
#include <soc.h>

#include "target.h"
Expand Down Expand Up @@ -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;
Expand All @@ -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)();
}
Expand Down Expand Up @@ -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)
;
}
Expand All @@ -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");

Expand Down
4 changes: 4 additions & 0 deletions boot/zephyr/serial_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 9 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down