OTA updates on CYBT-213043-02 module

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
CoreyW_81
Employee
Employee
50 sign-ins 50 replies posted 25 replies posted

I’m working on OTA updates now and (hopefully) only have a minor issue.

I found the Android updating app and installed it to my phone – it looks like it is working.

I found the sample app and copied the required code to my firmware.

When I compiled, all of the firmware update functions were unresolved.

I hit the “Select Middleware” icon in MTB and selected fw_upgrade_lib.

I recompiled the program and it compiled correctly.

I loaded it into my radio and wiced_ota_fw_upgrade_init() ran successfully – the image storage pointers also look correct.

It looks like I am all set to go … except … when I compile, I don’t create a .bin file.  I looked online and tried a number of things:

  • Putting “OTA_FW_UPGRADE=1” on the command line.
  • Putting “OTA_FW_UPGRADE=1” in the modus.mk file.
  • Putting “CY_APP_DEFINES = -DOTA_FW_UPGRADE=1” in the modus.mk file.

Do you know what I need to do?

0 Likes
7 Replies
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi Corey Wilner,

Could you please provide following information.

->Which application are you trying to compile?

->Which android app are you using?

->Are you using MTB2.0?

Just for the confirmation, your query is, "you are able to compile the application, but it doesn't create a .bin file compatible for OTA. Why?"

Please let me know if my understanding is wrong.

Thanks,

-Dheeraj

0 Likes

Hello Dheeraj,

Corey was asking on my behalf.  First your answers:

->Which application are you trying to compile?

My project is based on the hello_sensor project.

->Which android app are you using?

I am using LE OTA App v1.0.

->Are you using MTB2.0?

No.  I started the project with MTB 1.1.0 build 234 and don't want to change if I can avoid it.

Since, Corey posted, he pointed me to the MESH Dimmer project and I've been working on merging the differences.  I am now building the .bin file but there are slight differences in the console output pertaining to output file creation:

Dimmer project

Building in XIP section
Appending DS2 section
building OTA upgrade image (*.bin)
Adjusting image to trim DS2 app, we only want to ota update with DS1 + XIP code
OTA Upgrade file size is 150348
DS length 248832, OTA image size 150348

Post build processing completed

My project

Building in XIP section
building OTA upgrade image (*.bin)
OTA Upgrade file size is 127873
DS length 128512, OTA image size 127873

Post build processing completed

I was able to connect to my radio with the LE OTA App and select download.  Here is a portion of the trace log:

OTA handle cmd:1 state:0
OTA handle cmd:2 state:1
calling wiced_firmware_upgrade_init_nv_locations
done calling wiced_firmware_upgrade_init_nv_locations
state 2 total_len 127873
ota_fw_upgrade_handle_data
ota_fw_upgrade_handle_data
fw_upgrade_erase_sector:0 len:4096 ts 0x2951cec
   complete
sflash_write to:0 len:512
   complete
write failed, returned 0
ota_fw_upgrade_handle_data
ota_fw_upgrade_handle_data
sflash_write to:200 len:512
   complete
write failed, returned 0
...
ota_fw_upgrade_handle_data
sflash_write to:1f200 len:388
   complete
write failed, returned 0
OTA handle cmd:3 state:2
sflash_read from:0 len:128
sflash_read failed
sflash_read from:80 len:128
sflash_read failed
sflash_read from:100 len:128
sflash_read failed
...
sflash_read from:1f380 len:4
sflash_read failed
stored crc:4f1d2b84 received bytes crc:59bc9805 recvd crc:59bc9805
Verify failed

I am now in the process of going through the project settings to check for any other differences.  I'll post here again if I can't resolve this (or if I do) but if there is anything you know offhand, I would appreciate it.

Thanks

-Bill

0 Likes

Hello again,

A quick follow-up.  I did find some differences in the build settings and now at least the file creation portion appears similar.  I still get the same results when I try to perform the OTA upgrade.  I just found another difference in the settings but won't be able to resolve it until Monday.

-Bill

EDIT: Using the Dimmer project to figure out how to create the .bin file was a good idea.  Copying all the build settings - not so much.  The Dimmer project uses the CYBT-213043-MESH platform (which HAS an external SFLASH) whereas I am using the CYBT-213043-EVAL platform (which does NOT).  That accounts for all of the errors during the writes and reads.  I removed the defines for OTA_FW_UPGRADE_SFLASH_COPY and ENABLE_SFLASH_UPGRADE and have made some progress.

I still don't quite have something right.  I've set DS_LOCATION=0x501400 and DS2=0x53E000.  When I try to do an OTA upgrade, it appears to be trying to load to 0x53E000.  It appears to be writing successfully until it reaches 0x540000 when it starts failing (end of memory?).  In looking at the .map file, it appears the firmware upgrade functions are located at 0x53E000.  However, they don't appear to be over-written (can perform multiple attempts to upgrade).  I'll attempt to figure out the correct settings for DS2 but in the meantime, if anyone has any suggestions, I would appreciate it.

-Bill

0 Likes
lock attach
Attachments are accessible only for community members.

I’ve attached a log from my latest attempt.  I just picked DS2=0x51FA00 since it would make two equal areas (0x501400 – 0x51FA00 and 0x51FA00 – 0x53E00).  I turned on ENABLE_WICED_FW_DEBUG to see what was going on.  It looks like it is doing everything correct but does not recover from the subsequent reset.  I suspect it is one of the following:

  1. The boot firmware does not know where to find DS2 and is ending up in the weeds.
  2. My code is not compiled as position independent code.

  I’m not sure how to solve either one of those issues.  I’ve attached a log of my OTA update

0 Likes
lock attach
Attachments are accessible only for community members.

Here is the attachment.

-Bill

0 Likes
lock attach
Attachments are accessible only for community members.

I've attached a new log.  I found that the value for DS2 in the .btp file was 0x520A00 so I changed my settings accordingly.  Things are still not correct.  I programmed the board with a version string "0.74", then recompiled to get a bin file with version "0.75".

When the board is powered, I get the correct version, the dumps of both sections (DS1 and DS2) look correct, and the active section is shown as 0x501400.  The first download completes successfully, and on reset, the active section is shown as 0x520A00 and the section dumps look correct, however, the version still reads "0.74".

On the second download, the download stalls at 0x51C000 and the board hangs.  Upon inspection of the map file, this is where the fw_upgrade functions are located and I suspect the board is hangingwhen those functions are overwritten.  Again power cycling the board, the active section and section dumps look correct but the version is still incorrect.  Trying to do any subsequent downloads fail right away as I suspect the call to wiced_firmware_upgrade_init_nv_locations() is calling corrupted memory.

To further add to the mystery, on at least two occasions (there have been many), the firmware version has updated correctly, although not at the initial reset after the upgrade. 

It appears that the MCU is running code out of DS1 even though the active section is DS2.  I'm not sure how to verify and fix this.  Anyone have any ideas?

-Bill

0 Likes

Concluding this thread.

Dev team has detected a bug in the OTA firmware update and the fix will be available in the upcoming BTSDK release.

Thanks,

-Dheeraj