[HowTo] Upload your 3d Printer Firmware in Linux

User avatar
JustinSB
Posts: 0
Joined: Tue Nov 28, 2017 6:54 am
Location: Deepest, darkest Yorkshire

Re: [HowTo] Upload your 3d Printer Firmware in Linux

Post by JustinSB » Wed Dec 20, 2017 6:24 pm

Geeetech in the latest version of Arduino

### DISCONNECT FROM REPETIER-HOST FIRST...!

Boards info came from the comments section at the bottom of:
http://www.instructables.com/id/How-to- ... eetech-Pr/

You can use the latest version of the Arduino IDE if you want to, you're not restricted to using version 1.0.1

IMPORTANT - Disconnect any other "printer" software which might be connected to your printer before you do any of this.

Install the latest Arduino IDE (at the time of writing it is 1.8.5). Once it has finished installing, you will find that it also creates directory called ~/Arduino in your home directory.

This directory is where we store both our source code and libraries. This is important, because you will find that you cannot save your changes to any source code files stored outside of this directory, and if we don't add one vital Arduino library here, you won't be able to compile anything.

First, we need to install "Arduino's LiquidCrystal Library with SPI", without which we can't compile the source code - as it runs the LCD display on the printer.

Go to https://playground.arduino.cc/Main/LiquidCrystal and download LiquidCrystal_1.zip (the one for "newer" versions of Arduino) from https://playground.arduino.cc/uploads/M ... stal_1.zip

Open the downloaded zip file & extract the LiquidCrystal directory to ~/Arduino/libraries/LiquidCrystal

Next, download the Geeetech firmware zip for your printer, then extract the "Marlin" directory straight into the Arduino directory - ie to ~/Arduino/Marlin

IMPORTANT - Before you do anything else, in your file manager, go to ~/Arduino/Marlin and DELETE the file Marlin.pde - which is an exact copy of the file Marlin.ino, put there for backwards compatibility. As we are using the latest version of Arduino, it only causes confusion and will cause errors later on if you leave it here.

Now, finally, we can open Arduino...

I usually go straight to the File menu, choose "Preferences" and tick the selection boxes for "Display line numbers" and "Update sketch files to new extension on save (.pde -> .ino) - which is why we deleted the .pde file from our Marlin directory, as we already have a duplicate .ino file there so it errors immediately. I also un-tick "Check for updates on startup", as this also causes massive problems, as we'll see later.

Next, in the File menu, choose Open... It should drop you straight into your ~/Arduino directory, so click into the Marlin directory and open Marlin.ino

Lots & lots of files will open in tabs, & the last tab on the right has a drop down arrow which lists all of the other source files whose tabs it can't display. You will probably need to scroll down here to get to some of the files that you will need to edit.

Now, go to the "Tools" Menu > "Board" > "Boards Manager"

Click on "Arduino AVR Boards", then select "1.6.11" from the "Select version" drop down menu in the bottom right hand corner and click "Install".

IMPORTANT - If you choose an updated version that is newer than 1.6.11, any time you try to compile your source code it will fail - for this reason, we really don't want to ever update this, which is why we turned automatic updates off in the preferences earlier.

Now, if you go back to the Tools Menu and choose Board again, you will now see a list of relevant boards - from which we can now select "Arduino/Genuino Mega or Mega 2560".

You will also see a small square icon with a magnifying glass, at the far right hand side of the top button bar, just above the tabs. If you hover over it, it will say "Serial Monitor", and when you click it, it will open a new window where you should set the Baud Rate to "250000 baud". This allows you to watch the active communications with your printer board. As you click on the "Serial Monitor" button, you can see the Printer LCD refresh and hear the Stepper Motors click, which also confirms that you're properly connected to the Printer.

You can now start to test that everything works as expected. Firsly, it's worth choosing "Verify/Compile" from the "Sketch" menu before you actually do anything, to check that it can actually compile your version of the software without any errors. This should only take a couple of seconds, maximum.

Once you have done this, it's really worth checking that your instrallation of Arduino IDE is 100% happy, & can find all of the libraries that it needs to run. It installs a hidden config directory into your home directory at ~/.arduino15 & inside this is a binary file that causes loads of people loads of problems, as if it can't find the libraries that it requires, it causes your compiled code uploads to fail. The binary is ~/.arduino15/packages/arduino/tools/avrdude/6.0.1-arduino5/bin/avrdude_bin and Google is full of people's problems with "avrdude: error while loading shared libraries". There is a really simple solution to this! Use the ldd function to find out what it is missing, then just create a symbolic link so that it can find it!

