Armstrap Eagle and PlatformIO
In an attempt to learn more about microcontrollers I've recently acquired an Armstrap Eagle. This board is a significant departure from the simple (but limited) hardware and toolchain of Arduino fame, leveraging the strength of an ARM Cortex M4 and packed with extra features like a real-time clock and a powerful debugger. Following the documentation on the site, I was able to get a distribution of Eclipse running, able to compile, flash, and debug programs on the chip - but I wanted to see if I could do it another way.
I had previously used the fantastic tool PlatformIO to build and flash my Arduino programs - it's simple to use and manages your libraries for you, which is great. Luckily there's already a board configuration for the Armstrap, but there's some additional steps that must be taken to actually get it working.
Initialize
First, create a folder for your project and initialize the PlatformIO project inside of it (replace 2048 with your board's memory size if necessary):
platformio init --board armstrap_eagle2048
Configure PlatformIO
In platformio.ini
, add spl
to the framework list. This adds support for
the ST Standard Peripheral Library. Also, set the upload_protocol
to gdb
,
since the default ST-Link uploader won't work with the Armstrap Eagle.
Your platformio.ini
should look something like this:
[env:armstrap_eagle2048]
platform = ststm32
framework = cmsis,spl
board = armstrap_eagle2048
targets = upload
upload_protocol = gdb
Configure gdb
For uploading to work, we have to create a script upload.gdb
that will tell
gdb what to do.
target extended /dev/cu.usbmodem7B407FD1
monitor swdp_scan
attach 1
load
detach
quit
Most of this is taken from here.
You can use
platformio serialports list
to get the serial port path if /dev/cu.usbmodem7B407FD1
doesn't work.
Program
Here's an example src/main.cpp
which will blink the on-board LED:
#include <stm32f4xx_gpio.h>
#include <stm32f4xx_rcc.h>
void setup() {
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
GPIO_InitTypeDef gpioInit;
GPIO_StructInit(&gpioInit);
gpioInit.GPIO_Mode = GPIO_Mode_OUT;
gpioInit.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOC, &gpioInit);
}
void delay(uint32_t ms) {
ms *= 3360;
while (ms--) {
__NOP();
}
}
void loop() {
GPIO_ToggleBits(GPIOC, GPIO_Pin_1);
delay(250);
}
int main() {
setup();
while (true)
loop();
return 0;
}
Run
To upload to the board, simply run:
platformio run