lwIP library needs delay to work outside of debug mode.
Hello! I've been trying to use lwIP library with my STM32F769I-DISCO development board to assign IP address to the microcontroller. While in debug mode everything works fine, in normal mode, however, it doesn't. I had to add two 1s delays before MX_GPIO_Init();MX_LWIP_Init() instructions and SystemClock_Config() instruction to make my program work outside of debug mode (they can be replaced with one 2s delay before GPIO and LWIP init functions).
The code is presented below:
<code>
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "lwip.h"
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
extern ETH_HandleTypeDef heth;
extern struct netif gnetif;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MPU_Config(void);
static void MX_GPIO_Init(void);
int main(void)
{
/* MPU Configuration--------------------------------------------------------*/
MPU_Config();
/* Enable the CPU Cache */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
HAL_Delay(1000);
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
HAL_Delay(1000); //delay to make things work outside of debug mode.
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LWIP_Init();
/* USER CODE BEGIN WHILE */
while (1)
{
ethernetif_input(&gnetif);
sys_check_timeouts();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
</code>
I don't know why delays aren't needed in debug mode and are crucial outside of it, but it looks like some kind of bug to me. I decided to make this post in case somebody else also meets with this strange behaviour and in hope that it gets fixed in the future. Also I attach my STM32CubeIDE project with the code.
Regards!
