RA6M4 Azure RTOS nxd_bsd.c raw socket


I am trying to use raw socket on nxd_bsd.c, but running into some errors. I can't find the function for _nx_driver_hardware_packet_received_callback and _nx_driver_hardware_packet_send.

Please can someone help me locate where these functions are?

Thanks in advance,


Parents Reply Children
  • Hi AZ,

    Thanks for looking into this. Thanks for the project. I ran the project you sent and I see no error as well. I made some modifications to the project, on new_thread0_entry.c and nxd_bsd.h. 

    It looks like I can't insert a zip file here.

    These are the changes I made to new_thread0_entry.c.

    #include "new_thread0.h"
    #include "nxd_bsd.h"
        /* IP instance */
        NX_IP g_ip0;
        /* Stack memory for g_ip0. */
        uint8_t g_ip0_stack_memory[G_IP0_TASK_STACK_SIZE] BSP_PLACE_IN_SECTION(".stack.g_ip0") BSP_ALIGN_VARIABLE(BSP_STACK_ALIGNMENT);
        /* ARP cache memory for g_ip0. */
        uint8_t g_ip0_arp_cache_memory[G_IP0_ARP_CACHE_SIZE] BSP_ALIGN_VARIABLE(4);
        /* Packet pool instance (If this is a Trustzone part, the memory must be placed in Non-secure memory). */
        NX_PACKET_POOL g_packet_pool0;
        /* Stack memory for bsd. */
        uint8_t g_bsd_stack_memory[2048] BSP_PLACE_IN_SECTION(".stack.g_bsd") BSP_ALIGN_VARIABLE(BSP_STACK_ALIGNMENT);
         * @brief     Create the packet pool.
         * @param[IN] None
         * @retval    None
        void g_packet_pool0_quick_setup()
            /* Create the packet pool. */
                                                "g_packet_pool0 Packet Pool",
                                                G_PACKET_POOL0_PACKET_NUM * (G_PACKET_POOL0_PACKET_SIZE + sizeof(NX_PACKET)));
        static UINT ip_init0(void)
            UINT status = NX_SUCCESS;
            //uint32_union ipBytes;
            uint32_t staticIPAddress = 0xc0a50102;
            uint32_t staticSubmask = 0xffffff00;
            uint32_t staticGatewayAddress = 0xc0a50101;
            /* Create the ip instance. */
            nx_ip_create(&g_ip0, "g_ip0 IP Instance", staticIPAddress, staticSubmask, &g_packet_pool0, g_netxduo_ether_0, &g_ip0_stack_memory[0], G_IP0_TASK_STACK_SIZE, G_IP0_TASK_PRIORITY);
            /* Set the gateway address if it is configured. */
            nx_ip_gateway_address_set(&g_ip0, staticGatewayAddress);
            /* Enables Address Resolution Protocol (ARP).*/
            nx_arp_enable(&g_ip0, &g_ip0_arp_cache_memory[0], G_IP0_ARP_CACHE_SIZE);
            /* Enable udp.*/
            /* Enable TCP.*/
            /* Enable icmp.*/
            /*Enable fragmentation*/
            return status;
    /* New Thread entry function */
    void new_thread0_entry(void)
        /* TODO: add your own code here */
        /* Initialize NetX. */
        nx_system_initialize ();
        /* initialize packet pool */
        bsd_initialize (&g_ip0, &g_packet_pool0, (char *)g_bsd_stack_memory, 2048, 2);
        while (1)
            tx_thread_sleep (1);

  • Hi Victor,

    Glad it worked.

    Do you have further questions regarding this issue then ?

  • Hi AZ,

    The code you sent did compile with no error, but that is an empty project. it has no function calls and the #define NX_BSD_RAW_SUPPORT  was not enabled in nx_bsd.h. So, if you add code and enable the #define NX_BSD_RAW_SUPPORT, you will see an error. You can add the code I sent yesterday to your project and compile.

    How do one insert a file here. I tried using insert, but was unable to upload a zip file of your project that I modified.

    The main question I have is, where is _nx_driver_hardware_packet_send function define? I can't locate it.

    Please, take a look at this from ST, https://github.com/STMicroelectronics/x-cube-azrtos-h7/blob/33d13302a3d58ec4c86091a6e81185996f3f75c8/Middlewares/ST/netxduo/common/drivers/nx_stm32_eth_driver.c. From line 1886 to 1996 shows that the function was provide to ST back in 2020. I am expecting there should be a function like that for RA processors.



  • According to NetX documentation on https://learn.microsoft.com/en-us/azure/rtos/netx-duo/netx-duo-bsd/chapter2 , in order to enable raw socket support: 

    So I do not think that NX_BSD_RAW_SUPPORT should be enabled.

  • Thanks for your reply. I have NX_ENABLE_IP_RAW_PACKET_FILTER and NX_BSD_RAW_SUPPORT enabled. I will disable NX_BSD_RAW_SUPPORT and try again.

  • Hi AZ,

    I really need to enable NX_BSD_RAW_SUPPORT for me to support LLDP protocol. When I disable it, I get the errors shown below.

    These errors is a result of sockaddr_ll struct not defined in nx_bsd.h, as shown below.

    As you can see, for me to use sockaddr_ll struct I need to enable NX_BSD_RAW_SUPPORT. 

    The problem I have is when I enable NX_BSD_RAW_SUPPORT, I get the errors shown below.

    The question is where are these defined or what do I need to do to be able use these functions?



  • Hello  Victor,

    As my colleague told you "These functions are provided by Azure RTOS so the full body of the function may be unavailable". This error occurs since your calling on your new thread's function bsd_initialize() function. Notice that you do not have to call this function since this is automatically called  by NetX BSD Support Module. If you will not call this function and call any other NetX BSD Support Module API  you will see that these errors ,no longer appear.

    Best Regards,