-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Compiling and flashing the firmware
Right to the STM32, there is a debugging header with GND, 3V3, SWDIO and SWCLK. Connect GND, SWDIO and SWCLK to your SWD programmer, like the ST-Link found on many STM devboards.
If you have never flashed your sideboard before, the MCU is probably locked. To unlock the flash, check-out the wiki page How to Unlock MCU flash.
Do not power the mainboard from the 3.3V of your programmer! This has already killed multiple mainboards.
Make sure you hold the power button while flashing the firmware, as the STM might release the power latch and switches itself off during flashing. Battery > 36V have to be connected while flashing.
⚠If you are using a jumper instead of the power button, make sure you are not entering the Auto-Calibration by mistake, which would deactivate the inputs if you don't proceed with the calibration properly. If you face this issue, erase the chip in st-link utility before flashing the firmware, or do a proper auto-calibration⚠
To build and flash choose one of the following methods:
- Install Vscode
- Install Platformio
- open the folder in Vscode
- press the 'PlatformIO:Build' or the 'PlatformIO:Upload' button (bottom left in vscode).
- in Keil uVision, open the mainboard-hack.uvproj
- if you are asked to install missing packages, click Yes
- click Build Target (or press F7) to build the firmware
- click Load Code (or press F8) to flash the firmware.
- prerequisites: install ST-Flash utility.
- open a terminal in the repo check-out folder and if you have definded the variant in config.h type:
make
or you can set the variant like this
make -e VARIANT=VARIANT_####
- flash the firmware by typing:
make flash
- or
openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c flash "write_image erase build/hover.bin 0x8000000"
- prerequisites: first get brew https://brew.sh
- then install stlink ST-Flash utility
brew install stlink
- open a terminal in the repo check-out folder and if you have definded the variant in config.h type:
make
or you can set the variant like this
make -e VARIANT=VARIANT_####
If compiling fails because something is missing just install it with brew AND leave a comment to improve this howto or pull request ;-)
- flash the firmware by typing:
make flash
- if unlock is needed
make unlock
brew install platformio
platformio run -e VARIANT_####
platformio run –target upload -e VARIANT_####
If you have set default_envs in platformio.ini you can ommit -e parameter
If you cannot flash the firmware:
- Make sure you properly unlocked the chip
- Make sure you are don't have an already open connection to the chip in another software (st-link utility, ...)
- Make sure you properly soldered the headers/wires, clean contact is mandatory
- Also keep in mind the debugging header pinout can differ on some boards