Mechanical keyboard switch force curve analyzer.
The plan is to design hardware (3D printed structure) and software (probably on STM32 and hopefully written in Zig).
Requirements:
- ARM GCC toolchain: https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain
for buildinglibopencm3
and debugging - Zig: https://ziglang.org/download
- OpenOCD: https://github.com/openocd-org/openocd/releases
for flashing and debugging - Python 3.x
for linker script generation (fromlibopencm3
)
libopencm3
must be built with GCC arm-none-eabi (though in the future it might be handled by zig cc
).
https://github.com/libopencm3/libopencm3
- On Windows: https://www.msys2.org/
- Use UCRT64 environment
- Install
make
:pacman -S make
- If
python3
is missing, run viacmd
as Administrator:mklink "C:\Program Files\Python311\python3.exe" "C:\Program Files\Python311\python.exe"
-
. env.sh
-
make -C libopencm3 # TARGETS="stm32/f1"
zig build
zig build flash
- Install Cortex-Debug VSCode extension (https://github.com/Marus/cortex-debug)
- Also install
Cortex-Debug: Device Support Pack - STM32F1
and equivalent extensions as needed (to enable peripherals view in debug) - Set
cortex-debug.armToolchainPath
in VSCodesettings.json
to thebin
directory of yourarm-none-eabi
toolchain - Set
cortex-debug.openocdPath
toopenocd.exe
- Launch the included debug configuration(s)
SWO/SWV is used for trace output, OpenOCD and Cortex-Debug will automatically configure the needed on-chip registers (TPIU, ITM, DBGMCU) to enable SWO output.
TODO try DWT and ETM tracing
- https://ziglang.org/documentation/master
- https://ziglang.org/documentation/master/std
- https://maldus512.medium.com/zig-bare-metal-programming-on-stm32f103-booting-up-b0ecdcf0de35
- https://github.com/rbino/zig-stm32-blink
- https://rbino.com/posts/zig-stm32-blink/
- https://ciesie.com/tags/stm32/
- https://andrewkelley.me/post/zig-stack-traces-kernel-panic-bare-bones-os.html
- https://ikrima.dev/dev-notes/zig/zig-build/