Customizing and Compiling Marlin Firmware with Visual Studio



Downloading VS Code and Marlin project sources 

  1. Download and Install Visual Studio Code https://code.visualstudio.com/
  2. Download the Marlin firmware source code bundles.  https://github.com/MarlinFirmware
    1. If you have git installed and know how it use it clone the following repos, if you don't have git or related knowledge just download the compress version of each repo and extra to a working directory of your choosing (click 'code' download as zip)
      1.  Marlin
        1. git clone https://github.com/MarlinFirmware/Marlin.git
        2. git checkout 2.1.x
      2.  Configurations
        1. git clone https://github.com/MarlinFirmware/Configurations.git
        2. git checkout release-2.1.1

  3. Launch Visual Studio Code
    1. Open the 'Marlin' project source code directory:  File -> Open Folder 
    2. Visual Studio Code should automagically detect that their is an AutoBuild configuration available for this project and prompt you to install the necessary addons:
      • platform io
      • auto marlin build
      • others c++ and juypiter 

Setting up VS Code to use Marlin Autobuild

  1. Now if you got this far without getting stumped you should see something like the following image in VS Code :
  2. In the left had column section you should see a file listing of the Marlin project direction.
    1. If you don't see this make sure you click the very top icon on the left nav bar
  3. From the left hand column location the Configuration.h and the Configuration_adv.h. Double click on each file to open it in the editor window.
  4. These are the only two files which you may need to modify if you want to enable some custom tailored setting.

  1. Now open a file explorer or terminal window and navigate to the 'Configurations' project directory that you downloaded early. This project contains all the known configurations for specific 3d printer hardware.  For this how to I will be compiling for the much used Ender 3 models.
    1. Navigate to ../Configurations/config/examples and scroll through the list until you find your printer manufacturer.
    2. Then select your printer model for example ../Configurations/config/examples/Creality/Ender-3
    3. Finally select the motherboard, I choose 4.2.7 since I upgraded from the 4.2.2 to get the silent stepper drivers.  ex: ../Configurations/config/examples/Creality/Ender-3/CrealityV427/
  2. Once you have located the correct configuration directory for your printer you should see 4 files in that directory:
    1. Configuration.h
    2. Configuration_adv.h
    3. _Bootscreen.h
    4. _Statusscreen.h
  3. Select each of these files and copy them to the Marlin project directory that you downloaded earlier, in the ..Marlin sub directory of the project defaults of these files exist there so you will be replacing them with the ones you copied.
  4. If you pasted them in the correct location you Marlin Auto build window should have updated with the new configuration files you just pasted
  5. Generally I believe most people will want to build the top environment, if you have a legacy board or firmware you may need to use one of the other environments
  6. As a test click the Build button on the environment you choose, once the build completes it should display a directory where the .bin firmware file will be placed.  If there are any errors they will be displayed in the terminal window beneath the auto build window
    1. the following is common error, which I don't quite understand but is easily fixed:                 error: #error "Your Configuration_adv.h file is for an old version of Marlin. Downgrade Marlin or upgrade your Configuration_adv.h.
    2. to correct this error open the Configuration_adv.h locate the 'version' var definition (near the top) and change it to: #define CONFIGURATION_ADV_H_VERSION 02010200
    3. Make a similar change in Configuration.h, locate the 'version' var definition (near the top) and change it to: #define CONFIGURATION_H_VERSION 02010200
  7. Once the build succeeds the directory of the built source will be displayed. The 'firmware*.bin' file is the file you will place on your printers sd card.

Customizing the firmware

  1. Coming soon!




Comments