HowTo build the Marlin 3D Printer Firmware on the Raspberry Pi

If you are already running the excellent octoprint as a printserver on a Raspberry Pi it is very convenient to also build Marlin on it. The new Raspberry Pi Zero W with onboard wifi is at only 10$ just perfect for both tasks. If you want to use the camera streaming of octoprint I would recommend a Pi3 though.

I made a script that sets up the necessary build environment and provides commands for building and uploading. It uses the official Arduino toolchain. Everything is standalone, nothing is installed outside the marlintool directory.

It works on the Raspberry Pi and Linux in general but not on OSX. The script auto detects the build platform architecture. At the moment Linux 32 Bit, 64 Bit and ARM are supported.

Several parameters at the beginning of the script allow to adapt it further to your needs. Recently Anet A6/A8 support has been merged back into the main Marlin branch. I would highly recommend to switch to the official Marlin branch from now on. You can find example configurations for Anet printers in the Marlin sources at: https://github.com/MarlinFirmware/Marlin/tree/1.1.x/Marlin/example_configurations/Anet. Just replace the “Configuration.h” and “Configuration_adv.h” in the marlin directory with the files your find there for a good starting point of your configuration.

If you do not need additional hardware/board definitions because you use the ones that come with the toolchain set the parameter “hardwareDefinitionRepo” to an empty string. This prevents the script from fetching the board definition that is needed for the A8 from github.

If you are running octopi on you Raspberry you need to disconnect it from your printer before uploading otherwise the serial port is blocked.

Code

here on github: https://github.com/mmone/marlintool

or download directly as a zip: https://github.com/mmone/marlintool/archive/master.zip

Commandline parameters

-s  — setup

Download and configure the toolchain and the necessary libraries for building Marlin. Also fetches the Anet board hardware definition from github if specified.

-m  — marlin

Download Marlin sources.

-f –fetch

Update an existing Marlin clone.

-v  — verify

Build without uploading.

-u  — upload

Build and upload Marlin. If you are running octopi on you Raspberry you need to disconnect it before uploading otherwise the serial port is blocked.

-b  –backupConfig  [name]

Backup the Marlin configuration to the named backup.

-r  –restoreConfig [name]

Restore the given configuration into the Marlin directory.

-c  — clean

Cleanup everything. Remove Marlin sources and Arduino toolchain.

-p  — port [port]

Set the serialport for uploading the firmware. Overrides the default set in the script.

-h  — help

Show help.

Tweet about this on TwitterShare on Google+Share on FacebookPin on PinterestShare on RedditShare on LinkedInShare on StumbleUponEmail this to someone

12 thoughts on “HowTo build the Marlin 3D Printer Firmware on the Raspberry Pi

  1. Thanks for this script.

    But i have this error :

    ./marlintool.sh -v
    Verifying build…
    readlink: illegal option — f
    usage: readlink [-n] [file …]
    Picked up JAVA_TOOL_OPTIONS:
    Erreur : impossible de trouver ou charger la classe principale processing.app.Base

    (On a mac).

    Thanks

      • Hi,

        Got this error on linux mint 32bit and ubuntu 64bit :

        ./marlintool.sh -v
        Verifying build…
        ./arduino/arduino: line 35: /home/mint/Downloads/marlintool-master/arduino/java/bin/java: cannot execute binary file: Exec format error

        Thanks

        • Did you change the “arduinoToolchainArchitecture” parameter to either “linux32” or “linux64” depending on your installs architecture? By default the script is configured for the RaspberryPi which has an ARM processor. So change the parameter then run “./marlintool.sh –clean” to remove the old toolchain and after that “./marlintool.sh –setup” again to download the correct toolchain.

          — The platform architecture is now autodetected by the script. —

          • I have just understood the link between octopi and marlin. The script allows to update the firmware using the raspberry connected to the printer (no link with octopi, just the same material). Sorry for the inconvenience and thank you for your help

  2. Yay! Though for other noobs… I downloaded the zip file, unpacked and FTP’d it to /home/pi/marlintool-master.
    Then, I used puTTY to get into my Raspberry Pi. There I CD to /home/pi/marlintool-master
    Then, I sh marlintool.sh -s which downloads stuff.
    Then, I sh marlintool.sh -m which downloads more stuff.
    Followed by a sh marlintool.sh -v and lots of text whizzed by.
    Then… sh marlintool.sh -u and yet more whizzing of text followed by:

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.00s

    avrdude: Device signature = 0x1e9705 (probably m1284p)
    avrdude: reading input file “/home/pi/marlintool-master/./build/Marlin.ino.hex”
    avrdude: writing flash (120730 bytes):

    Writing | ################################################## | 100% 29.74s

    avrdude: 120730 bytes of flash written
    avrdude: verifying flash memory against /home/pi/marlintool-master/./build/Marlin.ino.hex:
    avrdude: load data flash data from input file /home/pi/marlintool-master/./build/Marlin.ino.hex:
    avrdude: input file /home/pi/marlintool-master/./build/Marlin.ino.hex contains 120730 bytes
    avrdude: reading on-chip flash data:

    The screen went off and on and I saw Skynet.

    Now I need to figure out how to edit the configuration.h file

    Thank you! I had been stuck trying to do it from Windows, following all the so easy instructions and not getting the upload to my Anet A8 with this error “Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions”
    But, your script did it! Once I figured out what to do with a script 🙂

    Be happy for ever,
    Steve

  3. I have followed all this with some success. However although the anet keypad line is correct in Configuration.h the right hand button of the pad does not go forward through menus but backwards. This means I cannot get to the home position and cannot print anything. The printer has been working perfectly and I only flashed the board because with a previously installed version of Skynet3D my LCD would go haywire from time to time and display rubbish.

    • I’m afraid I can’t help you with this problem. I think it would be best to raise an issue on the marlin or Skynet3D github.

Please Post Your Comments & Reviews

Your email address will not be published or shared.