Issues building with fresh marlin firmware and PlatformIO 2.2.1

Yeah still getting the same error

CalledProcessError: Command 'avr-g++.exe -D__MARLIN_FIRMWARE__ -D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h' returned non-zero exit status 1.:
  File "C:\users\tony\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 168:
    env.SConscript(item, exports="env")
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 286:
    apply_features_config()
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 118:
    if not env.MarlinFeatureIsEnabled(feature):
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 262:
    load_marlin_features()
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 250:
    define_list = subprocess.check_output(cmd, shell=True).splitlines()
  File "C:\Users\Tony\.platformio\python3\lib\subprocess.py", line 411:
    **kwargs).stdout
  File "C:\Users\Tony\.platformio\python3\lib\subprocess.py", line 512:
    output=stdout, stderr=stderr)

Aha but the path has changed. Before it contained the full path

Can you remove the .pio folder in the Marlin project and retry building?

Deleted the .pio folder and did a clean.

Results:

Verbose mode can be enabled via `-v, --verbose` option
CalledProcessError: Command 'avr-g++.exe -D__MARLIN_FIRMWARE__ -D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h' returned non-zero exit status 1.:
  File "C:\users\tony\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 168:
    env.SConscript(item, exports="env")
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 286:
    apply_features_config()
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 118:
    if not env.MarlinFeatureIsEnabled(feature):
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 262:
    load_marlin_features()
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 250:
    define_list = subprocess.check_output(cmd, shell=True).splitlines()
  File "C:\Users\Tony\.platformio\python3\lib\subprocess.py", line 411:
    **kwargs).stdout
  File "C:\Users\Tony\.platformio\python3\lib\subprocess.py", line 512:
    output=stdout, stderr=stderr)

Does the folder

exist?

Is there further a bin folder in there that contains a avr-g++ executable?

C:\Users\Tony.platformio\packages\toolchain-atmelavr exists and has a bin folder with avr-g++ exe

After a build, is there a .gcc_path file in the .pio\build\mega2560 folder of the Marlin project folder? What’s the content?

there is a .gcc_path file, contents are

avr-g++.exe

Hmm that should have been regenerated with the C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin\avr-g++.exe path when the .pio folder was deleted and rebuilt.

When you remove that .gcc_path file and hit “Build” again, does it still fail?

Does it fail when you manually replace the contents of that file with the path above?

Do you have a global AVR-GCC installation, by chance?

when i remove the gcc path and rebuild stills fails. I don’t not have another AVR-GCC installation, just a normal gcc from the mingw-64 install, not sure if that will impact it or not. Also it still fails when I replace the contents of the GCC path inside the build folder with “C:\Users\Tony.platformio\packages\toolchain-atmelavr\bin\avr-g++.exe”

With the same error that includes the full path?

Could you also again open a PIO CLI like in the first post and execute the two commands

"C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin\avr-g++.exe" -D__MARLIN_FIRMWARE__ -D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h
$LASTEXITCODE

and post in pastebin/xyz what that outputs.

