- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I can build and run snip/ota.fr properly in SDK 3.1.2. But the example doesn't show how to initiate the OTA app from any project application. Our product requires the user to initiate the ota upgrade from an Android app. Is there any API call to initiate the OTA application from the project application? After the API call, if the device will reboot, how can I have the Bootloader be able to copy the OTA Application from external flash into MCU RAM ? Any example code and documents?
Thanks
Solved! Go to Solution.
- Labels:
-
Over The Air Updates (OTA)
-
SDK 3.x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
have a look at Apps/snip/ota_fr/ota_fr.c. This file is just a small wrapper around the main API to start an OTA server ( WICED_ota_server_start ), calling this API from any application, will start an OTA server, try to receive the file, and after receiving it, set the boot loader to boot from the received file, restart the platform (and then the boot loader kicks in and copy the new received file). you can embed this API in any application you need and it will do the same. your application can use a signal from you phone (in any way like) to call this function and start the upgrade process.
Hope this answers your question.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
have a look at Apps/snip/ota_fr/ota_fr.c. This file is just a small wrapper around the main API to start an OTA server ( WICED_ota_server_start ), calling this API from any application, will start an OTA server, try to receive the file, and after receiving it, set the boot loader to boot from the received file, restart the platform (and then the boot loader kicks in and copy the new received file). you can embed this API in any application you need and it will do the same. your application can use a signal from you phone (in any way like) to call this function and start the upgrade process.
Hope this answers your question.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Our application is very cpu intense with 2 threads. Adding the ota_fr by calling wiced_ota_server_start() will create another thread, may use up all memories, and dramatically delay our real time audio streaming to the smartphone. So We want the OTA as an independent app from FR(Factory Reset) app and want to have an API call(very minimum task) to just initiate the OTA upgrade process from the Application. After the API call, the device reboots, bootloader copies the OTA App into MCU RAM. How can we achieve this?
In addition, are there any make target commands in SDK to do followings
1. build and download the otr_fr App to external flash.
2. build and download FR APP + FR DCT to external flash.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
What you are suggesting is totally valid and supported by WICED. WICED supports what we call multiapp file system in external flash. Its a list of applications written in external flash and can be booted from at any time. Some of those applications are specific to certain operations, while others are generic for the user. The list of supported applications are:
FR_APP: Factory reset application
DCT_IMAGE: Factory reset DCT Image
OTA_APP: OTA application
WIFI_FIRMWARE: A WLAN Firmware image (not fully supported yet)
FILESYSTEM_IMAGE: A read only file system
APP0: application 0
APP1: application 1
APP2: application 2
To put a certain application in its location in the multiapp file system (in external flash), all is required is the set the make variable for this application, for example (as in ota_fr.mk) to set the factory reset to the application we want we add in ota_fr.mk
FR_APP := $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).stripped.elf
DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf
So in your case, you need to create an app (very close to ota_fr, probably remove the LEG toggeling stuff), compile it and in your main application set your OTA_APP variable to point to it:
OTA_APP := build/snip_ota_fr-BCM943362WCD4/binary/snip_ota_fr-BCM943362WCD4.stripped.elf
your make target should also include download and download_apps (to download the mutli apps to external flash)
To reset the MCU and start the OTA application, you need two calls:
- static inline wiced_result_t wiced_framework_set_boot( uint8_t app_id, char load_once );
This will tell the boot loader to boot from the this application when restrted, app id, should be DCT_OTA_APP_INDEX and load_once should be true
- A call wiced_framework_reboot to reboot your MCU
Those functions are in wiced_framework.h (with documentation), also the ota_server is used them (to reboot in to the application again), you can use it as a guide on how to use them.
Hope this answers your question,
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Our main application has a DSP firmware that will be stored in the same external flash and will be loaded to the DSP after the main application is started. We want to upgrade the DSP firmware using the ota-fr example. My understanding is the existing ota-fr can only upgrade the app and save it to internal flash. How can we use the ota-fr to upgrade the DSP firmware and save it to external flash like application 0/1/2? I guess we have to modify the code in wiced_ota_server.c
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes, for now ota_server is writing only to APP0. in wiced_ota_server.c, you will find
if (wiced_framework_app_open( DCT_APP0_INDEX, &app ) != WICED_SUCCESS)
{
return -1;
}
replace DCT_APP0_INDEX with whatever index you want (APP1, APP2 would be a typical case). do the same thing for
wiced_framework_set_boot ( DCT_APP0_INDEX, PLATFORM_DEFAULT_LOAD );
we have also recently developed a tftp server and tftp snip applicatin that (based on name of received file) can update any of the files in the multi-app file system. it is not part of the release but if interested, I can pass it here.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Bdawood,
I am interesting the tftp server and tftp snip, Would you send a copy of the snip to me!
Thanks in advance!
Jone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
I am using SDK 3.1.2. Could you please send me a copy of the tftp server and tftp snip application?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
We want to upgrade two separate images. One is WICED main host(STM MCU) application. The other is the DSP firmware. The DSP chip is connected to STM MCU through SPI bus. The DSP image will be loaded through SPI interface in the WICED main host application and run on the DSP chip. We want to store the DSP image in the external flash that also stores FR_APP, DCT_IMAGE, OTA_APP, APP0, etc. Beside upgrading the host main application, we also want to upgrade the DSP image. I have following questions.
1. Can I use the ota_fr example to achieve the goal above? What changes I need to make?
2. I try to add APP0 := $(OUTPUT_DIR)/binary/(CLEANED_BUILD_STRING).stripped.elf in ota_fr.mk file and make target "snip.ota_fr_feng-ISM43362_M3G_L44 download download_apps run". I observe that it doesn't write the app0 image to the external flash.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Feng,
currently the ota_fr app is using the ota_server. The ota_server is doing two things that you need to change:
1- by default it writes to APP0, you need to need to change this to write to any other APP, Like APP1 for example (if you still want to keep APP0 for WICED upgrade)
2- After receiving the full file, ota_server call set boot function to tell WICED to load the new APP0 in to internal flash, you probably don't wan to do this when your APP is the DSP image.
Those 2 parts in are in libraries/deamons/ota_server/wiced_ota_server.c:
replace DCT_APP0_INDEX in wiced_framework_app_open with whatever app you need to write to
and comment out wiced_framework_set_boot function call.
Also note, this change is rather a proof of concept, because then you need to way later to tell the ota_server to either write to APP0 or APP1, depending on which one you want to update. Right now this is not included in the ota_server (may be the tftp apps that I'll try to upload soon may help)
finally, after writing an to serial flash, please not the the file size is aligned to sector size of the your flash (currently 4K), is if your DSP file size is 14K for example, the multi-app will see it as 16K, for our applications this is not big deal, because we put elf files so all data we need are within the file, if however your DSP image is a binary, you need a way to retrieve the actual size that you need to write to the DSP.
Hope this answers your question.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
We want to keep APP0 for WICED upgrade and use APP1 for DSP upgarde.
First step, I want to use WICED SDK 3.1.2 build to write the DSP image to external flash APP1. I add APP1 := silabs_image\fmhd_radio_4.0.10.bin in ota_fr.mk file below and make target "snip.ota_fr_feng-ISM43362_M3G_L44 download download_apps run". I observe that it doesn't write the DSP image to the external flash.
//ota_fr.mk
....
#Set factory reset application to be this same application.
FR_APP := $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).stripped.elf
DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf
APP1 := silabs_image\fmhd_radio_4.0.10.bin
//console output
Downloading Bootloader ...
Building apps lookup table
No changes detected
Downloading DCT ...
No changes detected
Downloading Application ...
No changes detected
Downloading FR_APP (build/snip_ota_fr_feng-ISM43362_M3G_L44/binary/snip_ota_fr_feng-ISM43362_M3G_L44.stripped.elf) at sector 1...
Downloading DCT_IMAGE (build/snip_ota_fr_feng-ISM43362_M3G_L44/DCT.stripped.elf) at sector 122...
Downloading APP1 (silabs_image\fmhd_radio_4.0.10.bin) at sector 128...
tools/makefiles/wiced_apps.mk:125: recipe for target 'APP1_DOWNLOAD' failed
Makefile:185: recipe for target 'main_app' failed
make.exe[1]: *** [APP1_DOWNLOAD] Error 1
make: *** [main_app] Error 2
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
I have fixed the APP1 loading issue. Now I can use the WICED SDK 3.1.2 build to write the DSP image to external flash APP1.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry for the delay, please find the attached patch for tftp library and snip app. The application can be configured as a client or a sever (to put or get files). if using windows please give good attention to windows firewall as it tends to block tftp applications. Linux is easier in this point.
This patch is based on WICED version 3.3.0, but I don't expect any problems if applied to WICED 3.1.2
This is a preliminary version, feel free to point me to bugs so that we can work on next release.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
Got it.
And put into SDK 3.1.2 without any issue!
I will verify and update status to you!
Thanks
Jone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
I hit below issue when the size of new firmware is different from origianl firmware.
It seems the writing error start when reach the current size.
I print the current_size and file_size (tftp->transfer_size)in snip_tftp_establish().
printf( "current size %lu file_size=%u\n", current_size, (unsigned) file_size);
Maybe the problem is why the file_size is 0 here.
Any comments? Did I miss something?
Below is my test step:
$ tftp 192.168.10.1
tftp> binary
tftp> put app0.elf
Sent 328520 bytes in 7.4 seconds
tftp> q
current size 331776 file_size=0
new size 331776
Writing size 512 from offset 0 [0x7f]
Writing size 512 from offset 512 [0x0]
Writing size 512 from offset 1024 [0x0]
....
Writing size 512 from offset 330752 [0x72]
Writing size 512 from offset 331264 [0x1]
Writing size 512 from offset 331776 [0x61]
Error Writing
Writing size 512 from offset 332288 [0x6e]
Error Writing
Writing size 512 from offset 332800 [0x54]
Error Writing
Writing size 512 from offset 333312 [0x25]
.......
Error Writing
Writing size 512 from offset 360960 [0xf4]
Error Writing
Writing size 512 from offset 361472 [0xf4]
Error Writing
Writing size 512 from offset 361984 [0x0]
Error Writing
Writing size 192 from offset 362496 [0x3]
Error Writing
File transfer complete.
Restarting...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sam.lin,
Two things come in mind, first make sure your make target has the download_apps in it (i.e):
snip.tftp-BCM943362WCD4 download donwload_apps
second (which I think may be more relevant) is the size of your APP/flash. At what offset is your APP0 in the flash? will the external flash take the full size of the new app (along with DCT and FR apps)?
A simple test you can do to verify this is to comment the FR_APP in the make file (keep the DCT), This is only for test, but it will basically not download the factory reset application to serial flash, so you should have more size in flash to download your new application.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Bassem,
I'm sure I have "donwload_apps" and it works if the firmware size does not chagne.
The problem only happens when new firmware size is different from old firmware size.
I should mention that I test it on 4390.
But I think this is platform independent. see below comments.
My use case is I'm running tftp_server on my device,
and on my PC I sent "put app0.elf".
I think the problem is the new file size is not set.
If I hard-coded the new file_size in snip_tftp_establish, the ota success!
e.g.
In snip_tftp_establish():
uint32_t file_size = tftp->transfer_size; // this is always zero
// I added below line for test
file_size = 362976; //Explicitly set (hard-coded) file_size to new firmware size
I don't find any command to set the file_size.
Did I miss something?
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sam.lin,
By default the tftp protocol doesn't send the size (just blocks of bytes), However, new tftp servers support extensions which can by used to send the size at the establishment of connection (RFC2349). Please read the comments in tftp.c. Make sure that your tftp server support extensions. if your using Ubuntu, try atftpd (advance tftp) rather than normal tftp server.
The other way is to find another path to set your size (or set it to a constant)
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
I don't get it.
I use TFTP_SNIP_SERVER rather than TFTP_SNIP_GET.
I have tftp_server_start() running on broadcom platform rather than on PC.
That is why I sent "put app0.elf" on my PC.
I did not setup tftp server on my PC at all.
I just tried atftp and sent "put app0.elf". Still got the same error.
Or do you mean the tftp snip only works for TFTP_SNIP_GET case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
I replaced WICED_STA_INTERFACE in tftp.c with WICED_AP_INTERFACE and did below in tftp.c
/* Undef TFTP_SERVER to run the test as a client */
#define TFTP_SNIP_SERVER
I made changes in tftp.mk below
#Set factory reset application to be this same application.
#FR_APP := $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).stripped.elf
#DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf
APP0 := $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).stripped.elf
APP1 := silabs_image/dsp_image.bin
My make target is "snip.tftp-ISM43362_M3G_L44 download download_apps run". I can upgrade app0 image properly from the tftp CS free app on my Samusang Galaxy tablet. As you knew in my previous email, We want to upgrade two separate images. One is WICED main application. The other is the DSP firmware. The DSP chip is connected to STM MCU through SPI bus. The DSP image will be loaded through SPI interface in the WICED main application and run on the DSP chip. We want to store the DSP image in the external flash as app1. The same external flash also stores FR_APP, DCT_IMAGE, OTA_APP, APP0, etc. After upgrading the DSP image(app1), we want to the system to reboot from app0 or the image in internal flash. I have following questions.
1. Right now after I upgrade the app1 image, it will reboot from the new app1 image. where can I make the code changes for rebooting from the app0 or the image in internal flash after upgrading the APP1(DSP image)?
2. What is the address info where the DSP is stored in external flash? We need the address to read the DSP image in Wiced main application.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Feng,
in apps/snip/tftp/tftp.c @ snip_tftp_close
if ( status == TFTP_NO_ERROR )
{
printf( "File transfer complete.\r\n" );
if ( ( tftp->request == TFTP_GET ) && ( file_index == DCT_APP0_INDEX ) )
{
wiced_framework_set_boot( file_index, PLATFORM_DEFAULT_LOAD );
printf( "Restarting...\n" );
wiced_framework_reboot( );
}
}
So as you in this code restarting from a new up is only done if APP0 is updated not APP1 and offcourse you can change this to you convenience. the snip_tftp_close is just a call back after the file transfer is complete.
As for the address of the file (APP1), you don't really need the address (you shouldn't be using it) . To read the file you just handle it as a file system call, ie.
Open: wiced_framework_app_open pass DCT_APP1_INDEX as the index
Read: wiced_framework_app_read
Close: wiced_framework_app_close
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sam.lin
I'll try to test your scenario and let you know soon. In the mean time, if applicable you can use the WICED board as the client and have atftpd running on the server and see if this works for you.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
Thanks for your support.
Somehow setup a tftp server is not easy for some of our customers.
So we decide to run tftp server on the device.
Btw, it seems below is a typo?
if ( strcmp( filename, "app1.elf" ) == 0 )
{
return DCT_APP0_INDEX;
}
app1.elf should write to DCT_APP1_INDEX,.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sam.Lin
As mentioned before, you need to pass the size of the file you are sending, even if you your machine (PC) is a client you can still achieve this with atftp, you just need to set this explicitly, So try:
atftp --option "tsize 297504" --put -l app0.elf 192.168.1.128
offcoure replace the ip address with the WICED ip address.
See if this solves your problem.
Regards,
Bassem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bassem,
Yeah, it works. Thanks a lot for your support.
It might be helpful for others if you can document this somewhere.
Thanks.