cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Wi-Fi Combo

Anonymous
Not applicable

There is an invalid enumerated type conversion in the WICED 4.1 OTA2 bootloader. The function wiced_ota2_image_get_status() takes a wiced_ota2_image_type_t as its first parameter, but value passed in is an ota2_boot_type_t: OTA2_BOOT_UPDATE. This value isn't equivalent to any wiced_ota2_image_type_t so it will trigger the default behavior for any invalid image type. I'm not sure what the significance of this is. I was trying to fix something else when I ran across this bug.

int main( void ) // SEE apps/waf/ota2_bootloader/ota2_bootloader.c

{...

    wiced_result_t              result;

...

    /* Check for Watchdog reset

     * This overrides everything. Use ota2_failsafe to recover

     */

    if (platform_watchdog_check_last_reset() == WICED_TRUE)

    {

        /* watchdog reset happened - which image do we try to use? */

        wiced_ota2_image_status_t   staged_update_status;

...

        /* if the downloaded image is good, use that over the factory reset */

        result = wiced_ota2_image_get_status( /*bug - should be and image type not a boot type*/OTA2_BOOT_UPDATE, &staged_update_status );

...

    }

}

// SEE  libraries/filesystems/ota2/wiced_ota2_image.h for the following:

typedef enum

{

    OTA2_BOOT_NEVER_RUN_BEFORE = 0,     /* Do not change this ENUM location */

    OTA2_BOOT_NORMAL,                   /* Do not change this ENUM location */

    /* Use these after failsafe recovery to continue the ota2 extraction preocess */

    OTA2_BOOT_EXTRACT_FACTORY_RESET,    /* Renamed in SDK-4.0.1, but stays the same ENUM as SDK OTA2_BOOT_FACTORY_RESET */

    OTA2_BOOT_EXTRACT_UPDATE,           /* Renamed in SDK-4.0.1, but stays the same ENUM as SDK OTA2_BOOT_FACTORY_RESET */

    OTA2_BOOT_SOFTAP_UPDATE,            /* Do not change this ENUM location */

    OTA2_BOOT_LAST_KNOWN_GOOD,          /* Do not change this ENUM location */

    OTA2_BOOT_FACTORY_RESET,

    OTA2_BOOT_UPDATE,

    /* Use these before starting an extraction. If extraction is interrupted, use failsafe */

    OTA2_BOOT_FAILSAFE_FACTORY_RESET,

    OTA2_BOOT_FAILSAFE_UPDATE,

    OTA2_MAX_BOOT_TYPES     /* Not a valid boot type */

} ota2_boot_type_t;

typedef enum

{

    WICED_OTA2_IMAGE_TYPE_NONE  = 0,

    WICED_OTA2_IMAGE_TYPE_FACTORY_RESET_APP,

    WICED_OTA2_IMAGE_TYPE_CURRENT_APP,

    WICED_OTA2_IMAGE_TYPE_LAST_KNOWN_GOOD,

    WICED_OTA2_IMAGE_TYPE_STAGED

} wiced_ota2_image_type_t;

1 Solution
Moderator
Moderator

Fixed in SDK 5.2.

/* Check for Watchdog reset

    * This overrides everything. Use ota2_failsafe to recover

    */

    if (platform_watchdog_check_last_reset() == WICED_TRUE)

    {

        /* watchdog reset happened - which image do we try to use? */

        wiced_ota2_image_status_t  staged_update_status;

        dct_ota2_config.boot_type = OTA2_BOOT_FAILSAFE_FACTORY_RESET;

        /* if the downloaded image is good, use that over the factory reset */

        result = wiced_ota2_image_get_status( WICED_OTA2_IMAGE_TYPE_STAGED, &staged_update_status );

        if ((result == WICED_SUCCESS) &&

            ((staged_update_status == WICED_OTA2_IMAGE_DOWNLOAD_COMPLETE) ||

            (staged_update_status == WICED_OTA2_IMAGE_VALID) ||

            (staged_update_status == WICED_OTA2_IMAGE_EXTRACT_ON_NEXT_BOOT) ||

            (staged_update_status == WICED_OTA2_IMAGE_DOWNLOAD_EXTRACTED)) )

        {

            dct_ota2_config.boot_type = OTA2_BOOT_FAILSAFE_UPDATE;

        }

        if (wiced_dct_write( &dct_ota2_config, DCT_OTA2_CONFIG_SECTION, 0, sizeof(platform_dct_ota2_config_t) ) != WICED_SUCCESS)

        {

            BOOTLOADER_PRINTF(("OTA2 Config DCT Write failed, continue on. We will reset if there is a problem and try again.\r\n"));

        }

    }

View solution in original post

0 Likes
Reply
4 Replies
Moderator
Moderator

Thank you for reporting this bug. I have raised a ticket internally explaining the problem in detail and it should be corrected. The type OTA2_BOOT_UPDATE is indeed an incompatible type passed as a parameter in wiced_ota2_image_get_status() on line 193 of the application code. The correction should be result = wiced_ota2_image_get_status( WICED_OTA2_IMAGE_TYPE_STAGED, &staged_update_status );

Honored Contributor

grsr wrote:

Thank you for reporting this bug. I have raised a ticket internally explaining the problem in detail and it should be corrected. The type OTA2_BOOT_UPDATE is indeed an incompatible type passed as a parameter in wiced_ota2_image_get_status() on line 193 of the application code. The correction should be result = wiced_ota2_image_get_status( WICED_OTA2_IMAGE_TYPE_STAGED, &staged_update_status );

grsr

This is *not* fix in wiced-studio 5.0 release.

Something wrong in your internal communication.

0 Likes
Reply
Moderator
Moderator

Fixed in SDK 5.2.

/* Check for Watchdog reset

    * This overrides everything. Use ota2_failsafe to recover

    */

    if (platform_watchdog_check_last_reset() == WICED_TRUE)

    {

        /* watchdog reset happened - which image do we try to use? */

        wiced_ota2_image_status_t  staged_update_status;

        dct_ota2_config.boot_type = OTA2_BOOT_FAILSAFE_FACTORY_RESET;

        /* if the downloaded image is good, use that over the factory reset */

        result = wiced_ota2_image_get_status( WICED_OTA2_IMAGE_TYPE_STAGED, &staged_update_status );

        if ((result == WICED_SUCCESS) &&

            ((staged_update_status == WICED_OTA2_IMAGE_DOWNLOAD_COMPLETE) ||

            (staged_update_status == WICED_OTA2_IMAGE_VALID) ||

            (staged_update_status == WICED_OTA2_IMAGE_EXTRACT_ON_NEXT_BOOT) ||

            (staged_update_status == WICED_OTA2_IMAGE_DOWNLOAD_EXTRACTED)) )

        {

            dct_ota2_config.boot_type = OTA2_BOOT_FAILSAFE_UPDATE;

        }

        if (wiced_dct_write( &dct_ota2_config, DCT_OTA2_CONFIG_SECTION, 0, sizeof(platform_dct_ota2_config_t) ) != WICED_SUCCESS)

        {

            BOOTLOADER_PRINTF(("OTA2 Config DCT Write failed, continue on. We will reset if there is a problem and try again.\r\n"));

        }

    }

View solution in original post

0 Likes
Reply
Honored Contributor

grsr wrote:

Fixed in SDK 5.2.

I know this is fixed in SDK-5.2.

However, it should be mentioned in the changelog.

It's really very hard to track the issues manually.

0 Likes
Reply