Firmware for the rocket payload flight controller, responsible for fin actuation, flight data acquisition and logging.
The payload core can be run on the STM32F411Xe family of microcontrollers, though the configuration is designed for the smaller STM32F411CE variant, found on the blackpill.
The system interfaces are assigned to the peripheral components as follows:
| Component | Model | Interface | Description |
|---|---|---|---|
| Fin Servos 1/2 | FS5106B-FB | PWM (TIM1_CH1/2) | Active fin control |
| Altimeter | BMP388 | SPI3 | Barometric pressure/altitude sensing |
| IMU | LSM9DS1 | SPI4 | 9-DOF inertial measurement |
| SD Card | - | SPI2 | Flight data logging |
The pin configuration is set up as follows:
For the pins setup as GPIO output, the definitions are as follows:
| Pin | Peripheral |
|---|---|
| PA4 | SPI2 CS |
| PA5 | SPI4 CS Mag, Onboard LED (Nucleo) |
| PA6 | SPI3 CS |
| PA7 | SPI4 CS Gyro/Accel |
| PC13 | Onboard LED (Blackpill) |
- PlatformIO (CLI Core or IDE)
- On Windows machines: ST-Link drivers
You can use the PlatformIO IDE GUI to build and flash this project.
If using PlatformIO Core:
# Build the project
pio run
# Build and upload
pio run --target uploadThe project uses the STM32Cube HAL framework. Key configuration options are in platformio.ini.
Initialization functions were generated by STM32CubeMX. The project file for that is located in the repository root. Should one need to change initialization configs, copy and paste the differences rather than overwriting files.
Place sensor driver libraries in the lib/ directory. Each library should have its own subdirectory with source files and headers, as such:
lib/
├── sensor123/
│ ├── sensor123.c
│ └── sensor123.h
└── motor456/
├── motor456.c
└── motor456.h
Flashing may be done over ST-Link or via DFU. DFU is the default. Make sure to set your upload protocol in platformio.ini.
If developing on the Nucleo, either upload protocol may be used. ST-Link is recommended.
If developing on the Blackpill, you must first set the blackpill to DFU mode by pressing the reset button while BOOT0 is held down. Then you can start the flash sequence in PlatformIO.
Debugging is via SWD.
If developing on the Nucleo, the onboard ST-LINK may be used (ensure the jumpers across header CN2 are in place) to debug the MCU.
If developing on the Blackpill, you must connect an external debugger to the 4-pin SWD header at the end of the board. If you are using another Nucleo board as an external debugger, be sure to remove the jumpers across header CN2. Store them at CN11/12.
In addition to the connectivity peripherals explained above, the RTC is also enabled.
For backwards compatibility with the Nucleo boards, the USART2 peripheral is used for serial communication between a host computer and the MCU. If using a Nucleo board as an external debugger, connect the Blackpill's USART pins to the Nucleo's CN3 TX/RX pins. If using J-link, you can use the VCOM feature.
The system is configured to use the internal oscillators (HSI/LSI) with the following configuration:
- System Clock: 16 MHz direct from HSI, no PLL
- RTC Clock: 32 KHz direct from LSI
- AHB/APB1/APB2/etc.: All clocks @ 16 MHz, no division
