Platformio build fails

I seldom need direct help with anything computer. I use google, forums and youtube. They usually point me in the right direction. But not this time. I cannot get Platformio to build my firmware update. I have tried 4 different downloaded versions of Marlin.

Marlin 2.0.x as of 2/12/2020

Marlin bugfix-2.0.x as of 2/12/2020

gazcbm /Marlin-2.0.x-SKR-Mini-E3-v1.2

BIGTREETECH-SKR-mini-E3

All fail immediately with the error:

C:\users\me.platformio.exe run’ failed to launch (exit code: {2})

I took ownership of the .platformio folder and all child folders and files.

If I try to open platformio.exe manually a command type window opens for about a half second and then closes. I don’t know what should of happened when I tried that.

I have tried several uninstall and reinstalls of python 3.8 and VScode 1.42, cleaning out as much as allowed in the registry and all folders/file that are related to python 3.8, platformio and VSCode.

I’m on Windows 10.

I have spent probably in excess of 20 hours working on this to no avail. This would be OK except I’m 85 and don’t have too many 20 hours left. So any help that anyone could give me would be greatly appreciated. larsnavy

You double-clicked on the platformio.exe file? Yes this will start the program, print the help text and then exit the program, so that’s correct behavior. This must be executed in a commandline to run properly, e.g. by starting the cmd.exe program (Windows → Search → cmd.exe) , then cd into the the target folder where the platformio.ini lies (like cd <path here>) and then execute platformio in the cmd window.

This doesn’t look good. This error occurs immediately after pressing the “Build” button in VSCode?

1 Like

Your 1st reply. It does the same from the command line in Powershell as an administrator. Opens for about a half second and closes. There doesn’t seem to be anything on the “window” that opens .But it does happen very fast.
Your 2nd reply.Yes it is immediate. Within a second
Thanks for your quick reply. From all my searching the net it seems like I’m the only one in the world having trouble building a Marlin firmware. Thanks again, larsnavy

Just to confirm your situation: Are these the steps you have exeuted?

  • You open a new shell (PowerShell) from the Windows start menu
  • In the shell window, you execute the PlatformIO command (see below)
  • A new window quickly appears and disappears
  • Visual Studio Code is not used at all in the process

The command could look like:

C:\Users\you\.platformio\penv\Scripts\platformio

Or:

cd C:\Users\you\.platformio\penv\Scripts
platformio

The expected behavior would be that no new windows appears. Instead PlatformIO would print output in the already open shell window.

1 Like

My mistake. I was using c:…\ RUN platformio ( I guess I’ve forgot the old DOS).

When I run just c:…\platformio a window does open with 26 lines (counting 2 blanks) of “usage”, “options” and “commands”. So evidently platformio is at least installed on my pc. It just doesn’t want to run from the VSCode shell.

For the heck of it, I just tried to build a couple versions of Marlin, again with same immediate “Failed To Launch” error

I’m sorry for wasting your time by forgetting how to open a program from the command line. And again Thanks much for your help.

1 Like

I’m still utterly confused with the window does open thing. Am I assuming correctly that you did not type the command in a shell window but rather into the single line Run dialog?

Can you try these steps:

  • In Visual Studio Code, open a TERMINAL view: Terminal / New Terminal
  • In the opened view, type the below commands:
platformio
C:\Users\you\.platformio\penv\Scripts\platformio

Both should NOT open any additional window but show the same usage information as before. If they don’t, describe what happens instead: show output, mention if a new windows appears etc.

1 Like

I’ll have to wait to answer your last post. VSCode tried to update and fouled everything up. I’ll need to completely clean out VScode and start over. Don’t know how long this might take. Thanks, larsnavy

Sounds like you have the same problem I had with the recent v1.42 VSCode update… it got stuck on updating one file and completely wrecked itself. I was able to remove the directory that it got stuck on (vscode-rng or something like that) and do a clean re-install.

Took awhile but I got VSCode running. Glad to hear I’m not the only one who had trouble.

After the upgrade I tried to build a Marlin firmware. Still failed immediately with same error.

As to your post about not understanding my post: what I was trying to say was that when I ran the platformio.exe from the Windows Powershell command line. Platformio did open and displayed several lines in the same windows that Powershell opened. The problem I had trying to open it before I got your message was I tried to open platformio with a wrong command C:…\script\ RUN platformio. The RUN was wrong. When I used your command line, platformio did display about 26 lines of platformio in the same window that Powershell opened. This leads me to believe that platformio is ok. It just won’t run from within VSCode.

As you suggested I tried a Terminal>New Terminal but Powershell wouldn’t open (had an error). Weird.

I’m going to run a sfc /scannow. Maybe something in windows is fouled up. I’ll get back later today. Sfc /scannow can take awhile.

What version of VSCOde are you running? Are there pending Windows updates?

You should investigate this specific problem. Possibly you need to change the user setting terminal.integrated.shell.windows. It’s path to either Powershell.exe or command.exe (see Integrated Terminal in Visual Studio Code).

1 Like

OK sfc /scannow found no problems (that’s rare, it always finds some). I think you are right it seems to have something to do with environmental variables and the paths. I’ll work on that for awhile. But 1st I am going to try adding a new user and see what happens.Thanks for your suggestion. I am running VSCode 1.42.1. Python 3.8.1 Windows 10 is fully uptodate. larsnavy

