Remove the simple pointers and use the "&" operator throughout to
simplify the understanding of the code.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to avoid overwriting an existing allocated buffer that has not
yet been processed by the main loop, switch to a new command buffer
whenever we have received a complete one.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
While building with Zephyr 1.12 for the nucleo_f091rc I got undefined
reference to __set_MSP() during linking. Including soc.h fixes the
problem. Thanks carlesc.
Signed-off-by: Evan Gates <evan@gnarbox.com>
It was possible that free_queue locks on the self referencing
node.
This patch introduce check for this issue
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Due to an issue described here:
https://github.com/zephyrproject-rtos/zephyr/issues/8393
interrupts are not enabled when multithreading is disabled.
Enable interrupts to allow the serial recovery mode UART to receive
characters.
Note: This commit must be reverted once the issue is addressed.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The k_fifo_* primitives are not available when multithreading is
disabled. Use sys_slist_* instead.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Power management requires multithreading and other kernel features that
are disabled in MCUboot, so disable it to avoid interrupts being
confused by power management code wrappers.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
For serial recovery enabled Assertions conditions were improperly
which cause runtime assertion whenever __ASSERT macro was enabled
along with the serial recovery mode running.
This patch fixes the issue.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
In order to provide a pleasant out-of-the-box experience to users,
default to the RSA .pem file so that users do not get a cryptic error
when building with the default .conf file in upstream.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The hardcoded keys for Zephyr were removed and external references were
added for the built time autogenerated variables. A hardcoded key file
was added specifically for the simulator.
Signed-off-by: Fabio Utzig <utzig@apache.org>
For both RSA (which uses Zephyr's mbedTLS copy) and ECDSA (which uses
our own for ASN1 parsing) use the common "mcuboot-mbedtls-cfg.h" header
file instead of relying on the default config.h bundled with mbedTLS.
Additionally issue a descriptive error when CONFIG_MBEDTLS is set and we
are building with our own copy.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This removes settings of log level on a per file basis. The log level
should be set by the global config, while per file log configuration can
still be set, don't enforce them.
Signed-off-by: Fabio Utzig <utzig@apache.org>
New logging macros were added for all supported platforms, following the
documentation defined in the template config file.
Signed-off-by: Fabio Utzig <utzig@apache.org>
This patch isolates mcuboot settings under `MCUBoot`
menu in menuconfig view. This improves legibility.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The patch introduce usage of zephyr flas_map module instead
of mcuboot zephyr-only implementation. Unused flash_area_to_sectors
API of former flash_map was removed as well.
Size of sector-status-update-map entry is now defined thanks to the
minimum write size supported by the flash driver.
For avoid ambiguity former zephyr-only files flash_map.c
were renamed to flash_map_extended.c (its code now implements
only addition to this what zephyr flash_map implements).
flash_map.h header include is now warped by flash_map_backedn.h headre
because implementations and include pathes are diferent in Zephyr and Mynewt.
Usage of hal_flash_align() were replaced by usage flash_area_align().
This provide consistency between MyNewt and Zephyr implementation as
this API is available in both RTOSes.
flash_map.h was moved to the simulator c-support files as now missing in
the boot/zephyr subdirectories.
f. boot_scratch_fa_device_id was removed as unused.
f. boot_img_fa_device_id was and expanded the only use of it
(on loader.c).
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Take the opportunity to clean up a bit of platform cruft that has
gotten into bootutil by moving it to mcuboot_config.h, and ensuring it
is documented in the template config file.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
This allows us to delete all the remaining compiler command line
configuration from CMakeLists.txt.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Finish the job of removing the CONF_xxx fields from CMakeLists.txt by
using the Kconfig symbol from the application runner configuration macro.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Handle CONFIG_BOOT_UPGRADE_ONLY in mcuboot_config.h, and switch the
release test Makefile to using an OVERLAY_CONFIG fragment.
This removes the last user of the Makefile BOOTLOADER_CONFIG variable,
so delete it as well.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Handle CONFIG_BOOT_VALIDATE_SLOT0 in mcuboot_config.h, and switch to
setting it with an OVERLAY_CONFIG fragment in the test Makefile.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Handle the CONFIG_BOOT_SIGNATURE_TYPE_xxx values in Zephyr's
mcuboot_config.h by converting them into the platform-agnostic MCUboot
definitions.
This requires some changes to the way the release test Makefile is
structured, since Kconfig symbols cannot be set from the command line.
Instead, use the OVERLAY_CONFIG feature of the Zephyr build system,
which allows specifying extra fragments to merge into the final
.config. (This is an orthogonal mechanism to setting CONF_FILE; it is
used by Zephyr's CI script sanitycheck to add additional fragments, so
it's appropriate for use by MCUboot's testing scripts as well.)
We additionally need to move to a single prj.conf file due to a
dependency issue. We can no longer determine CONF_FILE from the
signature type, since that is now determined from the final .config or
autoconf.h, which is a build output that depends on CONF_FILE.
To move to a single prj.conf:
- delete prj-p256.conf and adjust prj.conf to serve both signature types
- add a top-level mbedTLS configuration file which dispatches to
the right sub-header depending on the key type
- as a side effect, have the simulator pick the right config file
depending on the case
This fixes and cleans up quite a bit of the signature type handling,
which had become something of a mess over time. For example, it fixes
a bug in ECDSA mode's configuration that wasn't actually selecting
config-asn1.h, and forces the simulator to use the same mbedTLS
configuration file as builds for real hardware.
Finally, we also have to move the mbedTLS vs. TinyCrypt choice into
mcuboot_config.h at the same time as well, since CMakeLists.txt was
making that decision based on the signature type.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
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
The Zephyr CMakeLists.txt contains some configuration options that are
outside of Kconfig.
The standard way to configure Zephyr builds is with Kconfig, so it
would be better if MCUboot did not have a parallel configuration
mechanism.
Add equivalent Kconfig options to those which are defined in
CMakeLists.txt. Subsequent patches will use them.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
The kconfig file is a bit disorderly. Clean it up. There are no
changes in this commit which affect the bootloader's behavior.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
The flash driver name was changed upstream during the v1.11
development cycle. Remove a shim which kept the old name around in the
Zephyr port now that v1.11 is out.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Following warnings were fixed within this patch:
'isspace' macro should take an int value
function 'bs_reset' should return void
redefinition of 'MBEDTLS_CONFIG_FILE' macro while
it is already defined by the zephyr build system.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Zephyr's SOC_FAMILY_NRF5 keyword was changed to SOC_FAMILY_NRF to
align with zephyr code-base.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Zephyr has build-in tinycbor code of version which doesn't
require newlib-c by default. Also the cborattr module is now
taken form the zephyr code.
This patch decrease flash consumption by 10 KB for serial recovery build.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This still defaults to 128 for compatibility, but allows users to
specify less elements to save space, or more elements for devices that
have massive flash size and/or too small sectors.
Signed-off-by: Fabio Utzig <utzig@apache.org>
Allow the user to add additional device tree overlays onto the default
one that sets up the code partition.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
The macro _MspSet has gone away in Zephyr. Change to use the __set_MSP
macro from the CMSIS code that has always been present. This allows
mcuboot to build with Zephyr after:
commit c028f88b37d2a033d6a85c8d365ef048e1e4d621
Author: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Date: Mon Mar 12 10:45:02 2018 +0100
arch: arm: remove redundant asm inline headers
Fixes#246.
Signed-off-by: David Brown <david.brown@linaro.org>
The Zephyr CMakeLists.txt uses its own logic to have board-specific
overlays, named boards/${BOARD}.prj. However, the only overlay file we
have, arduino_101.conf, isn't in this boards directory, and this target
doesn't build.
Fix this by moving the target into the right directory. Fixes#188.
Signed-off-by: David Brown <david.brown@linaro.org>
Although MCUboot has used PKCS#1 v2.1 (PSS) for some time now, the mbed
TLS config file was calling out v1.5. This compiled because MCUboot
implements its own specialized version of the signature check, and only
needs the underlying primitives from mbed TLS. (The general code in
mbed TLS is quite a bit larger).
To make it clear that we are always using PSS, change the mbed TLS
configuration to call this out explicitly.
Signed-off-by: David Brown <david.brown@linaro.org>
Upstream zephyr will automatically link mbedtls when CONFIG_MBEDTLS is
enabled.
If user chose to use ECDSA_P256 as signature type, will get a compile
error message in file ${ZEPHYR_BASE}/ext/lib/crypto/mbedtls/zephyr_init.c:
fatal error: config-asn1.h: No such file or directory
Fix this by disable CONFIG_MBEDTLS when ECDSA_P256 signature type is
selected.
Signed-off-by: Ding Tao <miyatsu@qq.com>
The upstream Zephyr project is renaming FLASH_DRIVER_NAME to
FLASH_DEV_NAME as part of some changes related to device tree.
Work around this for now by keeping the MCUboot name the same if
FLASH_DRIVER_NAME is not provided by Zephyr, but FLASH_DEV_NAME is.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
It's recommended practice to mass erase the flash chip before
reflashing mcuboot. Add a configuration option for Zephyr which does
this by default on some Zephyr runner backends which can support
this (pyOCD and dfu-util). Additional runners can be added as needed.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
When the target doesn't have good enough generic support for MCUBoot,
you can specify the flash layout etc on a per-board basis by creating
a header, boot/zephyr/targets/BOARD.h.
The build system tries to pick this up, but isn't doing it
correctly. Fix it.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Since the Kconfig file was moved in 51a0921006 ("zephyr: Move Kconfig
file to boot/zephyr"), the CMakeLists.txt reference to it needs updating.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
Since not all ICs default to enabling flash page layout, enable it from
the MCUboot Kconfig options whenever it is available.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add a new MCUboot device settings option that enables or configures
features that are specific to a particular device.
Additionally enable software vector relay in Cortex-M0 CPUs that do not
have a hardware mechanism to relay or forward interrupts.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since the Kconfig file is only relevant to Zephyr, move it from the root
folder into boot/zephyr, in order to keep all Zephyr-related files
together.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>