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.

CCS/CC3220SF: Recent dropbox access token changes may require updates to TI OTA feature.

Part Number: CC3220SF


Tool/software: Code Composer Studio

Dropbox is giving clients until Sept 30th of 2021 to transition to their new access token protocol (they are deprecating the old one). We are using the TI toolset to build a product and our OTA feature is based on the example application code supplied by TI which depends on the underlying TI OTA library. The two items below:

#1 Ti Supplied Example Over The Air Update (OTA) application:
/Applications/ti/simplelink_cc32xx_sdk_4_10_00_07/examples/rtos/CC3220SF_LAUNCHXL/demos/cloud_ota

#2 Ti underlying OTA library:
/Applications/ti/simplelink_cc32xx_sdk_4_10_00_07/source/ti/net/ota

Am I correct that this portion of the simplelink tools are impacted by the recent DropBox announcement? Will there be an upcoming simplelink version that offers the necessary changes to migrate to Dropbox's new requirements? Below is a [portion of] the screen shot of the email notification we received from Dropbox regarding the issue. Thanks in advance!

  • Hi,

    We are learning about this update and will provide a fix in one of the following (quarterly) SDKs if needed.

    It seems that the current method can still work, but if a fix will be required we will notify about it.

    Br,

    Kobi

  • Hi Kobi,

    Just to give a bit more info -- I tried the current TI OTA method yesterday (SimpleLink 4.10) and could not get it to work with a newly created Dropbox folder that uses their new access auth (yet this system does work against the old style Dropbox folder). I believe I made the proper adjustments to otauser.h for that experiment. In particular, new settings for:

    #define OTA_VENDOR_DIR, and OTA_VENDOR_TOKEN

    If you know of something additional that is required please let me know.

    Here's is the transcript of that failed run.

    In setOTA() aId=2, to value 1
    PuzlLabs thread1(10) notified.
    PuzlLabs thread1(caseID_Initiate_OTA) notified.
    Calling Start_OTA_Process(true)
    entered Start_OTA_Process()
    ... launching the OtaTask() thread.



    SimpleLinkInitCallback: started in role -2012, set the requested role 0

    ********************************************************************************

                      OTA APP Application - Version 0.10.00.03        

    ********************************************************************************

    Host Driver Version: 3.0.1.61

    Build Version 3.15.0.1.31.2.0.0.0.2.2.0.7

    STA connected to AP speedyquick,
    BSSID is 60:19:71:16:f5:90

    NetApp event == SL_NETAPP_EVENT_IPV4_ACQUIRED.

    IPv4 acquired: IP = 192.168.0.16

    Gateway = 192.168.0.1

    Pinging GW...!

    (reminder) HAPserverThread_entry() stalled until next reboot or resume.
    NetApp event == SL_NETAPP_EVENT_IPV6_ACQUIRED.

    Ping done. Success rate: 100%



    Running OtaCheckAndDoCommit()
    HandlePingComplete: OTA Command arrived

    OtaInit: statistics = 0, 0, 0

    OtaInit: call Ota_init

    OtaConfig: call OTA_set EXTLIB_OTA_SET_OPT_SERVER_INFO,ServerName=api.dropboxapi.com

    OtaConfig: call OTA_set EXTLIB_OTA_SET_OPT_VENDOR_ID, VendorDir=OTA_Access_Controller

    OtaRunStep: WARNING Ota_run, Status=20004, continue fornext OTA retry



    (reminder) HAPserverThread_entry() stalled until next reboot or resume.
    OtaRunStep: WARNING Ota_run, Status=20004, continue fornext OTA retry



    NetApp event == SL_NETAPP_EVENT_IPV6_ACQUIRED.

    OtaRunStep: WARNING Ota_run, Status=20004, continue fornext OTA retry



    (reminder) HAPserverThread_entry() stalled until next reboot or resume.
    OtaRunStep: WARNING Ota_run, Status=20004, continue fornext OTA retry





    OtaRunStep: FATAL ERROR from Ota_run -21003 !!!!!!!!!!!!!!!!!!!!!!!!!!!



    Test failed: State = 6, Event = 17

    Event handler for gTransitionTable[6] failed..!!!



  • Hi Kobi,

    One thing that seems suspicious to me is that inside TI's ota.h is the following:

    #define MAX_VENDOR_TOKEN_SIZE   96

    And yet I notice that the access tokens that Dropbox now issues are longer. The new one that Dropbox issued to me (and that I tried unsuccessfully to use yesterday) is 139 characters long vs the 65 character tokens of old. Would you like me to adjust this setting a do another experiment, or is there possibly other things you already know about that might need to adjust as well? For example: Not sure about the following:

    #define OTA_SERVER_REST_HDR           "Authorization: Bearer "   // of TI's CdnDropboxV2.c

    Thanks,

    Steve.

  • Yes, if the token is now longer - you should update the MAX_VENDOR_TOKEN_SIZE definition.

    Please also enable the OTA library debug messages (uncomment the "SL_ENABLE_OTA_DEBUG_TRACES" in otauser.a) so we get more info on the failure.

    Br,

    Kobi

  • Hi Kobi,

    I might be reaching a limit on how much more time I can devote to the experiments you suggested. When I increased MAX_VENDOR_TOKEN_SIZE to 150 the OTA operation system locks up shortly after OTA is initiated. I wanted to do a second run with SL_ENABLE_OTA_DEBUG_TRACES defined but it wouldn't link as it complained there was no function defined for prototype "int Report(const char *format, ...)". I attempted to implement a function to satisfy the calls OTA debug tracing needed but I can't seem to figure out how to handle the variable argument list. In other words, this implementation of Report() didn't work for me. If you have a suggestion on how to correct this implementation I'll give it another try. Or maybe by now the TI team as already proceeded with additional development/debug needed to support the new DropBox access tokens. Can you let me know. Thanks.

    #include <ti/display/Display.h>
    extern Display_Handle display; // Initialized at boot by user code.
    int Report(const char *format, ...)
    {
        // In the next call we pass along the incoming parameters proceeded with a few
        // values required for the underlying Display_doPrintf() as implemented by TI.
        // See Display.h
        Display_doPrintf(display,0,0,format,...); // compile error.
                                                  // How to pass along the incoming variable list?
        return NULL;
    }

  • For adding the debug, replace the following line (in otauser.h):

    #define _SlOtaLibTrace(pargs) Report pargs
    
    

    with:

    #include <ti/display/Display.h>
    extern Display_Handle display;
    #define _SlOtaLibTrace(...) Display_printf(display, 0, 0, __VA_ARGS__);

    Regarding the issue with the token size, we will try to check this today or early next week.

    br,

    Kobi

  • Hi Kobi,

    Thanks for that proposed code. Very cool. Variable argument processing is a weak point for me. I put your suggested code in place and get the following compile warnings.

    CdnClient.c", line 56 (as just one example):
    _SlOtaLibTrace(("CdnClient_ConnectServer: HttpClient_Connect %s\r\n", pOtaServerInfo->ServerName));

    Generates warnings:
    ti/net/ota/source/CdnClient.c", line 56: warning #176-D: expression has no effect
    ti/net/ota/source/CdnClient.c", line 56: warning #169-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *

    All the OTA source code references to _SlOtaLibTrace() generate the warnings. I think something needs to change to account for the format string parameter that proceeds the variable argument list. Can you suggest a tweak?

    Maybe change your suggestion of:

    #define _SlOtaLibTrace(...) Display_printf(display, 0, 0, __VA_ARGS__);

    ...to someting like this instead:

    #define _SlOtaLibTrace(fmt,...) Display_printf(display, 0, 0,fmt, __VA_ARGS__);

    I know that isn't the right syntax, but something like that. Any ideas?

    Thanks,
    Steve.

  • I see. the problem is that _SlOtaLibTrace is used with double parenthesis (i missed that).

    Maybe something like this will work:

    #include <ti/display/Display.h>
    extern Display_Handle display;
    #define _SlOtaLibTrace(...) _OtaLog_ __VA_ARGS__
    #define _OtaLog_(...) Display_printf(display, 0, 0, __VA_ARGS__);
    

      

  • Hi Kobi,

    That syntax change you recommended did allow me to get a clean build. I re-ran the OTA experiment (using the new style longer Dropbox access token and the longer definition for MAX_VENDOR_TOKEN_SIZE), I enable OTA tracing, and the following transcript shows where it hangs:

    [Transcript of OTA attempt]
    SimpleLinkInitCallback: started in role -2012, set the requested role 0

    ********************************************************************************

                      OTA APP Application - Version 0.10.00.03        

    ********************************************************************************



    exiting Start_OTA_Process()
    HAPEngine_stop() must have been called.
    (reminder) HAPserverThread_entry() stalled until next reboot or resume.
    SimpleLinkInitCallback: restarted in role 0

    Host Driver Version: 3.0.1.61

    Build Version 3.15.0.1.31.2.0.0.0.2.2.0.7

    STA connected to AP speedyquick,
    BSSID is 60:19:71:16:f5:90

    NetApp event == SL_NETAPP_EVENT_IPV4_ACQUIRED.

    IPv4 acquired: IP = 192.168.0.16

    Gateway = 192.168.0.1

    Pinging GW...!

    (reminder) HAPserverThread_entry() stalled until next reboot or resume.
    NetApp event == SL_NETAPP_EVENT_IPV6_ACQUIRED.

    Ping done. Success rate: 100%



    Running OtaCheckAndDoCommit()
    HandlePingComplete: OTA Command arrived

    OtaInit: statistics = 0, 0, 0

    OtaInit: call Ota_init

    OTA_init: sizeof CdnClient=576, sizeof OtaArchive=4956

    OTA_init: sizeof OtaLib_t=7792, sizeof OTA_memBlock=7800

    OTA_init: OTA lib version = OTA_LIB_2.0.0.7

    OtaArchive_Init: OTA archive version = OTA_ARCHIVE_2.0.0.4

    OtaConfig: call OTA_set EXTLIB_OTA_SET_OPT_SERVER_INFO,ServerName=api.dropboxapi.com

    OtaConfig: call OTA_set EXTLIB_OTA_SET_OPT_VENDOR_ID, VendorDir=OTA_Access_Controller

    OTA_run: call CdnClient_ConnectServer OTA server=api.dropboxapi.com

    CdnClient_ConnectServer: HttpClient_Connect api.dropboxapi.com

    HttpClient_Connect: IP_ADDR=162.125.7.19

    HttpClient_Connect: WARNING Socket Connect, status=-468, Ignored...

    OTA_run: CdnClient_ReqOtaDir, VendorDir=OTA_Access_Controller

    CdnDropbox_SendReqDir: uri=/2/files/list_folder


    [system hung at this point]

  • Hi Steve,

    in CdnDropboxV2_SendReqDir() (within CdnDropboxV2.c) you will need to increase the size of ReqDirCmdBuf. 

    250B (instead of 200) should be enough to prevent the HW exception you are getting.

    However once i've done this, i'm facing some authorization issue (HTTP error 401), so i need to read the documentation once again (i may missed something in the creation of the new Dropbox app or need to update the request).

    br,

    Kobi

     

     

  • Hi Steve,

    It seems that if you set the "Access token expiration" as "No Expiration" and then generate the token - it will be short (as before) and new app will work.

    Make sure the right permissions are set also (i.e. at least the "files.metadata.read" and "files.content.read").

    Br,

    Kobi

     

  • Hi Kobi,

    I tried the experiment today using the new shorter DropBox Access Token and paid attention to setup the Dropbox permissions for readibility as you suggested. For my experiment I reverted the earlier experiments you had suggested and put the TI OTA feature back to it’s original form. In other words:

    #define MAX_VENDOR_TOKEN_SIZE   150

    …was put back to…

    #define MAX_VENDOR_TOKEN_SIZE   96

    And the two instances of:

    uint8_t ReqDirCmdBuf[250];

    …were put back to…

    uint8_t ReqDirCmdBuf[200];

    At this point I was back to the same cc32xx_sdk_4_10_00_07 source that I had been using successfully with the old style DropBox Access Tokens except of course I made the necessary two lines of edit to the following otauser.h definitions to accomodate the new 65 byte DropBox Access Token I had just acquired for the experiment.

    #define OTA_VENDOR_DIR  …

    #define OTA_VENDOR_TOKEN …

    I was unable to get a successul connection to DropBox. The transcript shown below shows the particular http error encountered. Again, putting the two lines of otauser.h back to that of the old style DropBox access token puts me back to a working OTA feature. If there was some additional logic change required to migrate to the new DropBox Access Tokens I’d be happy to try it.  See below for error:

    Thanks,

    Steve K.

  • Hi Steve,

    Please check your settings. Make sure the token and folder name in "otauser.h" matches exactly the Dropbox settings.

    I've verified this with the original OTA library.

    The only exception is that I enabled all the permissions in Dropbox (read and write) although i believe only the read access is relevant. 

    Br,

    Kobi

  • Hi Kobi,

    I verified that all the names matched exactly. Also, I decided to completely start from scratch with a brand new DropBox setup and to capture the screen shots along the way. I got exactly the same failure on this latest attempt. Is there a chance you can glance at all the screen shots below and validate I've used the correct steps. The last screen shot is my attempt to do OTA using the newly create Access Token and Folder name. Again, if is simple change two lines in my otauser.h back to the old DropBox settings the OTA feature once more works. Just not with the new DropBox setup. See below for setup:

    Thanks,

    Steve K.

  • Did you get the shorter (standard) token?

    The only difference between your dropbox app and  mine is that as i said before i enabled all the permissions (read and write).

    Other than this it can only be a typo of some source (wrong/incomplete token etc).

    I really don't know how to help with it. Maybe you can get the Dropbox support to provide logs that will explain this.

  • Hi Kobi,

    Wow, not sure what to say. Strange. I literally did a cut-and-paste of the new [shorter] DropBox access token and of the new DropBox Folder name to illuminate any possibility of a typo.  Can I ask, are you using the simplelink_cc32xx_sdk_4_10_00_07 version for your test?

    I suppose I could retry my test with all DropBox permissions checked, or maybe you were planning to do a test with just the "read" ones checked to match my test run. Otherwise it sounds like that might be the only difference between our experiments. Yes? Is that something you can check? Just the "read" permissions.

    And also, I'd like to confirm that in your case you are switching between the old system and the new one by changing exactly two lines in your otauser.h file. These two definitions only, correct? Nothing more, and with none of your other preliminary debug logic changes/experiments possibly inadvertently still in place:

    #define OTA_VENDOR_DIR

    #define OTA_VENDOR_TOKEN

    Thanks,

    Steve.

  • Yes, the OTA_VENDOR_DIR and OTA_VENDOR_TOKEN are the only thing you need to update.

    Tested it and verified that the OTA works even with only the read permissions.

    I'm using the CloudOTA and OTA lib from SDK 4.30 (i don't think there where any significant update from 4.10 - but you may try the latest).

    Br,

    Kobi

  • Hi Kobi,

    Unfortunately I will not be able to try the 4.30 as I need to stick with the version that supports the latest available HAP plugin library. Not sure how easy it might be for you to revert back to 4.10 for a test in the event that something indeed may have changed between the two versions. Also, can I confirm that in addition to creating the new DropBox App (where the permissions are established and where you generate the new Access Token) that beyond this you then also created a specific new DropBox folder (within that newly created DropBox App) and that is the folder name that you itemize in otauser.h and that is the folder that you place the *.tar file. Is that correct? In other words, looking back on my screen shots you'll see how I have the *.tar file placed at DropBox location: Apps > PUZL_HOME_OTA > ACCESS_CONTROLLER_OTA > *.tar

    And in my case the otauser.h definitions relate to this as follows:

    #define OTA_VENDOR_DIR  ACCESS_CONTROLLER_OTA

    #define OTA_VENDOR_TOKEN "<the 65 byte token generated for the PUZL_HOME_OTA DropBox App>"

    Thanks,

    Steve K.

  • ... Correction with what I typed in last post ...

    #define OTA_VENDOR_DIR  "ACCESS_CONTROLLER_OTA"

  • Yes, I created a new folder (new name) under the new application and updated both OTA_VENDOR_DIR and OTA_VENDOR_TOKEN accordnigly.

    Br,

    Kobi