Most of the guides on the internet only had instructions for Arduino which I did not have lying around. Instead I had a Raspberry Pi and knew it’s GPIO pinouts could be used but couldn’t really find much on until I found: Flash Bootloader and Install Firmware With Raspberry PI. PLEASE SEE THIS GUIDE FOR ANY TROUBLESHOOTING I have re-written it to succinctly summarize the instructions for flashing the Ender 3 using a Raspberry Pi.

NOTE: This guide was written for macOS so you may have to make some substitutions on instructions for your OS.

Things you will need

Setup

Before we get started we need to install a few things on both your machine and the Raspberry Pi.

On your machine

  • Install Arduino IDE

    1
    2
    
    brew cask install --appdir="/Applications" arduino
        
  • Download the TH3D firmware

    1
    2
    3
    4
    
    cd ~/Desktop
    git clone https://github.com/houseofbugs/TH3D-Unified-U1.R2.git
    cd TH3D-Unified-U1.R2/TH3DUF_R2/
        
  • Open the Arduino IDE

    • Go to Arduino > Preferences and paste https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json into Additional Board Manager URLs and click OK
    • Go to Tools > Board and select Sanguino
    • Go to Tools > Processor and select ATmega1284 or ATmega1284P (16 MHz)
    • Go to Tools > Manage Libraries… and type U8glib and click Install
    • Go to File > Open… and select TH3DUF_R2.ino
    • Go to the tab labeled Configuration.h find the line #define ENDER3 and remove the two leading //
    • In the same tab file the line #define DISABLE_BOOT and remove the two leading //
    • Go to Sketch > Export compiled Binary

You should now see two files: TH3DUF_R2.ino.sanguino.hex and TH3DUF_R2.ino.with_bootloader.sanguino.hex

  • Copy the files to the Raspberry Pi machine
    1
    2
    
    scp  -i ~/.ssh/YOUR_PRIVATE_KEY.rsa TH3DUF_R2.ino.sanguino.hex TH3DUF_R2.ino.with_bootloader.sanguino.hex pi@YOUR_RASPBERRY_PI_IP:~/
        

Change pi to the Raspberry Pi username and YOUR_RASPBERRY_PI_IP to the IP of the Raspberry Pi machine you are using on your home network

Connect the Ender 3 board and the Raspberry Pi

UNPLUG THE ENDER 3 POWER AND RASPBERRY PI POWER

Here is the Ender 3 Board with the pins you will be connecting labeled:

Ender 3 Board

And here is the Raspberry Pi 3 board with the pins you will be connecting:

Raspberry Pi 3b Board

Given these diagrams you can connect your jumper cables in the following way

Ender3 RaspberryPi
5V PIN 1
MISO PIN 12
MOSI PIN 16
SCK PIN 18
GND PIN 6
RESET PIN 11

On the Raspberry Pi

  • Plug back in the Raspberry Pi and wait some time for it to boot

  • SSH to the Raspberry Pi emachine on your network which you have just copied the .hex files to above in the Arduino IDE section above

    1
    2
    
    ssh -i ~/.ssh/YOUR_PRIVATE_KEY.rsa pi@YOUR_RASPBERRY_PI_IP:~/
        
  • Install the avrdude packages necessary

    1
    2
    
    sudo apt-get install avrdude
        
  • Copy the /etc/avrdude.conf to the home directory

    1
    2
    
    cp /etc/avrdude.conf ~/
        
  • Find the linuxspi line and change the baud rate to 115200

    1
    2
    3
    4
    5
    6
    7
    8
    
    programmer
        id = "linuxspi";
        desc = "Use Linux SPI device in /dev/spidev*";
        type = "linuxspi";
        reset = 25;
        baudrate=115200;
    ;
        
  • Add the following to the bottom of the file

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    
    # NOTE: THE LAST COMMA IS *NOT* A TYPO AND REQUIRED
    programmer
        id = "pi_1";
        desc = "Use the Linux sysfs interface to bitbang GPIO lines";
        type = "linuxgpio";
        reset = 17;
        sck = 24;
        mosi = 23;
        miso = 18;
    ;
        

  • Test to see if the board is recognized

    1
    2
    3
    4
    5
    6
    
    sudo avrdude \
        -p atmega1284p \
        -C ~/avrdude.conf \
        -c pi_1 \
        –v
        

    You should see output similar to the following:

    1
    2
    3
    4
    5
    6
    
    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.
        

    If you do NOT see the following DO NOT PROCEED and check your PIN connections.

  • ACTION STEP Now you can flash the board

    1
    2
    3
    4
    5
    6
    7
    
    sudo avrdude \
        -p atmega1284p \
        -C ~/avrdude.conf \
        -c pi_1 \
        -v \
        -U flash:w:TH3DUF_R2.ino.with_bootloader.sanguino.hex:i
        

    You should see the following output:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    
        avrdude: Version 6.3-20171130
    ...
             System wide configuration file is "/home/pi/avrdude.conf"
             User configuration file is "/root/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping
    ...
             Programmer Type : linuxgpio
             Description     : Use the Linux sysfs interface to bitbang GPIO lines
             Pin assignment  : /sys/class/gpio/gpio{n}
               RESET   =  17
               SCK     =  24
               MOSI    =  23
               MISO    =  18
    
    avrdude: AVR device initialized and ready to accept instructions
    
    Reading | ################################################## | 100% 0.00s
    ...
    avrdude: reading input file "TH3DUF_R2.ino.with_bootloader.sanguino.hex"
    avrdude: writing flash (131072 bytes):
    
    Writing | ################################################## | 100% 30.48s
    
    avrdude: 131072 bytes of flash written
    ...
    avrdude: reading on-chip flash data:
    
    Reading | ################################################## | 100% 28.04s
    
    avrdude: verifying ...
    avrdude: 131072 bytes of flash verified
    ...
    avrdude done.  Thank you.
        
  • You should now run the following

    1
    2
    
    sudo shutdown -h now
        
  • Wait one solid minute and now unplug the micro USB POWER to the Raspberry Pi

  • Unplug all of the jumper cables from the Raspberry Pi

You are now done flashing the board. You can now plug back in the Ender 3 and power it on. You may see a blank screen for a moment and then it should show the usual screen you see when there is no print in progress.

Extra

If you are like me you would like to:

  • Install a BLTouch
  • Install the Microswiss hotend
  • Install stepper motor dampers
  • Install the Petsfang to work with the dual blower 5015 fan mod and Microswiss hotend

The trick to both the BLTouch with the Petsfang dual 5015 blowers are some modifications to the firmware. The 5015 fans whine and there is a fix in the TH3D firmware for this as well as some tuning and enabling of the BLTouch.

Also, my Ender 3 came with pressed fit pulleys, and it wasn’t until I discovered this YouTube video that I knew I was hitting an obstacle that was not readily mentioned elsewhere. For this I had to print out modifications (mentioned and linked by the video) that I could then install the stepper motor dampers with the press fit pulleys. This required inverting the X-axis motor.

All of my modifications to the TH3D firmware are checked in under my fork of the repository and you can view those exact differences in the diff of my fork branch from the TH3D upstream master.