Mandate the presence of mcuboot_config/mcuboot_config.h

Mynewt uses this file to convert MYNEWT_VAL(xxx) to MCUBOOT_xxx config
options. Zephyr currently adds config options via the compiler command
line, but it should use this instead.

As prep work for that conversion, add an empty mcuboot_config.h to the
Zephyr port, and include this file unconditionally wherever it's
needed. This takes care of the simulator as well, since that puts
boot/zephyr/include on its C file include path.

This turned up a couple of files (bootutil_priv.h and caps.c) that
were using the MCUBOOT_xxx config values without including the
file. Add the includes there, as they'll be needed later.

To make this official, add it to the requirements in the porting guide
and provide a template file porters can use while getting started.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>

fixup! Mandate the presence of mcuboot_config/mcuboot_config.h
This commit is contained in:
Marti Bolivar 2018-04-12 12:40:46 -04:00 committed by Fabio Utzig
parent bc2fa4e1e7
commit f91bca51a6
12 changed files with 131 additions and 14 deletions

View File

@ -29,9 +29,7 @@
#ifndef __BOOTUTIL_CRYPTO_H_
#define __BOOTUTIL_CRYPTO_H_
#ifdef MCUBOOT_MYNEWT
#include "mcuboot_config/mcuboot_config.h"
#endif
#if defined(MCUBOOT_USE_MBED_TLS) && defined(MCUBOOT_USE_TINYCRYPT)
#error "Cannot define both MBED_TLS and TINYCRYPT"

View File

@ -23,6 +23,7 @@
#include "sysflash/sysflash.h"
#include "flash_map/flash_map.h"
#include "bootutil/image.h"
#include "mcuboot_config/mcuboot_config.h"
#ifdef __cplusplus
extern "C" {

View File

@ -15,6 +15,7 @@
*/
#include <bootutil/caps.h>
#include "mcuboot_config/mcuboot_config.h"
uint32_t bootutil_get_caps(void)
{

View File

@ -19,9 +19,7 @@
#include <string.h>
#ifdef MCUBOOT_MYNEWT
#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_EC
#include "bootutil/sign_key.h"

View File

@ -19,9 +19,7 @@
#include <string.h>
#ifdef MCUBOOT_MYNEWT
#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_EC256
#include "bootutil/sign_key.h"

View File

@ -19,9 +19,7 @@
#include <string.h>
#ifdef MCUBOOT_MYNEWT
#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_RSA
#include "bootutil/sign_key.h"

View File

@ -28,9 +28,7 @@
#include "bootutil/sha256.h"
#include "bootutil/sign_key.h"
#ifdef MCUBOOT_MYNEWT
#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_RSA
#include "mbedtls/rsa.h"

View File

@ -37,9 +37,7 @@
#define BOOT_LOG_LEVEL BOOT_LOG_LEVEL_INFO
#include "bootutil/bootutil_log.h"
#ifdef MCUBOOT_MYNEWT
#include "mcuboot_config/mcuboot_config.h"
#endif
static struct boot_loader_state boot_data;

View File

@ -17,9 +17,7 @@
* under the License.
*/
#ifdef MCUBOOT_MYNEWT
#include "mcuboot_config/mcuboot_config.h"
#endif
#include <assert.h>
#include <stddef.h>

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2018 Open Source Foundries Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __MCUBOOT_CONFIG_H__
#define __MCUBOOT_CONFIG_H__
/*
* This file is also included by the simulator, but we don't want to
* define anything here in simulator builds.
*
* Instead of using mcuboot_config.h, the simulator adds MCUBOOT_xxx
* configuration flags to the compiler command lines based on the
* values of environment variables. However, the file still must
* exist, or bootutil won't build.
*/
#ifndef __BOOTSIM__
/*
* Initially blank.
*/
#endif /* !__BOOTSIM__ */
#endif /* __MCUBOOT_CONFIG_H__ */

View File

@ -5,6 +5,10 @@ This document describes the requirements and necessary steps required to port
# Requirements
* `mcuboot` requires a configuration file, which can be included as
mcuboot_config/mcuboot_config.h, which configures various options
(that begin with MCUBOOT_).
* `mcuboot` requires that the target provides a `flash` API with ability to
get the flash's minimum write size, and read/write/erase individual sectors.
@ -46,6 +50,23 @@ After running the management functions of the bootloader, `boot_go` returns
an initialized `boot_rsp` which has pointers to the location of the image
where the target firmware is located which can be used to jump to.
## Configuration file
You must provide a file, mcuboot_config/mcuboot_config.h. This is
included by several files in the "library" portion of MCUboot; it
provides preprocessor definitions that configure the library's
build.
See the file samples/mcuboot_config/mcuboot_config.template.h for a
starting point and more information. This is a good place to convert
settings in your environment's configuration system to those required
by MCUboot. For example, Mynewt uses MYNEWT_VAL() and Zephyr uses
Kconfig; these configuration systems are converted to MCUBOOT_ options
in the following files:
- boot/zephyr/include/mcuboot_config/mcuboot_config.h
- boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
## Flash access and flash Map
* Regarding flash access the bootloader has two requirements:

View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2018 Open Source Foundries Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __MCUBOOT_CONFIG_H__
#define __MCUBOOT_CONFIG_H__
/*
* Template configuration file for MCUboot.
*
* When porting MCUboot to a new target, copy it somewhere that your
* include path can find it as mcuboot_config/mcuboot_config.h, and
* make adjustments to suit your platform.
*
* For examples, see:
*
* boot/zephyr/include/mcuboot_config/mcuboot_config.h
* boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
*/
/*
* Signature types
*
* You must choose exactly one signature type.
*/
/* Uncomment for RSA signature support */
/* #define MCUBOOT_SIGN_RSA */
/* Uncomment for ECDSA signatures using curve P-256. */
/* #define MCUBOOT_SIGN_EC256 */
/*
* Upgrade mode
*
* The default is to support A/B image swapping with rollback. A
* simpler code path, which only supports overwriting the
* existing image with the update image, is also available.
*/
/* Uncomment to enable the overwrite-only code path. */
/* #define MCUBOOT_OVERWRITE_ONLY */
#ifdef MCUBOOT_OVERWRITE_ONLY
/* Uncomment to only erase and overwrite those slot 0 sectors needed
* to install the new image, rather than the entire image slot. */
/* #define MCUBOOT_OVERWRITE_ONLY_FAST */
#endif
/*
* Cryptographic settings
*
* You must choose between mbedTLS and Tinycrypt as source of
* cryptographic primitives. Other cryptographic settings are also
* available.
*/
/* Uncomment to use ARM's mbedTLS cryptographic primitives */
/* #define MCUBOOT_USE_MBED_TLS */
/* Uncomment to use Tinycrypt's. */
/* #define MCUBOOT_USE_TINYCRYPT */
/*
* Always check the signature of the image in slot 0 before booting,
* even if no upgrade was performed. This is recommended if the boot
* time penalty is acceptable.
*/
#define MCUBOOT_VALIDATE_SLOT0
/*
* Flash abstraction
*/
/* Uncomment if your flash map API supports flash_area_get_sectors().
* See the flash APIs for more details. */
/* #define MCUBOOT_USE_FLASH_AREA_GET_SECTORS */
#endif /* __MCUBOOT_CONFIG_H__ */