Skip to content

Commit 0048e5f

Browse files
New modular OTA structure (#101)
* components: Remove ota_for_aws_iot_embedded_sdk Remove the ota_for_aws_iot_embedded_sdk component, as we will be replacing it with the new modular OTA. Signed-off-by: Chuyue Luo <[email protected]> * applications: Add C Runtime Helpers Add a crt-helpers/ directory within applicatons/helpers. Within this directory, add a custom implementation of `strnlen` (based on TF-M's `tfm_strnlen` implementation). This is required because the Arm Compiler for Embedded (v6.21) does not support `strnlen`. Signed-off-by: Chuyue Luo <[email protected]> * components: Add Jobs-for-AWS-IoT-embedded-sdk component Add the Jobs-for-AWS-IoT-embedded-sdk repository as a submodule. This library is used to interact with AWS IoT Jobs (remote operations that are sent to and executed on devices connected to AWS IoT). It is one of the two libraries that must be integrated to allow the new modular OTA to be used - second library (aws-iot-core-mqtt-file-streams-embedded-c) is integrated in a later commit. In addition, the required integration CMake files to build the component are added. Signed-off-by: Chuyue Luo <[email protected]> * components: Add patches for Jobs-for-AWS-IoT-embedded-sdk library Two patches are added for the Jobs-for-AWS-IoT-embedded-sdk library: - The Jobs library assumes the OTA job is signed using ECDSA. However, we currently use RSA. Therefore, add a patch to change the check for an ECDSA signature to a check for an RSA signature. - The Jobs library contains calls to the `strnlen` function. However, this function is not supported by the Arm Compiler for Embedded (v6.21). Therefore, add a patch which replaces these calls with calls to our custom implementation `app_strnlen`. Signed-off-by: Chuyue Luo <[email protected]> * components: Add aws-iot-core-mqtt-file-streams-embedded-c component Add the aws-iot-core-mqtt-file-streams-embedded-c repository as a submodule. This library allows files from a stream (an abstraction for a list of files) to be transferred to an IoT device. It is the second of the two libraries that must be integrated to allow the new modular OTA to be used. In addition, the required integration CMake files to build the component are added. Signed-off-by: Chuyue Luo <[email protected]> * components: Add patch for MQTT File Streams library The aws-iot-core-mqtt-file-streams-embedded-c library uses the `strnlen` function, which is not supported by the Arm Compiler for Embedded (v6.21). Therefore, add a patch which replaces the call to `strnlen` with a call to our custom implementation `app_strnlen`. Signed-off-by: Chuyue Luo <[email protected]> * applications: Add MQTT File Downloader config for keyword detection THe MQTT File Streams library allows a MQTTFileDownloader_config.h file to be provided, which defines custom values for build configuration macros. This commit adds a MQTTFileDownloader_config.h file for the keyword detection example. This file defines the block size that should be used when downloading the firmware image. Signed-off-by: Chuyue Luo <[email protected]> * components: Add patch for FreeRTOS OTA PAL PSA Add a patch for FreeRTOS OTA PAL PSA to allow it to work with the new modular OTA structure. This patch does the following: - Update header includes to remove headers from the old ota-for-aws-iot-embedded-sdk library, replace these with headers from the new Jobs-for-AWS-IoT-embedded-sdk library - Remove usage of data structures from ota-for-aws-iot-embedded-sdk library, replace these with data structures from Jobs-for-AWS-IoT-embedded-sdk library. Signed-off-by: Chuyue Luo <[email protected]> * ota: Add OTA orchestrator Add an OTA orchestrator as a helper within the applications/ directory. The OTA orchestrator uses functionality from the Jobs and MQTT File Streaming libraries to enable OTA updates. In addition, update the keyword detection CMakeLists.txt to allow this example to use the new modular OTA. Signed-off-by: Chuyue Luo <[email protected]> * applications: New modular OTA for speech recognition example Update speech recognition CMakeLists.txt and add MQTTFileDownloader_config.h file to allow this example to use the new modular OTA. Signed-off-by: Chuyue Luo <[email protected]> * applications: New modular OTA for object detection example Update object detection CMakeLists.txt and add MQTTFileDownloader_config.h file to allow this example to use the new modular OTA. Signed-off-by: Chuyue Luo <[email protected]> * applications: New modular OTA for FreeRTOS IoT Libraries Tests Update FreeRTOS IoT Libraries Tests CMakeLists.txt and add MQTTFileDownloader_config.h file to allow the tests to use the new modular OTA. Signed-off-by: Chuyue Luo <[email protected]> --------- Signed-off-by: Chuyue Luo <[email protected]>
1 parent 3780112 commit 0048e5f

File tree

65 files changed

+3424
-3353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3424
-3353
lines changed

.github/.cSpellWords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ coef
3939
compatibil
4040
coremqtt
4141
COSE
42+
coverity
4243
CLRF
4344
Cqqpk
4445
CSRS
@@ -147,6 +148,7 @@ Merkle
147148
Mfcc
148149
MFCC
149150
MFLN
151+
MISRA
150152
mlek
151153
mqtt
152154
mqttconfig

.gitmodules

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343
[submodule "open_iot_sdk_toolchain"]
4444
path = components/tools/open_iot_sdk_toolchain/library
4545
url = https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git
46-
[submodule "ota_for_aws_iot_embedded_sdk"]
47-
path = components/aws_iot/ota_for_aws_iot_embedded_sdk/library
48-
url = https://github.com/aws/ota-for-aws-iot-embedded-sdk.git
4946
[submodule "tinycbor"]
5047
path = components/aws_iot/tinycbor/library
5148
url = https://github.com/intel/tinycbor.git
@@ -76,3 +73,9 @@
7673
[submodule "googletest"]
7774
path = components/tools/googletest/library
7875
url = https://github.com/google/googletest.git
76+
[submodule "components/aws_iot/jobs_for_aws_iot_embedded_sdk/library"]
77+
path = components/aws_iot/jobs_for_aws_iot_embedded_sdk/library
78+
url = https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk.git
79+
[submodule "components/aws_iot/aws_iot_core_mqtt_file_streams_embedded_c/library"]
80+
path = components/aws_iot/aws_iot_core_mqtt_file_streams_embedded_c/library
81+
url = https://github.com/aws/aws-iot-core-mqtt-file-streams-embedded-c/

applications/freertos_iot_libraries_tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
108108
freertos-ota-pal-psa
109109
fri-bsp
110110
helpers-events
111-
ota-for-aws-iot-embedded-sdk
111+
ota-update
112112
provisioning-lib
113113
mbedtls
114114
tfm-ns-interface

applications/freertos_iot_libraries_tests/configs/aws_configs/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,3 @@ target_include_directories(freertos-pkcs11-psa-config
3131
INTERFACE
3232
.
3333
)
34-
35-
target_include_directories(ota-for-aws-iot-embedded-sdk-config
36-
INTERFACE
37-
.
38-
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright Amazon.com, Inc. and its affiliates. All Rights Reserved.
3+
* Copyright 2024 Arm Limited and/or its affiliates
4+
5+
*
6+
* SPDX-License-Identifier: MIT
7+
* Licensed under the MIT License. See the LICENSE accompanying this file
8+
* for the specific language governing permissions and limitations under
9+
* the License.
10+
*/
11+
12+
/**
13+
* @file MQTTFileDownloader_config.h
14+
* @brief MQTT File Streams options.
15+
*/
16+
17+
#ifndef MQTT_FILE_DOWNLOADER_CONFIG_H
18+
#define MQTT_FILE_DOWNLOADER_CONFIG_H
19+
20+
/* Standard includes */
21+
#include <stdint.h>
22+
23+
/**
24+
* @ingroup mqtt_file_downloader_const_types
25+
* @brief Configure the Maximum size of the data payload. The
26+
* smallest value is 256 bytes, maximum is 128KB. For more see
27+
* https://docs.aws.amazon.com/general/latest/gr/iot-core.html
28+
*/
29+
#define mqttFileDownloader_CONFIG_BLOCK_SIZE 4096U
30+
31+
#endif /* MQTT_FILE_DOWNLOADER_CONFIG_H */

applications/helpers/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
33
# SPDX-License-Identifier: MIT
44

5+
add_subdirectory(crt_helpers)
56
add_subdirectory(device_advisor)
67
add_subdirectory(events)
78
add_subdirectory(hdlcd)
89
add_subdirectory(logging)
10+
add_subdirectory(ota_orchestrator)
911
add_subdirectory(provisioning)
1012
# sntp helper library depends on FreeRTOS-Plus-TCP connectivity stack as it
1113
# includes `FreeRTOS_IP.h` header file in one of its source files (sntp_client_task.c),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2024 Arm Limited and/or its affiliates
2+
3+
# SPDX-License-Identifier: MIT
4+
5+
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
6+
# Left empty for future mocks.
7+
else()
8+
add_library(crt-helpers)
9+
10+
target_include_directories(crt-helpers
11+
PUBLIC
12+
inc/)
13+
14+
target_sources(crt-helpers
15+
PUBLIC
16+
src/app_strnlen.c
17+
)
18+
endif()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2021-2024, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef APP_STRNLEN_H
9+
10+
#include <stddef.h>
11+
12+
/**
13+
* @brief Determine the length of a fixed-size string, excluding the terminating
14+
* null byte ('\0'), and at most `maxlen`.
15+
*
16+
* @param[in] s The string to determine the length of.
17+
* @param[in] maxlen The maximum number of characters of the string `s` that
18+
* should be checked.
19+
*
20+
* @return The length of the string, up to `maxlen`.
21+
*/
22+
size_t app_strnlen( const char * s,
23+
size_t maxlen );
24+
25+
#endif
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2021-2024, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
/*
9+
* This file is based on
10+
* https://git.trustedfirmware.org/plugins/gitiles/TF-M/trusted-firmware-m.git/+/c9352b59f2a501b5af3f648b3fc91065993c002f/secure_fw/partitions/lib/runtime/crt_strnlen.c
11+
*/
12+
13+
#include <stddef.h>
14+
15+
size_t app_strnlen( const char * s,
16+
size_t maxlen )
17+
{
18+
size_t idx;
19+
20+
if( s == NULL )
21+
{
22+
return 0;
23+
}
24+
25+
for( idx = 0; idx < maxlen; idx++ )
26+
{
27+
if( s[ idx ] == '\0' )
28+
{
29+
return idx;
30+
}
31+
}
32+
33+
return idx;
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2024 Arm Limited and/or its affiliates
2+
3+
# SPDX-License-Identifier: MIT
4+
5+
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
6+
# Left empty for future mocks.
7+
else()
8+
add_library(ota-update
9+
src/mqtt_helpers.c
10+
src/ota_orchestrator_helpers.c
11+
src/ota_os_freertos.c
12+
src/ota_orchestrator.c
13+
)
14+
15+
target_include_directories(ota-update
16+
PUBLIC
17+
inc/
18+
)
19+
20+
target_link_libraries(ota-update
21+
jobs-for-aws-iot-embedded-sdk
22+
aws-iot-core-mqtt-file-streams-embedded-c
23+
freertos_kernel
24+
corejson
25+
coremqtt
26+
coremqtt-agent
27+
tinycbor
28+
freertos-ota-pal-psa
29+
helpers-events
30+
backoff-algorithm
31+
crt-helpers
32+
)
33+
endif()

0 commit comments

Comments
 (0)