Welcome! Log In Create A New Profile

Advanced

Compiling Marlin 3d printer firmware with stm32duino core using a makefile

Posted by ag123 
Compiling Marlin 3d printer firmware with stm32duino core using a makefile
August 22, 2021 01:53PM
This is a build log rather than a 'how to' post. I managed to compile

Marlin Firmware 2.0
with STM32duino core
and got it running on STM32 F4VET6 black board
(this isn't quite a '3d printer board' more than it is a 'development board', takes some imagination add 'ramps' board to get it to work)
using a unix/linux makefile. This makefile is maintained in this gist
[gist.github.com]

Accordingly the recommended method is to use Platform IO running in VS Code. There is also a "Auto Build Marlin" vscode extension for it

Note that building Marlin firmware in Arduino IDE, you may confront various challenges/problems with stm32duino. Apparently i found out that there are some defines passed from platformio ini files. This may mean that the original Arduino IDE may not work with the stm32duino core with Marlin 2.0 as it implies things like platform.txt and board.txt files may need to be edited. It may work though, but i've not tried.

What I've done instead is I've created a makefile, works only in linux/unix. This makefile should be considered 'alpha' code, i.e. it works for me but it may not work for you. The makefile is board and mcu specific (one single board variant at at time), Hence if you use a board other than STM32 F4VET6 black board, you would need to edit the various definitions / defines in the makefile and use a different variant. The makefile includes a pretty large exclusion list those are replicated from platformio.ini from Marlin firmware repository. If you build Marlin using this makefile and you are getting object not found errors at the linking stage, search in the exclusion list and comment off the relevant exclusions.
The 'usual' way to build marlin seemed to be, 1st get (e.g. git clone) the source
https://github.com/MarlinFirmware/Marlin
https://marlinfw.org/
and edit the configuration file
Configuration.h
and
Configuration_adv.h
there are some examples in this repository
https://github.com/MarlinFirmware/Configurations
e.g. for the STM32 F4VET6 black board there is one there
[github.com]
those can be used in place of the default Configuration.h and Configuration_adv.h
but be sure to check and edit the configurations
[marlinfw.org]

If you want to use this makefile (linux/unix only), in Windows, it would likely need WSL
[docs.microsoft.com]
using the makefile requires you to setup this project folder structure as follows
Root (project directory)
+-- src (your sources e.g. the sketch
| the files has to be cpp, c or h, no ino)
+-- Arduino_Core_STM32 (from https://github.com/stm32duino/Arduino_Core_STM32)
+-- CMSIS_5 (from https://github.com/ARM-software/CMSIS_5)
+-- Marlin (from https://github.com/MarlinFirmware/Marlin)
+-- variants (see below)
+-- Makefile (this makefile)

# this makefile can't handle the brackets/paranthesis naming convention used for the variants
# hence you need to create a local variant folder and copy all the files in
# Arduino_Core_STM32/variants/STM32F4xx/F407V(E-G)T_F417V(E-G)T/
# to
# variants/F407VX/

you would also have to edit to point to the installed location of your arm-none-eabi-gcc compiler in the make file in the line
ARM_NONE_EABI_PATH := /opt/arduino/xpack-arm-none-eabi-gcc/9.2.1-1.1/

this makefile is maintained in this gist
[gist.github.com]

Edited 8 time(s). Last edit at 08/22/2021 02:09PM by ag123.
Re: Compiling Marlin 3d printer firmware with stm32duino core using a makefile
August 22, 2021 01:54PM
I've created an instructables with more (complete) information
[www.instructables.com]
for some reason it keeps giving a 404 error if not logged in.
try logging in to instructables if you are getting that error.
Sorry, only registered users may post in this forum.

Click here to login