Btw, your case is really interesting, since we had sporadic reports of Marlin’s build script failing (this compiler-find logic), but we can’t figure out why exactly, since it is working on all machines I and the Marlin developers are testing it on ([BUG] 'CC' is not recognized as an internal or external command · Issue #20671 · MarlinFirmware/Marlin · GitHub). So I really appreciate your patience and the information we can gather from here to maybe finally erridicate this problem.

https://paste-bin.xyz/20110

PS D:\Marlin-2.0.x> $LASTEXITCODE
0

No worries i’m glad that someone is trying to help me with this issue. Also does the compiler act different when using different processors ie. amd to intel? Recently updated to amd from intel.

The output and link shows that the command could be executed successfully and the return-code of the invocation was 0 meaning no-error.

Then how in the world does it do a non-zero exit v

when compiled in VSCode + PlatformIO? >.<

Do you have any antivirus installed beyond the default/builtin Windows defender?

Can you also

  • follow this guide in conjunction with docs to add the C:\Users\Tony\.platformio\python3\Scripts folder to the PATH? (Check that it exists first)
  • compeltely remove all folders within C:\Users\Tony\.platformio\packages and C:\Users\Tony\.platformio\platforms
  • then completely remove the Marlin project folder
  • Reclone it fresh from the repo
  • Open a terminal (Windows + R → cmd.exe), change directory into the Marlin folder where the platformio.ini using the cd <path> command and execute pio run. Does it stilll fail, and if yes, with what exact error?

Nothing but windows defender installed/active

Just to clarify, just run “pio run”? Trying that errors out saying the pio is not a recognized command. I looked at the docs and installed platformio, which created a virtual environment with platformio installed

My bad, the path that needs to be added to the SYSTEM PATH should be C:\Users\Tony\.platformio\penv\Scripts. If you open this folder you also see the pio executable in it, right?

D:\Marlin-2.0.x>pio run
Processing mega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
------------------------------------------------------------------------------------------------------------------------
Platform Manager: Installing atmelavr
Platform Manager: atmelavr @ 3.1.0 has been installed!
The platform 'atmelavr' has been successfully installed!
The rest of the packages will be installed later depending on your build environment.
Tool Manager: Installing platformio/toolchain-atmelavr @ ~1.50400.0
Unpacking  [####################################]  100%
Tool Manager: toolchain-atmelavr @ 1.50400.190710 has been installed!
Tool Manager: Installing platformio/framework-arduino-avr @ ~5.1.0
Unpacking  [####################################]  100%
Tool Manager: framework-arduino-avr @ 5.1.0 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40001.0
Tool Manager: tool-scons @ 4.40001.0 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CalledProcessError: Command 'avr-g++.exe -D__MARLIN_FIRMWARE__ -D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h' returned non-zero exit status 1.:
  File "C:\Users\Tony\.platformio\penv\Lib\site-packages\platformio\builder\main.py", line 168:
    env.SConscript(item, exports="env")
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 286:
    apply_features_config()
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 118:
    if not env.MarlinFeatureIsEnabled(feature):
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 262:
    load_marlin_features()
  File "D:\Marlin-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 250:
    define_list = subprocess.check_output(cmd, shell=True).splitlines()
  File "C:\Users\Tony\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 420:
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\Tony\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 524:
    raise CalledProcessError(retcode, process.args,
============================================= [FAILED] Took 34.02 seconds =============================================

Environment    Status    Duration
-------------  --------  ------------
mega2560       FAILED    00:00:34.016
======================================== 1 failed, 0 succeeded in 00:00:34.016 ========================================

D:\Marlin-2.0.x>

Here are the results

Very interesting. But we should be getting to the bottom of this. Can you please

  • open the platformio.ini of the Marlin project and after the board line in the mega2560 environment

add the line

custom_verbose = 1

Then, remove the .pio folder in the project again, build the project and show logs. They should be more verbose now.

Then, please

It should hopefully start printing PATH: … and give some debug output as to why Marlin thinks that’s the right compiler path.

Processing mega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
PATH: ['C:\\Users\\Tony\\.platformio\\packages\\toolchain-atmelavr\\bin', 'C:\\Users\\Tony\\.platformio\\python3', 'C:\\Program Files\\AdoptOpenJDK\\jre-8.0.265.01-hotspot\\bin', 'C:\\Program Files\\AdoptOpenJDK\\jre-11.0.8.10-hotspot\\bin', 'C:\\Program Files (x86)\\AdoptOpenJDK\\jre-8.0.265.01-hotspot\\bin', 'C:\\Windows\\system32', 'C:\\Windows', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\Windows\\System32\\OpenSSH\\', 'C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common', 'C:\\Program Files\\dotnet\\', 'C:\\Program Files\\nodejs\\', 'C:\\Program Files\\NVIDIA Corporation\\NVIDIA 
NvDLISR', 'C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\', 'C:\\Users\\Tony\\.platformio\\penv\\Scripts', 'C:\\Program Files\\PuTTY\\', 'C:\\Users\\Tony\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\', 'C:\\Users\\Tony\\AppData\\Local\\Programs\\Python\\Python39\\', 'C:\\Users\\Tony\\AppData\\Local\\Microsoft\\WindowsApps', 'C:\\Users\\Tony\\AppData\\Roaming\\npm', 'C:\\Users\\Tony\\AppData\\Local\\Programs\\Microsoft VS Code\\bin']
Searching directory: C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin
Searching file avr-addr2line.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)
Searching file avr-ar.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)       
Searching file avr-as.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)       
Searching file avr-c++.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)      
Searching file avr-c++filt.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)  
Searching file avr-cpp.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)      
Searching file avr-elfedit.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)  
Searching file avr-g++.exe (dir C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin)      
Compiler found: C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin\avr-g++.exe
============================================================================================ [SUCCESS] Took 1.33 seconds ============================================================================================

Environment    Status    Duration
-------------  --------  ------------
mega2560       SUCCESS   00:00:01.326

Looks like the change to the common-dependencies.py worked, I reverted to the original and the it threw the same error as before. So seems that linked common-dependencies.py is the solution to my issue.

Aha. I’ve learnt from the devs in [BUG] 'CC' is not recognized as an internal or external command · Issue #20671 · MarlinFirmware/Marlin · GitHub that the 2.0.x branch does not have a fix for the common-dependencies.py file that is however present in the bugfix-2.0.x branch. Can you download https://github.com/MarlinFirmware/Marlin/archive/bugfix-2.0.x.zip, unpack it and try to build it, without any modifications to anything?

> Executing task in folder Marlin-bugfix-2.0.x: C:\Users\Tony\.platformio\penv\Scripts\pio.exe run --environment mega2560 <

Processing mega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CalledProcessError: Command '"C:\Users\Tony\.platformio\packages\toolchain-atmelavr\bin\avr-g++.exe" -D__MARLIN_FIRMWARE__ -D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h' returned non-zero exit status 1.:

  File "C:\Users\Tony\.platformio\penv\Lib\site-packages\platformio\builder\main.py", line 168:
    env.SConscript(item, exports="env")
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "D:\Marlin-bugfix-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 327:
    apply_features_config()
  File "D:\Marlin-bugfix-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 141:
    if not env.MarlinFeatureIsEnabled(feature):
  File "C:\Users\Tony\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:      
    return self.method(*nargs, **kwargs)
  File "D:\Marlin-bugfix-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 292:
    load_marlin_features()
  File "D:\Marlin-bugfix-2.0.x\buildroot\share\PlatformIO\scripts\common-dependencies.py", line 280:
    define_list = subprocess.check_output(cmd, shell=True).splitlines()
  File "C:\Users\Tony\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 420:
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\Tony\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 524:
    raise CalledProcessError(retcode, process.args,
============================================================================================================== [FAILED] Took 0.51 seconds ============================================================================================================== 

Environment    Status    Duration
-------------  --------  ------------
mega2560       FAILED    00:00:00.514
========================================================================================================= 1 failed, 0 succeeded in 00:00:00.514 =========================================================================================================

The command structure looks absolutely right. I have literally no idea what’s holding this back anymore / causing it to fail with return code 1.

Please open an issue at Issues · MarlinFirmware/Marlin · GitHub referencing this thread and the version of Marlin you’ve downloaded for the Marlin developers.