Firmware for Kleinvoet hardware project. Written in embedded C and compiled with ARM GCC.
- Kleinvoet (STM32F446RC/ET)
The SD card needs to be formatted using a modern version of mkfs.vfat
and
parted
. The following commands were used:
[OPTIONAL]
Zeroing the SD card helps that the controller doesn't have to clear pages wile
running. This improves performance but drastically diminishes the lif span of
the medium. Optionally you can specify the number of blocks(count=N
) if you
don't want to zero the whole drive. Good for testing purposes.
sudo dd if=/dev/zero of=/dev/sdX bs=4096 status=progress
# Create an DOS partition table
sudo parted /dev/sdX --script --align optimal -- mklabel msdos
# Specify partition as 'FAT32' with 1MiB clearance
sudo parted /dev/sdX --script --align optimal -- mkpart primary fat32 1MiB 100%
# Format partition as 'FAT32'
sudo mkfs.vfat -F32 /dev/sdXX
# Check to make sure everything is as it should be
sudo parted /dev/sdX --script -- print
- CubeMx (>= v6.0.1)
- OpenOCD (>= v0.10.0)
- gdb (>= 9.1-6)
- arm-none-eabi-gcc (>= v9.2.0-4, < v11.2)
Recommend using ARM Build tools from their website, as these are more up to date.
sudo apt install make libtool pkg-config autoconf automake texinfo libusb libusb-dev
sudo dnf install make libtool pkg-config autoconf automake texinfo libusb libusb-devel
If using an ST-Link V3 then OpenOCD requires stlink.cfg which isn't shipped with most linux distros. It is thus recommended that one compiles it from scratch. See this tutorial for a guide on how to compile
Alternatively make use of the STM32 fork of OpenOCD:
git clone https://github.com/STMicroelectronics/OpenOCD.git
cd OpenOCD
git pull
# [Recommended] Optionally checkout a specific version
git checkout v0.X.Y
./bootstrap
./configure --enable-stlink
make
sudo make install
The SVD file was downloaded from this link. Currently using version 1.2
Recommended IDE would be between setting up and amazing VIM experience. (DIY) Or using CLion, for most of this project CLion 2020.2 was used. CubeIDE seems to also be a good alternative if one is struggling with getting all the tooling to work. CubeIDE also has support for OpenOCD but uses a shelf shipped version.
To build a release run, replacing $BUILD_DIR
with the target output directory
of your choice:
cmake --build $BUILD_DIR --target all -- -j $(nproc)
To flash an *.elf
file using openocd
run:
openocd -f OCD_kleinvoet.cfg -c "tcl_port disabled" -c "gdb_port disabled" -c "tcl_port disabled" -c "program \"$BUILD_DIR/firmware.elf\"" -c reset -c shutdown
This is due to a udev rule problem. Installing CubeIDE installs these rules.
But creating them manually should work too. Place the appropriate file in the
/etc/udev/rules.d
directory.
49-stlinkv3.rules
# ST_PKG_VERSION 1.0.2-3
# stlink-v3 boards (standalone and embedded) in usbloader mode and
# standard (debug) mode
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374d", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3loader_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374f", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3753", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
49-stlinkv2-1.rules
# ST_PKG_VERSION 1.0.2-3
# stm32 nucleo boards, with onboard st/linkv2-1
# ie, STM32F0, STM32F4.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv2-1_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3752", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv2-1_%n"
If the WAVE_STATIC_FILE_ALLOC
is enabled and the file was not correctly ended
it will result in an corrupted header. To repair the file one can simply run:
sox --ignore-length corrupted.wav fixed.wav
shntool info
: Useful for checking the PCM dataexiftool
: Useful for checking chunk/subchunk infomediainfo
: General purpose tool
See forum post. Seems to be an problem with gcc >= 11.2