From e9a2caf9d3297f03656081ce3b4da94e8b44ced6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Ku=C4=87ma?= Date: Tue, 21 Nov 2023 17:04:42 +0100 Subject: [PATCH] Anjay-freertos-client 23.11 --- .gitignore | 2 ++ Application/Inc/anjay/anjay_config.h | 11 +++++++ .../Inc/avsystem/commons/avs_commons_config.h | 10 ++++++ Application/Inc/default_config.h | 2 +- CHANGELOG.md | 6 ++++ .../Inc/at_custom_modem_specific.h | 1 + .../Src/at_custom_modem_specific.c | 2 +- .../Src/stm32u5xx_hal_ospi.c | 6 ++-- Middlewares/Third_Party/Anjay | 2 +- .../Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin | 1 + .../UserApp/app_compat/barometer_driver.c | 4 +++ .../app_compat/barometer_driver.c | 4 +++ .../Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin | 1 + .../Binary/OEM_KEY_COMPANY1_key_AES_GCM.bin | 1 + .../UserApp/app_compat/barometer_driver.c | 9 ++++-- stm32u5_hal_ospi_noopt.patch | 32 ++++++++----------- xcc_type1sc_dnsrslv_timeout.patch | 32 +++++++++++++++++++ 17 files changed, 100 insertions(+), 26 deletions(-) create mode 100644 Projects/B-L462E-CELL1/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin create mode 100644 Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin create mode 100644 Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_GCM.bin create mode 100644 xcc_type1sc_dnsrslv_timeout.patch diff --git a/.gitignore b/.gitignore index 21decf5..6b0da3e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ Projects/**/STM32CubeIDE/crypto.txt Projects/**/STM32CubeIDE/postbuild.sh __pycache__/ /.metadata/ +!OEM_KEY_COMPANY1_key_AES_CBC.bin +!OEM_KEY_COMPANY1_key_AES_GCM.bin diff --git a/Application/Inc/anjay/anjay_config.h b/Application/Inc/anjay/anjay_config.h index de8633b..8b973bd 100644 --- a/Application/Inc/anjay/anjay_config.h +++ b/Application/Inc/anjay/anjay_config.h @@ -645,6 +645,17 @@ * in the open source version. */ /* #undef ANJAY_WITH_MODULE_OSCORE */ + +/** + * If enable Anjay doesn't handle composite operation (read, observe and write). + * Its use makes sense for LWM2M v1.1 upwards. + * + * This flag can be used to reduce the size of the resulting code. + * + * If active, anjay will respond with message code 5.01 Not Implemented to any + * composite type request. + */ +/* #undef ANJAY_WITHOUT_COMPOSITE_OPERATIONS */ /**@}*/ #endif // ANJAY_CONFIG_H diff --git a/Application/Inc/avsystem/commons/avs_commons_config.h b/Application/Inc/avsystem/commons/avs_commons_config.h index f7eac8d..6ec1917 100644 --- a/Application/Inc/avsystem/commons/avs_commons_config.h +++ b/Application/Inc/avsystem/commons/avs_commons_config.h @@ -442,6 +442,16 @@ */ /* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */ +/** + * Enables use of the psa_generate_random() function as the default + * random number generator when using the Mbed TLS crypto backend, instead of + * CTR-DRBG seeded by the Mbed TLS entropy pool. + * + * It's meaningful only when @ref AVS_COMMONS_WITH_MBEDTLS is enabled. However, + * it is independent from the above PSA engine settings. + */ +/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_RNG */ + /** * Is the dlsym() function available? * diff --git a/Application/Inc/default_config.h b/Application/Inc/default_config.h index 70f1ddd..49c12af 100644 --- a/Application/Inc/default_config.h +++ b/Application/Inc/default_config.h @@ -30,7 +30,7 @@ #else // USE_SIM_BOOTSTRAP #define DEFAULT_USE_SIM_BOOTSTRAP "n" #endif // USE_SIM_BOOTSTRAP -#define FIRMWARE_VERSION "23.09" +#define FIRMWARE_VERSION "23.11" #define MD5_OF_ZERO_BYTES_INITIALIZER \ { \ 0xD4, 0x1D, 0x8C, 0xD9, 0x8F, 0x00, 0xB2, 0x04, 0xE9, 0x80, 0x09, \ diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ebb72..11ee31d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +### 23.11 (Nov 21st, 2023) + +### Bugfixes +- Increased the AT command timeout for the DNS resolution command, for better + compatibility with various TYPE1SC firmware versions + ## 23.09 (Sep 7th, 2023) ### Features diff --git a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h index 4f6924b..258e87f 100644 --- a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h +++ b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h @@ -71,6 +71,7 @@ extern "C" { #define TYPE1SC_SIMREADY_TIMEOUT ((uint32_t)3000U) #if (USE_SOCKETS_TYPE == USE_SOCKETS_MODEM) +#define TYPE1SC_DNSRSLV_TIMEOUT ((uint32_t)60000) /* 60 sec */ #define TYPE1SC_PING_TIMEOUT ((uint32_t)15000) /* 15 sec */ #endif /* (USE_SOCKETS_TYPE == USE_SOCKETS_MODEM)*/ diff --git a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c index 5bd1d6a..f7aa4ad 100644 --- a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c +++ b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c @@ -256,7 +256,7 @@ void ATCustom_TYPE1SC_init(atparser_context_t *p_atp_ctxt) fCmdBuild_SOCKETDATA_RECEIVE, fRspAnalyze_SOCKETDATA }, { - CMD_AT_DNSRSLV, "%DNSRSLV", TYPE1SC_DEFAULT_TIMEOUT, + CMD_AT_DNSRSLV, "%DNSRSLV", TYPE1SC_DNSRSLV_TIMEOUT, fCmdBuild_DNSRSLV, fRspAnalyze_DNSRSLV }, { diff --git a/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c b/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c index 22643c7..6ef32b0 100644 --- a/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c +++ b/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c @@ -1,3 +1,5 @@ +#pragma GCC push_options +#pragma GCC optimize ("-O0") /** ****************************************************************************** * @file stm32u5xx_hal_ospi.c @@ -3000,7 +3002,6 @@ static void OSPI_DMAAbortCplt(DMA_HandleTypeDef *hdma) * @param Tickstart : Tick start value * @retval HAL status */ -__attribute__((optimize("O0"))) static HAL_StatusTypeDef OSPI_WaitFlagStateUntilTimeout(OSPI_HandleTypeDef *hospi, uint32_t Flag, FlagStatus State, uint32_t Tickstart, uint32_t Timeout) { @@ -3032,7 +3033,6 @@ static HAL_StatusTypeDef OSPI_WaitFlagStateUntilTimeout(OSPI_HandleTypeDef *hosp * @param cmd : structure that contains the command configuration information * @retval HAL status */ -__attribute__((optimize("O0"))) static HAL_StatusTypeDef OSPI_ConfigCmd(OSPI_HandleTypeDef *hospi, OSPI_RegularCmdTypeDef *cmd) { HAL_StatusTypeDef status = HAL_OK; @@ -3528,3 +3528,5 @@ HAL_StatusTypeDef HAL_OSPI_DLYB_GetClockPeriod(OSPI_HandleTypeDef *hospi, HAL_OS */ #endif /* OCTOSPI || OCTOSPI1 || OCTOSPI2 */ + +#pragma GCC pop_options diff --git a/Middlewares/Third_Party/Anjay b/Middlewares/Third_Party/Anjay index 0acafc4..4f451c7 160000 --- a/Middlewares/Third_Party/Anjay +++ b/Middlewares/Third_Party/Anjay @@ -1 +1 @@ -Subproject commit 0acafc41f108527853416f541ea7a1363127d15c +Subproject commit 4f451c7382591072735767de28bc201c2d14e4b5 diff --git a/Projects/B-L462E-CELL1/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin b/Projects/B-L462E-CELL1/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin new file mode 100644 index 0000000..7b3c9ad --- /dev/null +++ b/Projects/B-L462E-CELL1/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin @@ -0,0 +1 @@ +OEM_KEY_COMPANY1 \ No newline at end of file diff --git a/Projects/B-L462E-CELL1/UserApp/app_compat/barometer_driver.c b/Projects/B-L462E-CELL1/UserApp/app_compat/barometer_driver.c index cf7284d..a387354 100644 --- a/Projects/B-L462E-CELL1/UserApp/app_compat/barometer_driver.c +++ b/Projects/B-L462E-CELL1/UserApp/app_compat/barometer_driver.c @@ -39,6 +39,10 @@ static int get_pressure(float *out_pressure) { LOG(ERROR, "Error getting current pressure"); return -1; } + if (!*out_pressure) { + // Disregard 0 reading + return -1; + } // convert hPa to Pa *out_pressure = 100.0f * *out_pressure; return 0; diff --git a/Projects/B-U585I-IOT02A/app_compat/barometer_driver.c b/Projects/B-U585I-IOT02A/app_compat/barometer_driver.c index abfbe0e..fc005df 100644 --- a/Projects/B-U585I-IOT02A/app_compat/barometer_driver.c +++ b/Projects/B-U585I-IOT02A/app_compat/barometer_driver.c @@ -41,6 +41,10 @@ static int get_pressure(float *out_pressure) { LOG(ERROR, "Couldn't read pressure"); return -1; } + if (!*out_pressure) { + // Disregard 0 reading + return -1; + } // convert hPa to Pa *out_pressure = 100.0f * *out_pressure; return 0; diff --git a/Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin b/Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin new file mode 100644 index 0000000..7b3c9ad --- /dev/null +++ b/Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin @@ -0,0 +1 @@ +OEM_KEY_COMPANY1 \ No newline at end of file diff --git a/Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_GCM.bin b/Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_GCM.bin new file mode 100644 index 0000000..7b3c9ad --- /dev/null +++ b/Projects/STM32L496G-DISCO/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_GCM.bin @@ -0,0 +1 @@ +OEM_KEY_COMPANY1 \ No newline at end of file diff --git a/Projects/STM32L496G-DISCO/UserApp/app_compat/barometer_driver.c b/Projects/STM32L496G-DISCO/UserApp/app_compat/barometer_driver.c index 51aecf4..d142e29 100644 --- a/Projects/STM32L496G-DISCO/UserApp/app_compat/barometer_driver.c +++ b/Projects/STM32L496G-DISCO/UserApp/app_compat/barometer_driver.c @@ -46,13 +46,16 @@ static int get_pressure(float *out_pressure) { LOG(ERROR, "IKS01A2 barometer not initialized"); return -1; } - float pressure; - if (BSP_PRESSURE_Get_Press(g_sensor_barometer, &pressure)) { + if (BSP_PRESSURE_Get_Press(g_sensor_barometer, out_pressure)) { LOG(ERROR, "error getting current pressure"); return -1; } + if (!*out_pressure) { + // Disregard 0 reading + return -1; + } // convert hPa to Pa - *out_pressure = 100.0f * pressure; + *out_pressure = 100.0f * *out_pressure; return 0; } diff --git a/stm32u5_hal_ospi_noopt.patch b/stm32u5_hal_ospi_noopt.patch index b10a8fa..46026b7 100644 --- a/stm32u5_hal_ospi_noopt.patch +++ b/stm32u5_hal_ospi_noopt.patch @@ -1,24 +1,20 @@ -# Following patch was applied to STM32U5's HAL OSPI driver to disable optimizations -# for certain functions. Compiling the app in -Os mode for certain STM32CubeIDE +# Following patch was applied to STM32U5's HAL OSPI driver to disable +# optimizations. Compiling the app in -Os mode for certain STM32CubeIDE # versions causes the driver to not function correctly. diff --git a/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c b/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c -index 3d38b50..22643c7 100644 +index 3d38b50..6ef32b0 100644 --- a/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c +++ b/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_ospi.c -@@ -3000,6 +3000,7 @@ static void OSPI_DMAAbortCplt(DMA_HandleTypeDef *hdma) - * @param Tickstart : Tick start value - * @retval HAL status +@@ -1,3 +1,5 @@ ++#pragma GCC push_options ++#pragma GCC optimize ("-O0") + /** + ****************************************************************************** + * @file stm32u5xx_hal_ospi.c +@@ -3526,3 +3528,5 @@ HAL_StatusTypeDef HAL_OSPI_DLYB_GetClockPeriod(OSPI_HandleTypeDef *hospi, HAL_OS */ -+__attribute__((optimize("O0"))) - static HAL_StatusTypeDef OSPI_WaitFlagStateUntilTimeout(OSPI_HandleTypeDef *hospi, uint32_t Flag, - FlagStatus State, uint32_t Tickstart, uint32_t Timeout) - { -@@ -3031,6 +3032,7 @@ static HAL_StatusTypeDef OSPI_WaitFlagStateUntilTimeout(OSPI_HandleTypeDef *hosp - * @param cmd : structure that contains the command configuration information - * @retval HAL status - */ -+__attribute__((optimize("O0"))) - static HAL_StatusTypeDef OSPI_ConfigCmd(OSPI_HandleTypeDef *hospi, OSPI_RegularCmdTypeDef *cmd) - { - HAL_StatusTypeDef status = HAL_OK; + + #endif /* OCTOSPI || OCTOSPI1 || OCTOSPI2 */ ++ ++#pragma GCC pop_options diff --git a/xcc_type1sc_dnsrslv_timeout.patch b/xcc_type1sc_dnsrslv_timeout.patch new file mode 100644 index 0000000..8307ff9 --- /dev/null +++ b/xcc_type1sc_dnsrslv_timeout.patch @@ -0,0 +1,32 @@ +# Following patch was applied to X-Cube-Cellular 7.1.0 to make it more +# compatible with some newer revisions of the TYPE1SC firmware, in which the +# AT%DNSRSLV request sometimes takes longer than 15 seconds if performed just +# after attaching to the network. The timeout may cause the eventual response +# to interfere with subsequent AT command requests, which causes a fatal error +# in a situation where successful communication is perfectly possible. + +diff --git a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h +index 4f6924bb..258e87fc 100644 +--- a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h ++++ b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Inc/at_custom_modem_specific.h +@@ -71,6 +71,7 @@ extern "C" { + #define TYPE1SC_SIMREADY_TIMEOUT ((uint32_t)3000U) + + #if (USE_SOCKETS_TYPE == USE_SOCKETS_MODEM) ++#define TYPE1SC_DNSRSLV_TIMEOUT ((uint32_t)60000) /* 60 sec */ + #define TYPE1SC_PING_TIMEOUT ((uint32_t)15000) /* 15 sec */ + #endif /* (USE_SOCKETS_TYPE == USE_SOCKETS_MODEM)*/ + +diff --git a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c +index 5bd1d6a3..f7aa4ad2 100644 +--- a/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c ++++ b/Drivers/BSP/X_STMOD_PLUS_MODEMS/TYPE1SC/AT_modem_type1sc/Src/at_custom_modem_specific.c +@@ -256,7 +256,7 @@ void ATCustom_TYPE1SC_init(atparser_context_t *p_atp_ctxt) + fCmdBuild_SOCKETDATA_RECEIVE, fRspAnalyze_SOCKETDATA + }, + { +- CMD_AT_DNSRSLV, "%DNSRSLV", TYPE1SC_DEFAULT_TIMEOUT, ++ CMD_AT_DNSRSLV, "%DNSRSLV", TYPE1SC_DNSRSLV_TIMEOUT, + fCmdBuild_DNSRSLV, fRspAnalyze_DNSRSLV + }, + {