Uploading to Yun (32U4) from eclipse - How?

Hi,
I have all of my Arduino programs in Eclipse. I've brought in the latest Arduino sources so I can build for the Yun - 32U4. MY problem is I can't load anything onto the 32U4 using AVRDude. The Arduino IDE includes a piece of Java code which resets the Com port, opens it at 1200baud, and closes it... but I can't do this from Eclipse.

The Arduino playground seems to suggest I should be able to just press the 32U4 reset button and AVRDude will connect, but I can't get it to work.

Has anyone else managed to use AVRDude to load code onto the Yun outside of the Arduino IDE?
Cheers, Con

I prefer the eclipse environment as well, you can definitely do this. Exactly how depends on what OS you are working in.

Use run external tools in eclipse to kick off a script. Since I work in Linux I use bash scripts. The ones I list in the thread about flashing other arduinos from the Yun are straight from my eclipse setup.

GreyCon, take a look at stty
We use it is some test code we run on boards

If you are using the arduino eclipse plugin 2.1.0.3 and you are talking about uploading via USB there may be a way to get the upload button to work with yun.
As I have a hard time finding a way to implement the new library specifications there will probably never be a arduino eclipse plugin compatible with Arduino IDE 1.5.3/4 beta.
If desired I'm willing to look into hacking platform.txt and platform.txt to get it to work with Arduino IDE 1.5.2

Best regards
Jantje

I looked into my setup a bit more this morning, I am away from the computer I have this set up on but this should be close to what you need in your script:

echo $1
stty -F /dev/ttyACM0 1200;avrdude -C/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:$1:i;stty -F /dev/ttyACM0 115200

This works in linux, you would need a script set up for your OS, this may work on a mac but definitely not windows. You just make the script do what the IDE shows you in the little window at the bottom. You would need to find a program for your platform that is the equivalent of stty if you are not working on linux.

Here is how to set this up in the External tools in eclipse:

-On the main menu click Run, External Tools, External Tools Configurations
-Right Click on Program select New
-In the Name box put:
flash
-In the Location box click Browse File System, navigate to your script
-In the Arguments box put:
${project_loc}/Release/${project_name}.hex
-In the Build tab ucncheck the Build before launch box
-Click Apply, click close

Good Luck!

Folks,
thank you all so much for your help. Based on all of your suggestions, I pretty much have it working now. In case it may ever help anyone else, I am going to summarise the problem and solution.

I am trying to do all of my development work (Obj C, Java, C++ for Arduino) on Mac OSX these times, since I love my MBP with Retina so much. However I ran in to some problems with Eclipse, and the AVR Toolchain, so I decided to get it all working on Windows as a baseline.

I have some code in Eclipse, using the "Old" AVR Eclipse plugin (2.4) - (I haven't tried yours yet Jantje, but I will). I compiled the Arduino 1.5.4 Core, for Yun, and some sample code to try. I couldnt get it to load onto the Arduino.

I installed the actual Arduino IDE, and it managed to install code just fine. It turns out that the Arduino IDE has some Java code to open the serial port used for the Arduino Yun (COM6 in my case), set the BAUD rate to 1200bps, and close it again. Now, the odd thing. When it does this, the COM6 virtual port disappears, ( I could see this in the Windows Device Manager) and gets replaced, for a few seconds, by COM7. I guess this is when the Yun 32U4 Bootloader is active.

So, based on a suggestion from Federico, I used the Windows Mode command (Equivalent of STTY in *NIX) to set the baud rate for COM6 to 1200, waited for 1 second, and then tried the AVRDUDE command to upload my code, to COM7 ! Success!

Next step, based on wisdom from noblepepper, is to add this stuff as an external script to eclipse. I am so impressed that you even enumerated the steps for adding an external script to Eclipse for me! If you're ever in Dublin, I'm buying the beer.

So thanks again to each of you. I'm really enjoying the mix of technologies involved with this product, (I've been immersed in iOS Objective C and Java Web Services for the past year.) and if I can manage to give anything back to this community I will certainly do so.

Cheers,
Con

GreyCon:
I installed the actual Arduino IDE, and it managed to install code just fine. It turns out that the Arduino IDE has some Java code to open the serial port used for the Arduino Yun (COM6 in my case), set the BAUD rate to 1200bps, and close it again. Now, the odd thing. When it does this, the COM6 virtual port disappears, ( I could see this in the Windows Device Manager) and gets replaced, for a few seconds, by COM7. I guess this is when the Yun 32U4 Bootloader is active.

This is indeed how the leonardo and the yun are working. This can be very confusing (I know from experience)
There is a difference between yun and Leonardo on the dual com port.
When powering a leonardo (for instance by plugging it in a USB port) leonardo will do the dual port trick. My windows goes ping pong ping. 2 drivers need to be installed.
Yun does not try to bootload when powered on. This means thy second driver needs to be installed at the first trial to upload.

