cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfaults because of alignment after updating to STM32CubeIDE 1.18.1

Sansh
Associate

I am using STM32U5 MCUs in my development. The code seems to be broken after updating from 1.16.1 to 1.18.1 and migrating the project using the latest version of compiler tools. 

Following the debug to disassembly, I see 16-bit or 32-bit STR, LDR access to odd addresses. These are part of a struct that has a byte and 16-bit/32-bit elements. Based on my understanding of any ARMV8, the compiler tools are supposed to do byte access when not aligned.

The USBX CDCACM code based on the example generated from the 1.16.1 IDE, migrated to 1.18.1 seems to see the issue as well with lots of structures defined as PACKED (ALIGNED(1)). 

 

Is this a known issue or am I missing something.

 

 

Thanks

Sansh

4 REPLIES 4
nico23
Senior

Latest CubeIDE version is 1.18.0

You sure you have the 1.18.1?

TDK
Guru

The M33 supports unaligned access. Is it disabled? Which structure access in which file is causing the hard fault?

If you feel a post has answered your question, please click "Accept as Solution".
Sansh
Associate

Yeah, it is 1.18.0 (typo). If someone from ST could correct the Title, that would help.

in ux_device_descriptors.c, 

I see a hard fault at this highlighted line 

======

static void USBD_FrameWork_AddConfDesc(uint32_t Conf, uint32_t *pSze)

{

/* Intermediate variable to comply with MISRA-C Rule 11.3 */

USBD_ConfigDescTypedef *ptr = (USBD_ConfigDescTypedef *)Conf;

 

ptr->bLength = (uint8_t)sizeof(USBD_ConfigDescTypedef);

ptr->bDescriptorType = USB_DESC_TYPE_CONFIGURATION;

ptr->wDescriptorLength = 0U;

ptr->bNumInterfaces = 0U;

ptr->bConfigurationValue = 1U;

ptr->iConfiguration = USBD_CONFIG_STR_DESC_IDX;

ptr->bmAttributes = USBD_CONFIG_BMATTRIBUTES;

ptr->bMaxPower = USBD_CONFIG_MAXPOWER;

*pSze += sizeof(USBD_ConfigDescTypedef);

}

====

OR

====

in the function,

static void USBD_FrameWork_CDCDesc(USBD_DevClassHandleTypeDef *pdev,

uint32_t pConf, uint32_t *Sze)

 

 

/* Append Endpoint descriptor to Configuration descriptor */

__USBD_FRAMEWORK_SET_EP(pdev->tclasslist[pdev->classId].Eps[2].add, \

USBD_EP_TYPE_INTR,

(uint16_t)pdev->tclasslist[pdev->classId].Eps[2].size,

USBD_CDCACM_EPINCMD_HS_BINTERVAL,

USBD_CDCACM_EPINCMD_FS_BINTERVAL);

======

 

Using default 13.3 toolchain that comes with STM32Cube IDE 1.18.0 , I see the issue at later point.

If I use local toolchain sysgcc (arm-eabi-none-*) , then I see issue at former with "-m-no-unaligned-access" and later with "-maligned-access"

 

 

Sansh
Associate

with -mno-unaligned-access flag

Sansh_0-1741874791568.png