So I’m seeing a lot of posts on Reddit and other places about people wanting to compile Marlin and having a tough time with, or more commonly, many people just aren’t doing it because it seems intimidating. I’m hoping to put together a walkthrough that simplifies the process as much as possible for people that aren’t really comfortable compiling something. Many people think you need to be a programmer to do it. You don’t.
Why should I compile it?
Well, there are a lot of features you can make use of that will help improve your prints. Here are just a handful of them:
- Mesh Bed Leveling – Whether you want to automatically level using a BLTouch(Amazon) / (AliExpress) or do manual mesh leveling(This is what I do), you can enable mesh leveling to compensate for a bed that isn’t completely level, even after leveling the bed using the knobs.
- Linear Advance – This can be used, mainly on 32 bit boards, to help get some perfect corners on your prints, while printing extremely fast. It basically uses some fancy computations to adjust the flow of material when going around corners at high speed. You can shave a pretty large percentage of time off your prints without affecting the quality.
- Increase buffers – You can increase some buffers to help prevent them from emptying when printing curves (which take a lot of GCode commands in a short period of time) with something like OctoPrint at high speed.
- LCD’s/Lights(NeoPixels)/etc. – There are all kinds of upgrades like touch LCD screens, lighting, and additional extruders that you will need to recompile in order to be able to use.
- The one that I’m currently fiddling with is ARC support. @formerlurker recently posted this on the OctoPrint forums to help with stuttering issues, but it seems like something that can improve print quality irrespective of the OctoPrint stuttering. It basically takes curves and converts them into a few ARC GCode commands instead of dozens of tiny straight line commands. This should produce smoother curves, and it allows for fewer GCode commands needing to be sent which should help any blobbing that would be cause by stuttering on curves.
Why are there so many files?
So this is probably the most intimidating part. When you download Marlin’s source files, there are hundreds of files. However, you only need to worry about .\Marlin\configuration.h and .\Marlin\configuration_adv.h. These are the 2 files that contain all the settings you need for your printer. The first one contains the basic settings, and the second one contains the more advanced stuff, as the name implies. There is a lot of information in both files, but you don’t need to go through it all. Just figure out, either via documentation or Google Search, what settings you need to change in order to do what you want, and then search those 2 files for the appropriate settings and make the changes.
NOTE: I did all this on Windows 10, with the latest versions of everything at the time of writing, which is May 6, 2020.
- Install Python.
- Install VSCode and then open it.
- Download Marlin. Typically you will want the latest version, which is 220.127.116.11 at the time of writing. After downloading the zip file, extract it somewhere.
- Download the Marlin config files and extract them. This file contains config files for a huge number of printers. All the popular printers and boards should be in there. Find the configuration.h and configuration.adv for your printer and copy and paste them into the .\Marlin folder that is in the folder that you extracted in the previous step. Overwrite the 2 files that are there.
NOTE: you may need to do some additional legwork here. For example, my printer is the Ender 5, and I installed the BigTreeTech SKR Mini E3. However, the config files for that board are setup for the Ender 3. However, a quick Google search allowed me to find version of these config files for this board on my printer.
- In VSCode, install the Auto Build Marlin extension – To do that, click the extensions button on the left side of VSCode and search for ‘Auto Build Marlin’ and click Install on it. That will also install Platform.io, which can take a minute.
- Close VSCode and open it again to ensure platform.io is ready. You should see the platoform.io and an Auto Build Marlin icons on the left side.
- Click Platform.io and click the ‘Open Project’ button. If that button isn’t there on the right side, you may need to click ‘Open’ under ‘PIO Home’ .
- Browse to the folder, where you extracted Marlin earlier, and click ‘Open’
- Now, click on the ‘Explorer’ button on the left side(should be the top button), and edit the configuration.h and/or the configuration_adv files under the ‘Marlin’ folder to change the settings you want. I’m not going to go into any detail on this, since that would be like writing a book. But there should be plenty of information on nearly anything you are looking for via a Google search.
- After you make the changes and save them, you are ready to compile. Click the Auto Build Marlin button on the left side. On the left pane, when you hover over the ‘Build’ section, you should see some icons pop up. The first one is a hammer. That is the Build button. Click on that.
- On the right side, you should see options to build or Upload your firmware. Click on Build.
- If everything went right, it should start compiling. This can take 5 to 10 minutes. After the first compile, it will go much faster next time you make changes to your configuration files.
- To confirm everything went well, at the end of the terminal output, you should see a list of boards, with most of them saying ‘Ignored’, and your board listed as ‘Success’.
- Now go back to the folder where you extracted Marlin, and go to .\.pio\build\TheNameOfYourBoard. You should see a firmware.bin file. That’s the file you will flash to your board.
I believe this is where the boards may vary. I know that on the stock Ender3/5 board, you have to unlock your bootloader first. And then you have to upload it via a USB cable. In that case, you can just hit the upload button in Auto Build Marlin. For my board, I just have to copy that file to an SD card, put it into my printer, and the power on the printer.
And that’s it. There’s really not much to it. Now it’s just a matter of what you want to do. Once you figure that out, you simply make the appropriate changes in the config files, and compile it again. I really feel that manual mesh leveling and linear advance(If your board can handle it) are must have features.
As always, please let me know if you have any questions or comments about this.