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

Parents
  • 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.

  • 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);
        }
    }
    

  • 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.

    Thanks,

    Victor

  • 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?

    Thanks,

    Victor

  • 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,

    IK

  • Hi IK,

    According to the Microsoft documentation, it says you need to call the bsd_initialize function (see link and description below). What function should I call in order to use the NetX BSD Support Module?

     

     

    Using NetX Duo BSD

    A NetX Duo BSD application project must include nxd_bsd.h after it includes tx_api.h and nx_api.h to be able to use BSD services specified later in this guide. The application must also include nxd_bsd.c in the build process. This file must be compiled in the same manner as other application files and its object form must be linked along with the files of the application. This is all that is required to use NetX Duo BSD.

    To utilize NetX Duo BSD services, the application must create an IP instance, create a packet pool for the BSD layer to allocate packets from, allocate memory space for the internal BSD thread stack, and specify the priority of the internal BSD thread. The BSD layer is initialized by calling bsd_initialize and passing in the parameters. This is demonstrated in the "Small Examples" later in this document but the prototype is shown below:

    CCopy

    INT bsd_initialize(NX_IP *default_ip, NX_PACKET_POOL *default_pool,

                        *CHAR *bsd_thread_stack_area,

                        *ULONG bsd_thread_stack_size,

                        *UINT bsd_thread_priority*);

    The default_ip is the IP instance the BSD layer operates on. The default_pool is used by the BSD services to allocate packets from. The next two parameters: bsd_thread_stack_area, bsd_thread_stack_size defines the stack area used by the internal BSD thread, and the last parameter, bsd_thread_priority, sets the priority of the thread.

    Best Regards,

    Victor

  • Hey IK,

    I'm working with Victor on this. Any thoughts on his comment below?

    The Microsoft documentation that Renesas refers to seems to be saying different than what you and AZ are saying. 

    Please advise what function is to be called to use the NetX module if bsd_initialize is not to be used. 

    Best Regards

Reply Children
No Data