RA6M4 Azure RTOS nxd_bsd.c raw socket

Hi,

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,

Victor

  • Hello Victor,

    Thanks for reaching out Renesas Engineering Community!

    Could you please give us more information about your application?

    Thank you!

    Best Regards,

    IK

  • Hello,

    The application is implementing EtherNet/IP protocol on RA6m4 using BSD addon. EtherNet/IP protocol requires LLDP to pass certification. To support LLDP, I think I need to use raw socket. To use raw socket I need to define it in nxd_bsd.h.

    When I define this, it enables some codes in nxd_bsd.h and nxd_bsd.c. I do have error message on the code below.

    I don't know where _nx_driver_hardware_packet_send and _nx_driver_hardware_packet_received_callback are defined. I have looked in every file in netxduo folder with no success.

    On ST github, I see they have _nx_driver_hardware_packet_send defined in https://github.com/STMicroelectronics/x-cube-azrtos-h7/blob/33d13302a3d58ec4c86091a6e81185996f3f75c8/Middlewares/ST/netxduo/common/drivers/nx_stm32_eth_driver.c. It looks like we are missing some RA driver files.

    Please, I need help locating the files.

    Thanks,

    Victor

  • Hello Victor,

    When using Azure RTOS NetX Duo BSD Support stack with all the necessary configuration a folder named BSD in location ra/microsoft/azure-rtos/netxduo/addons/BSD is generated which includes two files nx_bsd.c and nx_bsd.h file. If you will search on these files you will see that: 

    #ifdef NX_BSD_RAW_SUPPORT
    _nx_driver_hardware_packet_received_callback = _nx_bsd_hardware_packet_received;
    #endif /* NX_BSD_RAW_SUPPORT */

    in function bsd_initialize() at line 431.

    The implementation of _nx_bsd_hardware_packet_received() function starts from line 12865.

    Regarding function _nx_driver_hardware_packet_send() ,in the same file nx_bsd.c you will find out that this function is called by function _nx_bsd_hardware_internal_sendto(). The implementation of _nx_bsd_hardware_internal_sendto() starts at line 12681.

    What kind of error message are you getting on your code?

    Hope it helps!
    Best Regards,

    IK

  • Hello IK,

    Thanks for looking into this for me. Your explanation is correct, but the I am having is undefined reference on both _nx_driver_hardware_packet_received_callback and _nx_driver_hardware_packet_send(). 

    _nx_driver_hardware_packet_received_callback error

    _nx_driver_hardware_packet_send() error

    I can not find where these two are defined. Please can you help tell me where they are defined?

    Thanks very much for spending your time to look at this.

    Victor

  • Hello all,

    Please, I am still looking for solution for this. If anyone has any suggestion, please let me know.

    Thanks,

    Victor 

  • Hi IK,

    This is correct. 

    Regarding function _nx_driver_hardware_packet_send() ,in the same file nx_bsd.c you will find out that this function is called by function _nx_bsd_hardware_internal_sendto(). The implementation of _nx_bsd_hardware_internal_sendto() starts at line 12681.

    But where is function _nx_driver_hardware_packet_send() defined. That function call in function _nx_bsd_hardware_internal_sendto() is giving me an error. The error is below.

    Thanks,

    Victor

  • Hello,

    Do you see any build errors after building the project ?

    These functions are provided by Azure RTOS so the full body of the function may be unavailable.

  • Hello,

    Yes, I did compile the code. And these are the errors I got.

    Do you think the code is incomplete?

    Thanks,

    Victor

  • Hi Victor,

    After adding 'Azure RTOS NetX Duo BSD Support' stack and modifying according to FSP warnings, I built the project and I can see no errors.

    I attach the project for you to check.

    Test_RA6M4_BSD.zip

  • 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;
        uint8_t g_packet_pool0_pool_memory[G_PACKET_POOL0_PACKET_NUM * (G_PACKET_POOL0_PACKET_SIZE + sizeof(NX_PACKET))] BSP_ALIGN_VARIABLE(4) ETHER_BUFFER_PLACE_IN_SECTION;
    
        /* 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. */
            nx_packet_pool_create(&g_packet_pool0,
                                                "g_packet_pool0 Packet Pool",
                                                G_PACKET_POOL0_PACKET_SIZE,
                                                &g_packet_pool0_pool_memory[0],
                                                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.*/
            nx_udp_enable(&g_ip0);
    
            /* Enable TCP.*/
            nx_tcp_enable(&g_ip0);
    
            /* Enable icmp.*/
            nx_icmp_enable(&g_ip0);
    
            /*Enable fragmentation*/
            nx_ip_fragment_enable(&g_ip0);
    
            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 */
        g_packet_pool0_quick_setup();
    
        ip_init0();
    
        bsd_initialize (&g_ip0, &g_packet_pool0, (char *)g_bsd_stack_memory, 2048, 2);
        while (1)
        {
            tx_thread_sleep (1);
        }
    }