Commit graph

31 commits

Author SHA1 Message Date
Krzysztof Chruscinski
041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Yong Cong Sin
ae587f8e50 subsys/mgmt/hawkbit: format for readability
Formatted the code so that it is easier to read.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-07 11:52:10 +02:00
Fabio Baltieri
e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Gerard Marull-Paretas
5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Yong Cong Sin
313c49ec21 subsys/mgmt/hawkbit: Check the hash of stored firmware
Previously, the hash of the firmware is checked while we are
downloading the firmware. This isn't ideal as the validity of
the firmware written into the flash is not verified and can be
corrupted. Furthermore, checking while downloading will have an
negative impact to the download speed as the CPU need to do
more work during the data transfer.

This PR removes the previous verify-hash-while-download
implementation and use the flash_img_check API instead.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-31 10:28:22 +02:00
Yong Cong Sin
77d829e31e subsys/mgmt/hawkbit: Improve hawkbit_probe readability
After the firmware is downloaded in hawkbit_probe, a series of
operations are done by using the fact that the conditions of
an if-else statement will be ran until a match.

This patches separate these condition into individual
if-condition for better readability

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-31 10:28:22 +02:00
Yong Cong Sin
d2f7d696aa subsys/mgmt/hawkbit: update http response handling
Following the merge of #42026, the http body handling can be
simplified.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-16 10:25:38 +01:00
Yong Cong Sin
49c2d8a635 net: http: Rename body_start to body_frag_start
Following #42026, the body_start pointer now points to the
start of the body fragment in the recv_buffer as long as there
is body in it, either entirely or partially.

Rename the body_start to body_frag_start to better reflect
what it represents.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-03-15 10:05:21 +01:00
Gerard Marull-Paretas
252053f4fe mgmt: hawkbit: nvs: use nvs_mount
Replace deprecated nvs_init() with nvs_mount().

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-01 12:46:34 +01:00
Yong Cong Sin
54490e8fe3 subsys/mgmt/hawkbit: Check retval of mbedtls_md_update
Check the return value of mbedtls_md_update and break on error.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
5cee596c9b subsys/mgmt/hawkbit: Cleanup connection if error after http_request
All errors that occured after http_request should clean up the
connection.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
22b5a03321 subsys/mgmt/hawkbit: Break and return if error
There's no need to continue if there's an error, so just break and
return.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
dfb55e5353 subsys/mgmt/hawkbit: Warning if image is unconfirmed
Add a warning if the image is unconfirmed. Add a delay before rebooting
so that the user knows what happened.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
8363e805c0 subsys/mgmt/hawkbit: Handle multipacket response properly
The current HAWKBIT_PROBE & HAWKBIT_PROBE_DEPLOYMENT_BASE response
handlers aren't able to handle multipacket response from Hawkbit
server. This commit fixes it by using the implementation from
HAWKBIT_DOWNLOAD.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Signed-off-by: Joep Buruma <burumaj50@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
793c0340d4 subsys/mgmt/hawkbit: Implement DDI API authentication
Implement Hawkbit DDI API authentication for the client.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
8ffb5e2ff2 subsys/mgmt/hawkbit: Use log_strdup for string pointers
Use log_strdup for string pointers.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
6e8b1d7c29 subsys/mgmt/hawkbit: Clean up log and print error codes
Clean up log messages and print error codes wherever possible.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-14 12:28:40 -04:00
Yong Cong Sin
d156fa754e subsys/mgmt/hawkbit: Compute & compare image hash
Compute the SHA256 hash of the downloaded image and compare that with
the hash in the deploymentBase to guarantee that only the correctly
downloaded image will be flashed.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
eaa29d9d71 subsys/mgmt/hawkbit: Prevent multiple instances of hawkbit_probe
Use a semaphore to prevent the hawkbit_probe from running more than once
at the same time since it reset the hawkbit context on entry and will
affect other running instance.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
17dd9f4928 subsys/mgmt/hawkbit: Check if the download completed
Remove the unused semaphore and use a boolean variable to check if the
download is complete.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
73668323cf subsys/mgmt/hawkbit: Use dts for "storage" partition
Use devicetree for the "storage" partition.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
7c8de26f45 samples/subsys/mgmt/hawkbit: Remove unused definition
Remove unused NETWORK_TIMEOUT definition.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
1409b90c90 subsys/mgmt/hawkbit: Fix typos
Fix multiple typos and make the sample's log output consistent
with the subsys.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Co-Authored-By: Sylvio Alves <sylviojalves@gmail.com>
2021-08-18 20:10:21 -04:00
Yong Cong Sin
a5f49ac943 subsys/mgmt/hawkbit: Add missing CONFIG_HAWKBIT_LOG_LEVEL
Add missing CONFIG_HAWKBIT_LOG_LEVEL so that its verbosity can be
configured.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00
Joep Buruma
6f6e5dfde0 mgmt: hawkbit: fix codestyle and whitespaces
Fix compliance code check

Signed-off-by: Joep Buruma <burumaj50@gmail.com>
2021-07-28 07:32:46 -04:00
Joep Buruma
e45c07cd60 mgmt: hawkbit: Fix case where body_data not set correctly
When downloading large files from the hawkbit server
 the only time rsp->body_start is checked is on the
first call. After this it is never checked again.

This caused the wrong data to be written to flash
and a failed update.

Signed-off-by: Joep Buruma <burumaj50@gmail.com>
2021-07-28 07:32:46 -04:00
Gerard Marull-Paretas
f163bdb280 power: move reboot functionality to os lib
Reboot functionality has nothing to do with PM, so move it out to the
subsys/os folder.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 20:34:00 -04:00
Navin Sankar Velliangiri
62149516c4 mgmt: hawkbit: Conversion of k_work API
Implement new workqueue API changes.

Signed-off-by: Navin Sankar Velliangiri <navin@linumiz.com>
2021-04-27 13:29:39 -04:00
NavinSankar Velliangiri
dd8f135e2c mgmt: hawkbit: Fix NULL pointer dereferences
Coverity spots that null pointer is passing to flash_img_buffered_write.
This patch fixes the problem.

Signed-off-by: NavinSankar Velliangiri <navin@linumiz.com>
2020-09-16 13:51:55 -05:00
Flavio Ceolin
e28d3404eb mgmt: hawkbit: Fix resources leakage
Coverity spots that memory allocated for addr was leaking, but the
code was also leaking the socket file descriptor in the error path.
This patch fixes both problems.

Fixes #28172

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-16 12:05:21 +02:00
NavinSankar Velliangiri
ddd6a650e2 mgmt: hawkbit: Add Hawkbit FOTA Support
Add Hawkbit FOTA support

Signed-off-by: NavinSankar Velliangiri <navin@linumiz.com>
2020-09-03 22:13:52 +02:00