renesas / fsp

Flexible Software Package (FSP) for Renesas RA MCU Family
https://renesas.github.io/fsp/
Other
182 stars 82 forks source link

DA16XXX: Calling WIFI_Off() with DA16xxx Drivers May Cause a Hard Fault #326

Closed renesas-adam-benson closed 7 months ago

renesas-adam-benson commented 8 months ago

Issue

When calling WIFI_Off() a pointer dereference happens that may lead to a fault due to an illegal memory access.

Workaround

This issue can be fixed by manually setting the bad pointer in the instance ctrl for the WiFi transport interface. To do this first add the following definitions to your code:

#if (BSP_FEATURE_SCI_VERSION == 2U)
sci_b_uart_instance_ctrl_t dummy_uart_ctrl =
#else
sci_uart_instance_ctrl_t dummy_uart_ctrl =
#endif
{
    .open = 0
};

const uart_cfg_t dummy_uart_cfg =
{
    .channel = 255,
};

uart_instance_t dummy_uart_instance =
{
    .p_ctrl        = &dummy_uart_ctrl,
    .p_cfg         = &dummy_uart_cfg,
#if (BSP_FEATURE_SCI_VERSION == 2U)
    .p_api         = &g_uart_on_sci_b
#else
    .p_api         = &g_uart_on_sci
#endif
};

After calling WIFI_On() insert the following line to set the pointer:

g_at_transport_da16xxx_ctrl.uart_instance_objects[1] = &dummy_uart_instance;