Edit/update: This post was written in October 2018. Since then, Marlin firmware has made quite some progress in supporting STM32 boards. Please check the Marlin firmware documentation, GitHub page, Facebook groups, etc. for the latest info, since I am quite sure what I have written here is outdated.
A note for myself. And for those who want to know how to compile Marlin 2.0 for the STM32F4 series. I was trying to compile for the black STM32F407VET6 development board available on eBay and Aliexpress from Chinese vendors.
First, it seems the only Arduino STM32 core that can be used with Marlin 2.0 for this board is from STMicroelectronics. Even then, the version available via Arduino IDE's package manager is old, and the latest git version must be used for STM32F407VET6 support. To install the git version, see:
https://github.com/stm32duino/wiki/wiki/Using-git-repository
BTW, I was using Arduino IDE 1.8.5, there could be issues with newer IDE versions having to do with preprocessors. Also, I had problems compiling Marlin 2.0 for STM32F407VET6 on PlatformIO. It seems uncertain if the official STMicroelectronics core is available on it or not, which may explain my errors with:
'IWDG_HandleTypeDef' does not name a type
'TIM_HandleTypeDef' does not name a type
'stm32f4_timer_t {aka struct tTimerConfig}' has no member named 'handle'
etc. when I try to compile it for
board = genericSTM32F407VET6
in platformio.ini
Anyway, I digress. Install from git repository should allow Marlin 2.0 to be compiled with the following changes to the git version of Marlin 2.0:
#define SERIAL_PORT 1
#define MOTHERBOARD BOARD_STM32F4
However, if you try to add LCD support, you may encounter issues. I worked around it by editing
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp
to add
#elif MB(STM32F4)
to this part of the code:
#if F_CPU >= 20000000
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(50)
#elif MB(3DRAG) || MB(K8200) || MB(K8400) || MB(SILVER_GATE)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(188)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(MINIRAMBO) || MB(EINSY_RAMBO) || MB(EINSY_RETRO)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(250)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(RAMBO)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(BQ_ZUM_MEGA_3D)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(189)
#elif MB(REMRAM_V1)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(ARMED)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(STM32F4)
#elif F_CPU == 16000000
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(63)
#else
#error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'"
#endif
Don't worry, the delays are actually defined in pins_STM32F4.h already, but somehow, the STM32F4 is not included here as a board, which results in the "No valid condition" error during compile when LCD is enabled.
Still, this is just compiling the firmware. I have yet to actually load the firmware for testing on an actual board, which is the next logical step. Stay tuned!
A note for myself. And for those who want to know how to compile Marlin 2.0 for the STM32F4 series. I was trying to compile for the black STM32F407VET6 development board available on eBay and Aliexpress from Chinese vendors.
First, it seems the only Arduino STM32 core that can be used with Marlin 2.0 for this board is from STMicroelectronics. Even then, the version available via Arduino IDE's package manager is old, and the latest git version must be used for STM32F407VET6 support. To install the git version, see:
https://github.com/stm32duino/wiki/wiki/Using-git-repository
BTW, I was using Arduino IDE 1.8.5, there could be issues with newer IDE versions having to do with preprocessors. Also, I had problems compiling Marlin 2.0 for STM32F407VET6 on PlatformIO. It seems uncertain if the official STMicroelectronics core is available on it or not, which may explain my errors with:
'IWDG_HandleTypeDef' does not name a type
'TIM_HandleTypeDef' does not name a type
'stm32f4_timer_t {aka struct tTimerConfig}' has no member named 'handle'
etc. when I try to compile it for
board = genericSTM32F407VET6
in platformio.ini
Anyway, I digress. Install from git repository should allow Marlin 2.0 to be compiled with the following changes to the git version of Marlin 2.0:
#define SERIAL_PORT 1
#define MOTHERBOARD BOARD_STM32F4
However, if you try to add LCD support, you may encounter issues. I worked around it by editing
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp
to add
#elif MB(STM32F4)
to this part of the code:
#if F_CPU >= 20000000
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(50)
#elif MB(3DRAG) || MB(K8200) || MB(K8400) || MB(SILVER_GATE)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(188)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(MINIRAMBO) || MB(EINSY_RAMBO) || MB(EINSY_RETRO)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(250)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(RAMBO)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(BQ_ZUM_MEGA_3D)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(189)
#elif MB(REMRAM_V1)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(ARMED)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(STM32F4)
#elif F_CPU == 16000000
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(63)
#else
#error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'"
#endif
Don't worry, the delays are actually defined in pins_STM32F4.h already, but somehow, the STM32F4 is not included here as a board, which results in the "No valid condition" error during compile when LCD is enabled.
Still, this is just compiling the firmware. I have yet to actually load the firmware for testing on an actual board, which is the next logical step. Stay tuned!