Describe the bug
When running the flash_new command via OpenOCD on Windows using an unofficial xpack binary, the firmware successfully flashes and verifies. However, the process halts immediately after with a memory write failure during the rcc_fix procedure. The script fails to write magic numbers back into the RCC memory, throwing an error at mww 0x40002989 0x1d0f0000.
Environment:
To Reproduce
Follow https://github.com/Asmageddon/airbreak-plus/blob/3a42fbc3e5f4e991a2022997cba003b57e6457de/docs/firmware.md
Steps to reproduce the behavior:
- Connect the STM32 device via OpenOCD on a native Windows machine.
- Execute the command:
flash_new stm32-patched.bin
- The flashing and verification process completes successfully ("Verifying that flash was written properly...").
- The process then fails during the
reset_watchdog_bit -> rcc_fix step.
Console Output / Logs
> flash_new stm32-patched.bin
Unable to match requested speed 2000 kHz, using 1000 kHz
Unable to match requested speed 2000 kHz, using 1000 kHz
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800021c msp: 0x2000f000
Tickling watchdog...
device id = 0x100f6413
flash size = 1024 KiB
Resetting device...
Unable to match requested speed 2000 kHz, using 1000 kHz
Unable to match requested speed 2000 kHz, using 1000 kHz
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800021c msp: 0x2000f000
Overwriting flash memory...
device id = 0x100f6413
flash size = 1024 KiB
Verifying that flash was written properly...
Unable to match requested speed 2000 kHz, using 1000 kHz
Unable to match requested speed 2000 kHz, using 1000 kHz
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800021c msp: 0x2000f000
Resetting watchdog bit...
Unable to match requested speed 2000 kHz, using 1000 kHz
Unable to match requested speed 2000 kHz, using 1000 kHz
Writing magic numbers back into RCC memory...
Failed to write memory at 0x4000286c
tcl/airsense.cfg:92: Error:
Traceback (most recent call last):
File "tcl/airsense.cfg", line 86, in flash_new
reset_watchdog_bit
File "tcl/airsense.cfg", line 70, in reset_watchdog_bit
rcc_fix
File "tcl/airsense.cfg", line 92, in rcc_fix
mww 0x40002989 0x1d0f0000
>
Possible Cause
- The failure likely stems from the
mww command requiring 32-bit alignment, which the address 0x40002989 violates, triggering memory errors specifically on Windows.
- It is ambiguous whether this is a flaw in the
airsense.cfg script or the OpenOCD xPack.
- Replacing the command with the following
mwb (byte-level) writes resolves the issue by bypassing alignment restrictions. Further technical context can be found: https://rsaxvc.net/blog/2018/11/24/Unaligned_Access_on_Cortex-M_Loads_vs_Stores,_M4_vs_M7.html
# Replace mww 0x40002989 0x1d0f0000 with(STM32 is little-endian):
mwb 0x40002989 0x00
mwb 0x4000298a 0x00
mwb 0x4000298b 0x0f
mwb 0x4000298c 0x1d
Workaround
As a workaround, I successfully completed the entire flashing process by running OpenOCD inside WSL (Windows Subsystem for Linux) and forwarding the USB device using usbipd. In the WSL environment, the rcc_fix completed perfectly without any memory write errors.
Additional Context
I am opening this issue primarily for archiving purposes and to help document this for other Windows users who might run into the exact same problem. I may close this issue later, but I am open to suggestions if there is a better, proper fix for native Windows environments.
Describe the bug
When running the
flash_newcommand via OpenOCD on Windows using an unofficial xpack binary, the firmware successfully flashes and verifies. However, the process halts immediately after with a memory write failure during thercc_fixprocedure. The script fails to write magic numbers back into the RCC memory, throwing an error atmww 0x40002989 0x1d0f0000.Environment:
To Reproduce
Follow https://github.com/Asmageddon/airbreak-plus/blob/3a42fbc3e5f4e991a2022997cba003b57e6457de/docs/firmware.md
Steps to reproduce the behavior:
flash_new stm32-patched.binreset_watchdog_bit->rcc_fixstep.Console Output / Logs
Possible Cause
mwwcommand requiring 32-bit alignment, which the address0x40002989violates, triggering memory errors specifically on Windows.airsense.cfgscript or the OpenOCD xPack.mwb(byte-level) writes resolves the issue by bypassing alignment restrictions. Further technical context can be found: https://rsaxvc.net/blog/2018/11/24/Unaligned_Access_on_Cortex-M_Loads_vs_Stores,_M4_vs_M7.html# Replace mww 0x40002989 0x1d0f0000 with(STM32 is little-endian): mwb 0x40002989 0x00 mwb 0x4000298a 0x00 mwb 0x4000298b 0x0f mwb 0x4000298c 0x1dWorkaround
As a workaround, I successfully completed the entire flashing process by running OpenOCD inside WSL (Windows Subsystem for Linux) and forwarding the USB device using
usbipd. In the WSL environment, thercc_fixcompleted perfectly without any memory write errors.Additional Context
I am opening this issue primarily for archiving purposes and to help document this for other Windows users who might run into the exact same problem. I may close this issue later, but I am open to suggestions if there is a better, proper fix for native Windows environments.