2024-08-20 12:35 AM
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!
Solved! Go to Solution.
2024-08-23 09:27 AM
Hello @_AdamNtrx ,
You can start your project from ready-to-use LwIP project:
You can also follow the instructions (step-by-step) provided in this article: How to create a project for STM32H7 with Ethernet ... - STMicroelectronics Community (instructions application for STM32F7).
2024-08-23 09:27 AM
Hello @_AdamNtrx ,
You can start your project from ready-to-use LwIP project:
You can also follow the instructions (step-by-step) provided in this article: How to create a project for STM32H7 with Ethernet ... - STMicroelectronics Community (instructions application for STM32F7).
2024-08-27 11:31 PM
I changed the configuration of TCP/IP according to Adam BERLINGER's guide and now I don't need the 2s delay. I don' understand the magic behind this but the guide seemed to help with setting up the connection. Thank you!
PS I don't use MPU or FreeRTOS in most recent project. Also I periodically call MX_LWIP_Process in main loop, as recommended in the guide.
2024-09-20 07:19 PM
Your project works only by modifying the configuration of the TCP/IP ? I have the same issue(but in stm32f407series), but unfortunately this modification not work for me.
2024-09-23 10:33 PM
Yes, if I remember correctly I made only these changes and it fixed the problem. There are other valuable tips in the rest of the Adam Berlinger's guide, so maybe one of them could help you with resolving your issue.