Skip to content

Commit 8cfd849

Browse files
LoveKarlssonkartben
authored andcommitted
arch: arm: mpu: Fix alignment check for iccarm
The IAR C/C++ compiler can't resolve a cast on a pointer to a constant expression. This is used in the _ARCH_MEM_PARTITION_ALIGN_CHECK macro. This fix checks if an IAR compiler is used and disables the start-alignment check if it is. This was already fixed for v7 in rev d34d554. Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
1 parent a9f2a19 commit 8cfd849

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/zephyr/arch/arm/mpu/arm_mpu_v8.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,20 @@ typedef struct {
419419

420420
#endif /* _ASMLANGUAGE */
421421

422+
423+
/* Some compilers do not handle casts on pointers in constant expressions */
424+
#if defined(__IAR_SYSTEMS_ICC__)
425+
#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
426+
BUILD_ASSERT( \
427+
(size > 0) && \
428+
((size) % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0), \
429+
"The start and size of the partition must align with the minimum MPU " \
430+
"region size.")
431+
#else
422432
#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
423433
BUILD_ASSERT((size > 0) && \
424434
((uint32_t)start % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0U) && \
425435
((size) % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0), \
426436
"The start and size of the partition must align with the minimum MPU " \
427437
"region size.")
438+
#endif /* defined(__IAR_SYSTEMS_ICC__) */

include/zephyr/arch/arm/mpu/nxp_mpu.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ extern const struct nxp_mpu_config mpu_config;
232232

233233
#endif /* _ASMLANGUAGE */
234234

235+
/* Some compilers do not handle casts on pointers in constant expressions */
236+
#if defined(__IAR_SYSTEMS_ICC__)
237+
#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
238+
BUILD_ASSERT( \
239+
(size) % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0 && \
240+
(size) >= CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE, \
241+
"The size of the partition must align with minimum MPU region size" \
242+
" and greater than or equal to minimum MPU region size.\n" \
243+
"The start address of the partition must align with minimum MPU region size.")
244+
#else
235245
#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
236246
BUILD_ASSERT( \
237247
(size) % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0 && \
@@ -240,5 +250,6 @@ extern const struct nxp_mpu_config mpu_config;
240250
"The size of the partition must align with minimum MPU region size" \
241251
" and greater than or equal to minimum MPU region size.\n" \
242252
"The start address of the partition must align with minimum MPU region size.")
253+
#endif
243254

244255
#endif /* ZEPHYR_INCLUDE_ARCH_ARM_MPU_NXP_MPU_H_ */

0 commit comments

Comments
 (0)