Commit Graph

648 Commits

Author SHA1 Message Date
Fabio Utzig 2036263616 Update mynewt-core repo name
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-08-03 15:31:39 -07:00
Fabio Utzig 0f29c48e8d Initialize watchdog when running on Mynewt
On Mynewt some flash drivers on very slow devices tickle the watchdog to
avoid possible hangs; those were also trying to tickle the watchdog in
mcuboot when performing an upgrade or serial boot, without initializing
the watchdog, causing an invalid memory write and reset issue.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-07-30 08:33:00 -03:00
Carles Cufi 6400f0bf97 zephyr: serial_adapter: Cleanup queue variables
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>
2018-07-18 07:03:45 -03:00
Carles Cufi b124e39f79 zephyr: serial_adapter: Fix allocation of buffers
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>
2018-07-18 07:03:45 -03:00
Mark Schulte b88b2c4544 docs: (imgtool) explain --pad-header + hex file
Add an explanation for what happens when using the "--pad-header" flag
with a hex file.

Signed-off-by: Mark Schulte <mschulte@lyft.com>
2018-07-17 12:04:17 -03:00
Mark Schulte 884be206f9 imgtool: Adjust base_addr when injecting header
If adding a header to a .hex file (using the command line
"--pad-header"), the hex file gets shifted by header size. This may
cause hard coded addresses to be off by "header-size", making the
firmware unusable. Instead, adjust the base address by the header
size, so the existing firmware in the hex file is loaded to the
proper addresses.

Signed-off-by: Mark Schulte <mschulte@lyft.com>
2018-07-17 12:04:17 -03:00
Evan Gates 0ccee8741d fix the offset and size regular expressions in assemble.py
Given the example lines:

 #define FLASH_AREA_MCUBOOT_OFFSET_0 0x0
 #define FLASH_AREA_MCUBOOT_OFFSET   FLASH_AREA_MCUBOOT_OFFSET_0

Changing OFFSET_0 to OFFSET(_0)? allows the re to possibly match the
second line where it would have stopped the match before. This combined
with the (0x)? means that the re does match the second line, with the
third group being just the F of FLASH_AREA_IMAGE_1_OFFSET_0. The int()
function fails because F is not a valid number. This commit makes the
matching more precise by 1) matching the 0x when there are hex digits
and without the 0x when there are decimal digits and 2) matching until
the end of the line.

Signed-off-by: Evan Gates <evan@gnarbox.com>
2018-07-10 11:11:52 -03:00
Fabio Utzig c354e4ac5e Update sim dependencies
This updates error-chain to remove a warning on recent rust distros.
`pem` was update to get fairly recent `error-chain` as well.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-07-10 11:11:29 -03:00
Fabio Utzig ffffbaded0 Fix multi-line script call
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-07-10 09:51:06 -03:00
Szymon Janc c48e7f917e boot_serial: Fix build on Zephyr with ECDSA enabled
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2018-07-03 17:46:33 +02:00
Szymon Janc c1693d66bf Add Eclipse project files to gitignore
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2018-07-03 12:11:47 -03:00
Evan Gates 4632d8de5f include soc.h in main.c
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>
2018-06-29 11:18:18 -03:00
Fabio Utzig b97ec0fee8 Bump to version 1.2.0
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-26 13:24:41 -03:00
Fabio Utzig 3c93901a71 Update with 1.2.0 release notes
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-26 13:15:48 -03:00
Fabio Utzig 3b69d6f845 Deinit timer after serial load is finished
This fixes an issue where the bootloader is activating a timer that is
later not used by the installed target image causing a non handled interrupt
fault.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-26 09:12:43 -03:00
Fabio Utzig 5901fd55f5 Update imgtool documentation
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-22 07:58:14 -03:00
Fabio Utzig 44588eff41 Update `--included-header` parameter
The `--included-header` was "mandatory" when using imgtool with firmware
images generated by the Zephyr build system and it was a source of
issues when it was forgotten. This removes `--included-header` and adds
a new parameter `--pad-header` with inverted semantics, to be used only
when a zeroed header is required to be added to the firmware image.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-22 07:58:14 -03:00
Andrzej Puzdrowski 3011714194 zephyr: serial_adapter: preserve buffer list against lock
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>
2018-06-20 16:08:58 +02:00
Andrzej Puzdrowski ec1e4d1bef boot_serial: preserve against buffer overflow for zephyr
For zephyr it was possible to make buffer overflow while decoding
incoming base64 sting. This patch correct the available
buffer size transferred to base64 decoding function, which mitigate the
issue.

