2021-08-01 07:36 AM
The define O_NONBLOCK exists twice.
Once in:
...\ST\STM32CubeIDE_1.6.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\include\sys\_default_fcntl.h:
#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
....
#define O_NONBLOCK _FNONBLOCK
and at in:
<ProjectFolder>\Middlewares\Third_Party\LwIP\src\include\lwip\sockets.h:
#ifndef O_NONBLOCK
#define O_NONBLOCK 1 /* nonblocking I/O */
#endif
Now a call like this fails:
fcntl(socket_handle, F_SETFL, fcntl(socket_handle, F_GETFL, 0) | O_NONBLOCK);
as the define in _default_fcntl.h is not compatible with lwIP.
Please remove this define in _default_fcntl.h
2021-08-01 10:04 AM
The question is, how the _default_fcntl.h gets incuded into your program?
And why it doesn't get included into LwIP? (as LwIP usually is compiled from sources, along with your files).
Note the #ifndef O_NONBLOCK.
-- pa
2021-08-03 12:34 PM
Hi Pavel
The includes in my source file are:
#include "lwip/opt.h"
#include "lwip/arch.h"
#include "lwip/api.h"
#include "lwip/apps/fs.h"
#include "lwip/sockets.h"
#include "FreeRTOS.h"
#include "task.h"
and the in STM32CubeIDE project there are these includes:
Peter
2021-08-07 09:09 AM
Hi Pavel
I have some additional informations for you.
The basis for my project is the example application "LwIP_HTTP_Server_Netconn_RTOS" from STM Cube V1.6.0.
There for I had a deeper look there and have seen how the _default_fcntl.h gets incuded into my program. It comes via the includes in the project:
Please check this.
Kind regards Peter
2021-08-08 11:48 AM
Then ok, the _default_fcntl.h comes from the toolchain includes. Normally this is included via fcntl.h.
Just make sure that LwIP source files are cofigured so that fcntl.h from the toolchain gets included, and #ifndef O_NONBLOCK is false.
2021-08-09 12:24 PM
Hi Pavel
In my current project I have solved it by adding an #undef for O_NONBLOCK before socket.h is included:
#undef O_NONBLOCK /* in _default_fcntl.h defined as 0x4000, but lwip defines 1 in sockets.h */
....
#include "lwip/sockets.h"
...
As this problem comes from example application "LwIP_HTTP_Server_Netconn_RTOS" from STM Cube V1.6.0 which I used a basis for my project I like to provide a feedback the team who manages the STM Cube code. This should be fixed.
2021-08-09 01:50 PM
The team who manages the STM Cube code probably doesn't want to touch the newlib stuff in the toolchain because of some 3rd party library ... but who knows.
2021-08-10 10:20 AM
Lets try, in my eyes this is an error and I lost several hours to fix it. Unfortunately I commented out firstly this line in _default_fcntl.h. After an update this was lost and the problem was back...
Do you know where I can provide this feedback to the STM Cube team?