Marlin Firmware not compiling in VS code

Does anyone have any clue what is going wrong with my firmware? It worked perfectly up until July of 2022, I made no changes, and then it stopped working, and I have been putting off fixing it. This is the error that I get when I try to compile:

 *  Executing task: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run 

Warning! Ignore unknown configuration option `monitor_flags` in section [env]
Warning! `src_filter` configuration option in section [env:DUE] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:SAMD51_grandcentral_m4] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:STM32F4] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:STM32F7] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:malyan_M300] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:esp32] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:teensy31] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:teensy35] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:teensy36] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:teensy41] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_build_flags` configuration option in section [env:linux_native] is deprecated and will be removed in the next release! Please use `build_src_flags` instead
Warning! `src_filter` configuration option in section [env:linux_native] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Warning! `src_filter` configuration option in section [env:include_tree] is deprecated and will be removed in the next release! Please use `build_src_filter` instead
Processing STM32F103RET6_creality (platform: ststm32@~6.1; board: genericSTM32F103RE; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103RE.html
PLATFORM: ST STM32 (6.1.1) > STM32F103RE (64k RAM. 512k Flash)
HARDWARE: STM32F103RET6 72MHz, 64KB RAM, 512KB Flash
DEBUG: Current (jlink) External (blackmagic, jlink, stlink)
PACKAGES:
 - framework-arduinoststm32-maple @ 2.10000.200103 (1.0.0)
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
Converting Marlin.ino
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- SoftwareSerialM @ 1.0.0
|-- STM32ADC @ 1.0
|-- EEPROM
|-- Wire @ 1.0
|-- USBComposite for STM32F1 @ 0.91
|-- Servo(STM32F1) @ 1.1.2
Building in release mode
RuntimeError: deque mutated during iteration:
  File "C:\Users\Peter\.platformio\penv\Lib\site-packages\platformio\builder\main.py", line 180:
    env.SConscript(env.GetExtraScripts("post"), exports="env")
  File "C:\Users\Peter\.platformio\packages\tool-scons\scons-local-4.6.0\SCons\Script\SConscript.py", line 609:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Peter\.platformio\packages\tool-scons\scons-local-4.6.0\SCons\Script\SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "E:\MyDesktop\All 3D printing stuff\Multiple 3D printer Firmware\Printer101 Firmware stuffs\Firmware-printer101\buildroot\share\PlatformIO\scripts\creality.py", line 5:
    for define in env['CPPDEFINES']:
==================================================================================== [FAILED] Took 10.13 seconds ====================================================================================

Environment             Status    Duration
----------------------  --------  ------------
STM32F103RET6_creality  FAILED    00:00:10.128
=============================================================================== 1 failed, 0 succeeded in 00:00:10.128 =============================================================================== 

 *  The terminal process "C:\Users\Peter\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Already discussed in Marlin: RuntimeError: deque mutated during iteration: - #9 by maxgerhardt, please open buildroot\share\PlatformIO\scripts\creality.py in line 5 and replace

for define in env['CPPDEFINES']:

with

for define in env['CPPDEFINES'].copy():

This is a regression because you’re using a very new PlatformIO core to build an old Marlin firmware. Python + SCons behavior has changed.

1 Like

Thank you very much Max, that fixed the problem, and it compiles and works now.