Commit graph

36 commits

Author SHA1 Message Date
Gerson Fernando Budke 3add3d7b60 lib: updatehub: Add download block check
The current CoAP implementation not perform any checks including
duplicated packets. This add block sequency verification and a
timer to ensures that slow networks works apropriately.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-06-23 19:22:31 +02:00
Gerson Fernando Budke 092b962350 lib: updatehub: Kconfig: Add coap block size option
Allow select max CoAP block size for exchange data using coap protocol.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-06-23 19:22:31 +02:00
Gerson Fernando Budke 6c4c12d531 lib: updatehub: Kconfig: Add coap max retry option
The current implementation uses a fixed value for max retries. That
value could be good for an wired network like Ethernet. However,
wireless network can suffer with higher packet collision, low reception
signal etc. This refacts the variable to be defined at Kconfig. This
way max retries can be adjust conform the current media.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-06-23 19:22:31 +02:00
Gerson Fernando Budke a7c63d8818 lib: updatehub: Init metadata variable
Init metadata variable to a defined state.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-06-23 19:22:31 +02:00
Gerson Fernando Budke d16517e575 lib: updatehub: Init hints variable
The hints variable is used without a defined state. This fill the struct
with zeros to set variable at a well known state.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-06-23 19:22:31 +02:00
Gerson Fernando Budke 9a43250667 lib: updatehub: Add log level
Current log only prints default log level. Add LOG_LEVEL at updatehub
to switch between log variations based on CONFIG_UPDATEHUB_LOG_LEVEL.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-06-23 19:22:31 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Tahir Akram ba88c99677 lib: updatehub: Fix bus fault
Fix variable-size string copy patch that introduced a runtime bug that
causes a bus fault.

Fixes #24853.

Signed-off-by: Tahir Akram <mtahirbutt@hotmail.com>
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-05-26 14:37:54 +02:00
Gerson Fernando Budke 284e841bf4 lib: updatehub: Fix compile warning
Based on the current platform a warning can raise becase of missing
string.h include file.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-05-18 11:12:31 +02:00
Gerson Fernando Budke c35cad52f5 lib: updatehub: Add missing include for FLASH_AREA
The conversion from DT_FLASH_AREA to FLASH_AREA macros don't add the
storage flash_map.h include file.

Fixes: #25332

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-05-18 11:12:31 +02:00
Kumar Gala ff579a3af3 flash: Convert DT_FLASH_AREA to FLASH_AREA macros
Convert with a combo of scripts and by hand fixups:

git grep -l DT_FLASH_AREA_.*_ID | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_ID/FLASH_AREA_ID(\L\1)/'

git grep -l DT_FLASH_AREA_.*_OFFSET | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_OFFSET/FLASH_AREA_OFFSET(\L\1)/'

git grep -l DT_FLASH_AREA_.*_SIZE | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_SIZE/FLASH_AREA_SIZE(\L\1)/'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-13 21:22:53 +02:00
Gerson Fernando Budke 4980a13fc4 lib: updatehub: Update to new timeout api
Update to new timeout api. Without this change UpdateHub don't build
anymore.

Fixes: #25230

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-05-12 20:17:38 +02:00
David Brown 69e8a7b657 updatehub: Require peer verification with DTLS
DTLS without peer verification offers no security whatsoever (and is
arguably worse than not using DTLS in the first place).

