This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220S-LAUNCHXL: Use wifi_thermostat with CC3220S

Part Number: CC3220S-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF, CC3220S, UNIFLASH, CC3220SDK

Hi,

1. I am trying to use the wifi_thermostat example from http://www.ti.com/tool/TIDM-1020, but I see that it only works with the CC3220SF. What exactly are all the steps I need to do to convert to the CC3220S? I'd appreciate any help.

2. I also have a related question regarding the AWS of the wifi_thermostat example. On page 35 of http://www.ti.com/lit/ug/tidudq7a/tidudq7a.pdf, I see that the certification files must be copied and pasted directly into the code. Is there a way to reference the certification files (that I upload into Uniflash) in the code? If so, what would the code for this look like?

  • 1. e2e.ti.com/.../663392
    2. What do you want to do with the certification files?

    Jesu
  • 1. Could you provide a screenshot on how to "You need to change linker file. CC3220SF-*.cmd change to file CC3220S-** file in your project."?

    2. So instead of pasting the certification files like the image, I want to do something like the below code. How can I do this correctly?

    unsigned char root_ca_pem[] = "root_ca.pem";

  • Jack,

    To convert an SF project to an S project you need to replace the SF linker file with an S linker file (just get it from an S project). You also might need to make changes to the CC3220SF_LAUNCHXL.* and Board.h file to work for a CC3220S.

    You can define certificates like that.

    Jesu
  •  So these are the steps I took to configure to CC3220S according to your instructions. Does this seem correct?

    1. Copied these files to the project

    CC3220S_LAUNCHXL_TIRTOS.cmd
    CC3220S_LAUNCHXL.c
    CC3220S_LAUNCHXL.h

    2. Right clicked on project and clicked "Show Build Settings". Then I configured to the below image.

    3. Right clicked on below files and clicked "Exclude from Build".

    CC3220SF_LAUNCHXL_TIRTOS.cmd
    CC3220SF_LAUNCHXL.c

    4. Copied and modified "CC3220S_LAUNCHXL_GPIOName" & "gpioPinConfigs[]" in CC3220S_LAUNCHXL.* to setup the correct GPIO pins on the CC3220S.

    5. Changed all pins ending with "SF" to "S" in board.h + include "CC3220S_LAUNCHXL.h"

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    So now I get these MEMORY errors. I don't need to use the SENSORS, BLUETOOTH, or LCD TOUCH SCREEN. How exactly can I remove these completely from the project? Universally, I don't need to use the thermostat functionality - I just want to use the basic OTA, provisioning, AWS MQTT + Alexa Control (for my own purposes). So what can I do to fix this?

    gmake[1]: *** [wifi_thermostat_CC3220SF_LAUNCHXL_tirtos_ccs.out] Error 1
    gmake: *** [all] Error 2
    DEFAULT memory range overlaps existing memory range SRAM0 null: DEFAULT memory range overlaps existing memory range SRAM0
    DEFAULT memory range overlaps existing memory range SRAM null: DEFAULT memory range overlaps existing memory range SRAM
    <a href="processors.wiki.ti.com/.../10099">  program will not fit into available memory.  run placement with alignment fails for section ".bss" size 0x743a .  Available memory ranges:
    <a href="processors.wiki.ti.com/.../10099">  program will not fit into available memory.  placement with alignment fails for section ".const" size 0xf92e .  Available memory ranges:
    #10010 null: errors encountered during linking; "wifi_thermostat_CC3220SF_LAUNCHXL_tirtos_ccs.out" not built

  • Hi,

    Please provide here sizes of sections defined at linker file:

    MEMORY
    {
        SRAM0 (RWX) : origin = 0x20000000, length = 0x4000
        SRAM  (RWX) : origin = 0x20004000, length = 0x00040000 - 0x4000
    }

    and output of Memory allocation tool, like a:

    Jan

  • I have the same Memory sizes as you.

    MEMORY
    {
        SRAM0 (RWX) : origin = 0x20000000, length = 0x4000
        SRAM  (RWX) : origin = 0x20004000, length = 0x00040000 - 0x4000
    }

    How do I get to the memory allocation tool?

  • Hi,

    CCS -> View -> Memory Allocation

    Jan
  •  The below is all that shows in my memory allocation.

  • Hi,

    It seems that memory size overflow is big. This big memory overflow could not be solved by some kind of "easy" optimisation.

    You have options:
    - remove some features
    - use CC3220SF as was code designed originally

    Unfortunately I haven't experience with this particular design. From this reasons I cannot give you advice how remove unused features. But at this design is used display. Thing around display have usually big requirements to memory resources.

    Regards,

    Jan
  • Could you help me solve my post that contained the following question please?

    "So now I get these MEMORY errors. I don't need to use the SENSORS, BLUETOOTH, or LCD TOUCH SCREEN. How exactly can I remove these completely from the project? Universally, I don't need to use the thermostat functionality - I just want to use the basic OTA, provisioning, AWS MQTT + Alexa Control (for my own purposes). So what can I do to fix this?"

  • Hi Jack,

    If your goal is to simply make a CC3220 IoT Thing that's controllable by voice using Alexa, you don't actually need to use the thermostat TI design code. The thermostat code has a ton of functionality to control the LCD, get the weather, etc. that isn't useful to you and take up tons of space.

    What you should instead do is the following:

    1. Import the shadow_sample example for CC3220S from the latest release of the AWS IoT plugin: http://www.ti.com/tool/download/SIMPLELINK-CC32XX-PLUGIN-FOR-AWSIOT
    2. Replace the shadow_sample.c file with the attached file:/cfs-file/__key/communityserver-discussions-components-files/968/shadow_5F00_sample.c
    3. Ensure that you have tirtos from SDK version 2.10 or 2.20 imported from the CC3220SDK and build. It should build fine.
    4. Then, follow the steps in my AVS thermostat TI design guide to get the AVS/AWS cloud side setup. 
    5. Once you get your AVS skill up and running, modify the shadow_sample project so that you have the right certs/endpoint, etc. for your cloud setup.
    6. You should then be able to use Alexa to get the status of the CC3220 running the shadow_sample code, and set the target temperature.

    Try doing that and then working from there to add in the OTA, provisioning, and application-specific functionality that you need.

    Regards,
    Michael

  •  

    1. Could you give exact instructions on how to add Cloud OTA and Provisioning to the project?

    2. If I wanted to add another MQTT feature (e.g. turn on/off) in the shadow_sample, do I only need to replicate what you did in shadow_sample.c?

    3. Does the shadow project include the network_if functions from the thermostat project?

    3. I also see that the thermostat project has a sl_wifi_callback.c. Does the shadow project have this too?

  • Hi Jack,

    1. You should take a look at what is done in the thermostat, or the elock TI design to see how you would add in the cloud OTA and provisioning.

    2. Yes, you can add in any arbitrary shadow variable you want, much like how I added the setpoint variable. Do keep in mind you'll have to adjust some of the defines in aws_iot_config.h, like MAX_JSON_TOKEN_EXPECTED as you add more variables.

    3. No, it doesn't look like it has that file.

    4. No. The shadow sample project has the needed callbacks in network.c

    Seeing how you are running into some problems piecing together the needed components for OTA + provisioning, there is another route that you could pursue. Adapting the elock thermostat design (www.ti.com/.../tidc-01005) would be the most straightforward way for you to get all the features you want. The elock design has the OTA and provisioning built in, and runs off of the CC3220S. While it uses IBM as its MQTT broker instead of the AWS device shadows, you can take my thermostat AWS adaptation as a guide for how to migrate the Elock design to AWS.

    If you download the IBM-based CC3220 thermostat and then diff that against the AWS-based CC3220 thermostat, you'll see how the main difference is the addition of the AWS communication code in /aws, as well as the mqtt-related files being heavily modified. You should be able to apply that to the elock, and accomplish your goal of AWS communication, OTA and provisioning with the CC3220S.

    Regards,
    Michael
  •  I've decided to just build off of the wifi_thermostat example. So I went back to investigate my problem from the below image. This time I repeated my process to convert the CC3220SF cloud_ota sample to a CC3220S. I noticed that in the console, the project is still linked to the CC3220SF. So I don't think I have a memory problem, but rather a configuration problem. What steps am I missing to fully convert the project to CC3220S?

    "C:/Users/John/Desktop/CCS_WS/tirtos_builds_CC3220SF_LAUNCHXL_release_ccs/Debug/configPkg/linker.cmd", line 128: warning #10096-D: specified address lies outside memory map
    error #10264: DEFAULT memory range overlaps existing memory range SRAM0
    error #10264: DEFAULT memory range overlaps existing memory range SRAM
    error #10010: errors encountered during linking; "cloud_ota_CC3220S_LAUNCHXL_tirtos_ccs.out" not built

  • Hi Jack,

    Please see my previous answer e2e.ti.com/.../2790151

    I am 100% sure that my answer is correct. What you see at build log is "only" name of project. Please follow previous advices provided by Michael.

    Jan
  •  I said I retried my steps with the "CC3220SF cloud_ota" example. Are you able to try and convert the "CC3220SF cloud_ota" project to CC3220S successfully?

    I am mainly trying to see if I am missing any steps to convert any regular CC3220SF project (in general) to a CC3220S right now.

  • Hi Jack,

    Yes, I have not issue to port cloud_ota_CC3220SF_LAUNCHXL_tirtos_ccs from CC3220SF to CC3220S. I done following steps:

    • import cloud_ota_CC3220SF_LAUNCHXL_tirtos_ccs into workspace
    • removing files CC3220SF_LAUNCHXL.c, CC3220SF_LAUNCHXL.h, Board.h, CC3220SF_LAUNCHXL_TIRTOS.cmd
    • copy files from cloud_ota for CC3220S - CC3220S_LAUNCHXL.c, CC3220S_LAUNCHXL.h, Board.h, CC3220S_LAUNCHXL_TIRTOS.cmd
    • change dependencies from tirtos_builds_CC3220SF_LAUNCHXL_release_ccs to tirtos_builds_CC3220S_LAUNCHXL_release_cc
    • build

    Memory allocation before porting from SF to S and after porting:

    Comment to wifi_thermostat_CC3220SF_LAUNCHXL_tirtos_ccs. Original project (v3.0) requires 352kB of memory (280k + 72k). And CC3220S have only 256kB. There is no way how to fit 352kB into 256kB memory. Only possibility is a remove features from this project.

    Update: I quickly looked to wifi_thermostat source. Design of this code is nice and clean. It should not have any issue to remove unused features.

    Jan

  • Thanks. I got the wifi_thermostat working as CC3220S now.


    I have a general question about starting the OTA process for this project. On pg 37 of www.ti.com/.../tidudq7a.pdf, it says:

    "to trigger the OTA update, the OTA JSON variable should be set to 1 on the
    device shadow through the AWS IoT cloud interface."

    How do I do this? Do you have a screenshot of what this would look like?

    Lastly, when the CC3220S connected to a profile successfully, I get the below error when trying to connect to the "Shadow". How can I fix this?

    Shadow Init
    
    
    Shadow Connect
    
    
    ERROR: runAWSClient L#283
    SL_SOCKET_ASYNC_EVENT socket event 2, do restart
    Shadow Connection Error (-7)
    [SOCK EVENT] - Unexpected Event [20x]
    
    
    [MQTT Thread] Connection to broker failed, Error code: -7
    [MQTT Thread] MQTT Client not idle,  has state 11
    [MQTT Thread] MQTT Client Handle deleted
    [MQTT Thread] MQTT Client library initialized successfully

  • Hi Jack,

    To start the OTA process, you can modify the device shadow by directly editing the JSON shadow stored on the AWS cloud. If you select your device then access its shadow, there will be an edit button that you use to modify the JSON. 

    If you put the OTA variable there and press save, it will get picked up the shadow callback code on the CC3220 and invoke the OTA sequence.Since the CC3220 thermostat code will reinit the device shadow on reset, you must modify that struct while the CC3220 thermostat is already running and connected to AWS.

    The error that you see when connecting to AWS is probably due to either providing incorrect endpoint/device details in aws/aws_iot_config.h or due to not providing the correct certificates in aws/certs.h

    Regards,

    Michael

  •  I can't seem to figure out why AWS shadow won't connect. Could you try and test my endpoint, certificates, etc. out and see if it works?

    #define AWS_IOT_MQTT_HOST              "a37j7zivprtjq5-ats.iot.us-east-1.amazonaws.com" ///< Customer specific MQTT HOST. The same will be used for Thing Shadow
    #define AWS_IOT_MQTT_PORT              8883 ///< default port for MQTT/S
    #define AWS_IOT_MQTT_CLIENT_ID         "thermostat" ///< MQTT client ID should be unique for every device
    #define AWS_IOT_MY_THING_NAME 		   "thermostat" ///< Thing Name of the Shadow this device is associated with

    AWS.zip

  •  I still have no luck getting this working. I've tried using both "certs.h" files (attached below), but neither work. What do you suggest to get this working?

    1certs.h

    2certs.h

  • Hi Jack,

    I took the certificate files that you provided to make my own certs.h file and along with your aws_iot_config.h details tried connecting to AWS with my known-working CC3220 project. I got the the same -7 error that you encountered, and there are a number of reasons this could be the case, all of which have to do with the cloud configuration.

    1. Does your thermostat thing have a permissive iot policy set?
    2. Is your thing correctly associated with the certificates that you downloaded?
    3. Is the certificate associated with the thing activated?

    I advise you to look over section 3.2.2.1 of my thermostat TI design guide again and ensuring that you have followed those steps correctly.

    Regards,

    Michael

  • I've redone everything again. I went through all the steps and re-checked, but I still get the same error.

    Here is my new certs.h

    5140.certs.h

  • Hi Jack,

    Looking at your endpoint address, it looks like you are using the ATS version of your MQTT endpoint. This has a different root CA than the non-ATS endpoints. Please try providing the non-ATS endpoint in aws_iot_config.h and seeing it that fixes things.

    Regards,
    Michael
  •  Thanks. It works now. I also want to ask what is the subscribe and publish topics so that I can fill it in the iot console?

  • Hi Jack,

    The thermostat TI design uses device shadows, so it would be simplest if you checked the device state not through the online MQTT client, but directly on your thing's properties. If you access your thing, there is a 'Shadow' tab you can use to monitor the device shadow as well as directly modify the shadow.

    If you really want to use the MQTT pub/sub mechanism to control the device shadow, then you can look at the AWS documentation here:
    docs.aws.amazon.com/.../device-shadow-mqtt.html

    Regards,
    Michael
  •  Thanks. So I've been testing the OTA now, and I noticed that it seems to be stuck as shown below. How can I fix this?

    [MQTT Thread] Sending OTA command
    [Control Thread] Starting OTA...
    [OTA Task] OtaInit: statistics = 0, 0, 0
    [OTA Task] OtaInit: call Ota_init
    [OTA Task] OtaConfig: call OTA_set EXTLIB_OTA_SET_OPT_SERVER_INFO, ServerName=api.github.com
    [OTA Task] OtaConfig: call OTA_set EXTLIB_OTA_SET_OPT_VENDOR_ID, VendorDir=
    [OTA Task] OtaRunStep: status from Ota_run: OTA_RUN_STATUS_CHECK_NEWER_VERSION, accept and continue
    [OTA Task] OtaRunStep: CurrentVersion=00000000000000, NewVersion=test.tar, Start download ...
    [OTA Task] OtaRunStep: WARNING Ota_run, Status=20009, continue for next OTA retry
    [OTA Task] OtaRunStep: status from Ota_run: OTA_RUN_STATUS_CHECK_NEWER_VERSION, accept and continue
    [OTA Task] OtaRunStep: CurrentVersion=00000000000000, NewVersion=test.tar, Start download ...
    [OTA Task] OtaRunStep: WARNING Ota_run, Status=20009, continue for next OTA retry
    [OTA Task] OtaRunStep: status from Ota_run: OTA_RUN_STATUS_CHECK_NEWER_VERSION, accept and continue
    [OTA Task] OtaRunStep: CurrentVersion=00000000000000, NewVersion=test.tar, Start download ...
    [OTA Task] OtaRunStep: WARNING Ota_run, Status=20009, continue for next OTA retry
    [OTA Task] OtaRunStep: status from Ota_run: OTA_RUN_STATUS_CHECK_NEWER_VERSION, accept and continue
    [OTA Task] OtaRunStep: CurrentVersion=00000000000000, NewVersion=test.tar, Start download ...
    [OTA Task] OtaRunStep: WARNING Ota_run, Status=20009, continue for next OTA retry

  •  Never mind the last post. I've fixed it now. I do have a question about OTA in general though. I have a value called "state" with a value of "1" that is stored as a file in the CC3220, but when OTA occurs, the "state" is reset to "0". How can I retain the "state" value? How can I prevent OTA from overriding the existing file?

  • Hi Jack,

    It looks like I answered that last question in your other thread: e2e.ti.com/.../760844
    Please follow up there for the OTA topic. We'll close this thread for now.

    Best regards,
    Sarah