Configuring USB Serial For Marlin 2.0 and STM32F4

Hey there! Super in love with PlatformIO, absolute game changer coming from the Arduino IDE. Stoked to be part of the community!

I’m trying to compile Marlin 2.0 for an STM32F407VGT6. I’ve been able to successfully compile it, and even get it to upload using dfu-util, but try as I might I’m unable to get the serial port talking back over USB. The board is of my own design. I’m pretty confident that this is not a hardware issue because 1) the firmware uploads successfully, and 2) I’m able to use USB Serial without an issue when uploading a simple sketch using the Arduino IDE. This makes me think that it’s almost definitely something to do with my configuration in platformio.ini.

In the Marlin provided platformio.ini, there are multiple boards to select from. I ended up picking STM32F407VE_black and attempting to modify it to match my board. I did my best to identify which build flags I needed to change, but nothing has yet worked. I’m a bit out of my depths, and have been wrestling with this for a couple weeks, so any advice on things to try would be tremendously appreciated!

Some details:

  • On Mac, macOS 10.15.7
  • Hardware: STM32F407VGT6
  • High speed clock at 12MHz
  • Low speed clock at 32.768kHz

My platformio.ini file is below (just the common config and the STM32F407VE_black components):

[platformio]
src_dir      = Marlin
boards_dir   = buildroot/share/PlatformIO/boards
default_envs = STM32F407VE_black
include_dir  = Marlin

