diff --git a/CHANGELOG.md b/CHANGELOG.md index 4940d24..a602967 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,13 @@ -# Changelog for Mbed Cloud Client Reference Example +# Changelog for Pelion Device Management Client Reference Example + +## Release 1.5.0 (11.09.2018) +* Added a hardcoded RoT injection when application is configured to use developer mode. This preserves the Device Management Client credentials even when SOTP is erased (for example due to reflashing of the application binary). +* Updated to Mbed OS 5.9.6. +* Updated easy-connect to v1.2.16. +* Updated the storage selector with compiler warning fixes in the internal libraries. +* Replaced the notification delivery status functionality with a more generic message delivery status callback. +* Added an example on using the delayed response for execute operations. +* Added configurations for the K66F target board. ## Release 1.4.0 (13.07.2018) * Increased application main stack-size to 5120 to fix Stack overflow with ARMCC compiled binaries when tracing is enabled. @@ -6,10 +15,9 @@ * Updated to Mbed OS 5.9.2. * Updated easy-connect to v1.2.12. * Updated storage-selector with support for SPI flash frequency, and Nucleo F411RE board. -* Moved mbed_trace() init as first step in application init to allow printing any early debug-information from PAL-layer when debug tracing is enabled. +* Moved the initialization of `mbed_trace()` as the first step in the application initialization. This allows the printing of any early debug information from the PAL layer when debug tracing is enabled. * Added support for Nucleo F411RE board with Wifi-X-Nucleo shield. -* Increased the Mbed Cloud Client event loop thread stack size to 8192 bytes from default value of 6144. This fixes stack overflows in some cases - where crypto operations result in deep callstacks. +* Increased the event loop thread stack size to 8192 bytes from a default value of 6144. This fixes stack overflows in some cases where crypto operations result in deep callstacks. ## Release 1.3.3 (08.06.2018) * Updated to Mbed OS 5.8.5. diff --git a/CMakeLists.txt b/CMakeLists.txt index aba1131..df9b77c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ endif() # mbed-cloud-client-example include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source/include) # This is needed for compiling and linking SW. add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/source/platform") diff --git a/README.md b/README.md index fbffd78..8a4867b 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -The full documentation for this example is [available on our documentation site](https://cloud.mbed.com/docs/current/connecting/mbed-cloud-client-tutorials.html) +The full documentation for this example is [available on our documentation site](https://cloud.mbed.com/docs/current/connecting/device-management-client-tutorials.html) diff --git a/configs/eth_v4.json b/configs/eth_v4.json index ea70a78..e691095 100644 --- a/configs/eth_v4.json +++ b/configs/eth_v4.json @@ -24,6 +24,11 @@ "update-client.bootloader-details" : "0x00007188", "update-client.application-details": "(40*1024)" }, + "K66F": { + "target.mbed_app_start" : "0x0000a400", + "update-client.bootloader-details" : "0x00007188", + "update-client.application-details": "(40*1024)" + }, "NUCLEO_F429ZI": { "target.mbed_app_start" : "0x08010400", "update-client.bootloader-details" : "0x080078CC", diff --git a/configs/mesh_6lowpan.json b/configs/mesh_6lowpan.json index 80ec260..ac18bfe 100644 --- a/configs/mesh_6lowpan.json +++ b/configs/mesh_6lowpan.json @@ -17,6 +17,7 @@ "mbed-client.event-loop-size": 32768, "mbed-client.reconnection-count": 6, "mbed-client.dns-use-thread": 1, + "mbed-client-pal.pal-dns-api-version": 2, "mbed-client.sn-coap-blockwise-max-time-data-stored": 120, "mbed-trace.enable": null, "storage-selector.filesystem" : "FAT", diff --git a/configs/mesh_thread.json b/configs/mesh_thread.json index 6e7840b..f052603 100644 --- a/configs/mesh_thread.json +++ b/configs/mesh_thread.json @@ -18,6 +18,7 @@ "mbed-client.event-loop-size": 32768, "mbed-client.reconnection-count": 6, "mbed-client.dns-use-thread": 1, + "mbed-client-pal.pal-dns-api-version": 2, "mbed-client.sn-coap-blockwise-max-time-data-stored": 120, "mbed-trace.enable": null, "storage-selector.filesystem" : "FAT", diff --git a/easy-connect.lib b/easy-connect.lib index 69e52d6..8129987 100644 --- a/easy-connect.lib +++ b/easy-connect.lib @@ -1 +1 @@ -https://github.com/ARMmbed/easy-connect/#aaf89690919fc378799e680119a58a222402799f +https://github.com/ARMmbed/easy-connect/#bf48f5b649eba3ed7b810c77c630b5eb51301311 diff --git a/main.cpp b/main.cpp index 504bd56..1095be0 100644 --- a/main.cpp +++ b/main.cpp @@ -21,7 +21,7 @@ #include "mbed.h" #endif #include "application_init.h" -#include "common_button_and_led.h" +#include "mcc_common_button_and_led.h" #include "blinky.h" // event based LED blinker, controlled via pattern_resource @@ -37,6 +37,7 @@ int main(void) // Pointers to the resources that will be created in main_application(). static M2MResource* button_res; static M2MResource* pattern_res; +static M2MResource* blink_res; // Pointer to mbedClient, used for calling close function. static SimpleM2MClient *client; @@ -46,6 +47,14 @@ void pattern_updated(const char *) printf("PUT received, new value: %s\n", pattern_res->get_value_string().c_str()); } +void blinky_completed(void) +{ + printf("Blinky completed \n"); + + // Send response to backend + blink_res->send_delayed_post_response(); +} + void blink_callback(void *) { String pattern_string = pattern_res->get_value_string(); @@ -55,34 +64,39 @@ void blink_callback(void *) // The pattern is something like 500:200:500, so parse that. // LED blinking is done while parsing. const bool restart_pattern = false; - if (blinky.start((char*)pattern_res->value(), pattern_res->value_length(), restart_pattern) == false) { + if (blinky.start((char*)pattern_res->value(), pattern_res->value_length(), restart_pattern, blinky_completed) == false) { printf("out of memory error\n"); } } -void button_notification_status_callback(const M2MBase& object, const NoticationDeliveryStatus status) +void button_status_callback(const M2MBase& object, + const M2MBase::MessageDeliveryStatus status, + const M2MBase::MessageType /*type*/) { switch(status) { - case NOTIFICATION_STATUS_BUILD_ERROR: - printf("Notification callback: (%s) error when building CoAP message\n", object.uri_path()); + case M2MBase::MESSAGE_STATUS_BUILD_ERROR: + printf("Message status callback: (%s) error when building CoAP message\n", object.uri_path()); + break; + case M2MBase::MESSAGE_STATUS_RESEND_QUEUE_FULL: + printf("Message status callback: (%s) CoAP resend queue full\n", object.uri_path()); break; - case NOTIFICATION_STATUS_RESEND_QUEUE_FULL: - printf("Notification callback: (%s) CoAP resend queue full\n", object.uri_path()); + case M2MBase::MESSAGE_STATUS_SENT: + printf("Message status callback: (%s) Message sent to server\n", object.uri_path()); break; - case NOTIFICATION_STATUS_SENT: - printf("Notification callback: (%s) Notification sent to server\n", object.uri_path()); + case M2MBase::MESSAGE_STATUS_DELIVERED: + printf("Message status callback: (%s) Message delivered\n", object.uri_path()); break; - case NOTIFICATION_STATUS_DELIVERED: - printf("Notification callback: (%s) Notification delivered\n", object.uri_path()); + case M2MBase::MESSAGE_STATUS_SEND_FAILED: + printf("Message status callback: (%s) Message sending failed\n", object.uri_path()); break; - case NOTIFICATION_STATUS_SEND_FAILED: - printf("Notification callback: (%s) Notification sending failed\n", object.uri_path()); + case M2MBase::MESSAGE_STATUS_SUBSCRIBED: + printf("Message status callback: (%s) subscribed\n", object.uri_path()); break; - case NOTIFICATION_STATUS_SUBSCRIBED: - printf("Notification callback: (%s) subscribed\n", object.uri_path()); + case M2MBase::MESSAGE_STATUS_UNSUBSCRIBED: + printf("Message status callback: (%s) subscription removed\n", object.uri_path()); break; - case NOTIFICATION_STATUS_UNSUBSCRIBED: - printf("Notification callback: (%s) subscription removed\n", object.uri_path()); + case M2MBase::MESSAGE_STATUS_REJECTED: + printf("Message status callback: (%s) server has rejected the message\n", object.uri_path()); break; default: break; @@ -171,15 +185,17 @@ void main_application(void) // Create resource for button count. Path of this resource will be: 3200/0/5501. button_res = mbedClient.add_cloud_resource(3200, 0, 5501, "button_resource", M2MResourceInstance::INTEGER, - M2MBase::GET_ALLOWED, 0, true, NULL, (void*)button_notification_status_callback); + M2MBase::GET_ALLOWED, 0, true, NULL, (void*)button_status_callback); // Create resource for led blinking pattern. Path of this resource will be: 3201/0/5853. pattern_res = mbedClient.add_cloud_resource(3201, 0, 5853, "pattern_resource", M2MResourceInstance::STRING, M2MBase::GET_PUT_ALLOWED, "500:500:500:500", false, (void*)pattern_updated, NULL); // Create resource for starting the led blinking. Path of this resource will be: 3201/0/5850. - mbedClient.add_cloud_resource(3201, 0, 5850, "blink_resource", M2MResourceInstance::STRING, - M2MBase::POST_ALLOWED, "", false, (void*)blink_callback, NULL); + blink_res = mbedClient.add_cloud_resource(3201, 0, 5850, "blink_resource", M2MResourceInstance::STRING, + M2MBase::POST_ALLOWED, "", false, (void*)blink_callback, (void*)button_status_callback); + // Use delayed response + blink_res->set_delayed_response(true); // Create resource for unregistering the device. Path of this resource will be: 5000/0/1. mbedClient.add_cloud_resource(5000, 0, 1, "unregister", M2MResourceInstance::STRING, diff --git a/mbed-cloud-client.lib b/mbed-cloud-client.lib index 9ea6d31..41091ee 100644 --- a/mbed-cloud-client.lib +++ b/mbed-cloud-client.lib @@ -1 +1 @@ -https://github.com/ARMmbed/mbed-cloud-client/#9b0bc6a2f3f1f5dbb5be1827db83004d531b99c9 +https://github.com/ARMmbed/mbed-cloud-client/#13e0cef7f9508c10d50f3beb049eafea2af6f17b diff --git a/mbed-os.lib b/mbed-os.lib index 77acfe7..6092335 100644 --- a/mbed-os.lib +++ b/mbed-os.lib @@ -1 +1 @@ -https://github.com/ARMmbed/mbed-os/#62f8b922b420626514fd4690107aff4188469833 +https://github.com/ARMmbed/mbed-os/#0fdfcf7350896a9c0b57c4a18237677abfe25f1a diff --git a/mbed_app.json b/mbed_app.json index 0a8a343..d51f4cf 100644 --- a/mbed_app.json +++ b/mbed_app.json @@ -24,6 +24,11 @@ "update-client.bootloader-details" : "0x00007188", "update-client.application-details": "(40*1024)" }, + "K66F": { + "target.mbed_app_start" : "0x0000a400", + "update-client.bootloader-details" : "0x00007188", + "update-client.application-details": "(40*1024)" + }, "NUCLEO_F429ZI": { "target.mbed_app_start" : "0x08010400", "update-client.bootloader-details" : "0x080078CC", diff --git a/mbed_lib.json b/mbed_lib.json index 4817e99..1552915 100644 --- a/mbed_lib.json +++ b/mbed_lib.json @@ -65,6 +65,12 @@ "sotp-section-2-address" : "(36*1024)", "sotp-section-2-size" : "( 4*1024)" }, + "K66F": { + "sotp-section-1-address" : "(32*1024)", + "sotp-section-1-size" : "( 4*1024)", + "sotp-section-2-address" : "(36*1024)", + "sotp-section-2-size" : "( 4*1024)" + }, "NUCLEO_F411RE": { "sotp-section-1-address" : "(0x08000000+32*1024)", "sotp-section-1-size" : "(16*1024)", diff --git a/source/platform/common_setup_general.c b/source/app_platform_setup.c similarity index 66% rename from source/platform/common_setup_general.c rename to source/app_platform_setup.c index f1cad45..1e4c29c 100644 --- a/source/platform/common_setup_general.c +++ b/source/app_platform_setup.c @@ -14,21 +14,23 @@ * limitations under the License. */ -#include "common_setup.h" -#include "common_config.h" +#include +#include "app_platform_setup.h" +#include "mcc_common_setup.h" +#include "mcc_common_config.h" #include "factory_configurator_client.h" -#include #if MBED_CONF_APP_DEVELOPER_MODE == 1 #ifdef PAL_USER_DEFINED_CONFIGURATION #include PAL_USER_DEFINED_CONFIGURATION #endif #endif // #if MBED_CONF_APP_DEVELOPER_MODE == 1 - // Include this only for Developer mode and device which doesn't have in-built TRNG support #if MBED_CONF_APP_DEVELOPER_MODE == 1 #ifdef PAL_USER_DEFINED_CONFIGURATION +#define FCC_ROT_SIZE 16 +const uint8_t MBED_CLOUD_DEV_ROT[FCC_ROT_SIZE] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 }; #if !PAL_USE_HW_TRNG #define FCC_ENTROPY_SIZE 48 const uint8_t MBED_CLOUD_DEV_ENTROPY[FCC_ENTROPY_SIZE] = { 0xf6, 0xd6, 0xc0, 0x09, 0x9e, 0x6e, 0xf2, 0x37, 0xdc, 0x29, 0x88, 0xf1, 0x57, 0x32, 0x7d, 0xde, 0xac, 0xb3, 0x99, 0x8c, 0xb9, 0x11, 0x35, 0x18, 0xeb, 0x48, 0x29, 0x03, 0x6a, 0x94, 0x6d, 0xe8, 0x40, 0xc0, 0x28, 0xcc, 0xe4, 0x04, 0xc3, 0x1f, 0x4b, 0xc2, 0xe0, 0x68, 0xa0, 0x93, 0xe6, 0x3a }; @@ -62,14 +64,26 @@ int mcc_platform_reset_storage(void) int mcc_platform_fcc_init(void) { int status = fcc_init(); - if (status != FCC_STATUS_SUCCESS && status != FCC_STATUS_ENTROPY_ERROR) { + // Ignore pre-existing RoT/Entropy in SOTP + if (status != FCC_STATUS_SUCCESS && status != FCC_STATUS_ENTROPY_ERROR && status != FCC_STATUS_ROT_ERROR) { printf("fcc_init failed with status %d! - exit\n", status); return status; } -#if RESET_STORAGE - status = mcc_platform_reset_storage(); -#endif -// Include this only for Developer mode and device which doesn't have in-built TRNG support + status = mcc_platform_sotp_init(); + if (status != FCC_STATUS_SUCCESS) { + printf("fcc_init failed with status %d! - exit\n", status); + mcc_platform_fcc_finalize(); + } else { + // We can return SUCCESS here as preexisting RoT/Entropy is expected flow. + status = FCC_STATUS_SUCCESS; + } + return status; +} + +int mcc_platform_sotp_init(void) +{ + int status = FCC_STATUS_SUCCESS; +// Include this only for Developer mode and a device which doesn't have in-built TRNG support. #if MBED_CONF_APP_DEVELOPER_MODE == 1 #ifdef PAL_USER_DEFINED_CONFIGURATION #if !PAL_USE_HW_TRNG @@ -79,8 +93,21 @@ int mcc_platform_fcc_init(void) printf("fcc_entropy_set failed with status %d! - exit\n", status); mcc_platform_fcc_finalize(); return status; - } + } #endif // PAL_USE_HW_TRNG = 0 +/* Include this only for Developer mode. The application will use fixed RoT to simplify user-experience with the application. + * With this change the application be reflashed/SOTP can be erased safely without invalidating the application credentials. + */ + status = fcc_rot_set(MBED_CLOUD_DEV_ROT, FCC_ROT_SIZE); + + if (status != FCC_STATUS_SUCCESS && status != FCC_STATUS_ROT_ERROR) { + printf("fcc_rot_set failed with status %d! - exit\n", status); + mcc_platform_fcc_finalize(); + } else { + // We can return SUCCESS here as preexisting RoT/Entropy is expected flow. + printf("Using hardcoded Root of Trust, not suitable for production use.\n"); + status = FCC_STATUS_SUCCESS; + } #endif // PAL_USER_DEFINED_CONFIGURATION #endif // #if MBED_CONF_APP_DEVELOPER_MODE == 1 return status; diff --git a/source/application_init.cpp b/source/application_init.cpp index 314e615..c95ec13 100644 --- a/source/application_init.cpp +++ b/source/application_init.cpp @@ -20,8 +20,9 @@ #include "mbed-trace/mbed_trace.h" #include "mbed-trace-helper.h" #include "factory_configurator_client.h" -#include "common_setup.h" -#include "common_button_and_led.h" +#include "app_platform_setup.h" +#include "mcc_common_setup.h" +#include "mcc_common_button_and_led.h" #if defined (MBED_HEAP_STATS_ENABLED) || (MBED_STACK_STATS_ENABLED) #include "memory_tests.h" #endif @@ -165,10 +166,10 @@ static bool application_init_verify_cloud_configuration() int status; #if MBED_CONF_APP_DEVELOPER_MODE == 1 - printf("Start developer flow\n"); + printf("Starting developer flow\n"); status = fcc_developer_flow(); if (status == FCC_STATUS_KCM_FILE_EXIST_ERROR) { - printf("Developer credentials already exists\n"); + printf("Developer credentials already exist, continuing..\n"); } else if (status != FCC_STATUS_SUCCESS) { printf("Failed to load developer credentials\n"); } @@ -186,11 +187,24 @@ static bool application_init_fcc(void) #ifdef MBED_STACK_STATS_ENABLED print_stack_statistics(); #endif - int status = mcc_platform_fcc_init(); - if(status != FCC_STATUS_SUCCESS && status != FCC_STATUS_ENTROPY_ERROR) { - printf("fcc_init failed with status %d! - exit\n", status); + int status = mcc_platform_fcc_init(); + if(status != FCC_STATUS_SUCCESS) { + printf("application_init_fcc fcc_init failed with status %d! - exit\n", status); return 1; } +#if RESET_STORAGE + status = mcc_platform_reset_storage(); + if(status != FCC_STATUS_SUCCESS) { + printf("application_init_fcc reset_storage failed with status %d! - exit\n", status); + return 1; + } + // Reinitialize SOTP + status = mcc_platform_sotp_init(); + if (status != FCC_STATUS_SUCCESS) { + printf("application_init_fcc sotp_init failed with status %d! - exit\n", status); + return 1; + } +#endif status = application_init_verify_cloud_configuration(); if (status != 0) { @@ -198,6 +212,7 @@ static bool application_init_fcc(void) // primary storage if no valid certificates exist. // This should never be used for any kind of production devices. #ifndef MBED_CONF_APP_MCC_NO_AUTO_FORMAT + printf("Certificate validation failed, trying autorecovery...\n"); if (mcc_platform_reformat_storage() != 0) { return 1; } @@ -205,6 +220,10 @@ static bool application_init_fcc(void) if (status != FCC_STATUS_SUCCESS) { return 1; } + status = mcc_platform_sotp_init(); + if (status != FCC_STATUS_SUCCESS) { + return 1; + } status = application_init_verify_cloud_configuration(); if (status != 0) { return 1; @@ -213,7 +232,6 @@ static bool application_init_fcc(void) return 1; #endif } - return 0; } diff --git a/source/blinky.cpp b/source/blinky.cpp index 344733a..1eceea6 100644 --- a/source/blinky.cpp +++ b/source/blinky.cpp @@ -22,7 +22,7 @@ #include "nanostack-event-loop/eventOS_event_timer.h" #include "mbed-trace/mbed_trace.h" -#include "common_button_and_led.h" +#include "mcc_common_button_and_led.h" #include #include @@ -59,10 +59,10 @@ Blinky::~Blinky() stop(); } -bool Blinky::start(const char* pattern, size_t length, bool pattern_restart) +bool Blinky::start(const char* pattern, size_t length, bool pattern_restart, blinky_completed_cb cb) { assert(pattern); - + _callback = cb; _restart = pattern_restart; if (_tasklet < 0) { @@ -129,6 +129,7 @@ bool Blinky::run_step() // tr_debug("patt: %s, curr: %s, delay: %d", _pattern, _curr_pattern, delay); if (delay < 0) { + _callback(); _state = STATE_IDLE; return false; } diff --git a/source/blinky.h b/source/blinky.h index acbbcc2..3438d10 100644 --- a/source/blinky.h +++ b/source/blinky.h @@ -20,7 +20,7 @@ #define __BLINKY_H__ #include "nanostack-event-loop/eventOS_event.h" - +#include "m2mresource.h" #include class Blinky @@ -30,12 +30,14 @@ class Blinky STATE_STARTED, } BlinkyState; + typedef void(*blinky_completed_cb) (void); + public: Blinky(); ~Blinky(); - bool start(const char* pattern, size_t length, bool pattern_restart); + bool start(const char* pattern, size_t length, bool pattern_restart, blinky_completed_cb cb); void stop(); @@ -58,5 +60,7 @@ class Blinky static int8_t _tasklet; + blinky_completed_cb _callback; + }; #endif /* __BLINKY_H__ */ diff --git a/source/include/app_platform_setup.h b/source/include/app_platform_setup.h new file mode 100644 index 0000000..985529c --- /dev/null +++ b/source/include/app_platform_setup.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015-2018 ARM Limited. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APP_PLATFORM_SETUP_H +#define APP_PLATFORM_SETUP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Erases client credentials and SOTP storage, will also reformat +// the external storage for Mbed OS if initial erase fail. +int mcc_platform_reset_storage(void); + +// Initialize common details for fcc. +int mcc_platform_fcc_init(void); + +// For developer-mode only, (re)initializes the RoT and for non-TRNG boards +// also the entropy. +int mcc_platform_sotp_init(void); + +// Reverse the resource allocations done by mcc_platform_fcc_init(). +void mcc_platform_fcc_finalize(void); + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef APP_PLATFORM_SETUP_H diff --git a/source/platform/Linux/common_button_and_led.c b/source/platform/Linux/mcc_common_button_and_led.c similarity index 96% rename from source/platform/Linux/common_button_and_led.c rename to source/platform/Linux/mcc_common_button_and_led.c index ddd98f1..3662917 100644 --- a/source/platform/Linux/common_button_and_led.c +++ b/source/platform/Linux/mcc_common_button_and_led.c @@ -18,8 +18,8 @@ // INCLUDES /////////// -#include "common_config.h" -#include "common_button_and_led.h" +#include "mcc_common_config.h" +#include "mcc_common_button_and_led.h" #include #include diff --git a/source/platform/Linux/common_setup.c b/source/platform/Linux/mcc_common_setup.c similarity index 97% rename from source/platform/Linux/common_setup.c rename to source/platform/Linux/mcc_common_setup.c index a916659..e1168d1 100644 --- a/source/platform/Linux/common_setup.c +++ b/source/platform/Linux/mcc_common_setup.c @@ -24,11 +24,11 @@ #include #include -#include "common_setup.h" -#include "common_config.h" +#include "mcc_common_setup.h" +#include "mcc_common_config.h" #include "pal.h" -#include "common_button_and_led.h" +#include "mcc_common_button_and_led.h" //////////////////////////////////////// // PLATFORM SPECIFIC DEFINES & FUNCTIONS diff --git a/source/platform/include/common_button_and_led.h b/source/platform/include/mcc_common_button_and_led.h similarity index 90% rename from source/platform/include/common_button_and_led.h rename to source/platform/include/mcc_common_button_and_led.h index 40523ad..aaf450c 100644 --- a/source/platform/include/common_button_and_led.h +++ b/source/platform/include/mcc_common_button_and_led.h @@ -18,8 +18,8 @@ // INCLUDES /////////// -#ifndef COMMON_BUTTON_AND_LED_H -#define COMMON_BUTTON_AND_LED_H +#ifndef MCC_COMMON_BUTTON_AND_LED_H +#define MCC_COMMON_BUTTON_AND_LED_H #include @@ -41,4 +41,4 @@ uint8_t mcc_platform_init_button_and_led(void); #ifdef __cplusplus } #endif -#endif // COMMON_BUTTON_AND_LED_H +#endif // MCC_COMMON_BUTTON_AND_LED_H diff --git a/source/platform/include/common_config.h b/source/platform/include/mcc_common_config.h similarity index 70% rename from source/platform/include/common_config.h rename to source/platform/include/mcc_common_config.h index 9834105..f552fd9 100644 --- a/source/platform/include/common_config.h +++ b/source/platform/include/mcc_common_config.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef COMMON_CONFIG_H -#define COMMON_CONFIG_H +#ifndef MCC_COMMON_CONFIG_H +#define MCC_COMMON_CONFIG_H /* #define PLATFORM_ENABLE_BUTTON 1 for enabling button.*/ #ifndef PLATFORM_ENABLE_BUTTON @@ -27,11 +27,5 @@ #define PLATFORM_ENABLE_LED 0 #endif -// Resets storage to an empty state. -// Use this function when you want to clear storage from all the factory-tool generated data and user data. -// After this operation device must be injected again by using factory tool or developer certificate. -#ifndef RESET_STORAGE -#define RESET_STORAGE 0 -#endif -#endif /* COMMON_CONFIG_H */ +#endif /* MCC_COMMON_CONFIG_H */ diff --git a/source/platform/include/common_setup.h b/source/platform/include/mcc_common_setup.h similarity index 82% rename from source/platform/include/common_setup.h rename to source/platform/include/mcc_common_setup.h index ab50172..5fad04e 100644 --- a/source/platform/include/common_setup.h +++ b/source/platform/include/mcc_common_setup.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef COMMON_SETUP_H -#define COMMON_SETUP_H +#ifndef MCC_COMMON_SETUP_H +#define MCC_COMMON_SETUP_H #include @@ -44,20 +44,10 @@ void *mcc_platform_get_network_interface(void); // Format storage int mcc_platform_reformat_storage(void); -// Reset storage -int mcc_platform_reset_storage(void); - // initialize common details for storage for storing KCM data etc. // creates default folders, reformat. int mcc_platform_storage_init(void); -// initialize common details for fcc. -// reset storage to default if required. -int mcc_platform_fcc_init(void); - -// reverse the resource allocations done by mcc_platform_fcc_init() -void mcc_platform_fcc_finalize(void); - // Wait void mcc_platform_do_wait(int timeout_ms); @@ -74,4 +64,4 @@ int mcc_platform_run_program(main_t mainFunc); } #endif -#endif // #ifndef COMMON_SETUP_H +#endif // #ifndef MCC_COMMON_SETUP_H diff --git a/source/platform/mbed-os/common_button_and_led.cpp b/source/platform/mbed-os/mcc_common_button_and_led.cpp similarity index 96% rename from source/platform/mbed-os/common_button_and_led.cpp rename to source/platform/mbed-os/mcc_common_button_and_led.cpp index 75fd1de..624bbb1 100644 --- a/source/platform/mbed-os/common_button_and_led.cpp +++ b/source/platform/mbed-os/mcc_common_button_and_led.cpp @@ -19,8 +19,8 @@ /////////// #include "mbed.h" -#include "common_config.h" -#include "common_button_and_led.h" +#include "mcc_common_config.h" +#include "mcc_common_button_and_led.h" #include #if PLATFORM_ENABLE_BUTTON diff --git a/source/platform/mbed-os/common_setup.cpp b/source/platform/mbed-os/mcc_common_setup.cpp similarity index 98% rename from source/platform/mbed-os/common_setup.cpp rename to source/platform/mbed-os/mcc_common_setup.cpp index fee49ba..6f38f32 100644 --- a/source/platform/mbed-os/common_setup.cpp +++ b/source/platform/mbed-os/mcc_common_setup.cpp @@ -25,8 +25,8 @@ #endif #include "mbed.h" -#include "common_setup.h" -#include "common_config.h" +#include "mcc_common_setup.h" +#include "mcc_common_config.h" // This is for single or dual partition mode. This is supposed to be used with storage for data e.g. SD card. // Enable by 1/disable by 0 @@ -73,7 +73,7 @@ #endif #ifndef SECONDARY_PARTITION_START -#define SECONDARY_PARTITION_START PRIMARY_PARTITION_SIZE +#define SECONDARY_PARTITION_START PRIMARY_PARTITION_SIZE #endif #ifndef SECONDARY_PARTITION_SIZE @@ -239,6 +239,7 @@ static int mcc_platform_init_and_mount_partition(FileSystem **fs, BlockDevice** } status = (**part).init(); if (status != 0) { + (**part).deinit(); printf("Init of partition %d fail !!!\n", number_of_partition); return status; } @@ -249,6 +250,7 @@ static int mcc_platform_init_and_mount_partition(FileSystem **fs, BlockDevice** else { status = (**part).init(); if (status != 0) { + (**part).deinit(); printf("Init of partition %d fail !!!\n", number_of_partition); return status; } @@ -427,7 +429,7 @@ int mcc_platform_run_program(main_t mainFunc) void mcc_platform_sw_build_info(void) { printf("Application ready. Build at: " __DATE__ " " __TIME__ "\n"); - + // The Mbed OS' master branch does not define the version numbers at all, so we need // some ifdeffery to keep compilations running. #if defined(MBED_MAJOR_VERSION) && defined(MBED_MINOR_VERSION) && defined(MBED_PATCH_VERSION) diff --git a/source/platform/pal_plat_rot_insecure.c b/source/platform/pal_plat_rot_insecure.c index cb4aff5..68a2fe5 100644 --- a/source/platform/pal_plat_rot_insecure.c +++ b/source/platform/pal_plat_rot_insecure.c @@ -15,6 +15,9 @@ */ #include "pal.h" +#include "mbed-trace/mbed_trace.h" + +#define TRACE_GROUP "ROT" #define PAL_DEVICE_KEY_SIZE_IN_BYTES 16 @@ -29,7 +32,7 @@ palStatus_t pal_plat_osGetRoTFromHW(uint8_t *keyBuf, size_t keyLenBytes) static bool runOnce = true; if (runOnce) { - PAL_LOG(WARN, "You are using insecure Root Of Trust implementation"); + tr_warn("You are using insecure Root Of Trust implementation"); runOnce = false; } diff --git a/source/resource.cpp b/source/resource.cpp index dfe98ed..38a50bc 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -25,7 +25,7 @@ M2MResource* add_resource(M2MObjectList *list, uint16_t object_id, uint16_t instance_id, uint16_t resource_id, const char *resource_type, M2MResourceInstance::ResourceType data_type, M2MBase::Operation allowed, const char *value, bool observable, void *cb, - void *notification_status_cb) + void *message_status_cb) { M2MObject *object = NULL; M2MObjectInstance* object_instance = NULL; @@ -65,12 +65,12 @@ M2MResource* add_resource(M2MObjectList *list, uint16_t object_id, uint16_t inst } //Set allowed operations for accessing the resource. resource->set_operation(allowed); - if (observable) { - resource->set_notification_delivery_status_cb( - (void(*)(const M2MBase&, - const NoticationDeliveryStatus, - void*))notification_status_cb, NULL); - } + + resource->set_message_delivery_status_cb( + (void(*)(const M2MBase&, + const M2MBase::MessageDeliveryStatus, + const M2MBase::MessageType, + void*))message_status_cb, NULL); //Set callback of PUT or POST operation is enabled. //NOTE: This function does not support setting them both. diff --git a/source/resource.h b/source/resource.h index 9b8eded..4aad8c1 100644 --- a/source/resource.h +++ b/source/resource.h @@ -47,8 +47,7 @@ * NOTE: This function is not designed to support setting both * GET_PUT_ALLOWED and POST_ALLOWED for parameter allowed * at the same time. - * \param notification_status_cb Function pointer to notification_delivery_status_cb - * if resource is set to be observable. + * \param message_status_cb Function pointer to message_status_cb */ M2MResource* add_resource(M2MObjectList *list, uint16_t object_id, @@ -60,6 +59,6 @@ M2MResource* add_resource(M2MObjectList *list, const char *value, bool observable, void *cb, - void *notification_status_cb); + void *message_status_cb); #endif //RESOURCE_H diff --git a/source/simplem2mclient.h b/source/simplem2mclient.h index adaf6b6..c555ea5 100644 --- a/source/simplem2mclient.h +++ b/source/simplem2mclient.h @@ -22,7 +22,7 @@ #include #include "mbed-cloud-client/MbedCloudClient.h" #include "m2mdevice.h" -#include "common_setup.h" +#include "mcc_common_setup.h" #include "m2mresource.h" #include "mbed-client/m2minterface.h" #include "key_config_manager.h" @@ -254,9 +254,9 @@ class SimpleM2MClient { uint16_t resource_id, const char *resource_type, M2MResourceInstance::ResourceType data_type, M2MBase::Operation allowed, const char *value, - bool observable, void *cb, void *notification_status_cb) { + bool observable, void *cb, void *message_status_cb) { return add_resource(&_obj_list, object_id, instance_id, resource_id, resource_type, data_type, - allowed, value, observable, cb, notification_status_cb); + allowed, value, observable, cb, message_status_cb); } private: diff --git a/storage-selector.lib b/storage-selector.lib index bebdd5e..9d8f2af 100644 --- a/storage-selector.lib +++ b/storage-selector.lib @@ -1 +1 @@ -https://github.com/ARMmbed/storage-selector/#fb27e04db0a9fba9153f324639643f0ecb6da097 +https://github.com/ARMmbed/storage-selector/#c44b6715bd0a00bb050b2a7a7ce3160111cd149d diff --git a/tools/combine_bootloader_with_app.py b/tools/combine_bootloader_with_app.py index 9957959..eb6bef0 100755 --- a/tools/combine_bootloader_with_app.py +++ b/tools/combine_bootloader_with_app.py @@ -193,6 +193,9 @@ def addr_arg(s): 'k64f': { 'mem_start': '0x0' }, + 'k66f': { + 'mem_start': '0x0' + }, 'ublox_evk_odin_w2': { 'mem_start': '0x08000000' }, diff --git a/tools/mbed-bootloader-k64f-block_device-sotp-v3_3_0.bin b/tools/mbed-bootloader-k64f-block_device-sotp-v3_3_0.bin deleted file mode 100644 index 0516984..0000000 Binary files a/tools/mbed-bootloader-k64f-block_device-sotp-v3_3_0.bin and /dev/null differ diff --git a/tools/mbed-bootloader-k64f-block_device-sotp-v3_4_0.bin b/tools/mbed-bootloader-k64f-block_device-sotp-v3_4_0.bin new file mode 100644 index 0000000..cd96853 Binary files /dev/null and b/tools/mbed-bootloader-k64f-block_device-sotp-v3_4_0.bin differ diff --git a/tools/mbed-bootloader-k66f-block_device-sotp-v3_4_0.bin b/tools/mbed-bootloader-k66f-block_device-sotp-v3_4_0.bin new file mode 100644 index 0000000..099cc8f Binary files /dev/null and b/tools/mbed-bootloader-k66f-block_device-sotp-v3_4_0.bin differ diff --git a/tools/mbed-bootloader-nucleo_f411re-block_device-sotp-v3_3_0_2f113f3.bin b/tools/mbed-bootloader-nucleo_f411re-block_device-sotp-v3_3_0_2f113f3.bin deleted file mode 100755 index 345cfb8..0000000 Binary files a/tools/mbed-bootloader-nucleo_f411re-block_device-sotp-v3_3_0_2f113f3.bin and /dev/null differ diff --git a/tools/mbed-bootloader-nucleo_f411re-block_device-sotp-v3_4_0.bin b/tools/mbed-bootloader-nucleo_f411re-block_device-sotp-v3_4_0.bin new file mode 100644 index 0000000..529583c Binary files /dev/null and b/tools/mbed-bootloader-nucleo_f411re-block_device-sotp-v3_4_0.bin differ diff --git a/tools/mbed-bootloader-nucleo_f429zi-block_device-sotp-v3_3_0.bin b/tools/mbed-bootloader-nucleo_f429zi-block_device-sotp-v3_3_0.bin deleted file mode 100644 index 71729e9..0000000 Binary files a/tools/mbed-bootloader-nucleo_f429zi-block_device-sotp-v3_3_0.bin and /dev/null differ diff --git a/tools/mbed-bootloader-nucleo_f429zi-block_device-sotp-v3_4_0.bin b/tools/mbed-bootloader-nucleo_f429zi-block_device-sotp-v3_4_0.bin new file mode 100644 index 0000000..27b7049 Binary files /dev/null and b/tools/mbed-bootloader-nucleo_f429zi-block_device-sotp-v3_4_0.bin differ diff --git a/tools/mbed-bootloader-ublox_evk_odin_w2-block_device-sotp-v3_3_0.bin b/tools/mbed-bootloader-ublox_evk_odin_w2-block_device-sotp-v3_3_0.bin deleted file mode 100644 index 6ac03da..0000000 Binary files a/tools/mbed-bootloader-ublox_evk_odin_w2-block_device-sotp-v3_3_0.bin and /dev/null differ diff --git a/tools/mbed-bootloader-ublox_evk_odin_w2-block_device-sotp-v3_4_0.bin b/tools/mbed-bootloader-ublox_evk_odin_w2-block_device-sotp-v3_4_0.bin new file mode 100644 index 0000000..5076878 Binary files /dev/null and b/tools/mbed-bootloader-ublox_evk_odin_w2-block_device-sotp-v3_4_0.bin differ diff --git a/update_default_resources.c b/update_default_resources.c index c037eb2..ddb6fa1 100644 --- a/update_default_resources.c +++ b/update_default_resources.c @@ -23,10 +23,10 @@ #include #ifdef MBED_CLOUD_DEV_UPDATE_ID -const uint8_t arm_uc_vendor_id[16] = { "dev_manufacturer" }; +const uint8_t arm_uc_vendor_id[] = { "dev_manufacturer" }; const uint16_t arm_uc_vendor_id_size = sizeof(arm_uc_vendor_id); -const uint8_t arm_uc_class_id[16] = { "dev_model_number" }; +const uint8_t arm_uc_class_id[] = { "dev_model_number" }; const uint16_t arm_uc_class_id_size = sizeof(arm_uc_class_id); #endif diff --git a/update_ui_example.cpp b/update_ui_example.cpp index 76284a0..d03d3ed 100644 --- a/update_ui_example.cpp +++ b/update_ui_example.cpp @@ -25,8 +25,6 @@ static MbedCloudClient* _client; -#ifdef ARM_UPDATE_CLIENT_VERSION_VALUE -#if ARM_UPDATE_CLIENT_VERSION_VALUE > 101000 void update_ui_set_cloud_client(MbedCloudClient* client) { _client = client; @@ -69,8 +67,6 @@ void update_authorize(int32_t request) break; } } -#endif -#endif void update_progress(uint32_t progress, uint32_t total) { diff --git a/update_ui_example.h b/update_ui_example.h index d0e2768..0aeed8e 100644 --- a/update_ui_example.h +++ b/update_ui_example.h @@ -23,15 +23,11 @@ #ifdef MBED_CLOUD_CLIENT_SUPPORT_UPDATE -#ifdef ARM_UPDATE_CLIENT_VERSION_VALUE -#if ARM_UPDATE_CLIENT_VERSION_VALUE > 101000 /** * @brief Function for authorizing firmware downloads and reboots. * @param request The request under consideration. */ void update_authorize(int32_t request); -#endif -#endif /** * @brief Callback function for reporting the firmware download progress.