Skip to content

Commit cbd7656

Browse files
authored
Minor fixups to compile with TF-M (earlephilhower#2403)
* Minor fixups to compile with TF-M TF-M requires c99 compatibility, which throws errors at these lines This patch fixes those errors and is currently applied by TF-M when cloning the SDK, but it would be better to get it into the SDK by default so that patch isn't needed * #ifdef only on __STRICT_ANSI__ Also fix devinfo type
1 parent 8066bee commit cbd7656

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/common/pico_sync/sem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void sem_init(semaphore_t *sem, int16_t initial_permits, int16_t max_permits) {
1515
}
1616

1717
int __time_critical_func(sem_available)(semaphore_t *sem) {
18-
#ifdef __GNUC__
18+
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
1919
return *(volatile typeof(sem->permits) *) &sem->permits;
2020
#else
2121
static_assert(sizeof(sem->permits) == 2, "");

src/rp2_common/hardware_flash/flash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ static void flash_devinfo_update_field(uint16_t wdata, uint16_t mask) {
299299
// Boot RAM does not support exclusives, but does support RWTYPE SET/CLR/XOR (with byte
300300
// strobes). Can't use hw_write_masked because it performs a 32-bit write.
301301
io_rw_16 *devinfo = flash_devinfo_ptr();
302+
#ifdef __STRICT_ANSI__
303+
*(io_rw_16 *)hw_xor_alias_untyped(devinfo) = (*devinfo ^ wdata) & mask;
304+
#else
302305
*hw_xor_alias(devinfo) = (*devinfo ^ wdata) & mask;
306+
#endif
303307
}
304308

305309
// This is a RAM function because may be called during flash programming to enable save/restore of

src/rp2_common/pico_multicore/multicore.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ int core1_wrapper(int (*entry)(void), void *stack_base) {
101101
void multicore_reset_core1(void) {
102102
// Use atomic aliases just in case core 1 is also manipulating some PSM state
103103
io_rw_32 *power_off = (io_rw_32 *) (PSM_BASE + PSM_FRCE_OFF_OFFSET);
104+
#ifdef __STRICT_ANSI__
105+
io_rw_32 *power_off_set = hw_set_alias_untyped(power_off);
106+
io_rw_32 *power_off_clr = hw_clear_alias_untyped(power_off);
107+
#else
104108
io_rw_32 *power_off_set = hw_set_alias(power_off);
105109
io_rw_32 *power_off_clr = hw_clear_alias(power_off);
110+
#endif
106111

107112
// Hard-reset core 1.
108113
// Reading back confirms the core 1 reset is in the correct state, but also

0 commit comments

Comments
 (0)