diff --git a/.github/workflows/build_tests.sh b/.github/workflows/build_tests.sh index 5598291..c44d31e 100755 --- a/.github/workflows/build_tests.sh +++ b/.github/workflows/build_tests.sh @@ -28,20 +28,24 @@ cd tests mkdir build cd build +# Build weak use case +cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_PLATFORM_LOG_TYPE="generic/weak" -DCONFIG_MENDER_PLATFORM_NET_TYPE="generic/weak" -DCONFIG_MENDER_PLATFORM_OTA_TYPE="generic/weak" -DCONFIG_MENDER_PLATFORM_RTOS_TYPE="generic/weak" -DCONFIG_MENDER_PLATFORM_STORAGE_TYPE="generic/weak" -DCONFIG_MENDER_PLATFORM_TLS_TYPE="generic/weak" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=ON -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON +make -j$(nproc) + # Build ESP-IDF use case -cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_MCU_CLIENT_BOARD_TYPE="esp-idf" -DCONFIG_MENDER_MCU_CLIENT_NET_TYPE="esp-idf" -DCONFIG_MENDER_MCU_CLIENT_RTOS_TYPE="freertos" -DCONFIG_MENDER_MCU_CLIENT_TLS_TYPE="mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=ON -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON +cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_PLATFORM_LOG_TYPE="esp-idf" -DCONFIG_MENDER_PLATFORM_NET_TYPE="esp-idf" -DCONFIG_MENDER_PLATFORM_OTA_TYPE="esp-idf" -DCONFIG_MENDER_PLATFORM_RTOS_TYPE="freertos" -DCONFIG_MENDER_PLATFORM_STORAGE_TYPE="esp-idf/nvs" -DCONFIG_MENDER_PLATFORM_TLS_TYPE="generic/mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=ON -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON make -j$(nproc) -cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_MCU_CLIENT_BOARD_TYPE="esp-idf" -DCONFIG_MENDER_MCU_CLIENT_NET_TYPE="esp-idf" -DCONFIG_MENDER_MCU_CLIENT_RTOS_TYPE="freertos" -DCONFIG_MENDER_MCU_CLIENT_TLS_TYPE="mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=OFF -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON +cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_PLATFORM_LOG_TYPE="esp-idf" -DCONFIG_MENDER_PLATFORM_NET_TYPE="esp-idf" -DCONFIG_MENDER_PLATFORM_OTA_TYPE="esp-idf" -DCONFIG_MENDER_PLATFORM_RTOS_TYPE="freertos" -DCONFIG_MENDER_PLATFORM_STORAGE_TYPE="esp-idf/nvs" -DCONFIG_MENDER_PLATFORM_TLS_TYPE="generic/mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=OFF -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON make -j$(nproc) # Build Zephyr use case -cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_MCU_CLIENT_BOARD_TYPE="zephyr" -DCONFIG_MENDER_MCU_CLIENT_NET_TYPE="zephyr" -DCONFIG_MENDER_MCU_CLIENT_RTOS_TYPE="zephyr" -DCONFIG_MENDER_MCU_CLIENT_TLS_TYPE="mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=ON -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON +cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_PLATFORM_LOG_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_NET_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_OTA_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_RTOS_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_STORAGE_TYPE="zephyr/nvs" -DCONFIG_MENDER_PLATFORM_TLS_TYPE="generic/mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=ON -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON make -j$(nproc) -cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_MCU_CLIENT_BOARD_TYPE="zephyr" -DCONFIG_MENDER_MCU_CLIENT_NET_TYPE="zephyr" -DCONFIG_MENDER_MCU_CLIENT_RTOS_TYPE="zephyr" -DCONFIG_MENDER_MCU_CLIENT_TLS_TYPE="mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=OFF -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON +cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_PLATFORM_LOG_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_NET_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_OTA_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_RTOS_TYPE="zephyr" -DCONFIG_MENDER_PLATFORM_STORAGE_TYPE="zephyr/nvs" -DCONFIG_MENDER_PLATFORM_TLS_TYPE="generic/mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=OFF -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON make -j$(nproc) # Build Posix use case -cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_MCU_CLIENT_BOARD_TYPE="posix" -DCONFIG_MENDER_MCU_CLIENT_NET_TYPE="curl" -DCONFIG_MENDER_MCU_CLIENT_RTOS_TYPE="posix" -DCONFIG_MENDER_MCU_CLIENT_TLS_TYPE="mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=ON -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON +cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_PLATFORM_LOG_TYPE="posix" -DCONFIG_MENDER_PLATFORM_NET_TYPE="generic/curl" -DCONFIG_MENDER_PLATFORM_OTA_TYPE="posix" -DCONFIG_MENDER_PLATFORM_RTOS_TYPE="posix" -DCONFIG_MENDER_PLATFORM_STORAGE_TYPE="posix" -DCONFIG_MENDER_PLATFORM_TLS_TYPE="generic/mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=ON -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON make -j$(nproc) -cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_MCU_CLIENT_BOARD_TYPE="posix" -DCONFIG_MENDER_MCU_CLIENT_NET_TYPE="curl" -DCONFIG_MENDER_MCU_CLIENT_RTOS_TYPE="posix" -DCONFIG_MENDER_MCU_CLIENT_TLS_TYPE="mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=OFF -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON +cmake .. -G "Unix Makefiles" -DCONFIG_MENDER_PLATFORM_LOG_TYPE="posix" -DCONFIG_MENDER_PLATFORM_NET_TYPE="generic/curl" -DCONFIG_MENDER_PLATFORM_OTA_TYPE="posix" -DCONFIG_MENDER_PLATFORM_RTOS_TYPE="posix" -DCONFIG_MENDER_PLATFORM_STORAGE_TYPE="posix" -DCONFIG_MENDER_PLATFORM_TLS_TYPE="generic/mbedtls" -DCONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE=ON -DCONFIG_MENDER_CLIENT_CONFIGURE_STORAGE=OFF -DCONFIG_MENDER_CLIENT_ADD_ON_INVENTORY=ON -DCONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT=ON make -j$(nproc) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd9e13b..9dc713e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,19 +28,23 @@ cmake_minimum_required(VERSION 3.16.3) # List of sources file(GLOB SOURCES_TEMP "${CMAKE_CURRENT_LIST_DIR}/core/src/*.c" - "${CMAKE_CURRENT_LIST_DIR}/platform/board/${CONFIG_MENDER_MCU_CLIENT_BOARD_TYPE}/src/*.c" - "${CMAKE_CURRENT_LIST_DIR}/platform/net/${CONFIG_MENDER_MCU_CLIENT_NET_TYPE}/src/*.c" - "${CMAKE_CURRENT_LIST_DIR}/platform/rtos/${CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE}/src/*.c" - "${CMAKE_CURRENT_LIST_DIR}/platform/tls/${CONFIG_MENDER_MCU_CLIENT_TLS_TYPE}/src/*.c" + "${CMAKE_CURRENT_LIST_DIR}/platform/log/${CONFIG_MENDER_PLATFORM_LOG_TYPE}/src/*.c" + "${CMAKE_CURRENT_LIST_DIR}/platform/net/${CONFIG_MENDER_PLATFORM_NET_TYPE}/src/*.c" + "${CMAKE_CURRENT_LIST_DIR}/platform/ota/${CONFIG_MENDER_PLATFORM_OTA_TYPE}/src/*.c" + "${CMAKE_CURRENT_LIST_DIR}/platform/rtos/${CONFIG_MENDER_PLATFORM_RTOS_TYPE}/src/*.c" + "${CMAKE_CURRENT_LIST_DIR}/platform/storage/${CONFIG_MENDER_PLATFORM_STORAGE_TYPE}/src/*.c" + "${CMAKE_CURRENT_LIST_DIR}/platform/tls/${CONFIG_MENDER_PLATFORM_TLS_TYPE}/src/*.c" "${CMAKE_CURRENT_LIST_DIR}/add-ons/src/*.c" ) # Add include directories include_directories(${CMAKE_CURRENT_LIST_DIR}/include) -include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/board/${CONFIG_MENDER_MCU_CLIENT_BOARD_TYPE}/include) -include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/net/${CONFIG_MENDER_MCU_CLIENT_NET_TYPE}/include) -include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/rtos/${CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE}/include) -include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/tls/${CONFIG_MENDER_MCU_CLIENT_TLS_TYPE}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/log/${CONFIG_MENDER_PLATFORM_LOG_TYPE}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/net/${CONFIG_MENDER_PLATFORM_NET_TYPE}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/ota/${CONFIG_MENDER_PLATFORM_OTA_TYPE}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/rtos/${CONFIG_MENDER_PLATFORM_RTOS_TYPE}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/storage/${CONFIG_MENDER_PLATFORM_STORAGE_TYPE}/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/platform/tls/${CONFIG_MENDER_PLATFORM_TLS_TYPE}/include) # Define version file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/VERSION" MENDER_CLIENT_VERSION) diff --git a/esp-idf/CMakeLists.txt b/esp-idf/CMakeLists.txt index 39c8c07..4e5d9a9 100755 --- a/esp-idf/CMakeLists.txt +++ b/esp-idf/CMakeLists.txt @@ -29,12 +29,12 @@ list(APPEND srcs "${CMAKE_CURRENT_LIST_DIR}/../core/src/mender-artifact.c" "${CMAKE_CURRENT_LIST_DIR}/../core/src/mender-client.c" "${CMAKE_CURRENT_LIST_DIR}/../core/src/mender-utils.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/board/esp-idf/src/mender-log.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/board/esp-idf/src/mender-ota.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/board/esp-idf/src/mender-storage.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/net/esp-idf/src/mender-http.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/rtos/freertos/src/mender-rtos.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/tls/mbedtls/src/mender-tls.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/log/${CONFIG_MENDER_PLATFORM_LOG_TYPE}/src/mender-log.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/net/${CONFIG_MENDER_PLATFORM_NET_TYPE}/src/mender-http.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/ota/${CONFIG_MENDER_PLATFORM_OTA_TYPE}/src/mender-ota.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/rtos/${CONFIG_MENDER_PLATFORM_RTOS_TYPE}/src/mender-rtos.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/storage/${CONFIG_MENDER_PLATFORM_STORAGE_TYPE}/src/mender-storage.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/tls/${CONFIG_MENDER_PLATFORM_TLS_TYPE}/src/mender-tls.c" ) if(CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE) list(APPEND srcs @@ -49,7 +49,7 @@ endif() if(CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT) list(APPEND srcs "${CMAKE_CURRENT_LIST_DIR}/../add-ons/src/mender-troubleshoot.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/net/esp-idf/src/mender-websocket.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/net/${CONFIG_MENDER_PLATFORM_NET_TYPE}/src/mender-websocket.c" ) endif() diff --git a/esp-idf/Kconfig b/esp-idf/Kconfig index 0931a63..816779b 100755 --- a/esp-idf/Kconfig +++ b/esp-idf/Kconfig @@ -53,7 +53,7 @@ menu "Mender General Options" Setting this value to 0 permits to disable the periodic execution and relies on the application to do it. choice MENDER_LOG_LEVEL - bool "Mender client log verbosity" + prompt "Mender client log verbosity" default MENDER_LOG_LEVEL_INF help Specify how much output to see in Mender client logs. @@ -126,7 +126,7 @@ menu "Mender Addons Options" endif config MENDER_CLIENT_ADD_ON_TROUBLESHOOT - bool "Mender client Troubleshoot" + bool "Mender client Troubleshoot (EXPERIMENTAL)" default n help Troubleshoot add-on permits to perform debugging on the target from the Mender server. @@ -145,7 +145,113 @@ menu "Mender Addons Options" endmenu -menu "Mender Network Options" +menu "Mender Platform Options (ADVANCED)" + + choice MENDER_PLATFORM_LOG_TYPE + prompt "Mender platform log implementation type" + default MENDER_PLATFORM_LOG_TYPE_DEFAULT + help + Specify platform log implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_LOG_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_LOG_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_LOG_TYPE + string "Mender platform log implementation type" + default "esp-idf" if MENDER_PLATFORM_LOG_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_LOG_TYPE_WEAK + + choice MENDER_PLATFORM_NET_TYPE + prompt "Mender platform network implementation type" + default MENDER_PLATFORM_NET_TYPE_DEFAULT + help + Specify platform network implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_NET_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_NET_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_NET_TYPE + string "Mender platform network implementation type" + default "esp-idf" if MENDER_PLATFORM_NET_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_NET_TYPE_WEAK + + choice MENDER_PLATFORM_OTA_TYPE + prompt "Mender platform OTA implementation type" + default MENDER_PLATFORM_OTA_TYPE_DEFAULT + help + Specify platform OTA implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_OTA_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_OTA_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_OTA_TYPE + string "Mender platform OTA implementation type" + default "esp-idf" if MENDER_PLATFORM_OTA_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_OTA_TYPE_WEAK + + choice MENDER_PLATFORM_RTOS_TYPE + prompt "Mender platform RTOS implementation type" + default MENDER_PLATFORM_RTOS_TYPE_DEFAULT + help + Specify platform RTOS implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_RTOS_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_RTOS_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_RTOS_TYPE + string "Mender platform RTOS implementation type" + default "freertos" if MENDER_PLATFORM_RTOS_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_RTOS_TYPE_WEAK + + choice MENDER_PLATFORM_STORAGE_TYPE + prompt "Mender platform storage implementation type" + default MENDER_PLATFORM_STORAGE_TYPE_NVS + help + Specify platform storage implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_STORAGE_TYPE_NVS + bool "nvs" + config MENDER_PLATFORM_STORAGE_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_STORAGE_TYPE + string "Mender platform storage implementation type" + default "esp-idf/nvs" if MENDER_PLATFORM_STORAGE_TYPE_NVS + default "generic/weak" if MENDER_PLATFORM_STORAGE_TYPE_WEAK + + choice MENDER_PLATFORM_TLS_TYPE + prompt "Mender platform TLS implementation type" + default MENDER_PLATFORM_TLS_TYPE_MBEDTLS + help + Specify platform TLS implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_TLS_TYPE_MBEDTLS + bool "mbedtls" + config MENDER_PLATFORM_TLS_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_TLS_TYPE + string "Mender platform TLS implementation type" + default "generic/mbedtls" if MENDER_PLATFORM_TLS_TYPE_MBEDTLS + default "generic/weak" if MENDER_PLATFORM_TLS_TYPE_WEAK + +endmenu + +menu "Mender Network Options (ADVANCED)" if MENDER_CLIENT_ADD_ON_TROUBLESHOOT @@ -181,7 +287,7 @@ menu "Mender Network Options" endmenu -menu "Mender Scheduler Options" +menu "Mender RTOS Options (ADVANCED)" config MENDER_RTOS_WORK_QUEUE_STACK_SIZE int "Mender RTOS Work Queue Stack Size (kB)" diff --git a/include/mender-utils.h b/include/mender-utils.h old mode 100755 new mode 100644 index 9b0db08..4948232 --- a/include/mender-utils.h +++ b/include/mender-utils.h @@ -45,10 +45,11 @@ extern "C" { * @brief Mender error codes */ typedef enum { - MENDER_DONE = 1, /**< Done */ - MENDER_OK = 0, /**< OK */ - MENDER_FAIL = -1, /**< Failure */ - MENDER_NOT_FOUND = -2, /**< Not found */ + MENDER_DONE = 1, /**< Done */ + MENDER_OK = 0, /**< OK */ + MENDER_FAIL = -1, /**< Failure */ + MENDER_NOT_FOUND = -2, /**< Not found */ + MENDER_NOT_IMPLEMENTED = -3, /**< Not implemented */ } mender_err_t; /** diff --git a/platform/board/esp-idf/src/mender-log.c b/platform/log/esp-idf/src/mender-log.c similarity index 100% rename from platform/board/esp-idf/src/mender-log.c rename to platform/log/esp-idf/src/mender-log.c diff --git a/platform/log/generic/weak/src/mender-log.c b/platform/log/generic/weak/src/mender-log.c new file mode 100644 index 0000000..8bac7be --- /dev/null +++ b/platform/log/generic/weak/src/mender-log.c @@ -0,0 +1,55 @@ +/** + * @file mender-log.c + * @brief Mender logging interface for weak platform + * + * MIT License + * + * Copyright (c) 2022-2023 joelguittet and mender-mcu-client contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mender-log.h" + +__attribute__((weak)) mender_err_t +mender_log_init(void) { + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_log_print(uint8_t level, const char *filename, const char *function, int line, char *format, ...) { + + (void)level; + (void)filename; + (void)function; + (void)line; + (void)format; + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_log_exit(void) { + + /* Nothing to do */ + return MENDER_OK; +} diff --git a/platform/board/posix/src/mender-log.c b/platform/log/posix/src/mender-log.c similarity index 100% rename from platform/board/posix/src/mender-log.c rename to platform/log/posix/src/mender-log.c diff --git a/platform/board/zephyr/src/mender-log.c b/platform/log/zephyr/src/mender-log.c similarity index 100% rename from platform/board/zephyr/src/mender-log.c rename to platform/log/zephyr/src/mender-log.c diff --git a/platform/net/curl/src/mender-http.c b/platform/net/generic/curl/src/mender-http.c similarity index 100% rename from platform/net/curl/src/mender-http.c rename to platform/net/generic/curl/src/mender-http.c diff --git a/platform/net/curl/src/mender-websocket.c b/platform/net/generic/curl/src/mender-websocket.c similarity index 100% rename from platform/net/curl/src/mender-websocket.c rename to platform/net/generic/curl/src/mender-websocket.c diff --git a/platform/net/generic/weak/src/mender-http.c b/platform/net/generic/weak/src/mender-http.c new file mode 100644 index 0000000..d31809a --- /dev/null +++ b/platform/net/generic/weak/src/mender-http.c @@ -0,0 +1,67 @@ +/** + * @file mender-http.c + * @brief Mender HTTP interface for weak platform + * + * MIT License + * + * Copyright (c) 2022-2023 joelguittet and mender-mcu-client contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mender-http.h" + +__attribute__((weak)) mender_err_t +mender_http_init(mender_http_config_t *config) { + + (void)config; + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_http_perform(char * jwt, + char * path, + mender_http_method_t method, + char * payload, + char * signature, + mender_err_t (*callback)(mender_http_client_event_t, void *, size_t, void *), + void *params, + int * status) { + + (void)jwt; + (void)path; + (void)method; + (void)payload; + (void)signature; + (void)callback; + (void)params; + (void)status; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_http_exit(void) { + + /* Nothing to do */ + return MENDER_OK; +} diff --git a/platform/net/generic/weak/src/mender-websocket.c b/platform/net/generic/weak/src/mender-websocket.c new file mode 100644 index 0000000..9094a29 --- /dev/null +++ b/platform/net/generic/weak/src/mender-websocket.c @@ -0,0 +1,78 @@ +/** + * @file mender-websocket.c + * @brief Mender websocket interface for weak platform + * + * MIT License + * + * Copyright (c) 2022-2023 joelguittet and mender-mcu-client contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mender-websocket.h" + +__attribute__((weak)) mender_err_t +mender_websocket_init(mender_websocket_config_t *config) { + + (void)config; + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_websocket_connect( + char *jwt, char *path, mender_err_t (*callback)(mender_websocket_client_event_t, void *, size_t, void *), void *params, void **handle) { + + (void)jwt; + (void)path; + (void)callback; + (void)params; + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_websocket_send(void *handle, void *payload, size_t length) { + + (void)handle; + (void)payload; + (void)length; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_websocket_disconnect(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_websocket_exit(void) { + + /* Nothing to do */ + return MENDER_OK; +} diff --git a/platform/board/esp-idf/src/mender-ota.c b/platform/ota/esp-idf/src/mender-ota.c similarity index 100% rename from platform/board/esp-idf/src/mender-ota.c rename to platform/ota/esp-idf/src/mender-ota.c diff --git a/platform/ota/generic/weak/src/mender-ota.c b/platform/ota/generic/weak/src/mender-ota.c new file mode 100644 index 0000000..4d3a3a1 --- /dev/null +++ b/platform/ota/generic/weak/src/mender-ota.c @@ -0,0 +1,92 @@ +/** + * @file mender-ota.c + * @brief Mender OTA interface for weak platform + * + * MIT License + * + * Copyright (c) 2022-2023 joelguittet and mender-mcu-client contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mender-ota.h" + +__attribute__((weak)) mender_err_t +mender_ota_begin(char *name, size_t size, void **handle) { + + (void)name; + (void)size; + (void)handle; + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_ota_write(void *handle, void *data, size_t index, size_t length) { + + (void)handle; + (void)data; + (void)index; + (void)length; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_ota_abort(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_ota_end(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_ota_set_boot_partition(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_ota_mark_app_valid_cancel_rollback(void) { + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_ota_mark_app_invalid_rollback_and_reboot(void) { + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} diff --git a/platform/board/posix/src/mender-ota.c b/platform/ota/posix/src/mender-ota.c similarity index 100% rename from platform/board/posix/src/mender-ota.c rename to platform/ota/posix/src/mender-ota.c diff --git a/platform/board/zephyr/src/mender-ota.c b/platform/ota/zephyr/src/mender-ota.c similarity index 100% rename from platform/board/zephyr/src/mender-ota.c rename to platform/ota/zephyr/src/mender-ota.c diff --git a/platform/rtos/generic/weak/src/mender-rtos.c b/platform/rtos/generic/weak/src/mender-rtos.c new file mode 100644 index 0000000..113a4b2 --- /dev/null +++ b/platform/rtos/generic/weak/src/mender-rtos.c @@ -0,0 +1,154 @@ +/** + * @file mender-rtos.c + * @brief Mender RTOS interface for weak platform + * + * MIT License + * + * Copyright (c) 2022-2023 joelguittet and mender-mcu-client contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mender-rtos.h" + +__attribute__((weak)) mender_err_t +mender_rtos_init(void) { + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_rtos_work_create(mender_rtos_work_params_t *work_params, void **handle) { + + (void)work_params; + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_work_activate(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_work_set_period(void *handle, uint32_t period) { + + (void)handle; + (void)period; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_work_execute(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_work_deactivate(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_work_delete(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_delay_until_init(unsigned long *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_delay_until_s(unsigned long *handle, uint32_t delay) { + + (void)handle; + (void)delay; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_mutex_create(void **handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_mutex_take(void *handle, int32_t delay_ms) { + + (void)handle; + (void)delay_ms; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_mutex_give(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_mutex_delete(void *handle) { + + (void)handle; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_rtos_exit(void) { + + /* Nothing to do */ + return MENDER_OK; +} diff --git a/platform/board/zephyr/src/mender-shell.c b/platform/shell/zephyr/src/mender-shell.c similarity index 100% rename from platform/board/zephyr/src/mender-shell.c rename to platform/shell/zephyr/src/mender-shell.c diff --git a/platform/board/esp-idf/src/mender-storage.c b/platform/storage/esp-idf/nvs/src/mender-storage.c similarity index 100% rename from platform/board/esp-idf/src/mender-storage.c rename to platform/storage/esp-idf/nvs/src/mender-storage.c diff --git a/platform/storage/generic/weak/src/mender-storage.c b/platform/storage/generic/weak/src/mender-storage.c new file mode 100644 index 0000000..13d48e2 --- /dev/null +++ b/platform/storage/generic/weak/src/mender-storage.c @@ -0,0 +1,132 @@ +/** + * @file mender-storage.c + * @brief Mender storage interface for weak platform + * + * MIT License + * + * Copyright (c) 2022-2023 joelguittet and mender-mcu-client contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mender-log.h" +#include "mender-storage.h" + +__attribute__((weak)) mender_err_t +mender_storage_init(void) { + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_storage_set_authentication_keys(unsigned char *private_key, size_t private_key_length, unsigned char *public_key, size_t public_key_length) { + + (void)private_key; + (void)private_key_length; + (void)public_key; + (void)public_key_length; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_storage_get_authentication_keys(unsigned char **private_key, size_t *private_key_length, unsigned char **public_key, size_t *public_key_length) { + + (void)private_key; + (void)private_key_length; + (void)public_key; + (void)public_key_length; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_storage_delete_authentication_keys(void) { + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_storage_set_ota_deployment(char *ota_id, char *ota_artifact_name) { + + (void)ota_id; + (void)ota_artifact_name; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_storage_get_ota_deployment(char **ota_id, char **ota_artifact_name) { + + (void)ota_id; + (void)ota_artifact_name; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_storage_delete_ota_deployment(void) { + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +#ifdef CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE +#ifdef CONFIG_MENDER_CLIENT_CONFIGURE_STORAGE + +__attribute__((weak)) mender_err_t +mender_storage_set_device_config(char *device_config) { + + (void)device_config; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_storage_get_device_config(char **device_config) { + + (void)device_config; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_storage_delete_device_config(void) { + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +#endif /* CONFIG_MENDER_CLIENT_CONFIGURE_STORAGE */ +#endif /* CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE */ + +__attribute__((weak)) mender_err_t +mender_storage_exit(void) { + + /* Nothing to do */ + return MENDER_OK; +} diff --git a/platform/board/posix/src/mender-storage.c b/platform/storage/posix/src/mender-storage.c similarity index 100% rename from platform/board/posix/src/mender-storage.c rename to platform/storage/posix/src/mender-storage.c diff --git a/platform/board/zephyr/src/mender-storage.c b/platform/storage/zephyr/nvs/src/mender-storage.c similarity index 99% rename from platform/board/zephyr/src/mender-storage.c rename to platform/storage/zephyr/nvs/src/mender-storage.c index 430b55d..2cc853d 100644 --- a/platform/board/zephyr/src/mender-storage.c +++ b/platform/storage/zephyr/nvs/src/mender-storage.c @@ -70,7 +70,7 @@ mender_storage_init(void) { return MENDER_FAIL; } mender_storage_nvs_handle.sector_size = (uint16_t)info.size; - mender_storage_nvs_handle.sector_count = CONFIG_MENDER_STORAGE_SECTOR_COUNT; + mender_storage_nvs_handle.sector_count = CONFIG_MENDER_STORAGE_NVS_SECTOR_COUNT; /* Mount NVS */ if (0 != (result = nvs_mount(&mender_storage_nvs_handle))) { diff --git a/platform/tls/mbedtls/src/mender-tls.c b/platform/tls/generic/mbedtls/src/mender-tls.c similarity index 99% rename from platform/tls/mbedtls/src/mender-tls.c rename to platform/tls/generic/mbedtls/src/mender-tls.c index b3b937b..78953ca 100644 --- a/platform/tls/mbedtls/src/mender-tls.c +++ b/platform/tls/generic/mbedtls/src/mender-tls.c @@ -51,7 +51,7 @@ #define MENDER_TLS_SIGNATURE_LENGTH (512) /** - * @brief Authentication keys + * @brief Private and public keys of the device */ static unsigned char *mender_tls_private_key = NULL; static size_t mender_tls_private_key_length = 0; @@ -117,7 +117,7 @@ mender_tls_init_authentication_keys(bool recommissioning) { } } - /* Retrieve or generate authentication keys if not allready done */ + /* Retrieve or generate private and public keys if not allready done */ if (MENDER_OK != (ret = mender_storage_get_authentication_keys( &mender_tls_private_key, &mender_tls_private_key_length, &mender_tls_public_key, &mender_tls_public_key_length))) { diff --git a/platform/tls/generic/weak/src/mender-tls.c b/platform/tls/generic/weak/src/mender-tls.c new file mode 100644 index 0000000..667e66d --- /dev/null +++ b/platform/tls/generic/weak/src/mender-tls.c @@ -0,0 +1,71 @@ +/** + * @file mender-tls.c + * @brief Mender TLS interface for weak platform + * + * MIT License + * + * Copyright (c) 2022-2023 joelguittet and mender-mcu-client contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mender-tls.h" + +__attribute__((weak)) mender_err_t +mender_tls_init(void) { + + /* Nothing to do */ + return MENDER_OK; +} + +__attribute__((weak)) mender_err_t +mender_tls_init_authentication_keys(bool recommissioning) { + + (void)recommissioning; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_tls_get_public_key_pem(char **public_key) { + + (void)public_key; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_tls_sign_payload(char *payload, char **signature, size_t *signature_length) { + + (void)payload; + (void)signature; + (void)signature_length; + + /* Nothing to do */ + return MENDER_NOT_IMPLEMENTED; +} + +__attribute__((weak)) mender_err_t +mender_tls_exit(void) { + + /* Nothing to do */ + return MENDER_OK; +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1802f7e..c62748d 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -95,31 +95,31 @@ if(CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT) endif() # Add definitions depending of the target -if(CONFIG_MENDER_MCU_CLIENT_BOARD_TYPE MATCHES "zephyr") - add_compile_definitions(CONFIG_MENDER_STORAGE_SECTOR_COUNT=4) -endif() -if(CONFIG_MENDER_MCU_CLIENT_NET_TYPE MATCHES "curl") +if(CONFIG_MENDER_PLATFORM_NET_TYPE MATCHES "generic/curl") add_compile_definitions(CONFIG_MENDER_WEBSOCKET_THREAD_STACK_SIZE=64) add_compile_definitions(CONFIG_MENDER_WEBSOCKET_THREAD_PRIORITY=0) endif() -if(CONFIG_MENDER_MCU_CLIENT_NET_TYPE MATCHES "zephyr") +if(CONFIG_MENDER_PLATFORM_NET_TYPE MATCHES "zephyr") add_compile_definitions(CONFIG_NET_SOCKETS_SOCKOPT_TLS) add_compile_definitions(CONFIG_MENDER_NET_CA_CERTIFICATE_TAG=1) endif() -if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "freertos") +if(CONFIG_MENDER_PLATFORM_RTOS_TYPE MATCHES "freertos") add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE=20) add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_PRIORITY=5) add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_LENGTH=10) endif() -if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "posix") +if(CONFIG_MENDER_PLATFORM_RTOS_TYPE MATCHES "posix") add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE=64) add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_PRIORITY=0) add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_LENGTH=10) endif() -if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "zephyr") +if(CONFIG_MENDER_PLATFORM_RTOS_TYPE MATCHES "zephyr") add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_STACK_SIZE=12) add_compile_definitions(CONFIG_MENDER_RTOS_WORK_QUEUE_PRIORITY=5) endif() +if(CONFIG_MENDER_PLATFORM_STORAGE_TYPE MATCHES "zephyr/nvs") + add_compile_definitions(CONFIG_MENDER_STORAGE_NVS_SECTOR_COUNT=4) +endif() # Add sources file(GLOB_RECURSE SOURCES_TEMP "${CMAKE_CURRENT_LIST_DIR}/src/*.c") @@ -137,10 +137,10 @@ target_link_libraries(${APP_EXECUTABLE_NAME} mender-mcu-client pthread) if(CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT) target_link_libraries(${APP_EXECUTABLE_NAME} msgpack-c) endif() -if(CONFIG_MENDER_MCU_CLIENT_NET_TYPE MATCHES "curl") +if(CONFIG_MENDER_PLATFORM_NET_TYPE MATCHES "generic/curl") target_link_libraries(${APP_EXECUTABLE_NAME} curl) endif() -if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "posix") +if(CONFIG_MENDER_PLATFORM_RTOS_TYPE MATCHES "posix") target_link_libraries(${APP_EXECUTABLE_NAME} rt) endif() diff --git a/tests/mocks/CMakeLists.txt b/tests/mocks/CMakeLists.txt index d6e061a..f80763f 100755 --- a/tests/mocks/CMakeLists.txt +++ b/tests/mocks/CMakeLists.txt @@ -25,15 +25,16 @@ # Include all mocks include("${CMAKE_CURRENT_LIST_DIR}/cjson/CMakeLists.txt") -if(CONFIG_MENDER_MCU_CLIENT_BOARD_TYPE MATCHES "esp-idf") +if(CONFIG_MENDER_PLATFORM_LOG_TYPE MATCHES "esp-idf" OR CONFIG_MENDER_PLATFORM_NET_TYPE MATCHES "esp-idf" OR + CONFIG_MENDER_PLATFORM_OTA_TYPE MATCHES "esp-idf" OR CONFIG_MENDER_PLATFORM_STORAGE_TYPE MATCHES "esp-idf/nvs") include("${CMAKE_CURRENT_LIST_DIR}/esp-idf/CMakeLists.txt") endif() -if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "freertos") +if(CONFIG_MENDER_PLATFORM_RTOS_TYPE MATCHES "freertos") include("${CMAKE_CURRENT_LIST_DIR}/freertos/CMakeLists.txt") endif() -if(CONFIG_MENDER_MCU_CLIENT_RTOS_TYPE MATCHES "zephyr") +if(CONFIG_MENDER_PLATFORM_RTOS_TYPE MATCHES "zephyr") include("${CMAKE_CURRENT_LIST_DIR}/zephyr/CMakeLists.txt") endif() -if(CONFIG_MENDER_MCU_CLIENT_TLS_TYPE MATCHES "mbedtls") +if(CONFIG_MENDER_PLATFORM_TLS_TYPE MATCHES "generic/mbedtls") include("${CMAKE_CURRENT_LIST_DIR}/mbedtls/CMakeLists.txt") endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index f741905..a31ce6d 100755 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -32,13 +32,13 @@ if(CONFIG_MENDER_MCU_CLIENT) "${CMAKE_CURRENT_LIST_DIR}/../core/src/mender-artifact.c" "${CMAKE_CURRENT_LIST_DIR}/../core/src/mender-client.c" "${CMAKE_CURRENT_LIST_DIR}/../core/src/mender-utils.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/board/zephyr/src/mender-log.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/board/zephyr/src/mender-ota.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/board/zephyr/src/mender-storage.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/net/zephyr/src/mender-http.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/log/${CONFIG_MENDER_PLATFORM_LOG_TYPE}/src/mender-log.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/net/${CONFIG_MENDER_PLATFORM_NET_TYPE}/src/mender-http.c" "${CMAKE_CURRENT_LIST_DIR}/../platform/net/zephyr/src/mender-net.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/rtos/zephyr/src/mender-rtos.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/tls/mbedtls/src/mender-tls.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/ota/${CONFIG_MENDER_PLATFORM_OTA_TYPE}/src/mender-ota.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/rtos/${CONFIG_MENDER_PLATFORM_RTOS_TYPE}r/src/mender-rtos.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/storage/${CONFIG_MENDER_PLATFORM_STORAGE_TYPE}/src/mender-storage.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/tls/${CONFIG_MENDER_PLATFORM_TLS_TYPE}/src/mender-tls.c" ) zephyr_library_sources_ifdef(CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE "${CMAKE_CURRENT_LIST_DIR}/../add-ons/src/mender-configure.c" @@ -48,8 +48,8 @@ if(CONFIG_MENDER_MCU_CLIENT) ) zephyr_library_sources_ifdef(CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT "${CMAKE_CURRENT_LIST_DIR}/../add-ons/src/mender-troubleshoot.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/net/zephyr/src/mender-websocket.c" - "${CMAKE_CURRENT_LIST_DIR}/../platform/board/zephyr/src/mender-shell.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/net/${CONFIG_MENDER_PLATFORM_NET_TYPE}/src/mender-websocket.c" + "${CMAKE_CURRENT_LIST_DIR}/../platform/shell/zephyr/src/mender-shell.c" ) file (STRINGS "${CMAKE_CURRENT_LIST_DIR}/../VERSION" MENDER_CLIENT_VERSION) add_definitions("-DMENDER_CLIENT_VERSION=\"${MENDER_CLIENT_VERSION}\"") diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 07f5918..ced4d8c 100755 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -34,14 +34,12 @@ menuconfig MENDER_MCU_CLIENT select IMG_ENABLE_IMAGE_CHECK select IMG_ERASE_PROGRESSIVELY select IMG_MANAGER - select MBEDTLS select MPU_ALLOW_FLASH_WRITE select MSGPACK_C if MENDER_CLIENT_ADD_ON_TROUBLESHOOT select NETWORKING select NET_TCP select NET_SOCKETS select NET_SOCKETS_POSIX_NAMES - select NVS select REBOOT select STREAM_FLASH select WEBSOCKET_CLIENT if MENDER_CLIENT_ADD_ON_TROUBLESHOOT @@ -142,7 +140,7 @@ if MENDER_MCU_CLIENT menu "Mender Troubleshoot Addon Options" config MENDER_CLIENT_ADD_ON_TROUBLESHOOT - bool "Mender client Troubleshoot" + bool "Mender client Troubleshoot (EXPERIMENTAL)" default n help Troubleshoot add-on permits to perform debugging on the target from the Mender server. @@ -163,76 +161,192 @@ if MENDER_MCU_CLIENT endmenu - menu "Mender Network Options" + menu "Mender Platform Options (ADVANCED)" - config MENDER_NET_CA_CERTIFICATE_TAG - int "CA certificate tag" - default 1 + choice MENDER_PLATFORM_LOG_TYPE + prompt "Mender platform log implementation type" + default MENDER_PLATFORM_LOG_TYPE_DEFAULT help - A security tag that ROOT CA server credential will be referenced with, see tls_credential_add. - - config MENDER_NET_TLS_PEER_VERIFY - int "TLS_PEER_VERIFY option" - range 0 2 - default 2 + Specify platform log implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_LOG_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_LOG_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_LOG_TYPE + string "Mender platform log implementation type" + default "zephyr" if MENDER_PLATFORM_LOG_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_LOG_TYPE_WEAK + + choice MENDER_PLATFORM_NET_TYPE + prompt "Mender platform network implementation type" + default MENDER_PLATFORM_NET_TYPE_DEFAULT + help + Specify platform network implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_NET_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_NET_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_NET_TYPE + string "Mender platform network implementation type" + default "zephyr" if MENDER_PLATFORM_NET_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_NET_TYPE_WEAK + + choice MENDER_PLATFORM_OTA_TYPE + prompt "Mender platform OTA implementation type" + default MENDER_PLATFORM_OTA_TYPE_DEFAULT + help + Specify platform OTA implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_OTA_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_OTA_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_OTA_TYPE + string "Mender platform OTA implementation type" + default "zephyr" if MENDER_PLATFORM_OTA_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_OTA_TYPE_WEAK + + choice MENDER_PLATFORM_RTOS_TYPE + prompt "Mender platform RTOS implementation type" + default MENDER_PLATFORM_RTOS_TYPE_DEFAULT + help + Specify platform RTOS implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_RTOS_TYPE_DEFAULT + bool "default" + config MENDER_PLATFORM_RTOS_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_RTOS_TYPE + string "Mender platform RTOS implementation type" + default "zephyr" if MENDER_PLATFORM_RTOS_TYPE_DEFAULT + default "generic/weak" if MENDER_PLATFORM_RTOS_TYPE_WEAK + + choice MENDER_PLATFORM_STORAGE_TYPE + prompt "Mender platform storage implementation type" + default MENDER_PLATFORM_STORAGE_TYPE_NVS help - Peer verification level for TLS connection. + Specify platform storage implementation type, select 'weak' to use you own implementation. + + config MENDER_PLATFORM_STORAGE_TYPE_NVS + bool "nvs" + select NVS + config MENDER_PLATFORM_STORAGE_TYPE_WEAK + bool "weak" + endchoice + + config MENDER_PLATFORM_STORAGE_TYPE + string "Mender platform storage implementation type" + default "zephyr/nvs" if MENDER_PLATFORM_STORAGE_TYPE_NVS + default "generic/weak" if MENDER_PLATFORM_STORAGE_TYPE_WEAK + + choice MENDER_PLATFORM_TLS_TYPE + prompt "Mender platform TLS implementation type" + default MENDER_PLATFORM_TLS_TYPE_MBEDTLS + help + Specify platform TLS implementation type, select 'weak' to use you own implementation. - if MENDER_CLIENT_ADD_ON_TROUBLESHOOT + config MENDER_PLATFORM_TLS_TYPE_MBEDTLS + bool "mbedtls" + select MBEDTLS + config MENDER_PLATFORM_TLS_TYPE_WEAK + bool "weak" + endchoice - config MENDER_WEBSOCKET_THREAD_STACK_SIZE - int "Mender WebSocket client Thread Stack Size (kB)" - range 0 64 - default 4 - help - Mender WebSocket client thread stack size, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. + config MENDER_PLATFORM_TLS_TYPE + string "Mender platform TLS implementation type" + default "generic/mbedtls" if MENDER_PLATFORM_TLS_TYPE_MBEDTLS + default "generic/weak" if MENDER_PLATFORM_TLS_TYPE_WEAK - config MENDER_WEBSOCKET_THREAD_PRIORITY - int "Mender WebSocket client Thread Priority" - range 0 128 - default 5 - help - Mender WebSocket client thread priority, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. + endmenu + + if MENDER_PLATFORM_NET_TYPE_DEFAULT + + menu "Mender Network Options (ADVANCED)" - config MENDER_WEBSOCKET_CONNECT_TIMEOUT - int "Mender WebSocket client connect timeout (milliseconds)" - range 0 60000 - default 3000 + config MENDER_NET_CA_CERTIFICATE_TAG + int "CA certificate tag" + default 1 help - Mender WebSocket client connect timeout. Default value is suitable for most applications. + A security tag that ROOT CA server credential will be referenced with, see tls_credential_add. - config MENDER_WEBSOCKET_REQUEST_TIMEOUT - int "Mender WebSocket client request timeout (milliseconds)" - range 0 60000 - default 3000 + config MENDER_NET_TLS_PEER_VERIFY + int "TLS_PEER_VERIFY option" + range 0 2 + default 2 help - Mender WebSocket client request timeout. Default value is suitable for most applications. + Peer verification level for TLS connection. - endif + if MENDER_CLIENT_ADD_ON_TROUBLESHOOT - endmenu + config MENDER_WEBSOCKET_THREAD_STACK_SIZE + int "Mender WebSocket client Thread Stack Size (kB)" + range 0 64 + default 4 + help + Mender WebSocket client thread stack size, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. - menu "Mender Scheduler Options" + config MENDER_WEBSOCKET_THREAD_PRIORITY + int "Mender WebSocket client Thread Priority" + range 0 128 + default 5 + help + Mender WebSocket client thread priority, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. - config MENDER_RTOS_WORK_QUEUE_STACK_SIZE - int "Mender RTOS Work Queue Stack Size (kB)" - range 0 64 - default 12 - help - Mender RTOS work queue stack size, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. + config MENDER_WEBSOCKET_CONNECT_TIMEOUT + int "Mender WebSocket client connect timeout (milliseconds)" + range 0 60000 + default 3000 + help + Mender WebSocket client connect timeout. Default value is suitable for most applications. - config MENDER_RTOS_WORK_QUEUE_PRIORITY - int "Mender RTOS Work Queue Priority" - range 0 128 - default 5 - help - Mender RTOS work queue priority, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. + config MENDER_WEBSOCKET_REQUEST_TIMEOUT + int "Mender WebSocket client request timeout (milliseconds)" + range 0 60000 + default 3000 + help + Mender WebSocket client request timeout. Default value is suitable for most applications. - endmenu + endif + + endmenu + + endif + + if MENDER_PLATFORM_RTOS_TYPE_DEFAULT + + menu "Mender RTOS Options (ADVANCED)" + + config MENDER_RTOS_WORK_QUEUE_STACK_SIZE + int "Mender RTOS Work Queue Stack Size (kB)" + range 0 64 + default 12 + help + Mender RTOS work queue stack size, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. + + config MENDER_RTOS_WORK_QUEUE_PRIORITY + int "Mender RTOS Work Queue Priority" + range 0 128 + default 5 + help + Mender RTOS work queue priority, customize only if you have a deep understanding of the impacts! Default value is suitable for most applications. + + endmenu + + endif if MENDER_CLIENT_ADD_ON_TROUBLESHOOT - menu "Mender Shell Options" + menu "Mender Shell Options (ADVANCED)" config MENDER_SHELL_PROMPT string "Mender Shell prompt" @@ -300,15 +414,19 @@ if MENDER_MCU_CLIENT endif - menu "Mender Storage Options" + if MENDER_PLATFORM_STORAGE_TYPE_NVS - config MENDER_STORAGE_SECTOR_COUNT - int "Number of sectors of the mender_storage partition" - default 2 - range 2 8 - help - Number of sectors of the mender_storage partition, must match the configuration of the partition. + menu "Mender Storage Options" - endmenu + config MENDER_STORAGE_NVS_SECTOR_COUNT + int "Number of sectors of the mender_storage partition" + default 2 + range 2 8 + help + Number of sectors of the mender_storage partition, must match the configuration of the partition. + + endmenu + + endif endif