OTA upgrade problem

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

cross mob
Anonymous
Not applicable

Hello,

I have problems with OTA upgrade...

If I try example:

make snip.ota_fr-BCM943362WCD4 download download_apps run
OTA runs and i can upgrade example app snip_scan-BCM943362WCD4.stripped.elf (size 275 KB)

All works fine. Also If I hold SW1 button and push reset, the FR_APP (OTA loader) is restored and OTA runs again.

But if I try upgrade apliance demo (demo.appliance-BCM943362WCD4) and load stripped.elf (size 523 KB)

app doesn`t run....
If try my custom app (size about 820 KB), app doesn`t run and I can`t restore FR_APP (OTA app).
It seems like all i owerwrited..

How should I modify makefile to produce smaller size elf file (exclude wifi firmware, DCT......)?
Is it possible?
Similar question: http://community.broadcom.com/thread/3483?sr=stream&ru=13192

I tried SDK 3.1.1 and 3.1.2 but result is the same.

0 Likes
1 Solution
Anonymous
Not applicable

Hi Sam.Lin

One approach is use the DCT.stripped.elf and rather than using WICED frame work APIs (wiced_app_read_chunk and wiced_app_write_chunk), try to use the wiced_dct_restore_factory_reset(); directly.

I have never tried it before, but I don't see a reason why it shouldn't work. with a bit of debug, you can get it to work.

Regards,

Bassem

View solution in original post

0 Likes
11 Replies
Anonymous
Not applicable

Same problem with me.

In bootloader.c , 

Bootloader seems to be changed from SDK 3.1.1. to 3.1.2.  But FR_APP loading error occured

Following code does not seemt to work in BCM4390. 

#ifdef PLATFORM_HAS_OTA

    NoOS_setup_timing( );

    if ( wiced_waf_check_factory_reset( ) )

    {

        wiced_dct_restore_factory_reset( );

        wiced_waf_app_set_boot( DCT_FR_APP_INDEX, PLATFORM_DEFAULT_LOAD );

    }

    NoOS_stop_timing( );

#endif

0 Likes
SeyhanA_31
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi,

Please check out OTA Slots as defined in ota_fr.c.

Does it answer your question?

Seyhan

0 Likes
Anonymous
Not applicable

seyhan

It was driven from make file mistake.  we used dct.bin file.

This makes all problem, all are solved via Broadcom's technicall supprts.

Thanks for your supports.

FR_APP := $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).stripped.elf

#DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin       // <-- we put the DCT.bin file, this is mistakes

DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf   // <-- this make it works

//About this one : #DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin

- I did not know how to download DCT Image, and found this information from forum.

  So it drove me to mistakes. If you this information "Factory MFG manual",

  I would be helpful

Thanks

0 Likes
Anonymous
Not applicable

Hi,

My test got different result! (Test on 4390)

DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin works.

DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf does not work.

If using DCT.stripped.elf, reboot the devcie then wiced_network_up() always

fails.

So can someone confirm which setting is correct?

Any comments, bdawood?

Thanks.

0 Likes
Anonymous
Not applicable

Hi,

you should use

DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf


As to why it is not working on your side, this needs a bit of investigation.


Can you please explain more what is happening?


Regards,

Bassem

0 Likes
Anonymous
Not applicable

Hi Bassem,

Thanks for your reply.

When using DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf and do restore default settings,

below code always returns 2020.

    result = wiced_network_up(WICED_AP_INTERFACE, WICED_USE_INTERNAL_DHCP_SERVER,

                              &network_setting->ap_ip_settings);

My guess is dct reading does not return correct settings.

What I did to restore default settings is exactly the same as below:

http://community.broadcom.com/message/9153#9153

My first question is why using DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin can work?

(We have been using DCT.bin for a while and it works.)

What is the difference between DCT.bin and DCT.stripped.elf?

Note, DCT.stripped.elf is bigger than DCT.bin.

I just found DCT.stripped.elf is ELF 32-bit LSB  executable format.

Is this normal? I thought it's just settings.

$ file DCT.bin

DCT.bin: data

$ file DCT.stripped.elf

DCT.stripped.elf: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), statically linked, stripped

0 Likes
Anonymous
Not applicable

Hi sam_lin,

I think there is a bit of confusion, let me try to clear it a bit.

DCT.bin is a binary file, that means it has all the code (.text) and data (.data) sections but no addresses just a sequence of bytes. People usually use this when they know the target address (ie. where they are going to write). So when we download DCT to the internal flash, we use DCT.bin, we just write those bytes to their DCT memory region in the internal flash. On the other had, DCT.stripped.elf is an elf file, which means its has sections and sectors and each can tell you the final address that it needs to load to. So when loading applicatin from external flash to internal flash you need the stripped elf file so that you know where to put your final code.

So in summary when programming at the start we copy DCT.bin to internal flash, but when you write to the external flash we write the DCT.stripped.elf.

Another thing to note, is that once you do a factory reset (if you are using 3.1.2), DCT reset will occur as well, so the internal DCT (in internal flash) will be overwritten with the external one. Try and make sure that this overwriting is not erasing any thing special that is causing your problem.

if still not there, tell me your steps one by one and i'll try to reproduce it on my side.

Regards,

Bassem

0 Likes
Anonymous
Not applicable

Hi Bassem,

Our use case is simpler than the factory reset case.

We have a button to reset to default settings (in case users misconfig the device)

I use below code (snip.ping_webserver) to test it on BCM4390, and it shows

DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin works

but DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf does not work.

I modify snip.ping_webserver which includes a dct setting.

Add restore_default_settings() function.

I didn't modify any dct settings, so after calling restore_default_settings()

I should read back the same setting (ping_period_ms=1000, ping_timeout_ms=900).

Using DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin, I got

dct_app->ping_period_ms=1000 ping_timeout_ms=900

Using DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf, I got

dct_app->ping_period_ms=0 ping_timeout_ms=0

Below is the diff of ping_webserver.c for your reference.

diff --git a/apps/snip/ping_webserver/ping_webserver.c b/apps/snip/ping_webserver/ping_webserver.c

index ad88093..09a3023 100644

--- a/apps/snip/ping_webserver/ping_webserver.c

+++ b/apps/snip/ping_webserver/ping_webserver.c

@@ -119,6 +119,48 @@ END_OF_HTTP_PAGE_DATABASE();

  *               Function Definitions

  ******************************************************/

+static wiced_result_t restore_default_settings(void)

+{

+ platform_dct_wifi_config_t* dct_wifi_config;

+ ping_dct_t* user_dct;

+ static wiced_app_t dct_app;

+ wiced_result_t result;

+

+ result = wiced_framework_app_open(DCT_DCT_IMAGE_INDEX, &dct_app);

+if(result) printf("wiced_framework_app_open result=%u\r\n", result);

+ if (result != WICED_SUCCESS)

+  return result;

+

+ /* Restore wifi settings */

+ wiced_dct_read_lock((void**) &dct_wifi_config, WICED_TRUE, DCT_WIFI_CONFIG_SECTION, 0, sizeof(*dct_wifi_config));

+ result = wiced_framework_app_read_chunk(&dct_app, OFFSETOF(platform_dct_data_t, wifi_config),

+           (uint8_t *) dct_wifi_config , sizeof(*dct_wifi_config));

+if(result) printf("wiced_framework_app_read_chunk wifi result=%u\r\n", result);

+ if (result == WICED_SUCCESS) {

+  result = wiced_dct_write((const void*) dct_wifi_config, DCT_WIFI_CONFIG_SECTION, 0, sizeof(platform_dct_wifi_config_t));

+  if(result) printf("write result=%u\r\n", result);

+ }

+ wiced_dct_read_unlock(dct_wifi_config, WICED_TRUE);

+

+ if (result != WICED_SUCCESS)

+  goto out;

+

+ /* Restore user settings */

+ wiced_dct_read_lock((void **)&user_dct, WICED_TRUE, DCT_APP_SECTION, 0, sizeof(ping_dct_t));

+ result = wiced_framework_app_read_chunk(&dct_app, sizeof(platform_dct_data_t),

+           (uint8_t *) user_dct, sizeof(*user_dct));

+if(result) printf("wiced_framework_app_read_chunk result=%u\r\n", result);

+ if (result == WICED_SUCCESS) {

+  result = wiced_dct_write((const void *) user_dct, DCT_APP_SECTION, 0, sizeof(*user_dct));

+  if(result) printf("write result=%u\r\n", result);

+ }

+ wiced_dct_read_unlock(user_dct, WICED_TRUE);

+

+out:

+ wiced_framework_app_close(&dct_app);

+ return result;

+}

+

void application_start( )

{

     /* Init data */

@@ -181,11 +223,19 @@ void application_start( )

         wiced_dct_read_unlock( dct_app, WICED_FALSE );

+printf ("Testing restore dct settings\n");

+restore_default_settings();

+/* Get app specific data from Non Volatile DCT */

+wiced_dct_read_lock( (void**)&dct_app, WICED_FALSE, DCT_APP_SECTION, 0, sizeof(ping_dct_t) );

+printf ("dct_app->ping_period_ms=%d ping_timeout_ms=%d\n", dct_app->ping_period_ms, dct_app->ping_timeout_ms);

+wiced_dct_read_unlock( dct_app, WICED_FALSE );

+

     }

     else

     {

         WPRINT_APP_INFO(("Unable to bring up network connection\n"));

     }

+

}

diff --git a/apps/snip/ping_webserver/ping_webserver.mk b/apps/snip/ping_webserver/ping_webserver.mk

index 0c27c45..264770e 100644

--- a/apps/snip/ping_webserver/ping_webserver.mk

+++ b/apps/snip/ping_webserver/ping_webserver.mk

@@ -24,3 +24,5 @@ $(NAME)_RESOURCES  := apps/ping_webserver/top.html \

                       scripts/wpad.dat

APPLICATION_DCT    := ping_webserver_dct.c

+DCT_IMAGE := $(OUTPUT_DIR)/DCT.stripped.elf

+#DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin

0 Likes
Anonymous
Not applicable

Hi Sam.lin

Now that I see your code, it makes sense that the DCT.bin is working and not DCT.strpped.elf. The main reason, is that you are reading and using the DCT in a way different that how we load it in restoring factory reset. For example, you want to read some WIFI setting, so you are using:

result = wiced_framework_app_read_chunk(&dct_app, OFFSETOF(platform_dct_data_t, wifi_config),

           (uint8_t *) dct_wifi_config , sizeof(*dct_wifi_config));

Notice the offset in the file read is OFFSETOF(platform_dct_data_t, wifi_config), well this the offset of the wifi_config in the DCT ( the binary file as well), but it is not the offset in the elf file, because the elf file is organized in a total different way (sections and sectors).


So when you store the binary DCT (you are putting just a binary blob) and the offsets match, while if you storing the stripped elf, you need to read it as an elf file (so your offsets wouldn't match).


Hope this makes it clear.


Regards,

Bassem

Anonymous
Not applicable

Hi Bassem,

If we use DCT.bin here, I have to comment out wiced_dct_restore_factory_reset( );

to avoid OTA problem.

I'd like our implement match with how the SDK works.

So what should I change in my restore_default_settings() implement if we

switch to use DCT.stripped.elf?

Thanks a lot for your valuable reply.

0 Likes
Anonymous
Not applicable

Hi Sam.Lin

One approach is use the DCT.stripped.elf and rather than using WICED frame work APIs (wiced_app_read_chunk and wiced_app_write_chunk), try to use the wiced_dct_restore_factory_reset(); directly.

I have never tried it before, but I don't see a reason why it shouldn't work. with a bit of debug, you can get it to work.

Regards,

Bassem

0 Likes