Which platform should I use - Amazon FreeRTOS or Mbed OS?
It is a good question to think about before investing a lot of time into a new platform as at the end our time is our most precious resource, It requires some analysis. I've googled Internet, but was not able to answer a good answer.
I've used Mbed OS two years ago on another IoT on Wheels Design Challenge (you can read my blogs on Mbed OS IOT on Wheels Design Challenge - Smart Drive - First Steps with mbed os - Blog #2, IOT on Wheels Design Challenge - Smart Drive - MBed To The Rescue - Blog #7 , IOT on Wheels Design Challenge - Smart Drive - MBed with GPS Receiver - Blog #8 ). It is a fast growing web based collaborative platform. I believe it has all capabilities you are listed. And it was very light on PC hardware requirements. It was very easy to start development, build, deploy. There was almost no software to install/maintain on my machine.
But Amazon FreeRTOS (AFR) has additional capabilities, that seems important for some use cases - device onboarding, OTA updates, device shadow, secure storage, key management. Take a look at 10 minutes video IoT Edge Computing: Introduction to Amazon FreeRTOS I'm still looking forward to discover which of these extra capabilities of AFR are already supported on Cypress PSoC 6.
My plan for this challenge is to start with AFR/ModbusToolbox and keep Mbed OS as plan B, in case if run into dead end with plan A.
Here is the summary as I understand it after following AFR trainings, but before starting using it. I'll revise it as my understanding of it evolves.
Mbed OS | Amazon FreeRTOS | |
---|---|---|
Support of PSoC6 features | yes | yes |
Support external peripherals | yes | yes |
AWS IoT connectivity | yes | yes |
OTA updates | no | yes |
Device on-boarding | no | yes |
Device shadow | no | yes |
Secure storage | no | yes |
Key management | no | yes |
Community | yes | yes |
Support | yes | yes |
Web-based building tool chain | yes | no |
Web-based collaborative platform | yes | no |
Why ModbusToolbox?
It is the recommended tool for AFR Cypress PSoC development at this point.
Installing ModbusToolbox
I've followed ModusToolbox Installation Guide, but I've missed an important system requirement. It doesn't support the OS I'm using - Windows 10 32-bit. So I've got the error:
I have an old box with Ubuntu 18.04. It has only 1.5GB of RAM and one CPU core. It is much smaller than recommended for ModusToolbox.But installation completed successfully. And I was able launch it.
Screen Capture
The only problem so far - it is not convenient for me to snap pictures for this blog on Ubuntu.
I've attempted to solve it by using a remote display. I've installed xming X-Server on my Windows PC and than launched ModusToolbox on Ubuntu box.
cd ModusToolbox/ide_2.0/eclipse/ export DISPLAY=192.168.1.37:0.0 ./ModusToolbox
Initially it was looking very promising, but than after I've started using it I've realized that some interfaces of the IDE where missing or distorted on my X-Server.
Firmware Loader upgrade
I've downloaded and installed the newer version of Cypress firmware loader fw-loader-2.3.0.568-linux to replace one that was provided with ModusToolbox.
Demo project
I've loaded demo project, build it and loaded to the board. No problem so far.
I've installed terminal emulator, so I can get output from the board:
sudo apt install screen
Than I've started the terminal emulator.
screen /dev/ttyACM0 115200
And I've started the demo program on the board:
0WLAN MAC Address : 00:9D:6B:63:76:09 WLAN Firmware : wl0: Sep 5 2019 23:24:33 version 7.45.98.92 (r722362 CY) FWID 01-f7128517 WLAN CLM : API: 12.2 Data: 9.10.39 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2019-09-05 23:10:00 WHD VERSION : v1.70.0 : v1.70.0 : GCC 7.2 : 2019-12-02 04:14:53 -0600 .1 5585 [Tmr Svc] Wi-Fi Connected to AP. Creating tasks which use network... 2 5585 [Tmr Svc] IP Address acquired 192.168.1.71 3 7301 [Tmr Svc] Write certificate... 4 7841 [iot_threa] [INFO ][DEMO][lu] ---------STARTING DEMO--------- 5 7843 [iot_threa] [INFO ][INIT][lu] SDK successfully initialized. .6 12654 [iot_threa] [INFO ][DEMO][lu] Successfully initialized the demo. Network type for the demo:7 12654 [iot_threa] [INFO ][MQTT][lu] MQTT library successfully initialized. 8 12654 [iot_threa] [INFO ][DEMO][lu] MQTT demo client identifier is bio01 (length 5). .9 16322 [iot_threa] [INFO ][MQTT][lu] Establishing new MQTT connection. 10 16324 [iot_threa] [INFO ][MQTT][lu] Anonymous metrics (SDK language, SDK version) will be provid11 16325 [iot_threa] [INFO ][MQTT][lu] (MQTT connection 0x8012778, CONNECT operation 0x800c168) Wai.12 21325 [iot_threa] [INFO ][MQTT][lu] (MQTT connection 0x8012778, CONNECT operation 0x800c168) Wai13 21325 [iot_threa] [ERROR][MQTT][lu] Failed to establish new MQTT connection, error TIMEOUT. 14 21326 [iot_threa] [INFO ][MQTT][lu] Network connection closed on error. 15 21626 [iot_threa] [INFO ][MQTT][lu] (MQTT connection 0x8012778) Network connection destroyed. 16 21626 [iot_threa] [ERROR][DEMO][lu] MQTT CONNECT returned error TIMEOUT. 17 21626 [iot_threa] [INFO ][MQTT][lu] MQTT library cleanup done. 18 21626 [iot_threa] [ERROR][DEMO][lu] Error running demo. 19 21626 [iot_threa] [INFO ][INIT][lu] SDK cleanup done. 20 21626 [iot_threa] [INFO ][DEMO][lu] -------DEMO FINISHED-------
The board was able to connect to my WiFi network,but than it failed to connect with AWS IoT MQTT broker (line 14).
Unfortunately I was not able to find any debug information on the failed connection on AWS IoT Console.
I've opened support ticket at AWS IoT community forumhttps://community.cypress.com/message/229183#229183and at Cypress Community forum,
I was able to find the issue next day. It appeared that I missed one step in the on-boarding of the device and haven't activated its security certificate.
I was able activate it from the thing security page:
And than I was able to run the demo program from the board, create connection, publish and receive messages:
AWS IoT Connection Troubleshooting
I wish there is a way to troubleshot AWS IoT connection. Probably I just don't know about it.
What helped me a lot is that I've used AWS IoT Linux/Python demo program and it worked perfectly from the first time.
curl https://www.amazontrust.com/repository/AmazonRootCA1.pem > root-CA.crt python aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py -e my-ats.iot.us-east-1.amazonaws.com -r root-CA.crt -c bio2.cert.pem -k bio2.private.key vlasov01@remote:~/bio2$ python aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py -e my-ats.iot.us-east-1.amazonaws.com -r root-CA.crt -c bio2.cert.pem -k bio2.private.key 2020-03-29 22:33:03,311 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Initializing MQTT layer... 2020-03-29 22:33:03,312 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Registering internal event callbacks to MQTT layer... 2020-03-29 22:33:03,313 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - MqttCore initialized 2020-03-29 22:33:03,313 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Client id: basicPubSub 2020-03-29 22:33:03,313 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Protocol version: MQTTv3.1.1 2020-03-29 22:33:03,313 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Authentication type: TLSv1.2 certificate based Mutual Auth. 2020-03-29 22:33:03,314 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring endpoint... 2020-03-29 22:33:03,314 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring certificates... 2020-03-29 22:33:03,314 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring reconnect back off timing... 2020-03-29 22:33:03,314 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Base quiet time: 1.000000 sec 2020-03-29 22:33:03,314 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Max quiet time: 32.000000 sec 2020-03-29 22:33:03,315 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Stable connection time: 20.000000 sec 2020-03-29 22:33:03,315 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queueing: max queue size: -1 2020-03-29 22:33:03,316 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queue draining interval: 0.500000 sec 2020-03-29 22:33:03,316 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring connect/disconnect time out: 10.000000 sec 2020-03-29 22:33:03,316 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring MQTT operation time out: 5.000000 sec 2020-03-29 22:33:03,317 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync connect... 2020-03-29 22:33:03,317 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async connect... 2020-03-29 22:33:03,317 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Keep-alive: 600.000000 sec 2020-03-29 22:33:03,318 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event consuming thread started 2020-03-29 22:33:03,318 - AWSIoTPythonSDK.core.protocol.mqtt_core - DEBUG - Passing in general notification callbacks to internal client... 2020-03-29 22:33:03,318 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in fixed event callbacks: CONNACK, DISCONNECT, MESSAGE 2020-03-29 22:33:03,599 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Starting network I/O thread... 2020-03-29 22:33:03,707 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [connack] event 2020-03-29 22:33:03,707 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [connack] event 2020-03-29 22:33:03,709 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - No need for recovery 2020-03-29 22:33:03,709 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback... 2020-03-29 22:33:03,717 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync subscribe... 2020-03-29 22:33:03,718 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Adding a new subscription record: sdk/test/Python qos: 1 2020-03-29 22:33:03,719 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom suback event callback... 2020-03-29 22:33:03,802 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [suback] event 2020-03-29 22:33:03,802 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [suback] event 2020-03-29 22:33:03,802 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback... 2020-03-29 22:33:03,803 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation... 2020-03-29 22:33:05,835 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish... 2020-03-29 22:33:05,837 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback... 2020-03-29 22:33:05,905 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event 2020-03-29 22:33:05,906 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event 2020-03-29 22:33:05,907 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback... 2020-03-29 22:33:05,908 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation... 2020-03-29 22:33:05,943 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event 2020-03-29 22:33:05,945 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event Received a new message: {"message": "Hello World!", "sequence": 0} from topic: sdk/test/Python -------------- 2020-03-29 22:33:05,950 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback... 2020-03-29 22:33:06,955 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish... 2020-03-29 22:33:06,957 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback... 2020-03-29 22:33:07,024 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event 2020-03-29 22:33:07,025 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event 2020-03-29 22:33:07,026 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback... 2020-03-29 22:33:07,027 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation... 2020-03-29 22:33:07,055 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event 2020-03-29 22:33:07,057 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event Received a new message: {"message": "Hello World!", "sequence": 1} from topic: sdk/test/Python -------------- 2020-03-29 22:33:07,061 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback... 2020-03-29 22:33:08,073 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish... 2020-03-29 22:33:08,074 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback... 2020-03-29 22:33:08,165 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event 2020-03-29 22:33:08,167 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event 2020-03-29 22:33:08,168 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback... 2020-03-29 22:33:08,168 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation... 2020-03-29 22:33:08,172 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event 2020-03-29 22:33:08,174 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event Received a new message: {"message": "Hello World!", "sequence": 2} from topic: sdk/test/Python --------------
Than I've tried to use it with the thing certificate/private key and it failed. Than I've used the certificate/private key supplied with AWS IoT Linux/Python demo program and my device was able finally connect. So, I've realized that the issue was related to the thing certificate and private key. I've validated them and haven't found any issues:
Then I've started reading about management from CLI perspective. This is where I noticed activation step.
Top Comments