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.

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

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

Children