THIS SOLUTION IS NO LONGER MAINTAINED.
Follow the official guide for building based on PlatformIO instead: https://marlinfw.org/docs/basics/install_platformio_cli.html
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.
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.
Code
here on github: https://github.com/mmone/marlintool
or download directly as a zip: https://github.com/mmone/marlintool/archive/master.zip
Build configuration
Before first use: Rename the marlintool.params.example file to “marlintool.params”
In its default configuration the script is setup to build the official “Marlin” firmware but can be easily reconfigured to build any Marlin variant.
Several additional parameters in the “marlintool.params” file allow to adapt the script to your needs.
parameter | description |
---|---|
marlinRepositoryUrl | The marlin git repository. |
marlinRepositoryBranch | The branch of the configured repo to use. |
marlinDependencies | A list of dependencies to download in the format: [name],[repo url],[library directory](optional). A library directory should only be specified if the library is not in the root of the repository. |
hardwareDefinitionRepo | If you build for the Anet board this downloads the necessary hardware definition for the Arduino build environment. If you dont need this set it to an empty string. |
boardString | The Anet board identifier. |
arduinoToolchainVersion | The Arduino toolchain version to use. The build platform and architecture are auto detected. At the moment Linux 32 Bit, 64 Bit, ARM and OS X are supported. |
port | The serialport to use for uploading. |
arduinoDir | Where to put the Arduino toolchain. |
marlinDir | Where to checkout Marlin sources. |
buildDir | The build directory. |
Reminder: If you are running octopi on you Raspberry you need to disconnect it from your printer before uploading, otherwise the serial port is blocked.
Note: On OS X due to how the Arduino toolchain is packaged the Arduino splash screen will be displayed even when the toolchain is used from the commandline. This will cause the terminal window you launch marlintool from to lose focus. It also means that a build cannot be launched from a remote ssh session.
Building for Anet Hardware
If you are building the firmware for the Anet A6/A8 you can find suitable example configurations in the Marlin sources at: 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.
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.
I just want to say thank you, this is a great tool and it really helped me out. Awesome.
You’re welcome. Glad it helped.
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
The script only works on Linux, on Mac you can build in the Arduino IDE. If you want to build on the commandline have a look at the new Arduino CLI here: https://playground.arduino.cc/Learning/CommandLine.
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
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
hey!
great script – i have got my a8 clone flashed – was hoping the auto level function was in by default but doesnt seem to be – is it obvious how you include it? do i edit the Configuration.h file?
Thanks
Alan
Hi Alan,
Sure that is possible. The firmware you build and loaded is Marlin. There are many tutorials out there that explain how to configure autoleveling for the A8. For example: https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling
Happy printing
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.
Is this still the best method to build marlin on the pi?
Could you update this for the current marlin 1.1.9 or 2.0? I would like to build it on a raspberry pi 3b for the tevo tornado but it fails starting by not finding arduino 1.8.7 since it’s now at 1.8.13. It grabs libs that I think are only for anet as tevo is a mega2560 chip.
Using the ide fails miserably trying to compile hte th3d unified firmware (based on marlin) with error’s the windows users don’t get.
I’m not planing to update this. The best solution for building on the Pi is probably PlatformIO as suggested by the official documentation: https://marlinfw.org/docs/basics/install_platformio_cli.html