From 5f00f2495ca315e2c91285209e5a4da726014e52 Mon Sep 17 00:00:00 2001 From: Teemu Takaluoma Date: Tue, 11 Dec 2018 10:43:14 +0200 Subject: [PATCH] mbed-cloud-client-example 2.1.0 --- CHANGELOG.md | 4 +- mbed-cloud-client.lib | 2 +- mbed-os.lib | 2 +- source/platform/CMakeLists.txt | 18 ++++++- source/platform/mbed-os/mcc_common_setup.cpp | 52 ++++++++++++++++++++ source/platform/pal_plat_rot_insecure.c | 4 ++ 6 files changed, 77 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a450dd..db0c89b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog for Pelion Device Management Client reference example application -## Release 2.0.1.1 (16.10.2018) -* No changes. +## Release 2.1.0 (11.12.2018) +* Updated to Mbed OS 5.10.3. ## Release 2.0.1 (12.10.2018) * Application uses `wait_ms(int)` instead of `wait(float)`, this saves a bit on application size. diff --git a/mbed-cloud-client.lib b/mbed-cloud-client.lib index 71a3dd6..8993325 100644 --- a/mbed-cloud-client.lib +++ b/mbed-cloud-client.lib @@ -1 +1 @@ -https://github.com/ARMmbed/mbed-cloud-client/#62de4b89d2350379278893f2f7a3ac937b4ae5f6 +https://github.com/ARMmbed/mbed-cloud-client/#f84aeea5047569b5833caf84056e4b3aa429e12c diff --git a/mbed-os.lib b/mbed-os.lib index d586c7a..e665486 100644 --- a/mbed-os.lib +++ b/mbed-os.lib @@ -1,2 +1,2 @@ -https://github.com/ARMmbed/mbed-os/#c53d51fe9220728bf8ed27afe7afc1ecc3f6f5d7 +https://github.com/ARMmbed/mbed-os/#bf6f2c3c6434a6de9eb9511feffa5948b3d1f20f diff --git a/source/platform/CMakeLists.txt b/source/platform/CMakeLists.txt index 4060a6d..40fccd9 100644 --- a/source/platform/CMakeLists.txt +++ b/source/platform/CMakeLists.txt @@ -14,7 +14,23 @@ FILE(GLOB PLATFORM_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${OS_BRAND}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/${OS_BRAND}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/${OS_BRAND}/*.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/*.c" ) +# A source file which provides pal_plat_osGetRoTFromHW() implementation. +# By default the insecure version is used if PAL_USE_HW_ROT flag is set, so be warned. +# The compilation will also issue a warning, as will the first use of the insecure function. +# On "real" platform this needs to be replaced either here or in PAL with the platform specific one. +FILE(GLOB PLATFORM_ROT_SRC + "${CMAKE_CURRENT_SOURCE_DIR}/pal_plat_rot_insecure.c" + ) + + +# Library for providing the mcc_* functions. CREATE_LIBRARY(platformCommon "${PLATFORM_SRC}" "") + +# Create a separate library from the ROT implementation. This is needed as +# the PAL's ROT module will need to be linked against some ROT implementation. +# This can be overridden either in PAL by setting PAL_USE_HW_ROT=0, which enables its own SOTP based +# ROT emulation, or by adding a platform specific pal_plat_rot.c code into PAL or by creating platformROT +# library and providing PAL_USE_PLATFORM_ROT_OVERRIDE flag to PAL's CMakeLists.txt. +CREATE_LIBRARY(platformCommonROT ${PLATFORM_ROT_SRC} "") diff --git a/source/platform/mbed-os/mcc_common_setup.cpp b/source/platform/mbed-os/mcc_common_setup.cpp index 0952864..4a94828 100644 --- a/source/platform/mbed-os/mcc_common_setup.cpp +++ b/source/platform/mbed-os/mcc_common_setup.cpp @@ -97,6 +97,7 @@ static bd_size_t mcc_platform_storage_size = 0; /* local help functions. */ +static void print_network_information(NetworkInterface *iface); static int mcc_platform_reformat_partition(FileSystem *fs, BlockDevice* part); static int mcc_platform_test_filesystem(FileSystem *fs, BlockDevice* part); #if (MCC_PLATFORM_PARTITION_MODE == 1) @@ -155,6 +156,7 @@ int mcc_platform_init_connection(void) { nsapi_error_t e; e = network_interface->connect(); if (e == NSAPI_ERROR_OK) { + print_network_information(network_interface); return 0; } printf("Failed to connect! error=%d\n", e); @@ -167,6 +169,7 @@ int mcc_platform_close_connection(void) { if (network_interface) { const nsapi_error_t err = network_interface->disconnect(); if (err == NSAPI_ERROR_OK) { + network_interface->attach(NULL); network_interface = NULL; return 0; } @@ -431,6 +434,36 @@ int mcc_platform_storage_init(void) { int mcc_platform_init(void) { + // On CortexM (3 and 4) the MCU has a write buffer, which helps in performance front, + // but has a side effect of making data access faults imprecise. + // + // So, if one gets a Mbed OS crash dump with following content, a re-build with + // "PLATFORM_DISABLE_WRITE_BUFFER=1" will help in getting the correct crash location. + // + // --8<--- + // Crash Info: + // <..> + // Target and Fault Info: + // Forced exception, a fault with configurable priority has been escalated to HardFault + // Imprecise data access error has occurred + // --8<--- + // + // This can't be enabled by default as then we would test with different system setup than customer + // and possible OS and driver issues might get pass the tests. + // +#if defined(PLATFORM_DISABLE_WRITE_BUFFER) && (PLATFORM_DISABLE_WRITE_BUFFER==1) + +#if defined(TARGET_CORTEX_M) + + SCnSCB->ACTLR |= SCnSCB_ACTLR_DISDEFWBUF_Msk; + + tr_info("mcc_platform_init: disabled CPU write buffer, expect reduced performance"); +#else + tr_info("mcc_platform_init: disabling CPU write buffer not possible or needed on this MCU"); +#endif + +#endif + return 0; } @@ -500,3 +533,22 @@ void mcc_platform_sw_build_info(void) { printf("Mbed OS version \n"); #endif } + +static void print_network_information(NetworkInterface *iface) +{ + if (iface->ethInterface()) { + printf("Connected using Ethernet\n"); + } else if (iface->wifiInterface()) { + printf("Connected using WiFi\n"); + } else if (iface->meshInterface()) { + printf("Connected using Mesh\n"); + } else if (iface->cellularBase()) { + printf("Connected using Cellular\n"); + } else if (iface->emacInterface()) { + printf("Connected using Emac\n"); + } else { + printf("Unknown interface\n"); + } + + printf("IP: %s\n", iface->get_ip_address()); +} diff --git a/source/platform/pal_plat_rot_insecure.c b/source/platform/pal_plat_rot_insecure.c index 68a2fe5..0fdcee7 100644 --- a/source/platform/pal_plat_rot_insecure.c +++ b/source/platform/pal_plat_rot_insecure.c @@ -19,11 +19,14 @@ #define TRACE_GROUP "ROT" +#if (PAL_USE_HW_ROT) + #define PAL_DEVICE_KEY_SIZE_IN_BYTES 16 //THIS CODE IS FOR TESTING PURPOSES ONLY. DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE palStatus_t pal_plat_osGetRoTFromHW(uint8_t *keyBuf, size_t keyLenBytes) { + #if defined (__CC_ARM) /* ARM compiler. */ #warning("PAL_INSECURE- You are using insecure Root Of Trust implementation, DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE") #else @@ -51,3 +54,4 @@ palStatus_t pal_plat_osGetRoTFromHW(uint8_t *keyBuf, size_t keyLenBytes) return PAL_SUCCESS; } +#endif