Change the verification option to require this peer verification.  To
use this, it may be necessary to install and use a root certificate.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-05-05 13:40:12 -05:00
Gerson Fernando Budke 894dcbbf15 lib: updatehub: Improve probe security
Improve buffer overflow security on probe_cb. This ensures that socket
buffer have fixed lenght and content received by COAP fills properly on
metadata buffer. After that, ensures that metadata content is a valid
string with length lower than metadata size.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-04-17 10:09:56 +03:00
Gerson Fernando Budke 6238e52062 lib: updatehub: Refact to use bin2hex
Use bin2hex instead inline conversion.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-04-17 10:09:56 +03:00
Gerson Fernando Budke 0801aef3fb lib: updatehub: Fix variable-size string copy
A malformed JSON payload that is received from an UpdateHub server
may trigger memory corruption in the Zephyr OS. This could result
in a denial of service in the best case, or code execution in the
worst case.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-04-17 10:09:56 +03:00
Gerson Fernando Budke d1e2d345fb lib: updatehub: Add missing do upgrade request call
After a success image download, UpdateHub needs inform MCUboot that
must test new image and then, on success, commit this new image. This
add missing upgrade request call step and fixes the upgarde flow.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2020-03-30 16:54:29 +03:00
Gerson Fernando Budke 1128eab3f2 lib: updatehub: Fix download block error
The current version aborts update when found last transfer block. Now,
system checks only at end of coap block transfer total size and install
if download is ok.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2020-03-30 16:54:29 +03:00
Gerson Fernando Budke 1fe1b0eec6 lib: updatehub: Extract sha256 final method
Extract finish sha256 calc method.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2020-03-30 16:54:29 +03:00
Gerson Fernando Budke 5f5919a900 lib: updatehub: Fix buffer sizes
The MAX_PAYLOAD_SIZE must reflect the size of COAP_BLOCK_x. This is
necessary becase BLOCK size represents max payload size. The current
value create inconsistencies for coap lib. The same way,
MAX_DOWNLOAD_DATA must allocate sufficient space for MAX_PAYLOAD_SIZE
plus all space for coap header etc.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2020-03-30 16:54:29 +03:00
Gerson Fernando Budke 92f9cd9f85 lib: updatehub: Fix build warnings
Fix all build warnings.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2020-03-30 16:54:29 +03:00
Robert Lubos 665d195f3a net: sockets: tls: Add missing symbols for a few options
`TLS_PEER_VERIFY` and `TLS_DTLS_ROLE` options accept specific values,
yet no symbols were defined for them. In result, magic numbers were used
in several places, making the code less readable.

Fix this issue, by adding the missing symbols to the `socket.h` header,
and using them in places where related socket options are set.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-20 09:58:23 +02:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Jan Van Winkel 9555f82d28 libc: Use select REQUIRES_FULL_LIBC instead of select NEWLIB_LIBC
Changed select NEWLIB_LIBC to select REQUIRES_FULL_LIBC

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-01 14:18:36 +01:00
Anas Nashif 8d22fd9263 updatehub: move header to library
Not a top-level zephyr core API and tied to third party environment, so
move it to where the code is in lib/updatehub.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-25 18:20:20 -04:00
Peter Bigot 66c8756956 coccinelle: standardize kernel API timeout arguments
Re-run with updated script to detect missed cases.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-04 16:23:57 -04:00
Anas Nashif 5b0aa794b2 cleanup: include/: move misc/reboot.h to power/reboot.h
move misc/reboot.h to power/reboot.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif f901e26de9 cleanup: include/: move hwinfo.h to drivers/hwinfo.h
move hwinfo.h to drivers/hwinfo.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif fe051a9055 cleanup: include/: move flash.h to drivers/flash.h
move flash.h to drivers/flash.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 0abdacf3a4 cleanup: include/: move json.h to data/json.h
move json.h to data/json.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
David B. Kinder 2aebc980e2 doc: fix Kconfig misspellings
Fix misspellings in Kconfig files missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-06-18 15:07:52 -04:00
Christian Tavares 543de09357 lib: updatehub: add support ipv6
This extends the UpdateHub library code to allow the
use of IPV6 for communication.

Signed-off-by: Christian Tavares <christian.tavares@ossystems.com.br>
2019-06-05 00:20:37 +02:00
Christian Tavares c5d74eccda lib: updatehub: add suport a CoAPS/DTLS
This extends the UpdateHub library code to allow the
use of CoAPS/DTLS for communication.

Refs: #13039.

Signed-off-by: Christian Tavares <christian.tavares@ossystems.com.br>
2019-06-05 00:20:37 +02:00
Christian Tavares 297ac3765f lib: updatehub: Add UpdateHub.io support
UpdateHub is an enterprise-grade solution which makes simple to
remotely update all your embedded devices in the field. It
handles all aspects related to sending Firmware Over-the-Air(FOTA)
updates with maximum security and efficiency, while you focus in
adding value to your product.

Signed-off-by: Christian Tavares <christian.tavares@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2019-06-05 00:20:37 +02:00