#
# The 'common' values are used for most Marlin builds
#
[common]
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
  -<src/lcd/HD44780> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft>
  -<src/lcd/menu>
  -<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
  -<src/lcd/menu/game/maze.cpp> -<src/lcd/menu/game/snake.cpp>
  -<src/lcd/menu/menu_backlash.cpp>
  -<src/lcd/menu/menu_bed_corners.cpp>
  -<src/lcd/menu/menu_bed_leveling.cpp>
  -<src/lcd/menu/menu_cancelobject.cpp>
  -<src/lcd/menu/menu_delta_calibrate.cpp>
  -<src/lcd/menu/menu_filament.cpp>
  -<src/lcd/menu/menu_info.cpp>
  -<src/lcd/menu/menu_job_recovery.cpp>
  -<src/lcd/menu/menu_led.cpp>
  -<src/lcd/menu/menu_media.cpp>
  -<src/lcd/menu/menu_mmu2.cpp>
  -<src/lcd/menu/menu_password.cpp>
  -<src/lcd/menu/menu_power_monitor.cpp>
  -<src/lcd/menu/menu_spindle_laser.cpp>
  -<src/lcd/menu/menu_temperature.cpp>
  -<src/lcd/menu/menu_tmc.cpp>
  -<src/lcd/menu/menu_touch_screen.cpp>
  -<src/lcd/menu/menu_ubl.cpp>
  -<src/lcd/extui/lib/mks_ui>
  -<src/lcd/extui/lib/dgus> -<src/lcd/extui/dgus_lcd.cpp>
  -<src/lcd/extui/example.cpp>
  -<src/lcd/extui/malyan_lcd.cpp>
  -<src/lcd/extui/lib/ftdi_eve_touch_ui>
  -<src/lcd/extui/lib/anycubic_i3mega>
  -<src/lcd/extui/anycubic_tft.cpp>
  -<src/lcd/lcdprint.cpp>
  -<src/sd/usb_flashdrive>
  -<src/feature/backlash.cpp>
  -<src/feature/baricuda.cpp> -<src/gcode/feature/baricuda>
  -<src/feature/bedlevel/abl> -<src/gcode/bedlevel/abl>
  -<src/feature/bedlevel/mbl> -<src/gcode/bedlevel/mbl>
  -<src/feature/bedlevel/ubl> -<src/gcode/bedlevel/ubl>
  -<src/feature/binary_stream.cpp> -<src/libs/heatshrink>
  -<src/feature/bltouch.cpp>
  -<src/feature/cancel_object.cpp> -<src/gcode/feature/cancel>
  -<src/feature/caselight> -<src/gcode/feature/caselight>
  -<src/feature/closedloop.cpp>
  -<src/feature/controllerfan.cpp> -<src/gcode/feature/controllerfan>
  -<src/feature/dac> -<src/feature/digipot>
  -<src/feature/direct_stepping.cpp> -<src/gcode/motion/G6.cpp>
  -<src/feature/e_parser.cpp>
  -<src/feature/encoder_i2c.cpp>
  -<src/feature/fanmux.cpp>
  -<src/feature/filwidth.cpp> -<src/gcode/feature/filwidth>
  -<src/feature/fwretract.cpp> -<src/gcode/feature/fwretract>
  -<src/feature/host_actions.cpp>
  -<src/feature/hotend_idle.cpp>
  -<src/feature/joystick.cpp>
  -<src/feature/leds/blinkm.cpp>
  -<src/feature/leds/leds.cpp>
  -<src/feature/leds/pca9533.cpp>
  -<src/feature/leds/pca9632.cpp>
  -<src/feature/leds/printer_event_leds.cpp>
  -<src/feature/leds/tempstat.cpp>
  -<src/feature/max7219.cpp>
  -<src/feature/mixing.cpp>
  -<src/feature/mmu2> -<src/gcode/feature/prusa_MMU2>
  -<src/feature/password> -<src/gcode/feature/password>
  -<src/feature/pause.cpp>
  -<src/feature/power.cpp>
  -<src/feature/power_monitor.cpp> -<src/gcode/feature/power_monitor>
  -<src/feature/powerloss.cpp> -<src/gcode/feature/powerloss>
  -<src/feature/probe_temp_comp.cpp>
  -<src/feature/runout.cpp> -<src/gcode/feature/runout>
  -<src/feature/snmm.cpp>
  -<src/feature/solenoid.cpp>
  -<src/feature/spindle_laser.cpp> -<src/gcode/control/M3-M5.cpp>
  -<src/feature/tmc_util.cpp> -<src/module/stepper/trinamic.cpp>
  -<src/feature/twibus.cpp>
  -<src/feature/z_stepper_align.cpp>
  -<src/gcode/bedlevel/G26.cpp>
  -<src/gcode/bedlevel/G35.cpp>
  -<src/gcode/bedlevel/G42.cpp>
  -<src/gcode/bedlevel/M420.cpp>
  -<src/gcode/calibrate/G33.cpp>
  -<src/gcode/calibrate/G34_M422.cpp>
  -<src/gcode/calibrate/G76_M871.cpp>
  -<src/gcode/calibrate/G425.cpp>
  -<src/gcode/calibrate/M12.cpp>
  -<src/gcode/calibrate/M48.cpp>
  -<src/gcode/calibrate/M100.cpp>
  -<src/gcode/calibrate/M425.cpp>
  -<src/gcode/calibrate/M666.cpp>
  -<src/gcode/calibrate/M852.cpp>
  -<src/gcode/config/M43.cpp>
  -<src/gcode/config/M217.cpp>
  -<src/gcode/config/M218.cpp>
  -<src/gcode/config/M221.cpp>
  -<src/gcode/config/M281.cpp>
  -<src/gcode/config/M302.cpp>
  -<src/gcode/config/M305.cpp>
  -<src/gcode/config/M540.cpp>
  -<src/gcode/control/M7-M9.cpp>
  -<src/gcode/control/M211.cpp>
  -<src/gcode/control/M605.cpp>
  -<src/gcode/feature/advance>
  -<src/gcode/feature/camera>
  -<src/gcode/feature/i2c>
  -<src/gcode/feature/L6470>
  -<src/gcode/feature/leds/M150.cpp>
  -<src/gcode/feature/leds/M7219.cpp>
  -<src/gcode/feature/macro>
  -<src/gcode/feature/mixing/M163-M165.cpp>
  -<src/gcode/feature/mixing/M166.cpp>
  -<src/gcode/feature/pause/G27.cpp>
  -<src/gcode/feature/pause/G60.cpp>
  -<src/gcode/feature/pause/G61.cpp>
  -<src/gcode/feature/pause/M125.cpp>
  -<src/gcode/feature/pause/M600.cpp>
  -<src/gcode/feature/pause/M603.cpp>
  -<src/gcode/feature/pause/M701_M702.cpp>
  -<src/gcode/feature/trinamic/M122.cpp>
  -<src/gcode/feature/trinamic/M569.cpp>
  -<src/gcode/feature/trinamic/M906.cpp>
  -<src/gcode/feature/trinamic/M911-M914.cpp>
  -<src/gcode/geometry/G17-G19.cpp>
  -<src/gcode/geometry/G53-G59.cpp>
  -<src/gcode/geometry/M206_M428.cpp>
  -<src/gcode/host/M16.cpp>
  -<src/gcode/host/M113.cpp>
  -<src/gcode/host/M360.cpp>
  -<src/gcode/host/M876.cpp>
  -<src/gcode/lcd/M0_M1.cpp>
  -<src/gcode/lcd/M145.cpp>
  -<src/gcode/lcd/M250.cpp>
  -<src/gcode/lcd/M73.cpp>
  -<src/gcode/lcd/M995.cpp>
  -<src/gcode/motion/G2_G3.cpp>
  -<src/gcode/motion/G5.cpp>
  -<src/gcode/motion/G80.cpp>
  -<src/gcode/motion/M290.cpp>
  -<src/gcode/probe/G30.cpp>
  -<src/gcode/probe/G31_G32.cpp>
  -<src/gcode/probe/G38.cpp>
  -<src/gcode/probe/M401_M402.cpp>
  -<src/gcode/probe/M851.cpp>
  -<src/gcode/probe/M951.cpp>
  -<src/gcode/scara>
  -<src/gcode/sd>
  -<src/gcode/temp/M104_M109.cpp>
  -<src/gcode/units/G20_G21.cpp>
  -<src/gcode/units/M149.cpp>
  -<src/libs/L64XX> -<src/module/stepper/L64xx.cpp>
  -<src/libs/hex_print.cpp>
  -<src/libs/least_squares_fit.cpp>
  -<src/libs/nozzle.cpp> -<src/gcode/feature/clean>
  -<src/module/delta.cpp>
  -<src/module/planner_bezier.cpp>
  -<src/module/printcounter.cpp>
  -<src/module/probe.cpp>
  -<src/module/scara.cpp> -<src/gcode/calibrate/M665.cpp>
  -<src/module/stepper/TMC26X.cpp>
