-
Notifications
You must be signed in to change notification settings - Fork 7.6k
arch: arm: cortex_a_r: Improve support for big endian #72693
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
Conversation
9c9f1ca
to
b3fc89f
Compare
@ithinuel please take a look |
#if defined(CONFIG_BIG_ENDIAN) | ||
#define E_BIT (1 << 9) | ||
#else | ||
#define E_BIT (0 << 9) | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set or un-set E_BIT
in thread.c
. This file is encoding the BIT position, so the E_BIT
position is always 1 << 9
but only set for CONFIG_BIG_ENDIAN
.
arch/arm/core/cortex_a_r/thread.c
Outdated
@@ -94,7 +94,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, | |||
iframe->a3 = (uint32_t)p2; | |||
iframe->a4 = (uint32_t)p3; | |||
|
|||
iframe->xpsr = A_BIT | MODE_SYS; | |||
iframe->xpsr = E_BIT | A_BIT | MODE_SYS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iframe->xpsr = E_BIT | A_BIT | MODE_SYS; | |
#if defined(CONFIG_BIG_ENDIAN) | |
iframe->xpsr = E_BIT | A_BIT | MODE_SYS; | |
#else | |
iframe->xpsr = A_BIT | MODE_SYS; | |
#endif |
#if defined(CONFIG_BIG_ENDIAN) | ||
#define E_BIT (1 << 9) | ||
#else | ||
#define E_BIT (0 << 9) | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if defined(CONFIG_BIG_ENDIAN) | |
#define E_BIT (1 << 9) | |
#else | |
#define E_BIT (0 << 9) | |
#endif | |
#define E_BIT (1 << 9) |
These suggestions are essentially what @carlocaione is requesting. |
b3fc89f
to
3cfd2b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little nitpick is the space style not matching everywhere (on E_BIT definition).
Otherwise LGTM
When this bit is not set, it defaults to 0 (little endian). This causes issues for big-endian devices, as data will be accessed using little endian. Signed-off-by: Sigmund Klåpbakken <sigmundklaa@outlook.com>
Sets the property `PROPERTY_OUTPUT_FORMAT` to `elf32-bigarm` when `CONFIG_BIG_ENDIAN` is set to `y`. Signed-off-by: Sigmund Klåpbakken <sigmundklaa@outlook.com>
3cfd2b3
to
04c8953
Compare
Fixed |
This enables support for big endian Cortex A/R devices. The pull request consists of two changes:
PROPERTY_OUTPUT_FORMAT
toelf32-bigarm
whenCONFIG_BIG_ENDIAN=y
CPSR
register, ensuring that the CPU stays in big endian mode when switching to the main thread. Without this, data accesses used the wrong endianness, causing a (very big) headache.The
CPSR
issue was the only problem I noticed when porting theTMS570LS1224
big endian Cortex R4F SoC. With this fixed, it seems to work completely fine. My setup is available at https://github.com/OrbitNTNU/zephyr-hw if that is relevant.