OTA upgrades Wiced 3.0

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

cross mob
Anonymous
Not applicable

Hello,

I discover that OTA upgrades are unavailable in Wiced 3.0: core functions (platform_load_ota_app ...) emptied and apps/waf/ota_upgrade sample app removed!

Will such an important feature be available back soon ?

Furthermore, we would like to implement OTA in a different way, a bit like how apps/waf/sflash_write does: The new firmware would be downloaded and written to the SPI flash, then the boot-loader would copy it to internal MCU flash at next reboot (not at the end of download).

I've been looking at the sflash_write app code  but I can't figure out how it works because it is driven by an external TCL script ( openOCD). Any help would be appreciated.

Best regards,

Pascal.

0 Likes
1 Solution
Anonymous
Not applicable

Hi,

We have done similar thing using http server to receive file and store in external SPI flash 1st. And then, reboot and copy back to the original one.

The procedure:

1, modify the http_server.c so as to receive the file and store in external spi flash.

2. modify the waf/bootloader.c to support the new function so as to reset after recieved the new firmware

3. modify the platform_bootloader.c to support loading the new firmware from external flash to internal flash

Let us know if you have any questions.

Best Regards,

Keith Lam

View solution in original post

4 Replies
Anonymous
Not applicable

Hi,

We have done similar thing using http server to receive file and store in external SPI flash 1st. And then, reboot and copy back to the original one.

The procedure:

1, modify the http_server.c so as to receive the file and store in external spi flash.

2. modify the waf/bootloader.c to support the new function so as to reset after recieved the new firmware

3. modify the platform_bootloader.c to support loading the new firmware from external flash to internal flash

Let us know if you have any questions.

Best Regards,

Keith Lam

Anonymous
Not applicable

Hello,

I've done step 1 (modify http_server.c)

Step 2: waf/bootloader.c already contains code to detect new firmware in external flash "if ( load_details->valid )" .


Step 3: There is no more 'platform_bootloader.c' file in Wiced 3.


But there is an empty platform_copy_external_to_internal() function in :

     WICED/platform/MCU/STM32F2xx/WAF/waf_platform.c

so I can't imagine how the bootloader can copy the new firmware from external to internal flash. (We work on   BCM943362WCD4 and BCM9WCDPLUS114)


I thought that apps/waf/sflash_write was relying on the bootloader to copy the jtag uploaded firmware from external to internal, but I have now a doubt.



Firmware upgrade via external flash is a very important feature, not only for us I think, can you provide sample code or technical information to implement this.


Thanks in advance,

Pascal.

0 Likes
Anonymous
Not applicable

Hi,

The procedure is for version2.4.1. But, it should be work in Wiced 3 also and it is using different file name.

The step can be like this.

1. you should have the new firmware ready in the external flash.

2. you can use the platform_copy_external_to_internal(), copy from external to internal. But, the function should be done none since the inside is not finished yet. You can just copy it from external to internal and start the app. (Remark: we are working on BCM9WCDUSI09 module)


If everything is OK, no jtag is needed to program the external flash.

Yes, you are right. Therefore, we have customized our OTA version instead of original one.


Keith Lam


void platform_upgrade_app( void )

{

    sflash_handle_t sflash_handle;

    bootloader_app_header_t external_app_header;

    platform_dct_header_t external_dct_header;

    bootloader_app_header_t image_header;

    uint32_t image_loc;

    static uint8_t  rx_buffer[4096]; /* API Function will not return, so it is safe to declare static big buffer */

    uint32_t write_address = APP_HDR_START_ADDR;

    uint32_t progress;

    /* Init the external SPI flash */

    init_sflash( &sflash_handle, PLATFORM_SFLASH_PERIPHERAL_ID, SFLASH_WRITE_NOT_ALLOWED );

    sflash_read( &sflash_handle, 0, &external_app_header, sizeof( external_app_header ) );

    sflash_read( &sflash_handle, external_app_header.size_of_app, &external_dct_header, sizeof( external_dct_header ) );

    watchdog_kick( );

    image_loc = ((external_app_header.size_of_app + external_dct_header.used_size)/(64*1024) + 1)*64*1024;

    /* Mark the App image as invalid to guard against power failure during writing */

    platform_set_app_valid_bit( APP_INVALID );

    watchdog_kick( );

    /* Erase the internal flash memory */

    platform_erase_app( );

    watchdog_kick( );

    /* Read the image header */

    sflash_read( &sflash_handle, image_loc, &image_header, sizeof( image_header ) );

    watchdog_kick( );

    /* Quick image validation */

    /* Flash the upgrade app */

    progress = 0;

    while ( progress < image_header.size_of_app )

    {

        /* Read a chunk of image data */

        uint32_t read_size = MIN(image_header.size_of_app - progress, sizeof(rx_buffer));

        sflash_read( &sflash_handle, image_loc + progress, &rx_buffer, read_size );

        /* Write it to the flash */

        platform_write_flash_chunk( write_address, rx_buffer, read_size );

        write_address += read_size;

        progress      += read_size;

        watchdog_kick( );

    }

    platform_set_app_valid_bit( APP_VALID );

    platform_start_app( 0 );

}

Anonymous
Not applicable

Hello,

I think that the 'new firmware' detection in the bootloader is for firmware written in spi flash by the apps/waf/sflash_write app, and this app is not actually involved in any firmware upload process, even jtag.

So we are free to modify the bootloader without breaking compatibility with any wiced firmware upgrade method. Am I right ?

Thanks in advance,

Pascal.


0 Likes