GreyCon:
I have some code in Eclipse, using the "Old" AVR Eclipse plugin (2.4) - (I haven't tried yours yet Jantje, but I will). I compiled the Arduino 1.5.4 Core, for Yun, and some sample code to try. I couldnt get it to load onto the Arduino.

Given your level of knowledge I'm not sure you'll like V2 of the plugin. But give it a try anyways :wink:
At least you can stay all mac.

GreyCon:
So thanks again to each of you. I'm really enjoying the mix of technologies involved with this product, (I've been immersed in iOS Objective C and Java Web Services for the past year.) and if I can manage to give anything back to this community I will certainly do so.

The mix of technologies is why I love arduino development in eclipse to. I have bash scripts, arduino code and lua code all in the same environment. They should because I use all of them for the same project so it is under version control together.

Best regards
Jantje

Well, it's never over ...

I seem to have bricked the 32U4 side of my Yun. I compiled my test code under Eclipse, (A trivial program that sends a string out the Serial port) , created an external batch file to:

  1. Set COM6 to 1200bps
  2. Wait 5 seconds
  3. AVRdude the .hex file to COM7

All of which seemed to work swimmingly. Pretty normal console output, and avrdude thanked my nicely at the end.

But... my COM7 port then disappeared, and my COM6 port never returned.

I've powered it all down, reset it, etc, but I'm not getting any virtual com ports, and no LEDs. The Linux side is alive, and I can connect to arduino.local.

Anyone any ideas? I seem to have over-written the bootloader?

Cheers,
Con

To get things working again I would use the Arduino IDE on the WiFi port, it combines the boot loader and sketch then writes the whole blob from linino through the gpio's like an ICP I believe.

To figure out what went wrong compare what the IDE is doing to what your script does and make them the same. In Linux I run each from the command line with &>output.txt to put all output to a file instead of the screen. I have no idea how to redirect in windows, sorry.

If I ever make it to Dublin I'll definitely take you up on that beer I've never met an Irishman that wasn't a lot of fun. If y'all ever get around Nashville I'll show you the best redneck dives in town!

Thanks Dr Pepper!
I had a similar thought process to you - but ended up doing it by uploading a small sketch, and using command-line tools on the YUN to re-flash the 32U4. I posted details on the forum in case anyone else ever has to do it.

I'm just about to start the comparison between my upload commands, and the IDE upload commands. Thanks for all your help and support. Nashville is on the list 8)

C

Does somebody managed to get it work to upload to a Yun via usb and a Mac finally?
If I try, I receive a problem notification saying: Leonardo port is not disappearing after reset

Im using Arduino IDE 1.5.6-r2
And the latest Eclipse Jantje plugin V2.2 (btw great work!)

Cheers

J

Ping

Please heeeeeelp :slight_smile:

I never got leonardo nor yun to work on my USB port. So there may be a problem.
There has been a fix in one of the latest version that has to do with the resetting of the board. Have you tried the nightly build?
And why not use the wifi upload? I prefer that one by far and it works with eclipse because I use it ]:D.
Best regards
Jantje

Thanks for your reply.

Please correct me if Im wrong (Im a newbie).
Im not using the wifi upload, because its not possible to use the serial console.
Or is there a way to use the console combined with wifi ?

I havent test nightly build so far. Will inform you about the result.

Cheers

J

calomy:
Im not using the wifi upload, because its not possible to use the serial console.
Or is there a way to use the console combined with wifi ?

there are ways to use the serial console. I know 3 of them there may be more.

  1. The most arduino way is use the bridge console.
  2. Connect usb yun leonardo to usb yun linino and run minicom manually (ssh->minicom)
  3. Do as 2 but setup a service.

For 1 see the bridge documentation.
For 2 and 3 see more details on http://blog.baeyens.it/#home

Best regards
Jantje

Thank you, I think the bridge serial function will work out for me!

Cheers

J

calomy:
Thank you, I think the bridge serial function will work out for me!

Cheers

J

Now I think of it. You will have to use the Arduino IDE serial monitor as this is not (yet) supported in eclipse.

What really worked out fpr me , is to use the ssh upload and the serial eclipse console
via , in my case , (mac) tty usbmodem.

Now upload via ssh + console via usbmodem = Im happy :wink:

Cheers

J

calomy:
What really worked out fpr me , is to use the ssh upload and the serial eclipse console
via , in my case , (mac) tty usbmodem.

Now upload via ssh + console via usbmodem = Im happy :wink:

Cheers

J

Cool
I had to google usb modem to understand what you are talking about.
Can you show a picture of how you connected the usbmodem to the yun?
Best regards
Jantje

Maybe I didnt explained it very well.
My Yun is connected via usb and recognized as /dev/tty.usbmodemXXXX.
This device can be addressed in the serial console in Eclipse.

Output via serial console is possible but not the programming.

Cheers

J