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.

 

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

15 REPLIES 15
MGogr.1
Associate III

why dont you try with static ip address? see if it works properly and then move to dhcp.

MStackDev_376
Associate III

Hi,

 

This is probably an issue with the Ethernet DMA TX/RX descriptors. In case you have the D-Cache enabled, try to disable it (from our experience, D-Cache wreaks havoc with the descriptors, causing the same issue you are experiencing).

 

Also check that the memory sections in which the descriptors are placed are also specified in the linker script. If this is not the case, then please add them in the linker. You'll find something like this in main.c

 

ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection")));
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection")));

Make sure the section names are mentioned in the linker script

One final tip, make sure you have enabled the appropriate PHY driver (IIRC, the option must be somewhere in Connectivity->ETH menu).

 

Hope this helps you.

STackPointer64
ST Employee

Hello @sparqy and welcome to ST Community!

In the Example1 IOC you attached, you enabled the wrong Ethernet interrupt. Instead of enabling the Ethernet Global Interrupt, you enabled the Ethernet Wakeup Global Interrupt. Also, the application and IP instance thread sizes were not configured properly. I have attached a corrected working IOC below for you to compare the changes and use as a reference.

Best regards,

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

Also, make sure you have a working DHCP server on your computer if you're connecting the board directly to it and not through a router. The DHCP DORA (Discover, Offer, Request, ACK) sequence should complete flawlessly.

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

I have fixed all these issues exactly as you implemented in your IOC to no avail. Could the issue be related to Ethernet DMA descriptors as mentioned by @MStackDev_376?

DCACHE is not enabled.

Nothing of the sort is mentioned in the linker script. Can you walk me through how to add it in?

Thanks

STackPointer64
ST Employee

Could you please try placing the IOC file I sent you into a folder, generate the project using it, run the project without making any changes, and monitor the traffic using Wireshark? Which application are you using to create the DHCP server? Or are you connecting the board directly to your router?

Regarding the issue mentioned by @MStackDev_37A about Ethernet DMA descriptors: No, the D-Cache is already disabled in the IOC and no modifications are needed in the linker file in your case.

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

I took a closer look at the descriptor placement for H563ZI, and it turns out the Ethernet DMA TX/RX descriptors are already located in the correct memory region by default. So, I believe there’s no need to manually define or modify any additional memory sections in the linker script, the existing configuration already handles it properly. Please disregard this potential cause, it's not the case here.

Though the fact that you see no packets on Wireshark while waiting for DHCP to get an IP likely indicates an issue on the Ethernet hardware/clocks setup issue. Since DCACHE is disabled and that's not the issue,  maybe you can also double check the Ethernet pins are the correct ones.

Just generated from the IOC file and still nothing through Wireshark. I don't know if this is relevant but just to ensure, for the project to build i have to modify 3 lines of the MakeFile. Specifically line 50 which is a duplicate of line 49 thus causing already defined issues. And lines 875-876 to append ASMMC_SOURCES to build objects. This bugs out the MakeFile trying to replace the vpath for .S and the project never builds. Thre are no ASMMC_SOURCES in the MakeFile to begin with so i believe this is fine.

These are the only changes ive made, other then that, I generated, built and flashed. The DHCP server is a router sitting on my desk with only my computer and the baord connected to it. I have tested a second router as well as factory reset this router. The ST board also never appears in the DHCP client list if this was just a wireshark issue. 

Also to add, I have just tried setting a default ip address and mask then pinging the Ip address. This also doesnt work.