Saturday, October 27, 2018

Compiling Marlin 2.0 for STM32F4

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!

Thursday, October 18, 2018

Don't troll

Trump’s fanciful, falsehood-filled AP interview, annotated

The 40 most outrageous lines in Donald Trump's Associated Press interview

Okay, I am not a fan of Trump, but The Washington Post and CNN seem to have taken things a bit too far. I mean, these are supposed to be legitimate news outlets. They should not be embroiled in petty stuff, right? But The Washington Post's annotations of the AP interview seems more like trolling. CNN's article is in the same league.

Annotating with facts is fine. Calling out lies with facts is fine. But throwing in opinions and other subjective comments borders on trolling, and is not something that a respectable news agency does, even if the rest of the country has gone to the dogs in terms of civility.

I just hope someone out there can go through the transcript, and prepare a proper annotation with the facts.

Read the transcript of AP’s interview with President Trump
(the original from AP)