SDK-3.6.3 / SDK-3.7.0 wiced_framework_set_boot() doesn't work

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

cross mob
lock attach
Attachments are accessible only for community members.
JeGu_2199941
Level 5
Level 5
25 likes received 10 likes received 10 likes given

Test procedure :

     step 1. extract the attached file to apps/ folder

     step 1. build with make target : snip.app1-BCM94343W_AVN

     step 2. build with make target : snip.app0-BCM94343W_AVN download download_apps run

In SDK 3.5.2 it works as expected :

     app0

     wiced_framework_set_boot(DCT_APP1_INDEX, WICED_FRAMEWORK_LOAD_ONCE) = 0

     app1

     wiced_framework_set_boot(DCT_APP0_INDEX, WICED_FRAMEWORK_LOAD_ONCE) = 0

     app0

     wiced_framework_set_boot(DCT_APP1_INDEX, WICED_FRAMEWORK_LOAD_ONCE) = 0

     app1

     (repeat)

In SDK 3.6.3 & 3.7.0 I can see only the first boot :

     app0

     wiced_framework_set_boot(DCT_APP1_INDEX, WICED_FRAMEWORK_LOAD_ONCE) = 0

     (stop here)

Remark:

1. In SDK 3.5.2, file wiced_waf_common.c is modified as this post : Possible 3.5.2 bug in wiced_framework_set_boot()

2. In SDK 3.7.0, file platform/BCM94343W_AVN/platform.c is modified as this post : Re: SDK 3.7.0 BLE doesn't work

3. In all 3 SDK version stock snip.ota_fr works out of box with snip.scan

0 Likes
1 Solution

I finally found the problem!  The platform_spi_init function has an optimization where it checks to see if the spi has already been initilaized

WICED/platform/MCU/STM32F4xx/peripherals/platform_spi.c line 180

    if (spi_current_config[spi_number].bits == config->bits &&

            spi_current_config[spi_number].cs.port == config->chip_select->port &&

            spi_current_config[spi_number].cs.pin_number == config->chip_select->pin_number &&

            spi_current_config[spi_number].mode == config->mode &&

            spi_current_config[spi_number].speed == config->speed &&

            spi_current_config[spi_number].spi == spi->port &&

            spi_current_config[spi_number].spi_ready == WICED_TRUE)

        return PLATFORM_SUCCESS;

What happens is the configuration is stored in spi_current_config structure and is compared to the config parameter and returns success if it's the same.  When the system resets the values in api_current_config aren't reset and the system assumes that the spi bus has already been configured and doesn't properly enable the spi bus.  So the system halts when the spi bus is accessed because it's not enabled.

The solution I came up with is to check that the SPI register has been enabled.  The datasheet says the default value of the CR1 register is 0x0000 after a reboot.

    if (spi_current_config[spi_number].bits == config->bits &&

            spi_current_config[spi_number].cs.port == config->chip_select->port &&

            spi_current_config[spi_number].cs.pin_number == config->chip_select->pin_number &&

            spi_current_config[spi_number].mode == config->mode &&

            spi_current_config[spi_number].speed == config->speed &&

            spi_current_config[spi_number].spi == spi->port &&

            spi_current_config[spi_number].spi_ready == WICED_TRUE &&

            spi->port->CR1 != 0x0000)

        return PLATFORM_SUCCESS;

This completely fixed the issue for me.

-Rob

View solution in original post

34 Replies