Marlin Visual Studio Code



  1. Open up the downloaded Marlin Firmware project folder (NOT the 'Marlin' folder within) in Visual.
  2. Marlin 2.0 3D Printer firmware is the latest version that supports 32-bit Mainboards.If you have a 8-bit mainboard and want to install marlin check out our Marlin 1.1 Beginner Guide.Marlin 2.0 can applies to any Marlin HAL-compatible controller with an onboard bootable SD card.
  3. Using Octoprint with an Ender 3 Pro that has Marlin on it (stock printer otherwise). So I'm working on a print that I have to stop and raise the nozzle a bit. When I resume the print, the next layer is a few mm off and the printer is moving significantly slower for the next 1-2 layers.
  4. Visual Studio Code (VSCode) & Prerequisites. VSCode Download Page (Windows/Mac/Linux) VSCode Official Setup Documentation; Python Installation Page; TH3D Unified 2 Firmware. Unified 2 Firmware Downloads; Main Github Page for Source Code; Marlin Firmware. Marlin Firmware Download Page; Setting up PlatformIO with VSCode.

This guide will show you how to compile the CR-6 Community firmware we’ve been working on for the past couple of months. Always wanted to compile your own firmware, with your own acceleration and stepping defaults? This visual guide is for you.

Installation of the tools

To get started, let’s first download our tools. We need Visual Studio Code and its Platform.io plugin.

Marlin 2.0 introduces a layer of abstraction so that all the existing high-level code can be built for 32-bit platforms while still retaining full 8-bit AVR compatibility. Retaining AVR compatibility and a single code-base is important to us, because we want to make sure that features and patches get as much testing and attention as possible.

Visual Studio Code installation

Let’s install Visual Studio Code first. If you have already installed it, make sure it is up to date or follow the steps below.

Go to code.visualstudio.com and select the package appropiate for your operating system.

I’m using Windows 10, so I download the Windows 10 package.

Accept the license agreement.

Follow the setup wizard.

Be sure to select the options as selected, when using Windows

Follow the rest of the wizard and let the installation start.

Let the install run its course

Eventually the installation finishes.

When the installation has finished, let it open Visual Studio Code.

You are greeted with the welcome page

Compiling Marlin In Visual Studio

Platform.IO plugin installation

Where Visual Studio Code is the text editor, Platform.io is the toolset that allows you to actually compile the firmware. It automatically downloads all dependencies and simplifies compilation to a click on a button.

Find the extension manager at the left side, search for platformio and install it.

By clicking “Install” the extension will be installed

Extension installation will take a few moments.

How To Compile Marlin Visual Studio Code

When the extension installation is complete, Visual Studio will prompt to restart the editor

Close Visual Studio Code when the extension is installed - we will first download the firmware source code.

Download source code package

I won’t bore you here with installation of a source control system like git - let’s do it simple and easy, and just download the source code directly.

You have two choices when downloading source code:

  1. You can download the latest source code from the home page. You will have the latest source code but also possible issues and you’Il have to build the CR-6 touch screen software too.
  2. You can download the source code of the latest official release. If you have not purchased a BigTreeTech TFT you need to still flash your touch screen too - you need the files in the archive for that.

This is how you download the latest sources

This is how you download the source code from the latest official release

The source code is in a zip file - you need to extract it.

Make sure you choose a short path to extract the source code to

Now we have everything extracted - we must change some files so it compiles right for our board.

Prepare the source code

You need to change some files so the configuration of the firmware is right for the particular hardware configuration you have.

In the extracted source you’Il find the “config” directory. Navigate to it and choose the correct folder like shown below.

There are several folders here - for different hardware configurations of the CR-6 SE and MAX

Note the description file, platformio-environment file (you need this for later) and the Configuration[_adv].h files

Each configuration folder has a “description.txt” file. This contains the description of the particular configuration. Open it to check you have the right configuration files.

Once you have found the right configuration files, open platformio-environment.txt and take note of the contents. You’Il need this later.

Copy the Configuration.h and Configuration_adv.h files - and go to the “Marlin” folder in the source code.

Building Marlin 2.0

Inside the Marlin folder, overwrite the two Configuration_[adv].h files which are already there

Next, go to the root folder of the source code (the one with platformio.ini in it), and open Visual Studio Code in that folder.

You can right click and select ‘Open in VSCode’ or alternatively open Visual Studio Code and select to open this folder

Remember that platformio-environment.txt file from a few steps ago? We need to set that value in the platformio.ini file, next to the default_envs = statement.

Replace the value (if different) with the value of platformio-environment.txt of your config folder

Now we are ready for our first build!

Build it!

You can now build the source code! In the bottom status bar you will find a checkmark. Click it and the build will start.

That tiny check is easy to miss, but it is the one you need

When the build starts a terminal will open and a lot of text will appear and scroll up.

This might take a while, especially if you have a lower-end processor

Marlin

But after a while the process is done, and the firmware will show up:

Marlin Visual Studio Code

Build succeeded!

Visual studio code platformio marlin

Finding the files

Marlin

Now the build is done, you can find the files in .pio/build folder.

This matches the platform.io env from the platformio-environment.txt file

From the direction you need to pick the .bin file.

A lot of files, but the firmware.bin or firmware-[numbers].bin file is the only one that matters

Now you can take this file, put it on an SD card and flash it according to the instructions in the release notes.

Altering your configuration

The default configuration contains settings that are generally good for your printer. If you want to make any changes, follow the documentation of ‘Configuring Marlin’.

Troubleshooting

“File not found” or “No such file or directory exists”

Try:

  • Installing Git for Windows and rebooting your computer afterwards (or re-open Visual Studio Code)
  • Move the source files to a shorted part (for instance C:Temp) orenable Windows long paths

The “checkmark” compilation button is missing

You may have opened the platformio.ini file itself, or the wrong directory. You must open the directory of platformio.ini. Not a child directory nor the parent directory.

Final thoughts

I hope this short guide has helped you compile the CR-6 Community Firmware. If you’d like to support the CR-6 community firmware developers - please check the Credits section of the readme.

Thank you!