Skip to main content
Associate II
June 25, 2026
Question

etharp_raw word alignement issue

  • June 25, 2026
  • 9 replies
  • 80 views

Hello,

I’m working on a stm32h753 MCU and trying to use LwIP. I followed a lot of topics on that but I’m still not able to make it work.

When I’m using debugger to identify issue, I’m always falling in unaligned access issue.

backtrace in debug

Here is my configuration :

MPU_config

void MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_InitStruct = {0};

/* Disables the MPU */
HAL_MPU_Disable();

/* Configure the MPU as Strongly ordered for not defined regions */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x00;
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x87;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Configure the MPU attributes as Device not cacheable
for ETH DMA descriptors */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x30000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Configure the MPU attributes as Normal Non Cacheable
for LwIP RAM heap which contains the Tx buffers */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x30000200;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER2;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Enables the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}

Now my lwip linker section :

.lwip_sec (NOLOAD) :
{
. = ABSOLUTE(0x30000000);
*(.RxDecripSection)

. = ABSOLUTE(0x30000100);
*(.TxDecripSection)

. = ABSOLUTE(0x30000200);
*(.Rx_PoolSection)
} >RAM_D2 AT> ROM

and then the same in ethernetif.c

ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */
ETH_DMADescTypeDef DMATxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */

I would love to understand why it isn’t working and how to correct it.

 

Best regards

9 replies

mƎALLEm
ST Technical Moderator
June 25, 2026

Hello ​@giorgio29 ,

Ethernet/Stacks related questions need to be asked in STM32 MCUs Embedded software forum board.

STM32 MCUs Products are dedicated to the silicon related questions and documentation: datasheet/reference manual etc ..

I’m moving that post then.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
giorgio29Author
Associate II
June 25, 2026

Ok thank you, soory for troubles.

mƎALLEm
ST Technical Moderator
June 25, 2026

Check if you have any unaligned access to 256 bytes starting from 0x30000000 and to 16KB starting from 0x30000200.

    MPU_InitStruct.BaseAddress = 0x30000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
    MPU_InitStruct.BaseAddress = 0x30000200;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;

Cortex-M7 doesn’t allow unaligned access to Device and Strongly-Ordered memory types.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
giorgio29Author
Associate II
June 26, 2026

This is a solly question but how to debug those unaligned access ? (I’ve made the modifications on the size)

Pavel A.
June 26, 2026

The debugger in CubeIDE has special tool for this, Fault analyzer. When your program gets a fault, open it and it will show the available details. If the fault is “precise” (the happy case) , the return PC address displayed there is the instruction that caused the fault. From there you can figure out what the program did, which address it tried to read or write etc.

Pavel A.
June 26, 2026
    MPU_InitStruct.BaseAddress = 0x30000200;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;

This combination is invalid. Region base address must be aligned on the region size.

For region #1 you need 512 bytes (0x200), not 256.

 

 

giorgio29Author
Associate II
June 29, 2026

So, I’ve made a bit of investigation, and here is the result :

I’ve added a function to get some information on the hard fault :

What I’m understanding is that the issue is related to the memory rx pool base ?

I’ve also took a look at the PC instruction address which is : 0xce87a7d8 and there is nothing out there.

Is this helping ?

Pavel A.
June 29, 2026

0xce87a7d8 is not a valid code address for STM32H7. Likely you have a stack corruption. This is hard to debug, unfortunately.