Example using the UBLOX_C030_U201 board to communicate over a cellular link with Mbed Cloud.

Files at this revision

API Documentation at this revision

Comitter:
MarceloSalazar
Date:
Sun Oct 14 17:06:16 2018 +0100
Parent:
1:eabbeaa37715
Commit message:
Add support for FW Update

Changed in this revision

bootloader/mbed-bootloader-C030_U201.bin Show annotated file Show diff for this revision Revisions of this file
bootloader/mbed_app.json Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
simple-mbed-cloud-client.lib Show annotated file Show diff for this revision Revisions of this file
diff -r eabbeaa37715 -r a34e80e223c2 bootloader/mbed-bootloader-C030_U201.bin
Binary file bootloader/mbed-bootloader-C030_U201.bin has changed
diff -r eabbeaa37715 -r a34e80e223c2 bootloader/mbed_app.json
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bootloader/mbed_app.json	Sun Oct 14 17:06:16 2018 +0100
@@ -0,0 +1,65 @@
+{
+    "macros": [
+        "MBEDTLS_USER_CONFIG_FILE=\"bootloader_mbedtls_user_config.h\"",
+        "MAX_COPY_RETRIES=1",
+        "SHOW_PROGRESS_BAR=1",
+        "MAX_BOOT_RETRIES=3",
+        "ARM_UC_USE_PAL_CRYPTO=0",
+        "ARM_BOOTLOADER_USE_NVSTORE_ROT=1",
+        "ARM_UC_USE_PAL_BLOCKDEVICE=1",
+        "ARM_UC_PAAL_TRACE_ENABLE=0",
+        "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE",
+        "DEFAULT_MAX_APPLICATION_SIZE=(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - MBED_CONF_APP_APPLICATION_START_ADDRESS)",
+        "DISABLE_ERROR_DESCRIPTION=1",
+        "Mutex=PlatformMutex"
+    ],
+    "config": {
+        "application-start-address": {
+            "help": "Address to the beginning of the active application firmware in flash",
+            "value": null
+        },
+        "application-jump-address": {
+            "help": "Jump address for running the active application firmware",
+            "value": null
+        },
+        "max-application-size": {
+            "help": "Maximum size of the active application",
+            "value": null
+        },
+        "flash-start-address": {
+            "help": "Start address of internal flash. Only used in this config to help the definition of other macros.",
+            "value": null
+        },
+        "flash-size": {
+            "help": "Total size of internal flash. Only used in this config to help the definition of other macros.",
+            "value": null
+        }
+    },
+    "target_overrides": {
+        "*": {
+            "target.features_remove": ["LWIP"],
+            "target.features_add"   : ["COMMON_PAL"],
+            "platform.stdio-baud-rate"    : 115200,
+            "platform.stdio-flush-at-exit": false,
+            "update-client.storage-address"  : "(1024*1024*64)",
+            "update-client.storage-size"     : "(1024*1024*2)",
+            "update-client.storage-locations": 1,
+            "update-client.firmware-header-version": "2"
+        },
+        "UBLOX_C030_U201": {
+            "flash-start-address"              : "0x08000000",
+            "flash-size"                       : "(1024*1024)",
+            "nvstore.area_1_address"           : "(0x080C0000)",
+            "nvstore.area_1_size"              : "(128*1024)",
+            "nvstore.area_2_address"           : "(0x080E0000)",
+            "nvstore.area_2_size"              : "(128*1024)",
+            "update-client.application-details": "(MBED_CONF_APP_FLASH_START_ADDRESS+64*1024)",
+            "application-start-address"        : "(MBED_CONF_APP_FLASH_START_ADDRESS+65*1024)",
+            "max-application-size"             : "DEFAULT_MAX_APPLICATION_SIZE",
+            "sd.SPI_MOSI"  : "D11",
+            "sd.SPI_MISO"  : "D12",
+            "sd.SPI_CLK"   : "D13",
+            "sd.SPI_CS"    : "D10"
+        }
+    }
+}
diff -r eabbeaa37715 -r a34e80e223c2 main.cpp
--- a/main.cpp	Sun Oct 14 12:07:03 2018 +0000
+++ b/main.cpp	Sun Oct 14 17:06:16 2018 +0100
@@ -106,10 +106,10 @@
 
     // Connect to the internet (DHCP is expected to be on)
     printf("Connecting to the network using Cellular, please wait up to 180 seconds for a connection...\n");
