Developing for Arduino on Eclipse
As a side-project I started to develop on the Arduino platform (more on the project-of-the-day later).
First Steps
Getting going on windows was easy: setting up Arduino 1.0.1, compiling and running the “blink” demo, changing the frequency etc … was straightforward.
Then: i found grbl. Flashing the premade 0.8a firmware from grbl – instant success.
Then: setting up the avr toolchain on a linux machine (Ubuntu 12.04), checking out with git, developing with joe and via the command line. Easy again.
Eclipse
Wanting some more comfort (and working on my Win7 laptop), i thought of running eclipse with an AVR plugin … First thing you find is the “avr-eclipse”. It seems you have to install avr-gcc and avrdude separately …. Then i found the Arduino eclipse plugin … It’s reusing the Arduino SDK … so all the additionally required tools and headers come in one package.
Issues
Downloaded the current “Juno” release of eclipse in c/c++ flavor, installed the plugin from the Arduino plugin update site: http://www.baeyens.it/eclipse/update … creating a project didn’t work. Well, reading the plugin’s page a little more carefully revealed that it’s not yet compatible with Juno.
Downgraded to “Indigo”. Installed “Uncategorized/Arduino Eclipse Plugin/1.2.4″ version of it. Now setting up a project works. Imported grbl code … but: compile errors:
Description Resource Path Location Type first defined here serial.c /grbl line 109 C/C++ Problem first defined here serial.c /grbl line 158 C/C++ Problem make: *** [grbl.elf] Error 1 grbl C/C++ Problem The type 'HardwareSerial' must implement the inherited pure virtual method 'Print::write' HardwareSerial.h /Arduino_Uno/arduino line 64 Code Analysis Problem multiple definition of `__vector_18' HardwareSerial.cpp /Arduino_Uno/arduino line 102 C/C++ Problem multiple definition of `__vector_19' HardwareSerial.cpp /Arduino_Uno/arduino line 196 C/C++ Problem
Solution
After a lot of googling:
- remove the “=0″ from the write function in “Print.h” (make it non-virtual)
... void clearWriteError() { setWriteError(0); } virtual size_t write(uint8_t); // = 0; size_t write(const char *str) { return write((const uint8_t *)str, strlen(str)); } ... - make the project NOT link against the aurduino library (gets rid of the “multiple definition”, grbl doesn’t use the default libraries anyway): delete the reference on “<project>/Properties/C/C++ Properties General/Paths and Symbols/Libraries”
- add “-CC:\dev\arduino-1.0.1\hardware\tools\avr\etc\avrdude.conf” (without the quotes!) as an “Other” option on the AVRdude “Other”-setup tab. If you now choose to automatically upload the hex file during the build process, avrdud will find it’s platform definition file.
- install “eGit” via the eclipse-integrated “Eclipse Marketplace”, create a repo on github, spawn a personal repo from chamnit’s “edge” version, do some changes … and commit.
Now grbl compiles without errors and the .hex file seems to have a “similar” size compared to the shell compiled version. I’ll test the firmware on the actual hardware tonight …
Update: uploading to the arduino works like a charm …
