How To Successfully Flash Your 3D Printer's Firmware
When customizing or upgrading your 3D printer, you may need to flash your firmware - here are the steps to succeed.
Flashing firmware can be a daunting task, especially if you’ve never done it before. Collectively, we at MatterHackers have done it hundreds, if not thousands of times, so we can appreciate the complexity involved.
In any case, just try to stay calm. Though it is complex, flashing firmware is a scientific process, and the rules of logic apply. Even when you’re looking at an error message telling you that you don’t have a certain library-- when you know for a fact that you’ve installed that particular library not five minutes ago-- and you can feel your blood boiling, just remind yourself that this isn’t a matter of life and death. We’ve been there, and there is a logical explanation that can (eventually) be found.
Process overview
The process for flashing firmware (at least in the context of the 3D printing world) consists of something like the following:
- Make sure you are running the latest version of Arduino software and have the correct libraries installed. If your board is not Arduino-based, obtain the comparable software.
- Download the correct firmware for your printer.
- Make any adjustments to the firmware, which is common for hardware modifications.
- Select the correct serial port and type of Arduino board for your printer.
- Compile and upload the firmware.
Not much to it, is there? Sometimes it is just that easy. If not, resources are available to help you along. See the section below, ‘Additional resources’.
Arduino
What is Arduino? Arduino is an open source electronics company and platform which designs and sells microcontrollers. The boards they produce are the basis for many of the boards used for controlling 3D printers due to their open source nature and ease of use.
As mentioned in the last section, the Arduino platform is not the only platform used for running 3D printer controllers. Smoothie is another such platform, and requires different software to flash boards which use it. In this guide we’re going to focus on Arduino-based controllers, since most boards we deal with are based on them. The concept and general process will be the same, though, so most everything we discuss here should be good information no matter what platform your printer runs on.
How do I know what platform my controller board runs on?
Good question. If your printer runs RAMPS, RAMBo, Duet, or anything else based on an Arduino board, then it’s Arduino-based.
Common non-Arduino boards include Smoothie, BeagleBone, and Duet. These require their own firmware-flashing software which we do not cover here.
If in doubt, check with the board manufacturer for information about flashing firmware.
How to install
Head over to the Arduino website and download the latest version of the Arduino IDE (integrated development environment) for your operating system: https://www.arduino.cc/en/Main/software
Just make sure you get the standalone version, not the online IDE. The online version requires an account, and since we’re mostly familiar with the standalone version, we’re going to outline the process using that. You are welcome to try to follow along using the online IDE, but there may be differences that we don’t cover.
See the Arduino Getting Started guide if you have any issues getting the IDE up and running: https://www.arduino.cc/en/Guide/HomePage
Purpose
So what does the Arduino IDE actually do? This program loads the firmware files into memory, allows the user to edit code if necessary, compiles the code, and finally sends the compiled code to the board over a serial connection.
Firmware
Firmware is the actual code that runs your printer. It starts as human-readable code, which defines the logic (i.e. how the printer is supposed to act given certain circumstances), is compiled into machine-readable code, then is uploaded to the memory on the controller board where it senses input and reacts according to the logic defined in the code. It’s very complex, and takes a lot of smart people a long time to develop.
Flavors
On its fundamental level, firmware is just a computer program. As is typical of any function that a computer program performs, different programs have been created that all work similarly. They all do the same thing (i.e. control a 3D printer), but the logic and algorithms they employ can be different, and thus function differently. We call these different programs different flavors-- like ice cream. One’s not necessarily better than another (though sometimes they certainly are), but just different.
Some of the common open source firmware solutions available include Repetier, Marlin, Sprinter, Smoothie, grbl, etc. We’ll touch on Repetier and Marlin specifically, though the same concepts will apply to most any of the others.
Download
Current versions of the firmware files for Repetier and Marlin can be found in their respective GitHub repositories:
Repetier: https://github.com/repetier/Repetier-Firmware
Marlin: https://github.com/MarlinFirmware/Marlin
Now just so you know, firmware is provided in various forms. Hex files (.hex) are common, but they are a result of having already compiled the code and cannot be configured, so you will need to get the files that contain the code to be able to edit if needed.
What you are looking for is the .ino file (file format for the Arduino program), along with the other .cpp and .h files that make up the code. They should all be in a folder called ‘Marlin’ or ‘Repetier’, depending on the flavor.
If your printer’s manufacturer has a website, hopefully they host pre-configured firmware intended specifically for your printer. Lulzbot, makers of the TAZ, has firmware readily available for all their printers, for example. While they provide .hex files on the main page listing available firmware, if you dig down into the FTP site you can find the Arduino file along with the other code you need to edit and compile from scratch. For example, here’s a link to the Marlin folder that contains the .ino, .cpp, and .h files that make up the Marlin firmware for the TAZ 6: TAZ 6 Marlin Firmware
Download the folder, with all the files inside, and open the .ino file using the Arduino IDE.
Configuration
Once you have the firmware open you can edit the code. You probably don’t need to touch most of these files, as they have lots of variables and information already defined, and messing something up could cause a compiler error. Generally speaking, it’s best not to edit anything unless you know what it does and you are sure that you need to.
Configuration.h
In Marlin and Repetier, the Configuration.h file is the one you’ll probably get to know the best. It contains most of the common user-editable settings that you’re likely to need to edit when doing a modification. Other firmware should have a comparable file, which will function similarly.
Below is a list of the most common settings you might want to change in both Marlin’s and Repetier’s Configuration.h files. For further information, you can consult the Marlin documentation at marlinfw.org or the Repetier documentation at repetier.com. Repetier also has a handy online configuration tool, so you do not need to edit the Configuration.h file directly.
When you are done, be sure to save your changes by hitting CTRL + S.
Baudrate
#define BAUDRATE 115200
The rate at which bits of data are interchanged between the board and the host computer. Common values are 115200 and 250000.
Motherboard type
#define MOTHERBOARD BOARD_RAMPS_14_EFB
The type of controller board your printer has. RAMPS, RAMBo, Azteeg, etc.
Thermistor type
#define TEMP_SENSOR_0 5
Different thermistors have different resistances to measure temperature. Defining which thermistor your hot end uses is absolutely necessary to ensure that the temperature is measured correctly.
Motor directions
#define INVERT_X_DIR true
#define INVERT_Y_DIR false
#define INVERT_Z_DIR true
#define INVERT_E0_DIR false
While motor wires can be physically swapped around to change the direction in which the motors turn, the firmware can sometimes more easily be changed. Changing the value for the direction of the motors will cause them to spin the opposite direction.
Steps per mm/motor current
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 4000, 500 }
Setting how many steps is required to move the motor one millimeter is critical for calibrating the printer and making sure it moves correctly.
Endstop configurations
#define X_MIN_ENDSTOP_INVERTING false
#define Y_MIN_ENDSTOP_INVERTING false
#define Z_MIN_ENDSTOP_INVERTING false
Knowing how many endstops the printer has and whether the switches are always on or always closed is important, and these settings are easily adjusted here.
Temperature maximums
#define HEATER_0_MAXTEMP 285
If you upgrade your hot end (say, to an all-metal E3D v6 from a PEEK one), you’ll want to be able to increase the maximum temperature so that the printer knows it can go up that high. Temperatures can be manually set in degrees Celsius.
Compiling and Uploading
Now that you have made all the changes you want to your firmware configuration, it is time to set up Arduino to upload your new firmware to your printer.
Libraries
Some firmwares require additional libraries to be installed. These are additional pieces of software which the firmware utilizes to perform certain functions. For instance, one library commonly used by printer firmwares is U8glib which handles graphical LCD displays. If your printer has a graphical (not text based) screen then you will need this library.
Libraries are easily installed through the Library Manager in Arduino.
- Go to Sketch > Include Library > Manage Libraries.
- Search for U8glib.
- Click Install.
Board
This is where you must select the type of motherboard that is installed in your printer. If you select the wrong board, you will most likely get an error when compiling.
Most 3D printer motherboards are based on the Arduino Mega 2560, so if you are in doubt then selecting “Arduino/Genuino Mega or Mega 2560” is a safe bet. In some cases, though, you will need to add a new board to Arduino.
Motherboards and Arduino Selection
Motherboard |
Arduino Board Selection |
Azteeg X3 and Azteeg X3 Pro |
Arduino/Genuino Mega or Mega 2560 |
Brainwave Pro |
Brainwave Pro |
Printrboard |
[BootloaderCDC]Teensylu/Printrboard |
RAMPS |
Arduino/Genuino Mega or Mega 2560 |
RAMBo and RAMBo Mini |
RAMBo Custom Board URL: https://raw.githubusercontent.com/ultimachine/ArduinoAddons/master/package_ultimachine_index.json |
Ultimainboard |
Arduino/Genuino Mega or Mega 2560 |
Installing Custom Boards
This process varies depending on which board you need to install, and which version of Arduino you are running. The following outlines the process using the built-in Boards Manager in Arduino 1.6 or later. This works for the RAMBo board. For other boards you will need to follow the instructions in the links provided above.
- Go to File > Preferences. In the box for “Additional Boards Manager URLs” paste the URL for your board.
- Go to Tools > Board > Boards Manager. Search for your motherboard, and click Install.
- Go back to Tools > Board and select your motherboard.
Port
This is the serial port you use to connect to your printer. This is the same as the serial port selected in MatterControl. If you have only one printer connected to your computer, then choose the only port available.
Compiling
Compiling converts the human readable (if you are a programmer) source code into binary instructions which the processor understands. When you click the checkbox button in Arduino, it will compile the firmware. During this process it will check for any issues with the code. Cross your fingers. If all goes well then when it is done it will report the size of the compiled firmware in white text in the console area. If there is an issue, it will give you an error message in orange text.
If you run into a problem, don’t panic. We have some common issues listed below. Check to see if your error message is among them.
Uploading
Finally, click the arrow button to upload the firmware to your printer. It will be automatically compiled if you have not done so already, and then the transfer will begin. This will take a minute or two; just be patient. When the process completes your printer will reboot.
Getting Help
If you run into a problem, don’t panic. We have some common issues listed below. Check to see if your error message is among them. If not, you will probably have to go to the internet for help. Google is your friend. Arduino will often give you a very long list of error messages in the console. The most critical one is usually the first one. Search for the error message along with the name of your firmware or printer. You will likely find some forum posts pointing you in the right direction.
If you do not turn up anything in your research, you may need to ask a question on a web forum. The best place to ask is probably the forum for your specific printer. The most important thing to remember when asking a question online is to include the full text of the error message. Whenever Arduino gives you an error, there will be a button above the console area which lets you copy the entire text. You can then post it using a service like Pastebin.
Common Errors
An error occurred while uploading the sketch
This means that Arduino is unable to communicate with your printer. Make sure that your printer is powered on and that you have selected the right port. Try pressing the reset button on your board after clicking upload. Some printers require special steps to be taken to put them in programming mode. Consult your printer’s documentation to see if there is a button combination you must press or hold down in order to flash the firmware.
If you are absolutely certain that your printer is powered and communicating with your computer then it may be possible that there is an issue with the microcontroller’s bootloader. Flashing the bootloader requires specialized equipment. If your bootloader is corrupt then you should contact your printer or motherboard’s manufacturer.
using typedef-name 'fpos_t' after 'struct'
You are using an older firmware which is not compatible with the latest versions of Arduino. Arduino 1.6 and later broke compatibility with older versions. Some printers still use older firmware which has not been updated yet. You will need to install Arduino version 1.0.6. You can find it here:
‘DIOZ_PROBE_PIN_RPORT’ was not declared in this scope
This indicates that the motherboard you are trying to use (the one you have defined in Configuration.h) is not fully supported by your firmware. Specifically, the firmware is trying to use pins that have not been defined in that motherboard’s entry in pins.h. This may happen if you are trying to use a different type of motherboard than your printer came with.
Error compiling for board Arduino/Genuino Mega or Mega 2560.
This type of error message is shown if Arduino cannot find a file it is looking for. Usually this is because you are missing one of the libraries required by your firmware. In the example above we are missing the U8glib library. See the section above on installing libraries.
You might also see a similar error message regarding Configuration.h if you opened the .zip file your firmware came in but did not unpack it. You must unpack the .zip in order for Arduino to read all the firmware files.
Additional Resources
- Marlin Firmware
- Repetier Firmware
- RAMBo Board Schematics
- RAMPS Board Schematics
Request a Quote
To learn about available discounts, training, and maintenance options, please use the form below and a MatterHackers Expert will contact you within one business day. Alternatively, you can always feel free to give us a call at +1 (800) 613-4290 or email sales@matterhackers.com.