Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardfault error caused by ARM Cortex m0 non-4-byte alignment #33969

Closed
maweicoltsmart opened this issue Apr 2, 2021 · 2 comments · Fixed by #34172
Closed

Hardfault error caused by ARM Cortex m0 non-4-byte alignment #33969

maweicoltsmart opened this issue Apr 2, 2021 · 2 comments · Fixed by #34172
Assignees
Labels
area: ARM ARM (32-bit) Architecture bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@maweicoltsmart
Copy link

MCU: ARM Cortex m0
File: subsys/random/rand32_timer.c
Function: void z_impl_sys_rand_get(void *dst, size_t outlen)

A hardfault error occurs when the address pointed to by the pointer udst is not aligned with 4 bytes

@maweicoltsmart maweicoltsmart added the bug The issue is a bug, or the PR is fixing a bug label Apr 2, 2021
@carlescufi carlescufi added the area: ARM ARM (32-bit) Architecture label Apr 6, 2021
@maweicoltsmart
Copy link
Author

In fact, I discovered this problem when porting net offload to an ARM Cortex m0 MCU. Although the protocol stack program can run, it sometimes crashes inexplicably. I think the cause of the crash should also be caused by the forced type conversion of non-four-byte aligned addresses in the net offload program. I am waiting for your help.

@maweicoltsmart
Copy link
Author

This can be solved. But I wonder if there are similar problems in other subsystems such as network

carlescufi added a commit to carlescufi/zephyr that referenced this issue Apr 16, 2021
The previous implementation assumed that the dst pointer was always
aligned to a 4-byte boundary in platforms that require alignment for
storage of 32-bit integers. Since this is required for certain platforms
(eg. Arm Cortex-M0), use memcpy() instead, which always takes
alignment into account.

Fixes zephyrproject-rtos#33969.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
nashif pushed a commit that referenced this issue Apr 16, 2021
The previous implementation assumed that the dst pointer was always
aligned to a 4-byte boundary in platforms that require alignment for
storage of 32-bit integers. Since this is required for certain platforms
(eg. Arm Cortex-M0), use memcpy() instead, which always takes
alignment into account.

Fixes #33969.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants