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

Wi-Fi Combo Forum Discussions

Anonymous
Not applicable

Hi,

The ota_fr snip reboots and runs the factory reset application when boot with SW1

button held. But it seems does not restore default settings.

Usually, the users expect the settings is also reset to default when doing factory reset.

So I'd like to restore default settings as well when doing factory reset.

Does SDK provide API to restore default settings? (Including user_dct and wifi settings)

Thanks.

0 Likes
1 Solution
Anonymous
Not applicable

Hi,

Future releases will support restoring the default DCT (as well as the factory reset application).

For now this can be done manually,

1 ) include DCT in to the serial flash, e.g. in ota_fr.mk

DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin

20 In your factory reset application, you can read the the parts that you want from DCT image (from the serial flash) and write it to the DCT, for example, to copy wifi_config part:

platform_dct_wifi_config_t* dct_wifi_config;

/* get the wi-fi config section for modifying, any memory allocation required would be done inside wiced_dct_read_lock() */

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

/* Load DCT factory reset image */

wiced_framework_app_read_chunk( DCT_DCT_IMAGE_INDEX, OFFSETOF( platform_dct_data_t, wifi_config ), dct_wifi_config , sizeof(*dct_wifi_config ));

/* Write new wifi config data */

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

/* release the read lock */

  wiced_dct_read_unlock( dct_wifi_config, WICED_TRUE );

View solution in original post

7 Replies
Anonymous
Not applicable

Hi,

Future releases will support restoring the default DCT (as well as the factory reset application).

For now this can be done manually,

1 ) include DCT in to the serial flash, e.g. in ota_fr.mk

DCT_IMAGE := $(OUTPUT_DIR)/DCT.bin

20 In your factory reset application, you can read the the parts that you want from DCT image (from the serial flash) and write it to the DCT, for example, to copy wifi_config part:

platform_dct_wifi_config_t* dct_wifi_config;

/* get the wi-fi config section for modifying, any memory allocation required would be done inside wiced_dct_read_lock() */

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

/* Load DCT factory reset image */

wiced_framework_app_read_chunk( DCT_DCT_IMAGE_INDEX, OFFSETOF( platform_dct_data_t, wifi_config ), dct_wifi_config , sizeof(*dct_wifi_config ));

/* Write new wifi config data */

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

/* release the read lock */

  wiced_dct_read_unlock( dct_wifi_config, WICED_TRUE );

Anonymous
Not applicable

Hi bassem_dawood,

Thanks for your reply.

I got error at:

wiced_framework_app_read_chunk( DCT_DCT_IMAGE_INDEX, OFFSETOF( platform_dct_data_t, wifi_config ), dct_wifi_config , sizeof(*dct_wifi_config ));

It returns 4 (WICED_ERROR).

I just checked DCT.map and found it only contains internal_dct.o and app_dct.o.

Did I miss something?

0 Likes
Anonymous
Not applicable

Hi Sam Lin,

My guessing is that the DCT is not actually copied to external flash. There are 2 copies of DCT one in to internal flash and one in to the external serial flash. As I mentioned above the ota_fr.mk need to be updated with the DCT_IMAGE line. you also probably want to do a clean build. your make target should be something like

snip.ota_fr-BCM943362WCD4 download donwload_apps

and you should see in your log the downloading of DCT IMAGE in serial flash

>>>

Downloading Bootloader ...

Building apps lookup table

Download complete

Downloading DCT ...

Download complete

Downloading Application ...

Download complete

Downloading FR_APP (build/snip_ota_fr-BCM943362WCD4/binary/snip_ota_fr-BCM943362WCD4.stripped.elf) at sector 1...

Downloading DCT_IMAGE (build/snip_ota_fr-BCM943362WCD4/DCT.bin) at sector 122...

Downloading apps lookup table at 0x0000...

Resetting target

Target running

Build complete

0 Likes
Anonymous
Not applicable

Hi  bassem_dawood,

It's working now.

I think I just forgot adding download_apps in build command because I test

it first in production application.

Thanks a lot for your help.

0 Likes
Anonymous
Not applicable

Hi bassem_dawood,

Our application has stored some settings in user_dct_data.

We also want to restore the default value of application's user_dct_data.

I think it's also stored in DCT.bin because I found .rodata._app_dct in DCT.map.

But it seesm wiced_framework_app_read_chunk() does not work for this case?

(I don't know what is the offset I should set to read back user_dct_data.)

What is the appropriate way to read back the _app_dct from flash?

Thanks.

0 Likes
Anonymous
Not applicable

The application data (written to DCT_APP_SECTION) is stored in the end part of the DCT, in this case you can try to use sizeof(paltform_dct_data_t) as your offset, which means skipping all the data part of DCT in to the application part.

have a look at DCT_section_offsets[] in wiced_dct_internal.c to get a more grasp of what i'm talking about.

Anonymous
Not applicable

It works fine.

Good information.

TKS

0 Likes