extra_scripts      =
  pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
  pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
build_flags        = -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants
lib_deps           =

#
# Feature Dependencies
#
[features]
HAS_TFT_LVGL_UI         = lvgl=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip
                          src_filter=+<src/lcd/extui/lib/mks_ui>
                          extra_scripts=download_mks_assets.py
HAS_TRINAMIC_CONFIG     = TMCStepper@~0.7.1
                          src_filter=+<src/feature/tmc_util.cpp> +<src/module/stepper/trinamic.cpp> +<src/gcode/feature/trinamic/M122.cpp> +<src/gcode/feature/trinamic/M906.cpp> +<src/gcode/feature/trinamic/M911-M914.cpp>
HAS_STEALTHCHOP         = src_filter=+<src/gcode/feature/trinamic/M569.cpp>
SR_LCD_3W_NL            = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
HAS_I2C_DIGIPOT         = SlowSoftI2CMaster
                          src_filter=+<src/feature/digipot>
HAS_TMC26X              = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip
                          src_filter=+<src/module/TMC26X.cpp>
HAS_L64XX               = Arduino-L6470@0.8.0
                          src_filter=+<src/libs/L64XX> +<src/module/stepper/L64xx.cpp> +<src/gcode/feature/L6470>
NEOPIXEL_LED            = Adafruit NeoPixel@1.5.0
                          src_filter=+<src/feature/leds/neopixel.cpp>
MAX6675_IS_MAX31865     = Adafruit MAX31865 library@~1.1.0
HAS_GRAPHICAL_LCD       = U8glib-HAL@0.4.1
                          src_filter=+<src/lcd/dogm>
