Skip to main content
Explorer II
January 23, 2025
Question

Adding BSD sockets to netxDuo for LLDP

  • January 23, 2025
  • 3 replies
  • 1210 views

Hi,

I was able to run a demo project on a STM32H573 dev board. I am using ThreadX and NetxDuo, with mqtt addon.

I was able to connect to the mqtt broker and send/receive messages.

I want also to be able to use the bsd sockets to send packets on layer 2. As far as I have understood, for sending and receiving layer 2 packets I need to use bsd sockets.

I followed the doc from github, added the files .h and .c 
I had to add the line

#define TX_THREAD_USER_EXTENSION int bsd_errno


in the user code part of "tx_user.h", so it can survive a code generation.

Then I enabled 
NX_ENABLE_EXTENDED_NOTIFY_SUPPORT
and

NX_ENABLE_IP_RAW_PACKET_FILTER

Then I got into a problem: the redefinitions of structs and function names, so I added

#define NX_BSD_ENABLE_NATIVE_API

in the user code part of "nx_user.h"
I want to have raw support, so I also added

#define NX_BSD_RAW_SUPPORT

in the user code part of "nx_user.h"

Now I get an error when I compile:
"nxd_bsd.c:474: undefined reference to `_nx_driver_hardware_packet_received_callback' "

Am I missing something or I am doing it wrong? 
Thanks in advance tor any help

    This topic has been closed for replies.

    3 replies

    coso2Author
    Explorer II
    January 24, 2025

    Ok, I got something in working condition.. kinda. I can init and create a raw socket.

    Now, if I call the function "nx_bsd_send", the compiler is complaining abount this:

    ../NetXDuo/App/nxd_bsd.c:13327: undefined reference to `_nx_driver_hardware_packet_send'

    that line is in the function

    static INT _nx_bsd_hardware_internal_sendto(NX_BSD_SOCKET *bsd_socket_ptr, CHAR *msg, INT msgLength, INT flags, struct nx_bsd_sockaddr* destAddr, INT destAddrLen)

    If I go to that line and press F3, I go to the declaration in nxd_bsd.h file:

    extern UINT _nx_driver_hardware_packet_send(NX_PACKET *packet_ptr);

    If I press again F3, I go straight to the implementation in the file "nx_stm32_eth_driver.c".

    How is it possible for the ide to find the function, but when I compile I get undefined reference?

    Thanks for any hint or advise

    ST Employee
    February 17, 2025

    Hello @coso2 ,

    This is clearly an include path problem it's normal that IDE recognizes the function and the compiler doesn't as it needs to have a path to the file where the function was declared.
    Regards

    coso2Author
    Explorer II
    February 18, 2025

    The function "_nx_driver_hardware_packet_send" in "nx_stm32_eth_driver.c" is static

     

     

    static VOID _nx_driver_packet_send(NX_IP_DRIVER *driver_req_ptr)

     

     

    And every time I generate the code, I have to manually remove the "static" keyword

    Graduate II
    February 24, 2025

    I am having the exact same issue. 

    The function "_nx_driver_hardware_packet_send" in "nx_stm32_eth_driver.c" is static and the "nxd_bsd.h" file has that function externed. Therefore, the only way for this addon to work is to go and edit the file every time. 

    NXD_BSD also externs `_nx_driver_hardware_packet_received_callback` when we enable NX_BSD_RAW_SUPPORT. This function doesn't seem to exist at all in the ethernet driver. 

    Does ST have any instructions for integrating the NXD_BSD addon into a H7 project using the NX_BSD_RAW_SUPPORT defined? This flag seems to be required if you want to support multicasting.