2025-03-16 9:27 AM
Hello everyone,
I’m currently working with the STM32H723ZG Nucleo board and am trying to interface microROS using UDP transport. I’m using the following environment:
I’ve carefully reviewed several guides covering MPU, Ethernet, LWIP, and FreeRTOS configurations. I was able to get microROS working over USART (per the Micro_ROS guide), but when I attempt the UDP transport I encounter a hard fault. I’ve tried replicating setups from the STM32H723_Nucleo_ETH and LWIP_UDP_Echo_Server examples (generated by CubeMX), but they don’t work as expected.
My project files are available here: tapererwaj/h723zg_microros_udp
Below, I have summarized my current configuration:
SCB_EnableICache();
SCB_EnableDCache();
/* Region 0: Ethernet DMA descriptors */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.BaseAddress = 0x0;
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
MPU_InitStruct.SubRegionDisable = 0x87;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/* Region 1: Ethernet/LWIP heap region */
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.BaseAddress = 0x30000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_32KB;
MPU_InitStruct.SubRegionDisable = 0x0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/* Region 2: Additional region (512B) */
MPU_InitStruct.Number = MPU_REGION_NUMBER2;
MPU_InitStruct.Size = MPU_REGION_SIZE_512B;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/* Enable the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
/* Modification start */
.lwip_sec (NOLOAD) :
{
. = ABSOLUTE(0x30000000);
*(.RxDecripSection)
. = ABSOLUTE(0x30000100);
*(.TxDecripSection)
} >RAM_D2
/* Modification end */
#define WITH_RTOS 1
#undef LWIP_PROVIDE_ERRNO
#define CHECKSUM_BY_HARDWARE 1
#define ETH_RX_BUFFER_SIZE 1536
#define MEM_ALIGNMENT 4
#define MEM_SIZE 32232
#define LWIP_RAM_HEAP_POINTER 0x30000200
#define LWIP_SUPPORT_CUSTOM_PBUF 1
#define LWIP_ETHERNET 1
#define LWIP_DNS_SECURE 7
#define TCP_MSS 1460
#define TCP_SND_BUF 5840
#define TCP_SND_QUEUELEN 16
#define LWIP_NETIF_LINK_CALLBACK 1
#define TCPIP_THREAD_STACKSIZE 2048
#define TCPIP_THREAD_PRIO osPriorityNormal
#define TCPIP_MBOX_SIZE 6
#define SLIPIF_THREAD_STACKSIZE 1024
#define SLIPIF_THREAD_PRIO 3
#define DEFAULT_THREAD_STACKSIZE 2048
#define DEFAULT_THREAD_PRIO 3
#define DEFAULT_UDP_RECVMBOX_SIZE 6
#define DEFAULT_TCP_RECVMBOX_SIZE 6
#define DEFAULT_ACCEPTMBOX_SIZE 6
#define RECV_BUFSIZE_DEFAULT 2000000000
#define LWIP_STATS 0
#define CHECKSUM_GEN_IP 0
#define CHECKSUM_GEN_UDP 0
#define CHECKSUM_GEN_TCP 0
#define CHECKSUM_GEN_ICMP6 0
#define CHECKSUM_CHECK_IP 0
#define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_TCP 0
#define CHECKSUM_CHECK_ICMP6 0
Issue:
When running the project, I encounter a hard fault. I suspect this might be due to potential MPU region overlap or an incorrect memory allocation in D2. (For example, my MPU configuration for Region 1 covers 0x30000000–0x30008000, which might conflict with the reserved descriptors.)
My Questions:
Any guidance or suggestions would be greatly appreciated!
Thank you in advance.