Ender 3 - Installing a bootloader with a Raspberry Pi
If you have a Raspberry Pi, you're probably already using it for OctoPrint and likely using
the OctoPi SD card image. This is good - because it already has most of what we need.
- Log into your OctoPi running on your Pi, then become the root user:
sudo su -
- Install avrdude if it is not already installed:
apt-get install -y avrdude
- Copy the avrdude config file to the root home directory:
cp /etc/avrdude.conf ~/avrdude.conf
~/avrdude.conf and find the 'linuxspi' programmer. Change the baud rate in the block to 115200. The block should look like the following:
id = "linuxspi";
desc = "Use Linux SPI device in /dev/spidev*";
type = "linuxspi";
reset = 25;
- At the bottom of the same file, add the following:
id = "pi_1";
desc = "Use the Linux sysfs interface to bitbang GPIO lines";
type = "linuxgpio";
reset = 17;
sck = 24;
mosi = 23;
miso = 18;
- Disconnect the Ender 3 from the power supply. This is important! It is sufficient to unplug the main XT60 connector.
- The pins on the Ender 3 board are laid out as:
RST | SCK | MISO
GND | MOSI | VCC
Ground and VCC are closest to the edge of the board, GND at the display connector side, VCC at the USB connector side.
- Connect the dupont cables to the following pins. You can use this guide to locate the correct pins on the Raspberry Pi
Raspi => Ender 3
3v3 => VCC
GND => GND
GPIO 17 => RST
GPIO 18 => MISO
GPIO 23 => MOSI
GPIO 24 => SCK
- Attempt to talk to the Ender 3 chip over this connection:
avrdude -p atmega1284p -C ~/avrdude.conf -c pi_1 -v
If this fails, check the connection of your dupont cables and try again.
- Download the bootloader onto the Pi:
- Flash the bootloader:
avrdude -p atmega1284p -C avrdude.conf -c pi_1 -U flash:w:optiboot_atmega1284p.hex:i
- You can now connect your Pi via USB to the Ender 3, download a firmware file from this site and flash via:
avrdude -p atmega1284p -c arduino -P /dev/ttyUSB0 -b 115200 -U flash:w:firmware.hex:i
Just remember to change
firmware.hex to match the file you have downloaded.
- I would suggest installing the Firmware Updater plugin for OctoPrint to update your firmware easily in the future.