flo199213 / Hoverboard-Firmware-Hack-Gen2

Hoverboard Hack Firmware Generation 2 for the Hoverboard with the two Mainboards instead of the Sensorboards (See Readme.md).
GNU General Public License v3.0
143 stars 112 forks source link

Add PlatformIO build support #16

Open maxgerhardt opened 3 years ago

maxgerhardt commented 3 years ago

Adds a board definition file, a platformio.ini and one minor modification to the code to make it work with GCC. Should still work with Keil.

The build system PlatformIO is a Python tool and a VSCode extension that can build firmwares for tons of devices (STM32, ESP32, ESP8266, AVR, nRF52, ...) in a cross-platform and automatic way.

Now one can do just

> pio run 
Processing GD32F130C8T6 (platform: ststm32; board: gd32f130c8; framework: spl)
------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/gd32f130c8.html
PLATFORM: ST STM32 (12.0.0) > Generic GD32F130C8T6
HARDWARE: GD32F130C8T6 72MHz, 8.00KB RAM, 64KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES:
 - framework-spl 2.10301.0 (1.3.1)
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\GD32F130C8T6\src\bldc.o
Compiling .pio\build\GD32F130C8T6\src\comms.o
Compiling .pio\build\GD32F130C8T6\src\commsBluetooth.o
Compiling .pio\build\GD32F130C8T6\src\commsMasterSlave.o
Compiling .pio\build\GD32F130C8T6\src\commsSteering.o
Compiling .pio\build\GD32F130C8T6\src\it.o
Compiling .pio\build\GD32F130C8T6\src\led.o
Compiling .pio\build\GD32F130C8T6\src\main.o
Compiling .pio\build\GD32F130C8T6\src\setup.o
Compiling .pio\build\GD32F130C8T6\FrameworkCMSISVariant\startup_gd32f1x0.o
Compiling .pio\build\GD32F130C8T6\FrameworkCMSISVariant\system_gd32f1x0.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_adc.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_can.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_cec.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_cmp.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_crc.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_dac.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_dbg.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_dma.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_exti.o
Archiving .pio\build\GD32F130C8T6\libFrameworkCMSISVariant.a
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_fmc.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_fwdgt.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_gpio.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_i2c.o
Indexing .pio\build\GD32F130C8T6\libFrameworkCMSISVariant.a
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_ivref.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_misc.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_opa.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_pmu.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_rcu.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_rtc.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_slcd.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_spi.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_syscfg.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_timer.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_tsi.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_usart.o
Compiling .pio\build\GD32F130C8T6\FrameworkSPL\gd32f1x0_wwdgt.o
Archiving .pio\build\GD32F130C8T6\libFrameworkSPL.a
Indexing .pio\build\GD32F130C8T6\libFrameworkSPL.a
Linking .pio\build\GD32F130C8T6\firmware.elf
Building .pio\build\GD32F130C8T6\firmware.bin
Checking size .pio\build\GD32F130C8T6\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.3% (used 272 bytes from 8196 bytes)
Flash: [==        ]  21.4% (used 14032 bytes from 65536 bytes)
=========== [SUCCESS] Took 2.34 seconds ===========

and the firmware is built :)

szepnorbee commented 3 years ago

Hi maxgerhardt! Have you tried this firmware? I tried Pro Mini and ESP8266, but no response. I try to access it on MASTER using the example code.(PPMDevice) The controller sends the data, the arduino sends the response, but nothing. The board is good because I can start the motors at a fixed speed by modifying the code (board firmware). Can you help me? Thank you.

maxgerhardt commented 3 years ago

I indeed got feedback that the compiled firmware wasn't quite working, but it's incredibly hard to do remote diagnosis when you don't have the hardware. There are macros for MASTER and.. slave mode that this platformio.ini doesn't yet incorporate, have ou tried setting those? (build_flags = -D MASTER, for example).

Derkades commented 1 year ago

I had to set

platform_packages = maxgerhardt/framework-spl@2.10301.0, toolchain-gccarmnoneeabi@~1.90301.0

For it to compile on a raspberry pi (aarch64). The older gccarmnoneeabi toolchain used by default supports x86 only