Generic Pelion Device Management example for various Renesas-based boards.
DEPRECATED
This example application is not maintained and not recommended. It uses an old version of Mbed OS, Pelion DM, and Arm toolchain. It doesn't work with Mbed Studio.
Please use: https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-pelion/
This example is known to work great on the following platforms:
- Renesas GR-LYCHEE over Wi-Fi and using SD card.
- Renesas GR-PEACH over Ethernet and using SD card.

Follow the Quick-Start instructions: https://cloud.mbed.com/quick-start
Example functionality
This example showcases the following device functionality:
- On user button click, increment Pelion LWM2M button resource.
- Allow the user to change the state of the board LED from Pelion LWM2M led_state resource and PUT request.
Instructions to use this program with Mbed CLI
1. Import the application into your desktop:
mbed import https://os.mbed.com/teams/Renesas/code/pelion-example-common cd pelion-example-common
2. Install the CLOUD_SDK_API_KEY
mbed config -G CLOUD_SDK_API_KEY <PELION_DM_API_KEY>
For instructions on how to generate your API key, please see the documentation.
3. Initialize firmware credentials (done once per repository). You can use the following command:
mbed dm init -d "<your company name in Pelion DM>" --model-name "<product model identifier>" -q --force
If above command do not work for your Mbed CLI, please consider upgrading Mbed CLI to version 1.8.x or above.
4. Compile and program:
mbed compile -t <toolchain> -m <TARGET_BOARD>
(supported toolchains : GCC_ARM / ARM / IAR)
Note
This platform and application is suitable for evaluation and initial development. For production purposes, we recommend to use a different variant with built-in security features - for more information please contact Renesas (https://en-support.renesas.com/mytickets)
Revision 0:6d2053b84a92, committed 2018-12-15
- Comitter:
- MACRUM
- Date:
- Sat Dec 15 12:47:53 2018 +0900
- Child:
- 1:c74d05affb1b
- Commit message:
- initial commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LICENSE.txt Sat Dec 15 12:47:53 2018 +0900 @@ -0,0 +1,165 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,542 @@
+# Simple Pelion Device Management Client - template application
+
+(aka Simple Mbed Cloud Client template)
+
+## Overview
+
+This is a template application for platform vendors. It demonstrates how to create a simple application that can connect to the Pelion IoT Platform service, register resources and get ready to receive a firmware update.
+
+It's intended to be forked and customized to add platform-specific features (such as sensors and actuators) and configure the connectivity and storage to work **out-of-the-box**. The template application works in **developer mode** by default.
+
+There is a mirror version of the stable (master) template application on [this location](https://os.mbed.com/teams/mbed-os-examples/code/mbed-cloud-example) to facilitate the fork and publish on os.mbed.com.
+
+## Table of Contents
+
+1. [Getting started with the application](#getting-started-with-the-application)
+2. [Porting to a new platform](#porting-to-a-new-platform)
+3. [Enabling firmware updates](#enabling-firmware-updates)
+4. [Automated testing](#automated-testing)
+5. [Known issues](#known-issues)
+
+## Getting started with the application
+
+This is a summary of the process for developers to get started and get a device connected to Pelion Device Management Client.
+
+### Mbed Online IDE
+
+1. Import the application into the Online IDE.
+2. Add the API key to establish connection.
+3. Install the developer certificate.
+4. Compile and program.
+
+### Mbed CLI tools
+
+1. Import the application into your desktop:
+
+ ```
+ mbed import https://os.mbed.com/teams/mbed-os-examples/code/mbed-cloud-example
+ cd mbed-cloud-example
+ ```
+
+2. Download the developer certificate from the Pelion Device Management [portal](https://portal.mbedcloud.com).
+3. Compile and program:
+
+ ```
+ mbed compile -t <toolchain> -m <target> -f
+ ```
+
+## Porting to a new platform
+
+### Requirements
+
+The hardware requirements for Mbed OS platforms to support Pelion Client are [here](https://cloud.mbed.com/docs/current/cloud-requirements/index.html).
+
+In general, to start creating a secure connected product, you need a microcontroller that has the following features:
+
+* RAM: 96K or more
+* Flash: 512K or more
+* True Random Number Generator (TRNG)
+* Real Time Clock (RTC)
+
+Additionally, to use the Device Management Client, the microcontroller needs to support the following in Mbed OS (latest version preferred) or in a compatible driver library:
+
+* A storage device (SDcard, SPI Flash, Data Flash)
+* IP connectivity (Ethernet, Wi-Fi, Cellular, 6LoWPAN, Thread)
+
+For the Firmware update over the air (FOTA), you need the following:
+
+* [FlashIAP](https://github.com/ARMmbed/mbed-os/blob/master/drivers/FlashIAP.h) - Flash In-Application Programming (IAP).
+* [Mbed Bootloader](https://github.com/ARMmbed/mbed-bootloader) or a compatible bootloader.
+* TCP connection - the current Firmware Download client only supports HTTP download over TCP (this will be resolved in a future release, so that CoAP blockwise transfer will be used for UDP connections).
+
+### References
+
+* Check which Mbed OS platforms are supported in the [Pelion Device Management quick-start guide](https://cloud.mbed.com/quick-start).
+* Check which storage options are available [here](https://os.mbed.com/docs/latest/reference/storage.html).
+* Check which network options are available [here](https://os.mbed.com/docs/latest/reference/network-socket.html).
+
+
+### Porting steps
+
+Supporting a new derivative platform requires the following steps:
+
+* Fork the template and create an example application for your platform in https://os.mbed.com/teams/your-team
+* Change the connectivity interface. Ethernet is the default - see `main.cpp`.
+* Change the filesystem and/or the block device for storage. FAT filesystem over SD card is the default. See `main.cpp`.
+* (Optional) Make minor changes in `mbed_app.json` to support multiple platforms with same connectivity and storage.
+* (Recommended) Remove information and files not related to the platform you're porting.
+
+<span class="notes">**Note:** Make sure that the application works out-of-the-box and no changes are required in the `main.cpp` file nor `mbed_app.json`. The goal is to deliver a great UX to our developers.</span>
+
+### Porting example
+
+In this example, an app with an SD card and on-chip Ethernet is taken to a custom board that has an MCU + Wi-Fi module.
+
+#### Changing the storage option
+
+<span class="notes">**Note:** From Mbed OS 5.10+, block device drivers have been moved to `mbed-os/components/storage/blockdevice` and many platforms have a default block device interface. </span>
+
+##### Non-default storage configuration
+
+If you wish to override the default storage configuration or add support for storage, you can add the configuration into the `mbed_app.json` file. For example:
+
+```json
+ "NUCLEO_F429ZI": {
+ "target.features_add" : ["STORAGE"],
+ "target.components_add": ["SD"],
+ "sd.SPI_MOSI" : "PE_6",
+ "sd.SPI_MISO" : "PE_5",
+ "sd.SPI_CLK" : "PE_2",
+ "sd.SPI_CS" : "PE_4"
+ }
+```
+
+##### Example of default storage configuration using Mbed OS 5.10+
+
+1. Include the header files for the FAT file system:
+
+ ```cpp
+ #include "FATFileSystem.h"
+ ```
+
+2. Declare the global object for the default block device driver:
+
+ ```cpp
+ BlockDevice* bd = BlockDevice::get_default_instance();
+ ```
+
+3. Declare the global objects for the file system:
+
+ ```cpp
+ FATFileSystem fs("sd", bd);
+ ```
+
+##### Example of SD card configuration using Mbed OS 5.9 and older
+
+1. Add the SD card driver (`sd-driver.lib`) if it is not already added. On the command line:
+
+ ```
+ mbed add https://github.com/armmbed/sd-driver
+ ```
+
+2. Include the header files for the SD driver and FAT file system:
+
+ ```cpp
+ #include "SDBlockDevice.h"
+ #include "FATFileSystem.h"
+ ```
+
+3. Declare the global objects for the SD card and file system:
+
+ ```cpp
+ SDBlockDevice bd(SPI_MOSI, SPI_MISO, SPI_CLK, SPI_CS);
+ FATFileSystem fs("sd", &sd);
+ ```
+
+<span class="notes">**Note:** The `SPI_*` macros represent the pin names. The names can be defined in a variety of places including the sd-driver, your project’s configuration file (`mbed_app.json`) or the `pinnames.h` file for the target that defines the default pin names. You can use other pin names depending on the platform and the connections.</span>
+
+For example, if the SPI signals for the SD card interface are connected on an Arduino compatible shield, you may define them like this:
+
+```cpp
+SDBlockDevice sd(D11, D12, D13, D10);
+```
+
+<span class="notes">**Note:** The default mounting point is `sd`. This can be overridden in the `mbed_app.json` file using `PAL_FS_MOUNT_POINT_PRIMARY` and `PAL_FS_MOUNT_POINT_SECONDARY`. See [documentation](https://cloud.mbed.com/docs/current/porting/port-filesystem.html).</span>
+
+##### For SPI Flash (devices that support SFDP)
+
+<Please note that this section of the document is under construction. More information is needed.>
+
+1. Add the SPI Flash driver (`spif-driver`) if it is not already added:
+
+ ```
+ mbed add https://github.com/armmbed/spif-driver
+ ```
+
+2. Include the header files for the SPI Flash driver and LitteFS file system. For SPI Flash, we recommend LittleFS file system which supports wear leveling:
+
+ ```cpp
+ #include "SPIFBlockDevice.h"
+ #include "LittleFileSystem.h"
+ ```
+
+3. Declare the global objects for the SD card and file system:
+
+ ```cpp
+ SPIFBlockDevice spif(SPI_MOSI, SPI_MISO, SPI_CLK, SPI_CS);
+ LittleFileSystem fs("fs", &spif);
+ ```
+
+4. Update the construction of the `SimpleMbedCloudClient` object to pass in the file system and block device:
+
+ ```cpp
+ SimpleMbedCloudClient client(&net, &spif, &fs);
+ ```
+
+#### Changing the network interface
+
+<span class="notes">**Note:** From Mbed OS 5.10, platforms have a default network interface defined in `mbed-os/targets/targets.json`. If you wish to override the default configuration, you can add the configuration into the `mbed_app.json` file.</span>
+
+##### Non-default network configuration
+
+If you wish to override the default network configuration, you can add the configuration into the `mbed_app.json` file. For example:
+
+```json
+ "NUCLEO_F429ZI": {
+ "target.network-default-interface-type" : "WIFI",
+ "esp8266.rx" : "D0",
+ "esp8266.tx" : "D1",
+ "esp8266.provide-default" : true,
+ "nsapi.default-wifi-security" : "WPA_WPA2",
+ "nsapi.default-wifi-ssid" : "\"SSID\"",
+ "nsapi.default-wifi-password" : "\"Password\""
+ }
+```
+
+##### Example of network initialization for Ethernet using Mbed OS 5.10+
+
+1. Declare the network interface object:
+
+ ```
+ EthernetInterface * net = NetworkInterface::get_default_instance();
+ ```
+
+2. Connect the interface:
+
+ ```
+ status = net->connect();
+ ```
+
+3. When the Client is started, pass the network interface:
+ ```
+ SimpleMbedCloudClient client(net, &sd, &fs);
+ ```
+
+##### Example of network initialization for Wi-Fi using Mbed OS 5.10+
+
+1. Declare the network interface object:
+
+ ```
+ WiFiInterface *net = WiFiInterface::get_default_instance();
+ ```
+
+2. Connect the interface:
+
+ ```
+ status = net->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
+ ```
+
+3. When the Client is started, pass the network interface:
+
+ ```
+ SimpleMbedCloudClient client(net, &sd, &fs);
+ ```
+
+
+##### Example of network initialization for Ethernet using Mbed OS 5.9 and older versions
+
+The Ethernet interface is included within Mbed OS, so you do not need to add a library.
+
+1. Include the header file for the interface:
+
+ ```
+ #include "EthernetInterface.h"
+ ```
+
+2. Declare the network interface object:
+
+ ```
+ EthernetInterface net;
+ ```
+
+3. Connect the interface:
+
+ ```
+ status = net.connect();
+ ```
+
+4. When the Client is started, pass the network interface:
+
+ ```
+ SimpleMbedCloudClient client(&net, &sd, &fs);
+ ```
+
+##### Example of network initialization for Wi-Fi using Mbed OS 5.9 and older versions
+
+This example references the ESP8266 Wi-Fi module, but the instructions are applicable to other modules.
+
+1. Add the ESP8266 Wi-Fi interface driver (esp8266-driver) if it is not already added:
+
+ ```
+ mbed add https://github.com/ARMmbed/esp8266-driver
+ ```
+
+ <span class="notes">**Note:** You may have to update the firmware inside the ESP8266 module.</span>
+
+2. Include the header file for the interface:
+
+ ```cpp
+ #include "ESP8266Interface.h"
+ ```
+
+3. Declare the network interface object:
+
+ ```cpp
+ ESP8266Interface net(D1, D0);
+ ```
+
+4. Connect the interface:
+
+ ```cpp
+ nsapi_error_t status = net.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
+ ```
+
+5. When the Client is started, pass the network interface:
+
+ ```cpp
+ SimpleMbedCloudClient client(&net, &sd, &fs);
+ ```
+
+6. Add the Wi-Fi credentials information in `mbed_app.json` (located at the top level of the example project):
+
+ ```json
+ "config": {
+ "wifi-ssid": {
+ "help": "WiFi SSID",
+ "value": "\"SSID\""
+ },
+ "wifi-password": {
+ "help": "WiFi Password",
+ "value": "\"PASSWORD\""
+ }
+ }
+ ```
+
+#### Changing the target MCU
+
+To change the target board to another board that is supported by Mbed OS, simply change the target name.
+
+##### Using the command line
+
+Use the -m option. For example:
+
+```
+mbed compile -m Hexiwear -t GCC_ARM
+```
+
+##### Using the online compiler
+
+Click the platform name on the top right corner, then select another platform.
+
+##### Using an IDE
+
+First re-export (create project files) for the target with the command line. For example:
+
+```
+mbed export -m Hexiwear -i uvision
+```
+
+#### Creating a custom target board
+
+Read the Mbed OS [Contributing](https://os.mbed.com/docs/latest/reference/porting-targets.html) documentation on how to add a new target.
+
+#### Update the application logic
+
+The template example uses a ticker object to periodically fire a software interrupt to simulate button presses. Let’s say you want to make an actual button press.
+
+By default, there is a Ticker object, which fires every five seconds and invokes a callback function:
+
+```cpp
+Ticker timer;
+timer.attach(eventQueue.event(&fake_button_press), 5.0);
+```
+
+This callback function changes the `button_res` resource:
+
+```cpp
+void fake_button_press() {
+ int v = button_res->get_value_int() + 1;
+
+ button_res->set_value(v);
+
+ printf("Simulated button clicked %d times\n", v);
+}
+```
+
+If you want to change this to an actual button, here is how to do it:
+
+1. Remove:
+
+ ```cpp
+ Ticker timer;
+ timer.attach(eventQueue.event(&fake_button_press), 5.0);
+ ```
+
+2. Declare an `InterruptIn` object on the button, and attach the callback function to the `fall` handler:
+
+ ```cpp
+ InterruptIn btn(BUTTON1);
+ btn.fall(eventQueue.event(&fake_button_press), 5.0);
+ ```
+
+3. Rename `fake_button_press` to `real_button_press`.
+
+
+#### Pelion Client v1.3.x SOTP-specific changes
+
+The version v1.3+ introduces a new feature called Software One-Time Programming (SOTP) that makes use of the internal flash of the MCU as an One-Time-Programmable section. It stores the keys required to decrypt the credentials stored in the persistent storage. Read more on this in the [porting documentation](https://cloud.mbed.com/docs/current/porting/changing-a-customized-porting-layer.html#rtos-module) under the RTOS module section.
+
+The flash must be divided into two sections (default 2, maximum 2) for your target. You need to modify the `mbed_app.json` file as follows:
+
+1. Add a section to the `target_overrides` with SOTP addresses and sizes.
+
+ You can find the memory map information in the reference manual of your MCU. Note the sectors should be placed at the last two sectors of the flash, so the SOTP region is preserved during drag and drop programming of binaries. This is an example for the NUCLEO_F429ZI board:
+
+ ```json
+ "NUCLEO_F429ZI": {
+ "app.sotp-section-1-address": "(0x081C0000)",
+ "app.sotp-section-1-size" : "(128*1024)",
+ "app.sotp-section-2-address": "(0x081E0000)",
+ "app.sotp-section-2-size" : "(128*1024)"
+ }
+ ```
+
+2. Add the macro definition to the "config" section. Note that the address and size macros are already provided. You only need to add the macro for the number of sections:
+
+ ```json
+ "sotp-num-sections": {
+ "help": "Number of SOTP sections",
+ "macro_name": "PAL_INT_FLASH_NUM_SECTIONS",
+ "value": null
+ }
+ ```
+
+## Enabling firmware updates
+
+Mbed OS 5.10 and Mbed CLI 1.8 simplifies the process to enable and perform Firmware Updates. Here is a summary on how to configure the device and verify its correct behaviour.
+
+For full documentation about bootloaders and firmware update, read the following documents:
+
+- [Introduccion to bootloaders](https://os.mbed.com/docs/latest/porting/bootloader.html)
+- [Creating and using a bootloader](https://os.mbed.com/docs/latest/tutorials/bootloader.html)
+- [Bootloader configuration in Mbed OS](https://os.mbed.com/docs/latest/tools/configuring-tools.html)
+- [Mbed Bootloader for Pelion Device Management Client](https://github.com/ARMmbed/mbed-bootloader)
+- [Updating devices with Arm Mbed CLI](https://os.mbed.com/docs/latest/tools/cli-update.html)
+
+This is a summary to use Arm Mbed OS managed bootloaders.
+
+#### Preparing a bootloader
+
+If Mbed OS contains a default pre-built bootloader in `mbed-os/feature/FEATURE_BOOTLOADER`, then you can skip this section.
+
+Otherwise, you'll need to compile the [mbed-bootloader](https://github.com/armmbed/mbed-bootloader) and add it to your application. Once it's done, we recommend to send a Pull-Requests to [Mbed OS](https://github.com/ARMmbed/mbed-os) to contribute with a default bootloader for your Mbed Enabled platform.
+
+You can see an example of bootloader configuration for the `NUCLEO_F429ZI` in `bootloader/mbed_app.json`. This is compatible with the `mbed_app.json` configuration in this template application.
+
+<span class="notes">**Note:** Make sure the configuration for the bootloader (`mbed_app.json`) corresponds with the configuration of your application's `mbed_app.json`, otherwise the bootloader may not be able to find an application or apply the new firmware.</span>
+
+#### Enabling the application to use a bootloader
+
+##### Option 1: default & prebuilt bootloader
+
+If Mbed OS contains a prebuilt bootloader for the target, then you can indicate to use it in the `mbed_app.json`. For example:
+
+```
+ {
+ "target_overrides": {
+ "K64F": {
+ "target.features_add": ["BOOTLOADER"]
+ }
+ }
+ }
+```
+
+##### Option 2: custom bootloader
+
+If you'd like to overide a default bootloader or use a custom one available in the application, then indicate the path to the booloader, `app_offset` and `header_offset` parameters in `mbed_app.json`. For example:
+
+```
+ "target_overrides": {
+ "K64F": {
+ "target.app_offset": "0xa400",
+ "target.header_offset": "0xa000",
+ "target.bootloader_img": "bootloader/my_bootloader.bin"
+ }
+ }
+```
+
+You may need to specify `header_format` as well. You could include the default header format from [Mbed OS](https://github.com/ARMmbed/mbed-os/blob/master/features/FEATURE_BOOTLOADER/mbed_lib.json) by adding `"target.features_add": ["BOOTLOADER"]`.
+
+#### Verifying that firmware update works
+
+Follow these steps to generate a manifest, compile and perform a firmware update of your device:
+
+1. Configure the API key for your Pelion account.
+
+ If you don't have an API key available, then login in [Pelion IoT Platform portal](https://portal.mbedcloud.com/), navigate to 'Access Management', 'API keys' and create a new one. Then specify the API key as global `mbed` configuration:
+
+ ```
+ mbed config -G CLOUD_SDK_API_KEY <your-api-key>
+ ```
+
+2. Initialize the device management feature:
+
+ ```
+ mbed dm init -d "company.com" --model-name "product-model" -q --force
+ ```
+
+3. Compile the application, include the firware update credentials generated before, merge with the bootloader and program the device:
+
+ ```
+ mbed compile -t <toolchain> -m <target> -c -f
+ ```
+
+4. Open a serial terminal, verify the application boots and is able to register to the Device Management service. Write down the `<endpoint ID>`, as it's required to identify the device to perform a firmware update.
+
+5. Update the firmware of the device through Mbed CLI:
+
+ ```
+ mbed dm update device -D <device ID> -t <toolchain> -m <target>
+ ```
+
+ Inspect the logs on the device to see the update progress. It should look similar to:
+
+ ```
+ Firmware download requested
+ Authorization granted
+ Downloading: [+++- ] 6 %
+ ```
+
+ When the download completes, the firmware is verified. If everything is OK, the firmware update is applied, the device reboots and attemps to connect to the Device Management service again. The `<endpoint ID>` should be preserved.
+
+## Automated testing
+
+The Simple Pelion Client provides Greentea tests to confirm your platform works as expected. The network and storage configuration is already defined in Mbed OS 5.10, but you may want to override the configuration in `mbed_app.json`.
+
+For details on Simple Pelion Client testing, refer to the documentation [here](https://github.com/ARMmbed/simple-mbed-cloud-client#testing).
+
+This template application contains a working application and tests passing for the `K64F` and `K66F` platforms.
+
+## Known issues
+
+Please check the issues reported on github.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bootloader/LICENSE Sat Dec 15 12:47:53 2018 +0900 @@ -0,0 +1,49 @@ +Permissive Binary License + +Version 1.0, September 2015 + +Redistribution. Redistribution and use in binary form, without +modification, are permitted provided that the following conditions are +met: + +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. + +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of this software is + permitted. + +3) Redistribution as part of a software development kit must include the + accompanying file named "DEPENDENCIES" and any dependencies listed in + that file. + +4) Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +Limited patent license. The copyright holders (and contributors) grant a +worldwide, non-exclusive, no-charge, royalty-free patent license to +make, have made, use, offer to sell, sell, import, and otherwise +transfer this software, where such license applies only to those patent +claims licensable by the copyright holders (and contributors) that are +necessarily infringed by this software. This patent license shall not +apply to any combinations that include this software. No hardware is +licensed hereunder. + +If you institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the software +itself infringes your patent(s), then your rights granted under this +license shall terminate as of the date such litigation is filed. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bootloader/bootloader_app.json Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,68 @@
+{
+ "macros": [
+ "MBEDTLS_USER_CONFIG_FILE=\"bootloader_mbedtls_user_config.h\"",
+ "SHOW_PROGRESS_BAR=0",
+ "MAX_COPY_RETRIES=1",
+ "MAX_BOOT_RETRIES=3",
+ "ARM_BOOTLOADER_USE_NVSTORE_ROT=1",
+ "ARM_UC_USE_PAL_CRYPTO=0",
+ "ARM_UC_USE_PAL_BLOCKDEVICE=1",
+ "ARM_UC_PAAL_TRACE_ENABLE=0",
+ "ARM_UC_PROFILE_MBED_CLOUD_CLIENT=1",
+ "ARM_UC_FEATURE_CRYPTO_PAL=0",
+ "ARM_UC_FEATURE_CRYPTO_MBEDTLS=1",
+ "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"
+ },
+ "GR_LYCHEE": {
+ "flash-start-address" : "0x18000000",
+ "flash-size" : "(8*1024*1024)",
+ "nvstore.area_1_address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(4*1024))",
+ "nvstore.area_1_size" : "(4*1024)",
+ "nvstore.area_2_address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(4*1024))",
+ "nvstore.area_2_size" : "(4*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": "P5_6",
+ "sd.SPI_MISO": "P5_7",
+ "sd.SPI_CLK": "P5_4",
+ "sd.SPI_CS": "P5_5"
+ }
+ }
+}
Binary file bootloader/mbed-bootloader-GR_LYCHEE.bin has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/drivers/network/esp32-driver.lib Sat Dec 15 12:47:53 2018 +0900 @@ -0,0 +1,1 @@ +https://github.com/d-kato/esp32-driver/#fd159f64c1e2394d9c9add7403b48ee965342dc0 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/storage/MySystemStorage.cpp Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 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.
+ */
+#include "BlockDevice.h"
+#include "FileSystem.h"
+#include "FATFileSystem.h"
+#include "LittleFileSystem.h"
+
+#if COMPONENT_SPIF
+#include "SPIFBlockDevice.h"
+#endif
+
+#if COMPONENT_QSPIF
+#include "QSPIFBlockDevice.h"
+#endif
+
+#if COMPONENT_DATAFLASH
+#include "DataFlashBlockDevice.h"
+#endif
+
+#if COMPONENT_SD
+#include "SDBlockDevice.h"
+#endif
+
+#if COMPONENT_FLASHIAP
+#include "FlashIAPBlockDevice.h"
+#endif
+
+#if COMPONENT_NUSD
+#include "NuSDBlockDevice.h"
+#endif
+
+using namespace mbed;
+
+// Align a value to a specified size.
+// Parameters :
+// val - [IN] Value.
+// size - [IN] Size.
+// Return : Aligned value.
+static inline uint32_t align_up(uint32_t val, uint32_t size)
+{
+ return (((val - 1) / size) + 1) * size;
+}
+
+BlockDevice *BlockDevice::get_default_instance()
+{
+#if COMPONENT_SPIF
+
+ static SPIFBlockDevice default_bd(
+ MBED_CONF_SPIF_DRIVER_SPI_MOSI,
+ MBED_CONF_SPIF_DRIVER_SPI_MISO,
+ MBED_CONF_SPIF_DRIVER_SPI_CLK,
+ MBED_CONF_SPIF_DRIVER_SPI_CS,
+ MBED_CONF_SPIF_DRIVER_SPI_FREQ
+ );
+
+ return &default_bd;
+
+#elif COMPONENT_QSPIF
+
+ static QSPIFBlockDevice default_bd(
+ MBED_CONF_QSPIF_QSPI_IO0,
+ MBED_CONF_QSPIF_QSPI_IO1,
+ MBED_CONF_QSPIF_QSPI_IO2,
+ MBED_CONF_QSPIF_QSPI_IO3,
+ MBED_CONF_QSPIF_QSPI_SCK,
+ MBED_CONF_QSPIF_QSPI_CSN,
+ MBED_CONF_QSPIF_QSPI_POLARITY_MODE,
+ MBED_CONF_QSPIF_QSPI_FREQ
+ );
+
+ return &default_bd;
+
+#elif COMPONENT_DATAFLASH
+
+ static DataFlashBlockDevice default_bd(
+ MBED_CONF_DATAFLASH_SPI_MOSI,
+ MBED_CONF_DATAFLASH_SPI_MISO,
+ MBED_CONF_DATAFLASH_SPI_CLK,
+ MBED_CONF_DATAFLASH_SPI_CS
+ );
+
+ return &default_bd;
+
+#elif COMPONENT_SD
+
+ static SDBlockDevice default_bd(
+ MBED_CONF_SD_SPI_MOSI,
+ MBED_CONF_SD_SPI_MISO,
+ MBED_CONF_SD_SPI_CLK,
+ MBED_CONF_SD_SPI_CS
+ );
+
+ return &default_bd;
+
+#elif COMPONENT_NUSD
+
+ static NuSDBlockDevice default_bd;
+
+ return &default_bd;
+
+#elif COMPONENT_FLASHIAP
+
+#if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF)
+
+ size_t flash_size;
+ uint32_t start_address;
+ uint32_t bottom_address;
+ FlashIAP flash;
+
+ int ret = flash.init();
+ if (ret != 0) {
+ return 0;
+ }
+
+ //Find the start of first sector after text area
+ bottom_address = align_up(FLASHIAP_ROM_END, flash.get_sector_size(FLASHIAP_ROM_END));
+ start_address = flash.get_flash_start();
+ flash_size = flash.get_flash_size();
+
+ ret = flash.deinit();
+
+ static FlashIAPBlockDevice default_bd(bottom_address, start_address + flash_size - bottom_address);
+
+#else
+
+ static FlashIAPBlockDevice default_bd;
+
+#endif
+
+ return &default_bd;
+
+#else
+
+ return NULL;
+
+#endif
+
+}
+
+FileSystem *FileSystem::get_default_instance()
+{
+#if COMPONENT_SPIF || COMPONENT_QSPIF || COMPONENT_DATAFLASH || COMPONENT_NUSD
+
+ static LittleFileSystem flash("flash", BlockDevice::get_default_instance());
+ flash.set_as_default();
+
+ return &flash;
+
+#elif COMPONENT_SD
+
+ static FATFileSystem sdcard("sd", BlockDevice::get_default_instance());
+ sdcard.set_as_default();
+
+ return &sdcard;
+
+#elif COMPONENT_FLASHIAP
+
+ static LittleFileSystem flash("flash", BlockDevice::get_default_instance());
+ flash.set_as_default();
+
+ return &flash;
+
+#else
+
+ return NULL;
+
+#endif
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,160 @@
+// ----------------------------------------------------------------------------
+// Copyright 2016-2018 ARM Ltd.
+//
+// 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 MBED_TEST_MODE
+
+#include "mbed.h"
+#include "simple-mbed-cloud-client.h"
+#include "FATFileSystem.h"
+
+// An event queue is a very useful structure to debounce information between contexts (e.g. ISR and normal threads)
+// This is great because things such as network operations are illegal in ISR, so updating a resource in a button's fall() function is not allowed
+EventQueue eventQueue;
+
+// Default block device
+BlockDevice *bd = BlockDevice::get_default_instance();
+FATFileSystem fs("fs");
+
+// Default network interface object
+NetworkInterface *net = NetworkInterface::get_default_instance();
+
+InterruptIn btn(USER_BUTTON0);
+// Declaring pointers for access to Pelion Device Management Client resources outside of main()
+MbedCloudClientResource *button_res;
+MbedCloudClientResource *pattern_res;
+
+void button_press() {
+ int v = button_res->get_value_int() + 1;
+
+ button_res->set_value(v);
+
+ printf("User button clicked %d times\n", v);
+}
+
+/**
+ * PUT handler
+ * @param resource The resource that triggered the callback
+ * @param newValue Updated value for the resource
+ */
+void pattern_updated(MbedCloudClientResource *resource, m2m::String newValue) {
+ printf("PUT received, new value: %s\n", newValue.c_str());
+}
+
+/**
+ * POST handler
+ * @param resource The resource that triggered the callback
+ * @param buffer If a body was passed to the POST function, this contains the data.
+ * Note that the buffer is deallocated after leaving this function, so copy it if you need it longer.
+ * @param size Size of the body
+ */
+void blink_callback(MbedCloudClientResource *resource, const uint8_t *buffer, uint16_t size) {
+ printf("POST received. Going to blink LED pattern: %s\n", pattern_res->get_value().c_str());
+
+ static DigitalOut augmentedLed(LED1); // LED that is used for blinking the pattern
+
+ // Parse the pattern string, and toggle the LED in that pattern
+ string s = std::string(pattern_res->get_value().c_str());
+ size_t i = 0;
+ size_t pos = s.find(':');
+ while (pos != string::npos) {
+ wait_ms(atoi(s.substr(i, pos - i).c_str()));
+ augmentedLed = !augmentedLed;
+
+ i = ++pos;
+ pos = s.find(':', pos);
+
+ if (pos == string::npos) {
+ wait_ms(atoi(s.substr(i, s.length()).c_str()));
+ augmentedLed = !augmentedLed;
+ }
+ }
+}
+
+/**
+ * Notification callback handler
+ * @param resource The resource that triggered the callback
+ * @param status The delivery status of the notification
+ */
+void button_callback(MbedCloudClientResource *resource, const NoticationDeliveryStatus status) {
+ printf("Button notification, status %s (%d)\n", MbedCloudClientResource::delivery_status_to_string(status), status);
+}
+
+/**
+ * Registration callback handler
+ * @param endpoint Information about the registered endpoint such as the name (so you can find it back in portal)
+ */
+void registered(const ConnectorClientEndpointInfo *endpoint) {
+ printf("Connected to Pelion Device Management. Endpoint Name: %s\n", endpoint->internal_endpoint_name.c_str());
+}
+
+int main(void) {
+ printf("Starting Simple Pelion Device Management Client example\n");
+ printf("Connecting to the network...\n");
+
+ // Connect to the internet (DHCP is expected to be on)
+ nsapi_error_t status = net->connect();
+
+ if (status != NSAPI_ERROR_OK) {
+ printf("Connecting to the network failed %d!\n", status);
+ return -1;
+ }
+
+ printf("Connected to the network successfully. IP address: %s\n", net->get_ip_address());
+
+ // SimpleMbedCloudClient handles registering over LwM2M to Pelion Device Management
+ SimpleMbedCloudClient client(net, bd, &fs);
+ int client_status = client.init();
+ if (client_status != 0) {
+ printf("Pelion Client initialization failed (%d)\n", client_status);
+ return -1;
+ }
+
+ // Creating resources, which can be written or read from the cloud
+ button_res = client.create_resource("3200/0/5501", "button_count");
+ button_res->set_value(0);
+ button_res->methods(M2MMethod::GET);
+ button_res->observable(true);
+ button_res->attach_notification_callback(button_callback);
+
+ pattern_res = client.create_resource("3201/0/5853", "blink_pattern");
+ pattern_res->set_value("500:500:500:500:500:500:500:500");
+ pattern_res->methods(M2MMethod::GET | M2MMethod::PUT);
+ pattern_res->attach_put_callback(pattern_updated);
+
+ MbedCloudClientResource *blink_res = client.create_resource("3201/0/5850", "blink_action");
+ blink_res->methods(M2MMethod::POST);
+ blink_res->attach_post_callback(blink_callback);
+
+ printf("Initialized Pelion Client. Registering...\n");
+
+ // Callback that fires when registering is complete
+ client.on_registered(®istered);
+
+ // Register with Pelion Device Management
+ client.register_and_connect();
+
+ // Setup the button
+ btn.mode(PullUp);
+
+ // The button fall handler is placed in the event queue so it will run in
+ // thread context instead of ISR context, which allows safely updating the cloud resource
+ btn.fall(eventQueue.event(&button_press));
+
+ // You can easily run the eventQueue in a separate thread if required
+ eventQueue.dispatch_forever();
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Sat Dec 15 12:47:53 2018 +0900 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#2fd0c5cfbd83fce62da6308f9d64c0ab64e1f0d6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,88 @@
+{
+ "macros": [
+ "ARM_UC_USE_PAL_BLOCKDEVICE=1",
+ "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE",
+ "MBED_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"",
+ "MBED_CLOUD_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"",
+ "PAL_USER_DEFINED_CONFIGURATION=\"sotp_fs_config_MbedOS.h\"",
+ "PAL_FS_MOUNT_POINT_PRIMARY=\"/fs\"",
+ "MBEDTLS_USER_CONFIG_FILE=\"mbedTLSConfig_mbedOS.h\"",
+ "PAL_DTLS_PEER_MIN_TIMEOUT=5000"
+ ],
+ "target_overrides": {
+ "*": {
+ "platform.stdio-baud-rate" : 115200,
+ "platform.stdio-convert-newlines" : true,
+ "update-client.storage-address" : "(1024*1024*64)",
+ "update-client.storage-size" : "(1024*1024*2)",
+ "update-client.storage-locations" : "1",
+ "mbed-trace.enable" : null,
+ "nsapi.default-wifi-security" : "WPA_WPA2",
+ "nsapi.default-wifi-ssid" : "\"SSID\"",
+ "nsapi.default-wifi-password" : "\"PASSWORD\""
+ },
+ "GR_LYCHEE": {
+ "target.features_add" : ["BOOTLOADER"],
+ "target.components_add" : ["SD"],
+ "target.extra_labels_add" : ["ESP32_DRIVER"],
+ "target.network-default-interface-type" : "WIFI",
+ "flash-start-address" : "0x18000000",
+ "flash-size" : "(8*1024*1024)",
+ "sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(4*1024))",
+ "sotp-section-1-size" : "(4*1024)",
+ "sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(4*1024))",
+ "sotp-section-2-size" : "(4*1024)",
+ "sotp-num-sections" : 2,
+ "target.bootloader_img" : "bootloader/mbed-bootloader-GR_LYCHEE.bin",
+ "target.header_offset" : "0x10000",
+ "target.app_offset" : "0x10400",
+ "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)"
+ }
+ },
+ "config": {
+ "format-storage-layer-on-error": {
+ "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!",
+ "value": 1
+ },
+ "developer-mode": {
+ "help": "Enable Developer mode to skip Factory enrollment",
+ "value": 1
+ },
+ "main-stack-size": {
+ "value": 6000
+ },
+ "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
+ },
+ "sotp-section-1-address": {
+ "help": "Flash sector address for SOTP sector 1",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS",
+ "value": null
+ },
+ "sotp-section-1-size": {
+ "help": "Flash sector size for SOTP sector 1",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_SIZE",
+ "value": null
+ },
+ "sotp-section-2-address": {
+ "help": "Flash sector address for SOTP sector 2",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_ADDRESS",
+ "value": null
+ },
+ "sotp-section-2-size": {
+ "help": "Flash sector size for SOTP sector 2",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_SIZE",
+ "value": null
+ },
+ "sotp-num-sections": {
+ "help": "Number of SOTP sections",
+ "macro_name": "PAL_INT_FLASH_NUM_SECTIONS",
+ "value": null
+ }
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app_prod.json Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,120 @@
+{
+ "macros": [
+ "ARM_UC_USE_PAL_BLOCKDEVICE=1",
+ "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE",
+ "MBED_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"",
+ "MBED_CLOUD_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"",
+ "PAL_USER_DEFINED_CONFIGURATION=\"sotp_fs_config_MbedOS.h\"",
+ "PAL_FS_MOUNT_POINT_PRIMARY=\"/fs\"",
+ "MBEDTLS_USER_CONFIG_FILE=\"mbedTLSConfig_mbedOS.h\"",
+ "PAL_DTLS_PEER_MIN_TIMEOUT=5000"
+ ],
+ "target_overrides": {
+ "*": {
+ "target.OUTPUT_EXT" : "hex",
+ "platform.stdio-baud-rate" : 115200,
+ "platform.stdio-convert-newlines" : true,
+ "update-client.storage-address" : "(1024*1024*64)",
+ "update-client.storage-size" : "(1024*1024*2)",
+ "update-client.storage-locations" : "1",
+ "mbed-trace.enable" : null,
+ "nsapi.default-wifi-security" : "WPA_WPA2",
+ "nsapi.default-wifi-ssid" : "\"SSID\"",
+ "nsapi.default-wifi-password" : "\"Password\""
+ },
+ "K64F": {
+ "target.features_add" : ["BOOTLOADER"],
+ "target.components_add" : ["SD"],
+ "flash-start-address" : "0x0",
+ "flash-size" : "(2048*1024)",
+ "sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 32*1024)",
+ "sotp-section-1-size" : "(4*1024)",
+ "sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 36*1024)",
+ "sotp-section-2-size" : "(4*1024)",
+ "sotp-num-sections" : 2,
+ "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 40*1024)",
+ "client_app.partition_mode" : "1",
+ "client_app.auto_partition" : "1",
+ "client_app.pal_number_of_partition": "1",
+ "client_app.primary_partition_size" : "(1024*1024*1024)"
+ },
+ "K66F": {
+ "target.features_add" : ["BOOTLOADER"],
+ "target.components_add" : ["SD"],
+ "flash-start-address" : "0x0",
+ "flash-size" : "(2048*1024)",
+ "sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 32*1024)",
+ "sotp-section-1-size" : "(4*1024)",
+ "sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 36*1024)",
+ "sotp-section-2-size" : "(4*1024)",
+ "sotp-num-sections" : 2,
+ "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)",
+ "client_app.partition_mode" : "1",
+ "client_app.auto_partition" : "1",
+ "client_app.pal_number_of_partition": "1",
+ "client_app.primary_partition_size" : "(1024*1024*1024)"
+ },
+ "NUCLEO_F429ZI": {
+ "target.features_add" : ["BOOTLOADER"],
+ "target.components_add" : ["SD"],
+ "flash-start-address" : "0x08000000",
+ "flash-size" : "(2048*1024)",
+ "sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 32*1024)",
+ "sotp-section-1-size" : "(16*1024)",
+ "sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 48*1024)",
+ "sotp-section-2-size" : "(16*1024)",
+ "sotp-num-sections" : 2,
+ "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)",
+ "client_app.partition_mode" : "1",
+ "client_app.auto_partition" : "1",
+ "client_app.pal_number_of_partition": "1",
+ "client_app.primary_partition_size" : "(1024*1024*4)"
+ }
+ },
+ "config": {
+ "format-storage-layer-on-error": {
+ "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!",
+ "value": 1
+ },
+ "developer-mode": {
+ "help": "Enable Developer mode to skip Factory enrollment",
+ "value": null
+ },
+ "main-stack-size": {
+ "value": 6000
+ },
+ "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
+ },
+ "sotp-section-1-address": {
+ "help": "Flash sector address for SOTP sector 1",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS",
+ "value": null
+ },
+ "sotp-section-1-size": {
+ "help": "Flash sector size for SOTP sector 1",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_SIZE",
+ "value": null
+ },
+ "sotp-section-2-address": {
+ "help": "Flash sector address for SOTP sector 2",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_ADDRESS",
+ "value": null
+ },
+ "sotp-section-2-size": {
+ "help": "Flash sector size for SOTP sector 2",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_SIZE",
+ "value": null
+ },
+ "sotp-num-sections": {
+ "help": "Number of SOTP sections",
+ "macro_name": "PAL_INT_FLASH_NUM_SECTIONS",
+ "value": null
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_cloud_client_user_config.h Sat Dec 15 12:47:53 2018 +0900 @@ -0,0 +1,59 @@ +// ---------------------------------------------------------------------------- +// Copyright 2016-2017 ARM Ltd. +// +// 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. +// ---------------------------------------------------------------------------- + +// This file is a template and it's intented to be copied to the application +// Enable this configuration + +#ifndef MBED_CLOUD_CLIENT_USER_CONFIG_H +#define MBED_CLOUD_CLIENT_USER_CONFIG_H + +#ifdef MBED_CONF_APP_ENDPOINT_TYPE +#define MBED_CLOUD_CLIENT_ENDPOINT_TYPE MBED_CONF_APP_ENDPOINT_TYPE +#else +#define MBED_CLOUD_CLIENT_ENDPOINT_TYPE "default" +#endif + +// Enable either TCP or UDP, but no both +#define MBED_CLOUD_CLIENT_TRANSPORT_MODE_TCP +// MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP + +#define MBED_CLOUD_CLIENT_LIFETIME 3600 + +#define MBED_CLOUD_CLIENT_SUPPORT_UPDATE +#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE 1024 + +// set flag to enable update support in mbed Cloud client +#define MBED_CLOUD_CLIENT_SUPPORT_UPDATE + +// set download buffer size in bytes (min. 1024 bytes) + +// Use larger buffers in Linux // +#ifdef __linux__ +#define MBED_CLOUD_CLIENT_UPDATE_BUFFER (2 * 1024 * 1024) +#else +#define MBED_CLOUD_CLIENT_UPDATE_BUFFER 2048 +#endif + +// Developer flags for Update feature +#if MBED_CONF_APP_DEVELOPER_MODE == 1 + #define MBED_CLOUD_DEV_UPDATE_CERT + #define MBED_CLOUD_DEV_UPDATE_ID +#endif // MBED_CONF_APP_DEVELOPER_MODE + +#endif // MBED_CLOUD_CLIENT_USER_CONFIG_H +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_cloud_dev_credentials.c Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017 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 __MBED_CLOUD_DEV_CREDENTIALS_H__
+#define __MBED_CLOUD_DEV_CREDENTIALS_H__
+
+#if MBED_CONF_APP_DEVELOPER_MODE == 1
+#error "Replace mbed_cloud_dev_credentials.c with your own developer cert."
+#endif
+
+#include <inttypes.h>
+
+const char MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME[] = "";
+const char MBED_CLOUD_DEV_ACCOUNT_ID[] = "";
+const char MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI[] = "";
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE[] =
+{ 0x0 };
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE[] =
+{ 0x0 };
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY[] =
+{ 0x0 };
+
+const char MBED_CLOUD_DEV_MANUFACTURER[] = "dev_manufacturer";
+
+const char MBED_CLOUD_DEV_MODEL_NUMBER[] = "dev_model_num";
+
+const char MBED_CLOUD_DEV_SERIAL_NUMBER[] = "0";
+
+const char MBED_CLOUD_DEV_DEVICE_TYPE[] = "dev_device_type";
+
+const char MBED_CLOUD_DEV_HARDWARE_VERSION[] = "dev_hardware_version";
+
+const uint32_t MBED_CLOUD_DEV_MEMORY_TOTAL_KB = 0;
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE);
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE);
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY);
+
+#endif //__MBED_CLOUD_DEV_CREDENTIALS_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simple-mbed-cloud-client.lib Sat Dec 15 12:47:53 2018 +0900 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/simple-mbed-cloud-client/#0995133c1d9ad3a3ceedae26c3ecf02e824e7fa5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/update_default_resources.c Sat Dec 15 12:47:53 2018 +0900
@@ -0,0 +1,41 @@
+// ----------------------------------------------------------------------------
+// Copyright 2016-2017 ARM Ltd.
+//
+// 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.
+// ----------------------------------------------------------------------------
+
+#ifdef MBED_CLOUD_CLIENT_USER_CONFIG_FILE
+#include MBED_CLOUD_CLIENT_USER_CONFIG_FILE
+#endif
+
+#include <stdint.h>
+
+#ifdef MBED_CLOUD_DEV_UPDATE_ID
+const uint8_t arm_uc_vendor_id[16] = { "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 uint16_t arm_uc_class_id_size = sizeof(arm_uc_class_id);
+#endif
+
+#ifdef MBED_CLOUD_DEV_UPDATE_CERT
+const uint8_t arm_uc_default_fingerprint[32] = { 0 };
+const uint16_t arm_uc_default_fingerprint_size =
+ sizeof(arm_uc_default_fingerprint);
+
+const uint8_t arm_uc_default_certificate[1] = { 0 };
+const uint16_t arm_uc_default_certificate_size =
+ sizeof(arm_uc_default_certificate);
+#endif