The avrdude binary file is called avrdude_bin & is deep in your home directory (change the path to match your system)

sudo ldd ~/.arduino15/packages/arduino/tools/avrdude/6.0.1-arduino5/bin/avrdude_bin

linux-vdso.so.1 (0x00007ffdf0d09000)
libusb-1.0.so.0 => /usr/lib/libusb-1.0.so.0 (0x00007f548a22b000)
libusb-0.1.so.4 => /usr/lib/libusb-0.1.so.4 (0x00007f548a025000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f5489e07000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f5489abb000)
libreadline.so.6 => not found
libncurses.so.5 => /usr/lib/libncurses.so.5 (0x00007f548985a000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f54894a2000)
libudev.so.1 => /usr/lib/libudev.so.1 (0x00007f5489284000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f548a444000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f5489080000)

NOTICE - it can't find libreadline.so.6

Now, we need to find if we have some version of libreadline installed (usually, you have the updated version 7 installed). I have mlocate installed, so I can just type
sudo locate libreadline

/usr/lib/libreadline.so
/usr/lib/libreadline.so.7
/usr/lib/libreadline.so.7.0
/usr/lib32/libreadline.so
/usr/lib32/libreadline.so.7
/usr/lib32/libreadline.so.7.0

OK, so now we know that I have both the 32 & 64 bit versions of libreadline.so.7 - but avrdude needs libreadline.so.6

All you have to do is to create a symbolic link between version 7 & 6 (but check your paths, as they are probably different & remember that you LINK THIS TO THAT ie "ln -s REAL_FILE SHORTCUT")

sudo ln -s /usr/lib32/libreadline.so.7.0 /usr/lib32/libreadline.so.6.0
sudo ln -s /usr/lib32/libreadline.so.7 /usr/lib32/libreadline.so.6
sudo ln -s /usr/lib/libreadline.so.7 /usr/lib/libreadline.so.6
sudo ln -s /usr/lib/libreadline.so.7.0 /usr/lib/libreadline.so.6.0

So now, if we run ldd again, we get this instead

sudo ldd ~/.arduino15/packages/arduino/tools/avrdude/6.0.1-arduino5/bin/avrdude_bin

linux-vdso.so.1 (0x00007ffc0f1ed000)
libusb-1.0.so.0 => /usr/lib/libusb-1.0.so.0 (0x00007f3f6febd000)
libusb-0.1.so.4 => /usr/lib/libusb-0.1.so.4 (0x00007f3f6fcb7000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f3f6fa99000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f3f6f74d000)
libreadline.so.6 => /usr/lib/libreadline.so.6 (0x00007f3f6f4ff000)
libncurses.so.5 => /usr/lib/libncurses.so.5 (0x00007f3f6f29e000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f3f6eee6000)
libudev.so.1 => /usr/lib/libudev.so.1 (0x00007f3f6ecc8000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f3f700d6000)
libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007f3f6ea90000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f3f6e88c000)
libtinfo.so.6 => /usr/lib/libtinfo.so.6 (0x00007f3f6e660000)

This fixed it for me, but on your system it may well have a different library that it can't find. The principle is exactly the same, & a little bit of searching will tell you what to link to where to fix your specific problem.

Once you have made sure that avrdude can find all of the shared libraries that it requires, we now need to check that it can actually compile & upload your source files. The easiest way to check this is just to change the author name STRING_CONFIG_H_AUTHOR from geeetech to your name on line 31 of Configuration.h - this is because each time you connect your printer to Repetier-Host, it echoes this string as part of the initialization string that it displays in the connection log, so you can instantly see that it's running the firmware that you haev just uploaded (just remember though, you can't have Repetier-Host connected while you are compiling & uploading your firmware using the Arduino software as they clash). Change geeetech to your name, then click the arrow button at the top of the screen to compile & upload your firmware. It takes a couple of seconds to complete the compile, & the upload should complete in under a minute or so. It will say "Upload complete..." when it's finished, & then you can click the "Connect" button in Repetier-Host & see your name as the Author of the firmware.


From here on, you can follow the instructions that Geeetech have given you to do whatever you need to do with the firmware.

catalinokim
Posts: 0
Joined: Tue Jan 02, 2018 12:22 pm

Re: [HowTo] Upload your 3d Printer Firmware in Linux

Post by catalinokim » Sun Feb 04, 2018 11:03 pm

Gracias a gente como tu, podemos intentar usar material como este

Post Reply