-    
+
     // Connect to the internet (DHCP is expected to be on)
     net = NetworkInterface::get_default_instance();
-    
+
     nsapi_error_t status = net->connect();
 
     if (status != NSAPI_ERROR_OK) {
@@ -120,7 +120,7 @@
         printf("activated your board [once] at http://www.jtiotsims.com/ubxC030).\n");
         return -1;
     }
-    
+
     printf("Connected to the network successfully. IP address: %s\n", net->get_ip_address());
 
     // SimpleMbedCloudClient handles registering over LwM2M to Mbed Cloud
@@ -163,4 +163,4 @@
     // You can easily run the eventQueue in a separate thread if required
     eventQueue.dispatch_forever();
 }
-#endif
\ No newline at end of file
+#endif
diff -r eabbeaa37715 -r a34e80e223c2 mbed_app.json
--- a/mbed_app.json	Sun Oct 14 12:07:03 2018 +0000
+++ b/mbed_app.json	Sun Oct 14 17:06:16 2018 +0100
@@ -12,17 +12,42 @@
     ],
     "target_overrides": {
         "*": {
-            "platform.stdio-baud-rate": 115200,
-            "platform.stdio-convert-newlines": true,
+            "target.features_add"   : ["COMMON_PAL"],
+            "platform.stdio-baud-rate"    : 115200,
+            "platform.stdio-flush-at-exit": false,
             "update-client.storage-address"  : "(1024*1024*64)",
             "update-client.storage-size"     : "(1024*1024*2)",
-            "update-client.storage-locations": "1",
-            "mbed-trace.enable": null
-        }, 
+            "update-client.storage-locations": 1,
+            "update-client.firmware-header-version": "2"
+        },
         "UBLOX_C030_U201": {
             "target.network-default-interface-type" : "CELLULAR",
-            "target.features_add"                   : ["STORAGE"],
+            "target.features_add"                   : ["STORAGE","BOOTLOADER"],
             "target.components_add"                 : ["SD"],
+            "target.app_offset"                     : "0x10400",
+            "target.header_offset"                  : "0x10000",
+            "target.bootloader_img"                 : "bootloader/mbed-bootloader-C030_U201.bin",
+            "target.header_format": [
+                ["magic", "const", "32be", "0x5a51b3d4"],
+                ["version", "const", "32be", "2"],
+                ["firmwareVersion", "timestamp", "64be", null],
+                ["firmwareSize", "size", "64be", ["application"]],
+                ["firmwareHash", "digest", "SHA256", "application"],
+                ["hashpad", "const", "64be", "0"],
+                ["hashpad", "const", "64be", "0"],
+                ["hashpad", "const", "64be", "0"],
+                ["hashpad", "const", "64be", "0"],
+                ["campaign", "const", "64be", "0"],
+                ["campaign", "const", "64be", "0"],
+                ["firmwareSignatureSize", "const", "32be", "0"],
+                ["headerCRC", "digest", "CRCITT32be", "header"]],
+            "sotp-section-1-address"                : "(0x080C0000)",
+            "sotp-section-1-size"                   : "(128*1024)",
+            "sotp-section-2-address"                : "(0x080E0000)",
+            "sotp-section-2-size"                   : "(128*1024)",
+            "sotp-num-sections"                     : 2,
+            "update-client.bootloader-details"      : "0x08007300",
+            "update-client.application-details"     : "(0x08000000+64*1024)",
             "target.features_add"                   : ["LWIP"],
             "lwip.ipv4-enabled"                     : true,
             "lwip.ethernet-enabled"                 : false,
diff -r eabbeaa37715 -r a34e80e223c2 simple-mbed-cloud-client.lib
--- a/simple-mbed-cloud-client.lib	Sun Oct 14 12:07:03 2018 +0000
+++ b/simple-mbed-cloud-client.lib	Sun Oct 14 17:06:16 2018 +0100
@@ -1,1 +1,1 @@
-https://github.com/armmbed/simple-mbed-cloud-client/#f904798403e0e7d848a04dd83a392dfad6a571ec
+https://github.com/armmbed/simple-mbed-cloud-client/#8b023aa9e04bcd15ac01726c6f5b58b9422fafad