USES_LIQUIDCRYSTAL      = LiquidCrystal@1.5.0
USES_LIQUIDTWI2         = LiquidTWI2@1.2.7
DWIN_CREALITY_LCD       = src_filter=+<src/lcd/dwin>
HAS_CHARACTER_LCD       = src_filter=+<src/lcd/HD44780>
HAS_GRAPHICAL_TFT       = src_filter=+<src/lcd/tft>
HAS_LCD_MENU            = src_filter=+<src/lcd/menu>
HAS_GAMES               = src_filter=+<src/lcd/menu/game/game.cpp>
MARLIN_BRICKOUT         = src_filter=+<src/lcd/menu/game/brickout.cpp>
MARLIN_INVADERS         = src_filter=+<src/lcd/menu/game/invaders.cpp>
MARLIN_MAZE             = src_filter=+<src/lcd/menu/game/maze.cpp>
MARLIN_SNAKE            = src_filter=+<src/lcd/menu/game/snake.cpp>
HAS_MENU_BACKLASH       = src_filter=+<src/lcd/menu/menu_backlash.cpp>
HAS_MENU_BED_CORNERS    = src_filter=+<src/lcd/menu/menu_bed_corners.cpp>
LCD_BED_LEVELING        = src_filter=+<src/lcd/menu/menu_bed_leveling.cpp>
HAS_MENU_CANCELOBJECT   = src_filter=+<src/lcd/menu/menu_cancelobject.cpp>
HAS_MENU_DELTA_CALIBRATE = src_filter=+<src/lcd/menu/menu_delta_calibrate.cpp>
HAS_MENU_FILAMENT       = src_filter=+<src/lcd/menu/menu_filament.cpp>
LCD_INFO_MENU           = src_filter=+<src/lcd/menu/menu_info.cpp>
HAS_MENU_JOB_RECOVERY   = src_filter=+<src/lcd/menu/menu_job_recovery.cpp>
HAS_MENU_LED            = src_filter=+<src/lcd/menu/menu_led.cpp>
HAS_MENU_MEDIA          = src_filter=+<src/lcd/menu/menu_media.cpp>
HAS_MENU_MIXER          = src_filter=+<src/lcd/menu/menu_mixer.cpp>
HAS_MENU_MMU2           = src_filter=+<src/lcd/menu/menu_mmu2.cpp>
HAS_MENU_PASSWORD       = src_filter=+<src/lcd/menu/menu_password.cpp>
HAS_MENU_POWER_MONITOR  = src_filter=+<src/lcd/menu/menu_power_monitor.cpp>
HAS_MENU_CUTTER         = src_filter=+<src/lcd/menu/menu_spindle_laser.cpp>
HAS_MENU_TEMPERATURE    = src_filter=+<src/lcd/menu/menu_temperature.cpp>
HAS_MENU_TMC            = src_filter=+<src/lcd/menu/menu_tmc.cpp>
HAS_MENU_TOUCH_SCREEN   = src_filter=+<src/lcd/menu/menu_touch_screen.cpp>
HAS_MENU_UBL            = src_filter=+<src/lcd/menu/menu_ubl.cpp>
ANYCUBIC_LCD_I3MEGA     = src_filter=+<src/lcd/extui/lib/anycubic_i3mega>
HAS_DGUS_LCD            = src_filter=+<src/lcd/extui/lib/dgus> +<src/lcd/extui/dgus_lcd.cpp>
TOUCH_UI_FTDI_EVE       = src_filter=+<src/lcd/extui/lib/ftdi_eve_touch_ui>
HAS_ANYCUBIC_TFT_EXTUI  = src_filter=+<src/lcd/extui/anycubic_tft.cpp>
EXTUI_EXAMPLE           = src_filter=+<src/lcd/extui/example.cpp>
MALYAN_LCD              = src_filter=+<src/lcd/extui/malyan_lcd.cpp>
HAS_SPI_LCD             = src_filter=+<src/lcd/lcdprint.cpp>
USB_FLASH_DRIVE_SUPPORT = src_filter=+<src/sd/usb_flashdrive>
AUTO_BED_LEVELING_BILINEAR = src_filter=+<src/feature/bedlevel/abl>
AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+<src/gcode/bedlevel/abl>
MESH_BED_LEVELING       = src_filter=+<src/feature/bedlevel/mbl> +<src/gcode/bedlevel/mbl>
AUTO_BED_LEVELING_UBL   = src_filter=+<src/feature/bedlevel/ubl> +<src/gcode/bedlevel/ubl>
BACKLASH_COMPENSATION   = src_filter=+<src/feature/backlash.cpp>
BARICUDA                = src_filter=+<src/feature/baricuda.cpp> +<src/gcode/feature/baricuda>
BINARY_FILE_TRANSFER    = src_filter=+<src/feature/binary_stream.cpp> +<src/libs/heatshrink>
BLTOUCH                 = src_filter=+<src/feature/bltouch.cpp>
CANCEL_OBJECTS          = src_filter=+<src/feature/cancel_object.cpp> +<src/gcode/feature/cancel>
CASE_LIGHT_ENABLE       = src_filter=+<src/feature/caselight> +<src/gcode/feature/caselight>
EXTERNAL_CLOSED_LOOP_CONTROLLER = src_filter=+<src/feature/closedloop.cpp> +<src/gcode/calibrate/M12.cpp>
USE_CONTROLLER_FAN      = src_filter=+<src/feature/controllerfan.cpp>
DAC_STEPPER_CURRENT     = src_filter=+<src/feature/dac>
DIRECT_STEPPING         = src_filter=+<src/feature/direct_stepping.cpp> +<src/gcode/motion/G6.cpp>
EMERGENCY_PARSER        = src_filter=+<src/feature/e_parser.cpp> -<src/gcode/control/M108_*.cpp>
I2C_POSITION_ENCODERS   = src_filter=+<src/feature/encoder_i2c.cpp>
HAS_FANMUX              = src_filter=+<src/feature/fanmux.cpp>
FILAMENT_WIDTH_SENSOR   = src_filter=+<src/feature/filwidth.cpp> +<src/gcode/feature/filwidth>
FWRETRACT               = src_filter=+<src/feature/fwretract.cpp> +<src/gcode/feature/fwretract>
HOST_ACTION_COMMANDS    = src_filter=+<src/feature/host_actions.cpp>
HOTEND_IDLE_TIMEOUT     = src_filter=+<src/feature/hotend_idle.cpp>
JOYSTICK                = src_filter=+<src/feature/joystick.cpp>
BLINKM                  = src_filter=+<src/feature/leds/blinkm.cpp>
HAS_COLOR_LEDS          = src_filter=+<src/feature/leds/leds.cpp> +<src/gcode/feature/leds/M150.cpp>
PCA9533                 = src_filter=+<src/feature/leds/pca9533.cpp>
PCA9632                 = src_filter=+<src/feature/leds/pca9632.cpp>
PRINTER_EVENT_LEDS      = src_filter=+<src/feature/leds/printer_event_leds.cpp>
TEMP_STAT_LEDS          = src_filter=+<src/feature/leds/tempstat.cpp>
MAX7219_DEBUG           = src_filter=+<src/feature/max7219.cpp> +<src/gcode/feature/leds/M7219.cpp>
MIXING_EXTRUDER         = src_filter=+<src/feature/mixing.cpp> +<src/gcode/feature/mixing/M163-M165.cpp>
PRUSA_MMU2              = src_filter=+<src/feature/mmu2> +<src/gcode/feature/prusa_MMU2>
PASSWORD_FEATURE        = src_filter=+<src/feature/password> +<src/gcode/feature/password>
ADVANCED_PAUSE_FEATURE  = src_filter=+<src/feature/pause.cpp> +<src/gcode/feature/pause/M600.cpp> +<src/gcode/feature/pause/M603.cpp>
AUTO_POWER_CONTROL      = src_filter=+<src/feature/power.cpp>
HAS_POWER_MONITOR       = src_filter=+<src/feature/power_monitor.cpp> +<src/gcode/feature/power_monitor>
POWER_LOSS_RECOVERY     = src_filter=+<src/feature/powerloss.cpp> +<src/gcode/feature/powerloss>
PROBE_TEMP_COMPENSATION = src_filter=+<src/feature/probe_temp_comp.cpp> +<src/gcode/calibrate/G76_M871.cpp>
HAS_FILAMENT_SENSOR     = src_filter=+<src/feature/runout.cpp> +<src/gcode/feature/runout>
MK2_MULTIPLEXER         = src_filter=+<src/feature/snmm.cpp>
EXT_SOLENOID|MANUAL_SOLENOID_CONTROL = src_filter=+<src/feature/solenoid.cpp>
HAS_CUTTER              = src_filter=+<src/feature/spindle_laser.cpp> +<src/gcode/control/M3-M5.cpp>
EXPERIMENTAL_I2CBUS     = src_filter=+<src/feature/twibus.cpp> +<src/gcode/feature/i2c>
Z_STEPPER_AUTO_ALIGN    = src_filter=+<src/feature/z_stepper_align.cpp> +<src/gcode/calibrate/G34_M422.cpp>
G26_MESH_VALIDATION     = src_filter=+<src/gcode/bedlevel/G26.cpp>
ASSISTED_TRAMMING       = src_filter=+<src/gcode/bedlevel/G35.cpp>
HAS_MESH                = src_filter=+<src/gcode/bedlevel/G42.cpp>
HAS_LEVELING            = src_filter=+<src/gcode/bedlevel/M420.cpp>
DELTA_AUTO_CALIBRATION  = src_filter=+<src/gcode/calibrate/G33.cpp>
CALIBRATION_GCODE       = src_filter=+<src/gcode/calibrate/G425.cpp>
Z_MIN_PROBE_REPEATABILITY_TEST = src_filter=+<src/gcode/calibrate/M48.cpp>
M100_FREE_MEMORY_WATCHER = src_filter=+<src/gcode/calibrate/M100.cpp>
BACKLASH_GCODE          = src_filter=+<src/gcode/calibrate/M425.cpp>
IS_KINEMATIC            = src_filter=+<src/gcode/calibrate/M665.cpp>
HAS_EXTRA_ENDSTOPS      = src_filter=+<src/gcode/calibrate/M666.cpp>
SKEW_CORRECTION_GCODE   = src_filter=+<src/gcode/calibrate/M852.cpp>
PINS_DEBUGGING          = src_filter=-<src/gcode/config/M43.cpp>
NO_VOLUMETRICS          = src_filter=-<src/gcode/config/M200-M205.cpp>
HAS_MULTI_EXTRUDER      = src_filter=+<src/gcode/config/M217.cpp>
HAS_HOTEND_OFFSET       = src_filter=+<src/gcode/config/M218.cpp>
EDITABLE_SERVO_ANGLES   = src_filter=+<src/gcode/config/M281.cpp>
PREVENT_COLD_EXTRUSION  = src_filter=+<src/gcode/config/M302.cpp>
HAS_USER_THERMISTORS    = src_filter=+<src/gcode/config/M305.cpp>
SD_ABORT_ON_ENDSTOP_HIT = src_filter=+<src/gcode/config/M540.cpp>
COOLANT_CONTROL         = src_filter=+<src/gcode/control/M7-M9.cpp>
HAS_SOFTWARE_ENDSTOPS   = src_filter=+<src/gcode/control/M211.cpp>
HAS_DUPLICATION_MODE    = src_filter=+<src/gcode/control/M605.cpp>
LIN_ADVANCE             = src_filter=+<src/gcode/feature/advance>
PHOTO_GCODE             = src_filter=+<src/gcode/feature/camera>
CONTROLLER_FAN_EDITABLE = src_filter=+<src/gcode/feature/controllerfan>
GCODE_MACROS            = src_filter=+<src/gcode/feature/macro>
GRADIENT_MIX            = src_filter=+<src/gcode/feature/mixing/M166.cpp>
HAS_SAVED_POSITIONS     = src_filter=+<src/gcode/feature/pause/G60.cpp> +<src/gcode/feature/pause/G61.cpp>
PARK_HEAD_ON_PAUSE      = src_filter=+<src/gcode/feature/pause/M125.cpp>
FILAMENT_LOAD_UNLOAD_GCODES = src_filter=+<src/gcode/feature/pause/M701_M702.cpp>
CNC_WORKSPACE_PLANES    = src_filter=+<src/gcode/geometry/G17-G19.cpp>
CNC_COORDINATE_SYSTEMS  = src_filter=+<src/gcode/geometry/G53-G59.cpp>
HAS_M206_COMMAND        = src_filter=+<src/gcode/geometry/M206_M428.cpp>
EXPECTED_PRINTER_CHECK  = src_filter=+<src/gcode/host/M16.cpp>
HOST_KEEPALIVE_FEATURE  = src_filter=+<src/gcode/host/M113.cpp>
REPETIER_GCODE_M360     = src_filter=+<src/gcode/host/M360.cpp>
HAS_GCODE_M876          = src_filter=+<src/gcode/host/M876.cpp>
HAS_RESUME_CONTINUE     = src_filter=+<src/gcode/lcd/M0_M1.cpp>
HAS_PREHEAT_COUNT       = src_filter=+<src/gcode/lcd/M145.cpp>
HAS_LCD_CONTRAST        = src_filter=+<src/gcode/lcd/M250.cpp>
LCD_SET_PROGRESS_MANUALLY = src_filter=+<src/gcode/lcd/M73.cpp>
TOUCH_SCREEN_CALIBRATION = src_filter=+<src/gcode/lcd/M995.cpp>
ARC_SUPPORT             = src_filter=+<src/gcode/motion/G2_G3.cpp>
GCODE_MOTION_MODES      = src_filter=+<src/gcode/motion/G80.cpp>
BABYSTEPPING            = src_filter=+<src/gcode/motion/M290.cpp>
Z_PROBE_SLED            = src_filter=+<src/gcode/probe/G31_G32.cpp>
G38_PROBE_TARGET        = src_filter=+<src/gcode/probe/G38.cpp>
MAGNETIC_PARKING_EXTRUDER = src_filter=+<src/gcode/probe/M951.cpp>
SDSUPPORT               = src_filter=+<src/gcode/sd>
HAS_EXTRUDERS           = src_filter=+<src/gcode/temp/M104_M109.cpp> +<src/gcode/config/M221.cpp>
INCH_MODE_SUPPORT       = src_filter=+<src/gcode/units/G20_G21.cpp>
TEMPERATURE_UNITS_SUPPORT = src_filter=+<src/gcode/units/M149.cpp>
NEED_HEX_PRINT          = src_filter=+<src/libs/hex_print.cpp>
NEED_LSF                = src_filter=+<src/libs/least_squares_fit.cpp>
NOZZLE_PARK_FEATURE     = src_filter=+<src/libs/nozzle.cpp> +<src/gcode/feature/pause/G27.cpp>
NOZZLE_CLEAN_FEATURE    = src_filter=+<src/libs/nozzle.cpp> +<src/gcode/feature/clean>
DELTA                   = src_filter=+<src/module/delta.cpp> +<src/gcode/calibrate/M666.cpp>
BEZIER_CURVE_SUPPORT    = src_filter=+<src/module/planner_bezier.cpp> +<src/gcode/motion/G5.cpp>
PRINTCOUNTER            = src_filter=+<src/module/printcounter.cpp>
HAS_BED_PROBE           = src_filter=+<src/module/probe.cpp> +<src/gcode/probe/G30.cpp> +<src/gcode/probe/M401_M402.cpp> +<src/gcode/probe/M851.cpp>
IS_SCARA                = src_filter=+<src/module/scara.cpp>
MORGAN_SCARA            = src_filter=+<src/gcode/scara>
(ESP3D_)?WIFISUPPORT    = AsyncTCP, ESP Async WebServer
  ESP3DLib=https://github.com/luc-github/ESP3DLib.git
  arduinoWebSockets=https://github.com/Links2004/arduinoWebSockets.git
  ESP32SSDP=https://github.com/luc-github/ESP32SSDP.git
  lib_ignore=ESPAsyncTCP

