2025-09-16 4:08 AM
Using H743 ETH example from how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack .
I want to use jumbo frames to avoid IP fragmentation while streaming audio via UDP. So, no jumbo frames have to be received. I only care about transmitting.
Below is my StartDefaultTask function, which is called in main(). Normal transmissions under 1500bytes MTU work fine when MAX_UDP_PAYLOAD_SIZE is adjusted.
I understand work needs to be done. I've tried changing buffer sizes and adjusting values in low_level_init(), but I'm unable to get it to work.
Currently, with ^^ at 2000bytes the debugger ends up here:
void StartDefaultTask(void *argument)
{
/* init code for LWIP */
MX_LWIP_Init();
/* USER CODE BEGIN 5 */
#define MAX_UDP_PAYLOAD_SIZE 2000
uint8_t large_data[MAX_UDP_PAYLOAD_SIZE];
const char* message1 = "Hello UDP message!\n\r";
osDelay(1000);
ip_addr_t PC_IPADDR;
IP_ADDR4(&PC_IPADDR, 192, 168, 1, 1);
struct udp_pcb* my_udp = udp_new();
udp_connect(my_udp, &PC_IPADDR, 55151);
struct pbuf* udp_buffer = NULL;
memset(large_data, 0xAA, MAX_UDP_PAYLOAD_SIZE);
/* Infinite loop */
for (;;) {
osDelay(1000);
/* !! PBUF_RAM is critical for correct operation !! */
udp_buffer = pbuf_alloc(PBUF_TRANSPORT, strlen(message1), PBUF_RAM);
if (udp_buffer != NULL) {
memcpy(udp_buffer->payload, message1, strlen(message1));
udp_send(my_udp, udp_buffer);
pbuf_free(udp_buffer);
}
udp_buffer = pbuf_alloc(PBUF_TRANSPORT, MAX_UDP_PAYLOAD_SIZE, PBUF_RAM);
if (udp_buffer != NULL) {
// 5. Fill the pbuf payload with the data from our source buffer
memcpy(udp_buffer->payload, large_data, MAX_UDP_PAYLOAD_SIZE);
// 6. Send the packet
udp_send(my_udp, udp_buffer);
// 7. Free the buffer
pbuf_free(udp_buffer);
}
}
/* USER CODE END 5 */
}