Showing results for 
Search instead for 
Did you mean: 

Can't Send UDP Packets to Specific IP Addresses on H563



Hello STM32 Community,

I'm encountering an issue with an Ethernet application I'm developing on an STM32 platform, where I can't seem to send UDP packets to a specific IP address within my local network. Broadcast UDP packets are sent and received successfully, but directed packets do not reach their destination.

Here's a summary of the setup and issue with github gists going into deeper details below:

  • Deelopment Board: H563ZI
  • MAC Address: Manually set to 0:80:e1:0:0:0
  • Target IP: (my notebook)
  • Broadcast IP: (Broadcasts work fine and are received by nc -lu PORT & wireshark)
  • LwIP version: 2.1.3
  • Router: Linksys e2500 v4 router, with DHCP range to
  • Firewall: Disabled on both router and my notebook.

Wireshark captures the broadcast packets, but not the packets directed to However, when I use the broadcast address, the messages are received and visible in Wireshark and on the nc -lu 6543 listener on my notebook.

Attempts to ping the development board's IP ( result in timeouts,

Despite the board's IP being in the destination computer's ARP table. I've also confirmed that firewalls are disabled on everywhere on the router and destination computer.

Unfortunately the router's current network management portal does not let me see list of devices connected.

The relevant code files are attached and briefly noted here. Started by initializing the network and send UDP messages, pretty standard stuff, follows the examples closely:

void udp_network_init(void)

// set device's ip address, netmask and gateway
ipaddr_aton("", &broadcast_ip);
ipaddr_aton("", &device_ip);
ipaddr_aton("", &computer_ip);
ipaddr_aton("", &router_ip);

ipaddr_aton("", &netmask);
ipaddr_aton("", &gateway);

// initialize the ethernet interface
eth_init();     // inits device mac adrress, starts eth clock, gpio, interrupts & checksums for ethernet packet
eth_mac_init(); // starts the ETH DMA Rx & Tx
lwip_init();    // starts network stack

// set up the network interface
if (!netif_add(&pnetif, &device_ip, &netmask, &gateway, NULL, ethernetif_init, ethernet_input)) {
ERROR("Failed to add network if");



udp_pcb = udp_new();

if (udp_pcb != NULL) {
err_t err = udp_bind(udp_pcb, &device_ip, UDP_PORT_SRC);
if (err != ERR_OK) {
INFO("Can't bind to device ip/ src port");
err = udp_connect(udp_pcb, &computer_ip, UDP_PORT_DST);
if (err != ERR_OK) {
INFO("Can't connect to computer ip");
udp_recv(udp_pcb, udp_recv_callback, NULL);

                 NULL, PRIORITY_MINIMUM

INFO("Ready to receive udp packets");
// udp_send_message("targetted ip test", &computer_ip, UDP_PORT_DST);
// udp_send_message("broadcast ip test", &broadcast_ip, UDP_PORT_DST);


void udp_send_message(const char* message, const ip_addr_t* target_ip, u16_t target_port)
err_t wr_err   = ERR_OK;
struct pbuf* p = pbuf_alloc(PBUF_TRANSPORT, strlen(message), PBUF_RAM);

if (p != NULL) {

memcpy(p->payload, message, strlen(message));
wr_err = udp_sendto_if(udp_pcb, p, target_ip, target_port, &pnetif);
if (wr_err) {
INFO("UDP_SENDTO_IF error %d", (int)wr_err);

static void ethernet_thread(void* v)
for (;;) {

void ethernet_loop(void)
I have tried a few problems/solutions that sounded applicable to my set up from this compiled list. However I have not had much success.

Here is a detailed compilations of things I have tried so far and I'm afraid I'm not getting much leads on this. It includes debug output, wireshark packets etc

ping test:
static arp:

min stack size for lwip:


Attached are the most relevant files as well.

Considering the above, I have a few questions for the community:

  1. How should I proceed with debugging this issue
  2. Have you encountered similar issues with UDP communication on STM32 platforms, and if so, how were they resolved?
  3. Is there a potential misconfiguration that I might be overlooking in my setup or initialization code?

Any insights, suggestions, or guidance you can provide would be greatly appreciated. Thank you in advance for your time and help!