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 for ARM. Everything is standalone, nothing is installed.

It also works on Linux in general. 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. The script is setup by default to build the Marlin fork “Skynet3D” for the Anet A8 Prusa clone.
Recently Anet A6/A8 support has been merged back into the main Marlin branch. You can find example configurations for Anet printers in the Marlin sources at: github.com/MarlinFirmware/Marlin/tree/1.1.x/Marlin/example_configurations/Anet
If you want to build stock Marlin change the “marlinRepositoryUrl” parameter respectively.

If you build for non Anet platforms you can also set the parameter “hardwareDefintionDirectory” to an empty string, this prevents the script from trying to copy the board definition that is needed for the A8.

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.

-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.

 
 
 
 
 
 
Gearbest  promotion

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

8 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.

          • 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

Please Post Your Comments & Reviews

Your email address will not be published or shared.