#
# Default values apply to all 'env:' prefixed environments
#
[env]
framework     = arduino
extra_scripts = ${common.extra_scripts}
build_flags   = ${common.build_flags}
lib_deps      = ${common.lib_deps}
monitor_speed = 250000
monitor_flags =
  --quiet
  --echo
  --eol
    LF
  --filter
    colorize
  --filter
    time

# STM32F407VET6 with RAMPS-like shield
# 'Black' STM32F407VET6 board - https://wiki.stm32duino.com/index.php?title=STM32F407
# Shield - https://github.com/jmz52/Hardware
#
[env:STM32F407VE_black]
platform          = ${common_stm32.platform}
extends           = common_stm32
board             = blackSTM32F407VET6
upload_port       = 0483:df11
upload_protocol   = dfu
board_build.f_cpu = 12000000L
build_flags       = ${common_stm32.build_flags}
  -D ARDUINO_BLACK_F407VE
  ; -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
  ; -D USBD_USE_CDC_COMPOSITE
  ; -D MENU_USB_SERIAL 
  ; -D MENU_SERIAL=SerialUSB
  ; -D USBCON 
   -D USBD_VID=0x0483
   -D USBD_PID=0x5740
   -DLSE_VALUE=32768U
   -DHSE_VALUE=12000000U
  ; -D USB_MANUFACTURER="Unknown"
  -D USB_PRODUCT=\"BLACK_F407VE\"
  ; -D HAL_PCD_MODULE_ENABLED
  ;-D PIO_FRAMEWORK_ARDUINO_SERIAL_WITHOUT_GENERIC
  -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
  ;-D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
  ;-D PIO_FRAMEWORK_ARDUINO_USB_HIGHSPEED_FULLMODE
   
