Ender 3 Pro – Firmware upgrade using Raspberry Pi

There are various ways of updating the Ender 3 (Pro) firmware. One of the most common way uses Arduino Uno to load the firmware to Ender 3 (Pro). As I did not have an Arduino lying around, I searched for a way to do the same using something I had – Raspberry Pi. I have both Raspberry Pi B Rev 2 and Pi Zero W. I used Raspberry Pi Model B as my Pi Zero does not have GPIO header pins soldered on it.

The process of upgrading the Ender 3 firware involves:

  1. Opening up your Ender 3 so you can connect Ender 3 mainboard to Raspberry Pi
  2. Downloading the firmware files. This depends on which firmware you want to install on your Ender 3 Pro
  3. Compiling/Sketching files in Arduino IDE
  4. Preparing Raspberry Pi – Installing avrdude and configuring it
  5. Connecting Raspberry Pi to the Ender 3 mainboard using Dupont jumper wires
  6. Uploading and installing the firmware using avrdude tool

Let’s look at these steps in detail but do remember that you are doing this at your own risk.

Opening up your Ender 3 Pro

Opening up the Ender 3 is simple. Just a couple of screws. Just make sure when you have removed the cover of the casing which houses the mainboard, you slide out the mainboard carefully. You won’t need to remove the mainboard completely, just enough to be able to connect the wires.

Choosing Firmware

There are couple of firmwares available for Ender 3 (Pro). I found Marlin 2.0 better than the TH3D as I saw a few options which I didn’t on TH3D firmware.

Marlin firmware:

TH3D firmware:

Download the firmware files along with all required tools (Aruino IDE) from https://support.th3dstudio.com/hc/en-us/articles/360043293452-TH3D-Unified-Firmware-Package. Just click Download Latest Firmware link.

Whether you are installing Marlin 2.0 or TH3D, make sure you have downloaded and unzipped the files in a directory as we will be using these files for building the install image which we will be written to the main board.

Compiling firmware with Arduino IDE

We will be opening an ino file and depending on which firware you downloaded, the location of the file itself will differ. In case of Marlin, you will have to copy over the configuration files from Ender-3 Pro configurations directory into Marlin main directory i.e

Copy configuration files from Configurations-bugfix-2.0.x/config/examples/Creality/Ender-3 Pro to Marlin-bugfix-2.0.x/Marlin directory. You will be overwritting some files so do that if you are asked to confirm.

Fire up Arduino IDE and open Marlin.ino under Marlin-bugfix-2.0.x/Marlin directory. Make sure you have Sanguino board installed and available. If this is not available, install it from Preferences.

Add https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json where it says Additional Boards Manager URLs under Settings tab in Preferences. Once done, go to Tools > Board > Boards Manager and search for Sanguino. Install it once found in the list.

Install U8glib library from Tools > Manage Libraries. This library is for TFT/LCD screens.

Once both of these are installed, Select Board as Sanguino, Processor as ATMega1284 or ATMega1284P (16 MHz).

We are not going to make any configuration changes for now as this post is about how we upload the firmware to the mainboard. So go ahead and hit Sketch > Export compiled Binary. This will take a few minutes and once done, the compiled binary will be placed in folder which you can open from Sketch > Show Sketch folder. The export creates 2 files: One plain firmware and another with bootloader.

Marlin.ino.sanguino.hex
Marlin.ino.with_bootloader.sanguino.hex

It is advisable to install bootloader binary as it will later let you use the mini usb port to upload any future firmware updates. Copy the one with bootloader in the filename to the Raspberry Pi.

Preparing Raspberry Pi

Now before we connect the Pi to the mainboard, we need to prepare it. The tool we are going to use for writing to the mainboard is called avrdude and on Raspbian, this can be installed by issuing the following command:

sudo apt-get install avrdude

Once avrdude is installed, we need to create a configuration file which will be used to set up Pi header pins which we will be connecting to the 6 ISP header pins.

Copy /etc/avrdude.conf to ~/avrdude.conf. Edit ~/avrdude.conf with vim. We need to find the linuxapi line inside programmer block and change the baudrate to 115200.

programmer
id = "linuxspi";
desc = "Use Linux SPI device in /dev/spidev*";
type = "linuxspi";
reset = 25;
baudrate=115200;
;

Add another programmer block at the end of the file:

programmer
id = "pi_1";
desc = "Use the Linux sysfs interface to bitbang GPIO lines";
type = "linuxgpio";
reset = 27;
sck = 22;
mosi = 24;
miso = 23;

;

Save the file. We are now ready with avrdude and the configuration file. The 4 pins configured above depend on which model of Pi you have and also which ones you choose to connect to the mainboard.

Connecting Raspberry Pi to Ender 3 Pro

You need to connect 5V and Ground of ISP header on mainboard to 5V and GRD of the Raspberry Pi. The other 4 pins, MISO, MOSI, SCK and RESET are to be connected to 4 free GPIO pins on the Pi. You would need to know the actual GPIO numbers for the pins instead of the serial number of the pins. I found the ones for my Pi here – https://raspi.tv/wp-content/uploads/2014/07/Raspberry-Pi-GPIO-pinouts.png

Raspberry Pi GPIO numbers

Do note that the GPIO numbers differ from model to model so you will have to adjust these in the config file we just created above. Pi Model B Rev 2, the one I have has 26 pins, the recent ones have 40 pins so you have more GPIO pins free to be used for I/O.

Once you have removed the mainboard cover and you can access the mainboard, connect the 6 ISP header pins to the pins configured above. Dupont jumper cables are color coded so it is easier to connect them without making any mistakes.

Installing the firmware

Once connected, power on the Pi. The blue light on the mainboard will light up. You do not need to power on the printer. Once all the 6 pins are connected, fire up the following command to check if the wires are connected correctly and the configuration is working as expected.

sudo avrdude -p atmega1284p -C ~/avrdude.conf -c pi_1 –v

If everything is hooked up and configured correctly, you should see an output ike this:

avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9705 (probably m1284p)
avrdude: safemode: Fuses OK (E:FD, H:DC, L:D6)
avrdude done. Thank you.

You are now ready to flash the firmware. Issue the following command on your Pi:

sudo avrdude -p atmega1284p -C ~/avrdude.conf -c pi_1 -v -U flash:w:Marlin.ino.with_bootloader.sanguino.hex:i

Take deep breath 🙂 and hit enter.

avrdude will show the config file options and configured pins. avrdude will read and write the firmware file and then verify the flashed firmware once the it has finished the flashing step.

If reading, writing and verification messages appear in the output along with a avrdude done. Thank you., it would mean flashing is done and your Ender 3 Pro has a new and shiny firmware installed.

Shutdown and disconnect the Raspberry Pi after a minute or so once the update has finished.

Before you put back the mainboard in the casing, power on your Ender to check it boots up as expected, making all the fan noises and TFT screen options. Do an Auto Home. Print a levelling bed print to make sure all is working as expected.

Enjoy the added features of the new firmware.

PS: Newer Ender 3 V2 among many others come with 32bit mainboard and silent stepper motor drivers and you are able to flash new firmware directly using a micro SD card. But I guess if you have read this far, you already have an Ender 3 (Pro) so hopefully this post will provide helpful information on firmware update/upgrade.

See you around!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s