Skip to content

Commit 23da0fa

Browse files
committed
Fixes issue with memory alignment in STM32
When compiling with optimizations on, an issue occurs where the claimed_pins/never_reset_pins memory location is shared with another variable. This causes some bad memory read, so the USB pins ended up being reset. Setting these to have an alignment of 4 bytes resolves this. Tested on nucleo_f746zg
1 parent 25d5f2c commit 23da0fa

File tree

1 file changed

+1
-1
lines changed
  • ports/stm/common-hal/microcontroller

1 file changed

+1
-1
lines changed

ports/stm/common-hal/microcontroller/Pin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool neopixel_in_use;
5555

5656

5757
STATIC uint16_t claimed_pins[GPIO_PORT_COUNT];
58-
STATIC uint16_t never_reset_pins[GPIO_PORT_COUNT];
58+
STATIC uint16_t __ALIGNED(4) never_reset_pins[GPIO_PORT_COUNT];
5959

6060
void reset_all_pins(void) {
6161
// Reset claimed pins

0 commit comments

Comments
 (0)