Skip to main content
robmilne
Associate II
Nov 1, 2023 8:02 PM UTC
Solved

NetX Duo BSD integration

Has anyone successfully used the BSD addon for netxduo inside CubeIDE?  I followed the instructions at the top of https://learn.microsoft.com/en-us/azure/rtos/netx/netx-bsd/chapter2 (the #define TX_THREAD_EXTENSION_3 int bsd_errno needed a trailing semi-colon) but the netx timeval and fd_set definitions conflict with the CubeIDE environment (/ST/STM32CubeIDE_1.10.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/arm-none-eabi/include/select.h and /ST/STM32CubeIDE_1.10.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.1.202309131626/tools/arm-none-eabi/include/sys/_timeval.h).

My only reason for using BSD is to to implement ModbusTCP with libmodbus .  I would gladly opt for a native netx implementation of ModbusTCP if anyone knows of one.

    This topic has been closed for replies.
    Haithem Rahmani
    Haithem RahmaniBest answer
    ST Employee
    Nov 2, 2023 3:43 PM UTC

    hi @robmilne,

    if you have a "nx_user.h" file in your project, please add the following

    #ifdef __BSD_VISIBLE
    #undef __BSD_VISIBLE
    #endif

    this should solve your problem.

     

    regards
    haithem.

     

    10 replies

    Haithem Rahmani
    Haithem RahmaniBest answer
    ST Employee
    Nov 2, 2023 3:43 PM UTC

    hi @robmilne,

    if you have a "nx_user.h" file in your project, please add the following

    #ifdef __BSD_VISIBLE
    #undef __BSD_VISIBLE
    #endif

    this should solve your problem.

     

    regards
    haithem.

     

    robmilne
    robmilneAuthor
    Associate II
    Nov 2, 2023 5:58 PM UTC

    Hi Haithem,

    Thanks!

    Your code stops compiler errors for the NetXDuo BSD addon files, but I get build errors after I add the libmodbus sources to my project.  I think building my own ModbusTCP from scratch using NetX will be less complicated than figuring out how to make this sockets-based library work with CubeIDE.  I did find a Renesas project that integrated libmodbus with NetX+BSD, but it was tailored to their environment and the libmodbus version was not current.

    Btw, I had already reached this point by defining __BSD_VISIBLE as 0 in ..\tools\arm-none-eabi\include\sys\features.h, but your method is much better.

    -rob

    Visitor II
    Apr 6, 2024 11:40 AM UTC

    Hello, thank you for your assistance. I also encountered the fd_set conflict issue when using the IDE, and defining nx as 0 did not resolve it. Do you have any other suggestions or solutions?

    robmilne
    robmilneAuthor
    Associate II
    Apr 8, 2024 2:36 PM UTC

    Unfortunately, no. I abandoned this approach and modified my modbustcp library to use native NetX.

    WHam.1
    Associate II
    Jan 6, 2025 3:11 AM UTC

    May be my  you tube site will help you even though the speaking language is korean. 

    https://www.youtube.com/watch?v=YVdNClVnT1s

     

    WHam.1
    Associate II
    Jan 6, 2025 12:15 PM UTC

    Please refer to my new youtube  for simpletest ECAT Master program Developed on STM32F769I-DISC board by using nxd_bsd and Netx Duo in Azure RTOS  operating combined with XMC4800 ECAT Slave Board.   

     

    https://studio.youtube.com/video/NWQJTNXTehI/edit

     

    WHam.1
    Associate II
    Jan 6, 2025 12:34 PM UTC

    Neglect  my previous reply. Sorry for that.

     

    Please refer to my new youtube  for simpletest ECAT Master program Developed on STM32F769I-DISC board by using nxd_bsd and Netx Duo in Azure RTOS  operating combined with XMC4800 ECAT Slave Board.   

    https://www.youtube.com/watch?v=NWQJTNXTehI

     

    JongOk Baek
    Associate III
    May 14, 2025 6:55 AM UTC

    Hello, robmilne.

     

    I reached same error such as you.

    Description	Resource	Path	Location	Type
    expected ':', ',', ';', '}' or '__attribute__' before 'ULONG'	tx_api.h	/ZMG-390AZ_BSD/Middlewares/ST/threadx/common/inc	line 630	C/C++ Problem

    So, I modified definition below. (with ';' semicolon end of the line)

    #define TX_THREAD_EXTENSION_3						int bsd_errno;

     but, I reached error message below

    error.png

    I'm getting errors redefining libraries and definitions under internal gnu tools.

     

    So, I uncomment the definition below in nxd_bsd.h

    #define NX_BSD_RAW_SUPPORT
    #define NX_BSD_ENABLE_NATIVE_API

    Finally, the definition below throws an error:

    #define NX_SOC_ERROR 	-1 /* Failure. */

    'expected identifier before '-' token'

     

    I wonder if this issue has been resolved.

    Best regards,

     

     

     

    robmilne
    robmilneAuthor
    Associate II
    May 14, 2025 11:25 AM UTC

    Hi JongOk,

    I abandoned this effort quite a while back. Sorry

    -rob

    JongOk Baek
    Associate III
    May 16, 2025 8:45 AM UTC

    Hi rob.

    Thanks for your reply.

    I continued to do the check-up for a few more days.

    The problem was in '#define' command.

    #define NX_SOC_ERROR -1 /* Failure. */
    #ifndef ERROR
    #define ERROR NX_SOC_ERROR
    #endif

    The 'ERROR' constant also exists in the standard library, causing a conflict.

    So, I modified this constant as below. And I replaced from ERROR to BSD_ERROR in nxd_bsd.c file.

    #define NX_SOC_ERROR 	-1 /* Failure. */
    #ifndef BSD_ERROR
    #define BSD_ERROR NX_SOC_ERROR
    #endif

     

    Now, error is gone.

     

    I will try to do TCP/UDP Test code with nxd_bsd.

     

    Best regards,