Clean up boot_serial_start function from unwanted
execution constant pointers.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Carles Cufi 5e48c55df9 zephyr: Enable interrupts unconditionally
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>
2018-06-20 16:08:58 +02:00
Carles Cufi 5ceeddb413 zephyr: Use sys_slist instead of k_fifo in serial adapter
The k_fifo_* primitives are not available when multithreading is
disabled. Use sys_slist_* instead.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Carles Cufi df4d9a4de1 zephyr: Disable power management
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>
2018-06-20 16:08:58 +02:00
Carles Cufi e2a361256e zephyr: Fix assert booleanness
Fix the __ASSERT() statement so it actually checks for success and not
for failure.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Marko Kiiskila 8b1ce3a6ce boot_serial; re-enable mynewt boot_serial unittests.
Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-18 13:13:41 -07:00
Marko Kiiskila c427af2e7e zephyr/serial_adapter; no need to inject \r on \n anymore.
boot_serial; syscfg tabs to spaces.

Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-14 23:19:06 +03:00
Marko Kiiskila 149b457a22 boot_serial; improve platform abstraction.
Pass function pointers to do reads/writes from uart.

Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-14 23:19:06 +03:00
Marko Kiiskila c0011585be boot_serial; fix mynewt unit test.
Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-14 23:19:06 +03:00
Marko Kiiskila ce50ab0648 boot_serial; text size reduction.
- Remove dependency to sprintf()
 - Remove dependency to cborattr
 - mynewt: replace console with more direct interface to uart
 - mynewt: settings to reduce included os code

Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-14 23:19:06 +03:00
Marko Kiiskila 316d361fb3 mynewt app; support additional options to enter serial dfu.
Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-14 23:19:06 +03:00
Andrzej Puzdrowski 82d7395b69 Fix assertions in zephyr main file
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>
2018-06-13 21:46:47 +02:00
Fabio Utzig dcf0c9b2b7 Allow passing in `--overwrite-only` flag
Overwrite only requires just magic + image_ok + copy_done. This fixes
issues generating images in overwrite only mode when the firmware image
is too big and overflows the swap status area.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-13 10:42:40 -07:00
Fabio Utzig 03dc9a09a3 Avoid touching the swap status area in overwrite-only
The swap status area is used to maintain information that allows
recovery when interrupted in the middle of a swap. This area has no
usefulness when doing a overwrite-only upgrade, which always copies the
entire slot.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-13 10:42:40 -07:00
Carles Cufi 29af9feeb7 zephyr: Default to RSA .pem file in config fragment
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>
2018-06-12 17:36:54 +02:00
Ding Tao f97cb7143d zephyr: cmake: Fix a typo in file CMakeLists.txt
Replace "bur" with "but".

Signed-off-by: Ding Tao <miyatsu@qq.com>
2018-06-08 12:11:57 -03:00
Fabio Utzig 263d4398fa Add --slot-size to allow size checking without pad
Add the new `--slot-size` and make `--pad` a bool flag, to allow
checking that firmware fits in the slot without overflowing into the
trailer region even when no padding was requested.

Fixes #241

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-07 14:29:33 -03:00
Fabio Utzig 806af0ed87 Update old hardcoded keys to use autogenerated
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>
2018-06-06 11:07:06 -03:00
Fabio Utzig b1e0dc5a03 Add auto generation of keys to cmake
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-06 11:07:06 -03:00
Fabio Utzig c690c76120 Add public/private key file option to Kconfig
Also adds instrutions and defaults to prj.conf.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-06 11:07:06 -03:00
Carles Cufi 69c61d0e91 zephyr: Properly use the same mbedTLS header macros
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>
2018-06-05 19:16:42 +02:00
Fabio Utzig 519285faa1 Allow passing max sectors as parameter to imgtool
This adds a new command line flag to allow passing in the max number of
sectors for a swap when the image is padded. It defaults to 128 and
should match the value configured in the bootloader.

Fixes #285

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-05 12:16:45 -03:00
Fabio Utzig 51c112a1bf Add click handling of cli options
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-05 10:58:01 -03:00
Fabio Utzig 48841f28ce Remove per file log level configs
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>
2018-06-04 06:54:39 -03:00
Fabio Utzig 94912c518f Enable serial only when required for Mynewt
For Mynewt when no logging (default option) or serial boot was selected,
avoid initializing all serial supporting system. This enables to save
flash space when only basic bootloader functionality is used.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-04 06:54:39 -03:00
Fabio Utzig a8e4e9714f Update logging to use per platform log macros
Now bootutil_log.h was converted to use per platform logging primitives
defined according to documentation established on the template file.

Some "null" macros were left to avoid breaking per source logging level
definition when MCUBOOT_HAVE_LOGGING was not defined.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-04 06:54:39 -03:00
Fabio Utzig 9a4b9ba1c0 Add per platform mcuboot_logging.h files
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>
2018-06-04 06:54:39 -03:00
Fabio Utzig 7d81786a14 Add template docs for MCUBOOT_HAVE_LOGGING
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-04 06:54:39 -03:00
Kiril Zyapkov 5d5c446443 Fix regexp matchers for FLASH_AREA_* defines
Zephyr has changed the format of macros used to define flash
area partitions -- they no longer contain the `_0` suffix.

Signed-off-by: Kiril Zyapkov <kiril.zyapkov@gmail.com>
2018-06-01 13:40:23 -03:00
David Brown 34fe103d04 sim: Add missing license headers
These (currently) trivial files do not add license headers.  Go ahead
and add the boilerplate Apache header.

In addition, I've also added an SPDX header.  Although this is a first
for the MCUboot project, this will provide a template for adding these
headers to other files.

Fixes #282

Signed-off-by: David Brown <david.brown@linaro.org>
CC: Marti Bolivar <marti@opensourcefoundries.com>
CC: Fabio Utzig <utzig@apache.org>
2018-05-23 09:29:25 -06:00
Andrzej Puzdrowski 9754328ac4 Reorganize zephyr kconfig
This patch isolates mcuboot settings under `MCUBoot`
menu in menuconfig view. This improves legibility.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-05-16 16:05:17 -03:00
Andrzej Puzdrowski b788c71c08 Replace mcuboot flash_map by zephyr flash_map
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>
2018-05-16 16:05:17 -03:00