extra_scripts     = ${common.extra_scripts}
  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
lib_ignore        = SoftwareSerial

Also, I’ve tried toggling effectively every combination of build_flags, including PIO_FRAMEWORK_ARDUINO_ENABLE_CDC and unfortunately did not see a port open. I’ve also tried configuring the BigTreeTech BTT002 V1.0 board option in the Marlin platformio.ini as it’s the precise same chip as what I’m using, but still nothing.

Please try a minimal Arduino sketch with USB serial first, as Marlin is huge and modifications to it might interfere with something else.

PIO knows 4 boards with the exact STM32F407VGT6 MCU already, I think you want to start from there ( black_f407vg, disco_f407vg, genericSTM32F407VGT6, diymore_f407vgt).

E.g., as platformio.ini:

[env:black_f407vg]
platform = ststm32
board = black_f407vg
framework = arduino
; uncomment to change upload protocol from stlink to dfu if needed
;upload_protocol = dfu
build_flags = 
	-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
	-D USBCON
	-D USBD_VID=0x0483
	-D USBD_PID=0x0003
	-D USB_MANUFACTURER="Unknown"
	-D USB_PRODUCT="\"black_f407vg\""
	-D HAL_PCD_MODULE_ENABLED

src\main.cpp

#include <Arduino.h>

