cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot get simple Ethernet working - NUCLEO-H563ZI - NetXDuo

sparqy
Associate II

Hello,

I have been trying to setup Ethernet on a NUCLEO-H563ZI to no avail. As recommended I am using the NETXDUO middleware. When setting up my project with CubeMX I enable DHCP but the MCU never seems to send any DHCP packets (Checking through wireshark). This is with completely unmodified code provided by the NX Core Init which generates the nx_app_thread_entry. After some further debugging it seems like the program hangs while waiting for the DHCP Semaphore which says that an IP Address is ready. Specifically this line:

tx_semaphore_get(&DHCPSemaphore, TX_WAIT_FOREVER) != TX_SUCCESS

 

Memory is not an issue in this case as those have been previous issues. I now assign well over 20kb for tx_app and nx_app.This sample program was also tested on a fresh board out of the box.

 

I also have another script that seems to work halfway with messages for DHCPDiscover and DHCPOffer.
Bellow is the main code for that program. In this case I don't use the pre-generated nx_app_thread. 

void Cu_main(ULONG thread_input){

    tx_thread_sleep(300);


    nx_system_initialize();

    status = nx_packet_pool_create(&packet_pool, "Packet Pool", 1536, packet_pool_memory, NX_PACKET_POOL_SIZE);
    printf("Packet pool: %u\n", status);

    status = nx_ip_create(&ip_instance, "NetX IP", 0, 0, &packet_pool, nx_stm32_eth_driver, ip_thread_stack, NX_IP_STACK_SIZE, 10);
    printf("IP create: %u\n", status);
    
    status = nx_arp_enable(&ip_instance, ARP_cache_memory, NX_ARP_CACHE_SIZE);
    printf("ARP enable: %u\n", status);

    status = nx_icmp_enable(&ip_instance);
    printf("ICMP enable: %u\n", status);

    status = nx_dhcp_create(&dhcp_client, &ip_instance, "DHCP Client");
    printf("DHCP create: %u\n", status);

    status = nx_dhcp_start(&dhcp_client);
    printf("DHCP start: %u\n", status);


    ULONG ip_addr, netmask;

    while (1){
        status = nx_ip_address_get(&ip_instance, &ip_addr, &netmask);
        printf("S: %u Got IP: %lu.%lu.%lu.%lu\n",
            status,
            (ip_addr >> 24) & 0xFF,
            (ip_addr >> 16) & 0xFF,
            (ip_addr >> 8) & 0xFF,
            ip_addr & 0xFF);

        if(ip_addr != 0){
            BSP_LED_Toggle(LED2);
        }
        BSP_LED_Toggle(LED1);
        tx_thread_sleep(100); 
    }
}

I have 0 idea why this is not working.

I will add both IOC files to this post.

Any help would be appreciated as I am losing hair over this haha.

 

15 REPLIES 15
STackPointer64
ST Employee

That is rather unusual. Do you have pre-configured security policies set by your IT department that block ICMP packets? Note that Windows Defender Firewall blocks inbound ICMP echo requests by default.

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

This is just a test router, it is not actually connected to the internet or the office network. I can ping/sniff packets from my phone and my laptop just not the nucleo.

STackPointer64
ST Employee

No, I was not referring to office network-level policies; I meant the security policies in your operating system. Is this the first time you have encountered this issue, or has it happened before with other STM32 Ethernet applications?

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

I can double check that, but again the STM32 does not even appear in the routers DHCP client list. This is the first time I have ever used STM32 Ethernet. Also as mentioned, my second example works but only for DHCP discover and Offer, in fact I see it attempting it multiple times.

STackPointer64
ST Employee

Are there any updates regarding your issue? Have you checked with your IT administrator?

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

UDP Never got enabled, therefore DHCP Packets were dropped. All I had to do was call nx_udp_enable before starting the dhcp service and the issue went away. I dont know why this is not done by default in the examples.