1 Like

Manuelbl. When I made a New User (wow was that fun), VSCode/platformio acted just the same. Closed immediately with the same error.

I assume the user settings you wanted me to change is “settings.json” which appears to be a python file. As I know nothing about python, I’ll skip on that. As I said I’m 85 so I can’t spend anymore time on this.

A friend gave me his old Windows 7 laptop and VSCode/platformio appeared to build and load a Marlin Firmware (took awhile) but the SD card is blank and there is no “firmware.bin” anywhere on the lap top . My question: Do people actually successfully build marlin firmware with VSCode/platformio. Just joking, I’m sure they do, I just don’t seem to be able to. I would try another program to build my firmware but there seems to be only two possibilities: VSCode/platformio and Arduino IDE.

I think what I’ll do is try more friends pc’s, maybe I can find 1 that will actually build and load Marlin firmware. After all this not something that needs to be done very often.

Unless you have some suggestions why the laptop seemed to build and load but I can’t find any firmware on the SD card or the laptop, I’ll say goodbye and thank you so much for you time and effort to help me. larsnavy

1 Like

So there’s a couple of different things that could be happening here, depending on exactly what you did.

Assuming you went with the default STM32F103RC_bigtree_NOUSB, just hit the build button

image
… and it compiled which a nice ‘SUCCESS!’ message at the end… there will be a firmware file on your computer, but it won’t be on the SD card, etc. Instead, it’ll be in a subfolder of the project called .pio\build\board-env-name and will be called firmware.bin.

If, instead of pressing build, you pressed upload …
image
… then it still won’t be on your SD card as when you press that button it tries to send it to the printer, which it expects to be attached to the computer (assuming that uploading has been correctly configured for that device/environment).

Even if you built a different version of Marlin, the same general location of the firmware file applies. It’s only some specialised cases where the build process will auto-detect the SD card.The SKR version of Marlin is not one of those cases, and in fact the very last step of their guide on compiling the firmware says to copy the file from the build folder to the SD card.

As long as it compiled successfully, the firmware file will still be there, and in the same folder, just not where you expected it to be. I hope that helps, and makes enough sense to you! :wink:

Thanks pfeeric. I didn’t know that the load button was for direct to printer. But after the supposedly successful build. a thorough search of the laptop found no new .bin file. Even more weird is, I can no longer get a supposedly successful build of the same version of Marlin on the laptop. I have tried 3 computers now and many versions of Marlin. And have never been able do a successful build. I, half jokingly. asked manuelbl if anyone had ever really built firmware. A search of the internet for a solution found another guy who asked. “has anyone ever actually built a firmware using VSCode w/Platformio?”. So I give up. I’m going to try replacing Window, on the laptop that my friend gave me, with Linux. I’ll put nothing but python and VSCode/platfotmio on the laptop. Maybe I can build with that configuration.Thanks again for your effort to help. larsnavy

One of the issues with your computer is that the terminal windows doesn’t work in Visual Studio Code. Instead of investing a lot of time in switching to another computer, you could also try this approach:

  • Use Visual Studio Code for editing the Marlin project
  • Use a separate Command shell or PowerShell to build the software

The commands you need to execute for building are pretty simple (you need to change the paths to match your Marlin project directory and/or PlatformIO installation):

cd C:\Users\you\Documents\Marlin-Project
pio run

Or if PlatformIO is not on your path:

cd C:\Users\you\Documents\Marlin-Project
C:\Users\you\.platformio\penv\Scripts\pio run

If it doesn’t successfully build, post your platformio.ini file and the output from the command shell and we can likely help you.

I can assure you that the Marlin firmware has been successfully built many, many times.

Thanks, I’ll try this right away. As you say it will be faster than reconfiguring the laptop. I might do that anyway as I have no need for the laptop. Just hoped it would build my skr mini e3 firmware. It will take me a little while to do what you recommend but I’ll’ get back to you with how it worked out, larsnavy

This will take longer than I thought. I can easily edit the Marlin files, I have no idea how to save them as a project. I did try your suggestions using the modified Marlin folder (in my case" cd “f:\Everything Computer\firmware\morningreis\marlin skr-e3”). This did run doing something. But it didn’t build a *.bin file. I’ll have to learn more about how to use VS. Get back to you soon, I hope!

I must be really dense. After several hours of searching (including the 2200 page platformio “manual”) I WAS able to make a phony New Project that was saved in C:…\documents\platformio\projects. But I found no way to save my opened Marlin folder into a project. The Save As button doesn’t seem to do anything. And there isn’t a Save Project button anywhere that I can find. If you don’t mind working with a dummy I sure would like some advice. Thanks a bunch, larsnavy. Oh yes I’m sure that most people are able to build firmware. I was just being a smart a…

Visual Studio Code doesn’t have the concept of a project. You open the root folder of your project and Visual Studio Code figures out the rest. It will save some files into the .vscode folder though. But they are immediately saved (without asking).

If you are working with the Marlin firmware, you probably don’t want to create a new project. Instead, you download the Marlin project and open that folder. As it contains a platformio.ini file, Visual Studio Code will know that PlatformIO tools should be available.