void setup(){
	//activate USB CDC driver
	SerialUSB.begin();
}

void loop() {
	SerialUSB.println("Hello world");
	delay(1000);
}

Thank you for the advice madgerhardt! I gave this a try with all four boards supported by PIO but no luck. I made a brand new PIO project, configured it for black_f407vg, and copy-pasted your examples in. Compiled and uploaded without an issue, but still no serial communication.

I tried poking around with a few other boards, and changing my platformio.ini file to reflect the the Adafruit Feather STM32F405 board (based on this) not only compiles and uploads, but gives me a serial output. Not sure what could be the difference here. Wouldn’t they use the same USB Serial libraries and such? Thanks again for your help!

There might be other problems unrelated to USB that prevent this from working, e.g. wrong clock configurations (external crystal, internal, …). Did you test that a simple Blinky is able to flash an LED with PlatformIO?

Which board are you choosing in the Arduino IDE, which other settings and which version of the STM32Duino core (I’m assuming this, or are you using Maple?) are using?

Thanks again for your help maxgerhardt! I think your thought of an incorrect clock config was the ticket. I tested a blinky program and it worked, but blinked at the incorrect speed.

I then went into ~/.platformio>packages>framework-arduinoststm32>variants>BLACK_F407XX> and edited variant.h to include the line #define HSE_VALUE 12000000U to match my crystal speed, and in variant.cpp updated the line RCC_OscInitStruct.PLL.PLLM = 8; to RCC_OscInitStruct.PLL.PLLM = (HSE_VALUE / 1000000);. These values were pulled from the known working config files for the Adafruit STM32F405 Feather. Lo and behold, USB Serial communications worked!

I’m still unable to get Marlin to compile with USB Serial working with a 12MHz HSE, but I think the solve there might be to just change my crystal. :smiley: Either way, not a PIO issue. Thank you so much for your help, I appreciate it tremendously!