Reporting some bugs and fixes

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

cross mob
GrSm_2135731
Level 2
Level 2
First like received

Here's some bugs and fixes that would be good to get into the release:

1. LwIP default interface and static IP

When using a static IP, a default interface is not set (it is for DHCP.) As such, trying to make a TCP connection do a different subnet (with a gateway) fails.

wiced_result_t wiced_ip_up( wiced_interface_t interface, wiced_network_config_t config, const wiced_ip_setting_t* ip_settings )

{

     if ( ( static_ip == WICED_FALSE ) && ( config == WICED_USE_EXTERNAL_DHCP_SERVER ))

    {

         ....

        /* Bring up the network interface */

        netif_set_up( &IP_HANDLE(interface) );

        netif_set_default( &IP_HANDLE(interface) );

        ...

     }

     else

     {

        netif_set_up( &IP_HANDLE(interface) );

        netif_set_default( &IP_HANDLE(interface) );

          ....

     }

}

2. LwIP TCP client connection

When making a TCP client connection, if it fails the first time, any subsequent retries will crash the app. The netconn itself is deleted, but the pointer is left with its prior no longer valid value.

WICED/network/LwIP/WICED/tcpip.c

wiced_result_t wiced_tcp_connect( wiced_tcp_socket_t* socket, const wiced_ip_address_t* address, uint16_t port, uint32_t timeout )

{

    ....

    lwip_error = netconn_connect( socket->conn_handler, (ip_addr_t*) &temp, port, (uint16_t) timeout );

    if ( lwip_error != ERR_OK )

    {

        netconn_delete( socket->conn_handler );

        socket->conn_handler = NULL;

        return LWIP_TO_WICED_ERR( lwip_error );

    }

3. STM32F2xx SPI master with DMA - clocks not enabled

When using DMA, the peripheral clocks are not enabled.

WICED/platform/MCU/STM32F2xx/peripherals/platform_spi.c

platform_result_t platform_spi_init( const platform_spi_t* spi, const platform_spi_config_t* config )

{

     ....

      /* Init and enable SPI */

     SPI_Init( spi->port, &spi_init );

     SPI_Cmd ( spi->port, ENABLE );

   if ( config->mode & SPI_USE_DMA )

    {

         /* Enable DMA peripheral clock */

         if (spi->tx_dma.controller == DMA1)

         {

              RCC->AHB1ENR |= RCC_AHB1Periph_DMA1;

         }

         else

         {

             RCC->AHB1ENR |= RCC_AHB1Periph_DMA2;

         }

    }

    platform_mcu_powersave_enable();

    return PLATFORM_SUCCESS;

}

4. STM32F2xx SPI master with DMA - typo

This bug was reported on forums 2 years but remains unfixed. Address operator missing on DR register.

WICED/platform/MCU/STM32F2xx/peripherals/platform_spi.c

static void spi_dma_config( const platform_spi_t* spi, const platform_spi_message_segment_t* message )

{

    DMA_InitTypeDef dma_init;

    uint8_t         dummy = 0xFF;

    ....

    /* Setup DMA stream for TX */

    dma_init.DMA_Channel            = spi->tx_dma.channel;

    dma_init.DMA_PeripheralBaseAddr = ( uint32_t )&(spi->port->DR);

    dma_init.DMA_DIR                = DMA_DIR_MemoryToPeripheral;

        ....

}

5. STM32F2xx SPI master with DMA - typo

This bug was reported on forums 2 years but remains unfixed. RX init has TX in it.

WICED/platform/MCU/STM32F2xx/peripherals/platform_spi.c

static void spi_dma_config( const platform_spi_t* spi, const platform_spi_message_segment_t* message )

{

    DMA_InitTypeDef dma_init;

    uint8_t         dummy = 0xFF;

    ....

    /* Init and activate RX DMA channel */

    DMA_Init( spi->rx_dma.stream, &dma_init );

    SPI_I2S_DMACmd( spi->port, SPI_I2S_DMAReq_Rx, ENABLE );

     ....

}

5. STM32F2xx SPI master with DMA  - complete flag check

This bug was reported on forums 2 years but remains unfixed. The line highlighted below is wrong, as the complete_flags variable is not suitable for passing to the GetFlagStatus function and throws an assertion.

WICED/platform/MCU/STM32F2xx/peripherals/platform_spi.c

static platform_result_t spi_dma_transfer( const platform_spi_t* spi, const platform_spi_config_t* config )

{

    uint32_t loop_count;

    /* Enable dma channels that have just been configured */

    DMA_Cmd( spi->tx_dma.stream, ENABLE );

    DMA_Cmd( spi->rx_dma.stream, ENABLE );

    /* Wait for DMA to complete */

    /* TODO: This should wait on a semaphore that is triggered from an IRQ */

    loop_count = 0;

    while ( ( DMA_GetFlagStatus( spi->tx_dma.stream, spi->tx_dma.complete_flags ) == RESET ) )

    {

        loop_count++;

        /* Check if we've run out of time */

       ....

}

Instead it should be something like:

     while ((get_dma_irq_status(spi->tx_dma.stream) & spi->tx_dma.complete_flags) == RESET)

3 Replies
GrSm_2135731
Level 2
Level 2
First like received

One further one. In the same platform_spi file, the below 60 Mhz value should not be hard coded.

The prescaler value depends if the SPI peripheral is clocked from APB1 or APB2.

E.g SPI1 is clocked from APB1 (typically 60 Mhz) and SPI2/SPI3 are clocked from APB2 (typically 30 Mhz.)

static platform_result_t calculate_prescaler( uint32_t speed, uint16_t* prescaler )

{

    uint8_t i;

    wiced_assert("Bad args", prescaler != NULL);

    for( i = 0 ; i < MAX_NUM_SPI_PRESCALERS ; i++ )

    {

        if( ( 60000000 / spi_baudrate_prescalers.factor ) <= speed )

        {

            *prescaler = spi_baudrate_prescalers.prescaler_value;

            return PLATFORM_SUCCESS;

        }

    }

    return PLATFORM_ERROR;

}

0 Likes

Thanks!

0 Likes
RoDe_1773541
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Another bug in SDK 3.7.0

sdk/WICED/platform/MCU/STM32F4xx/peripherals/platform_rtc.c fails to compile with "error: unknown type name 'wiced_rtc_time_t'" when WICED_ENABLE_MCU_RTC is defined in wiced_defaults.h

Need to add an include for wiced_platform.h

/** @file

* STM32F2xx RTC implementation

*/

#include <stdint.h>

#include <string.h>

#include "wwd_assert.h"

#include "platform_constants.h"

#include "platform_peripheral.h"

#include "wiced_platform.h"

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

*                      Macros

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

Also, the header comment says STM32F2xx, but the file is for the STM32F4xx.

-Rob