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.