A*** Studio and Arduino Uno R3, program through USB?

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, this is my first post on this forum, bear with me. I have been trying to research whether it's possible to connect to the Arduino Uno board through AVR/Atmel studio via USB, instead of devices like the AVRISPMkII, but haven't found anything conclusive.

This is all I'm asking.

Atmel's FLIP software sounds like something on the right track but.. Yeah I don't know.

The Uno board has an ATmega16U2 which connects through serial to the main ATmega328P-PU, right? And it comes with some firmware already loaded on there. What is the difference between this and the stuff FLIP puts on there?

Basically, can I program the main processor through USB and **** Studio!? :D

Cheers!
~tck

sol i sinne - brun inne

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The magic you are looking for is called avrdude.exe

You cannot simply connect an Arduino and have AS6 drive it as if it were an Atmel device because, while it does use an Atmel protocol for the communication, the protocol it uses is actually an out of date one that Studio no longer supports.

So you build your "plain C" program in AS6 then you use avrdude.exe separately to send the resulting .hex file to the Arduino. In AS6 you can set up a menu entry or toolbar button to invoke avrdude so you can have it feel like it's being done from within AS6.

Ironically even if the Arduino had chosen to implement DFU which is one of Atmel's more recent programmer/bootloader protocols you STILL couldn't drive it from inside AS6 as it curiously does not come with Flip (the other side of DFU) built in. That too would need to be invoked as an external command (batchisp rather than avrdude in this case).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
The magic you are looking for is called avrdude.exe

You cannot simply connect an Arduino and have AS6 drive it as if it were an Atmel device because, while it does use an Atmel protocol for the communication, the protocol it uses is actually an out of date one that Studio no longer supports.

So you build your "plain C" program in AS6 then you use avrdude.exe separately to send the resulting .hex file to the Arduino. In AS6 you can set up a menu entry or toolbar button to invoke avrdude so you can have it feel like it's being done from within AS6.

Ironically even if the Arduino had chosen to implement DFU which is one of Atmel's more recent programmer/bootloader protocols you STILL couldn't drive it from inside AS6 as it curiously does not come with Flip (the other side of DFU) built in. That too would need to be invoked as an external command (batchisp rather than avrdude in this case).

Whoa, this is great but slow down.. Are you positively telling me that I can use AVRDuDe and USB? I know avrdude can communicate through the MkII an' that but through USB too? Straight out of the box? What firmware needs to be on the 16U2 in that case? Flip's or Ardui's or some new DuDe dito?

I didn't catch that other part about DFU and batchisp and that..

(REALLY appreciate your quick answer and help! :))

sol i sinne - brun inne

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Are you positively telling me that I can use AVRDuDe and USB?

Given that is exactly how the Arduino IDE itself talks to an Arduino board then "yes".
Quote:

I know avrdude can communicate through the MkII an' that but through USB too?

No mkII is involved in this. avrdude can actually communicate in about 50 different ways (which is what makes it the swiss army knife of AVR programming). Sure you can tell it to talk "avrispmkII over usb" and that's what it uses when talking to an AVRISPmkII over USB but you can also tell it to talk "stk500 protocol over UART via USB" and that's what it talks when it's talking to the bootloader in an Arduino.

The Arduino chip you are talking to (not the 16U2 as that's just doing a USB-UART conversion) needs to contain a copy of the Arduino bootloader (probably "Optiboot") which is what talks the AVR side of the stk500 protocol it uses.

All Arduinos ship out with their chip (the main one not the USB-UART conversion chip) programmed with the standard bootloader which is why the IDE (avrduded in fact) is able to talk to them with nothing more than a USB cable.

Ignore the DFU/batchisp bit. I was just responding to a (misleading) point you had made. That's all something quite different and of no relevance here (though if you really want to know Flip/batchisp is a PC program equivalent of avrdude but talks something different (in fact the protocol it talks is one of the few things avrdude cannot do!) and DFU is the equivalent of the Arduino bootloader inside the AVR).

BTW don't be misled by the 16U2 on your Arduino board. Just treat that as a "black box". It's not something you program at all - it's an MCU but it's there to do a fixed job and never changes (that job being USB to UART conversion). In the past Arduinos had an FT232 from FTDI onboard doing the same thing but I'm guessing the Arduino people did a bulk deal with Atmel to buy 16U2's cheaper than FT232 and that's why the later boards have that doing the same job instead.

BTW you are only about the ten gazillionth person to ask this same question about using non Arduino development environments for writing code to be programmed into Arduino boards so there are only about a million existing articles and forum posts talking about this exact same subject (tens of thousands of them on the Arduino forums alone). You can find many blogs and online tutorials about all this. There's even posts in this forum about how to setup AS6 to invoke avrdude on a menu entry or icon to smooth the flow. Almost everything relevant will contain the words "arduino avrdude"

Last Edited: Fri. Jan 17, 2014 - 03:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

God I hate myself sometimes but I just can't resist this one.

Why the asterisks?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

God I hate myself sometimes but I just can't resist this one.

Why the asterisks?


Great minds - I wondered the same.

I guess OP probably doesn't realise that this message board is owned and run by Atmel? (OK three asterisks is not enough for "Atmel" so maybe it's supposed to hide some other word??).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Quote:

Are you positively telling me that I can use AVRDuDe and USB?

Given that is exactly how the Arduino IDE itself talks to an Arduino board then "yes".

lol yeah alrite :D message recieved

clawson wrote:
Quote:

I know avrdude can communicate through the MkII an' that but through USB too?

No mkII is involved in this. avrdude can actually communicate in about 50 different ways (which is what makes it the swiss army knife of AVR programming). Sure you can tell it to talk "avrispmkII over usb" and that's what it uses when talking to an AVRISPmkII over USB but you can also tell it to talk "stk500 protocol over UART via USB" and that's what it talks when it's talking to the bootloader in an Arduino.

The Arduino chip you are talking to (not the 16U2 as that's just doing a USB-UART conversion) needs to contain a copy of the Arduino bootloader (probably "Optiboot") which is what talks the AVR side of the stk500 protocol it uses.

All Arduinos ship out with their chip (the main one not the USB-UART conversion chip) programmed with the standard bootloader which is why the IDE (avrduded in fact) is able to talk to them with nothing more than a USB cable.


Okay so I write the code, build it, then use avrdude to transfer the hex or elf file (not sure what the differences are but I'll google it don't worry) to the arduino uno through the usb cable using the appropriate options and commands and stuff..?
Yeah if you think about it the only difference between this and using the Arduino IDE to do everything is that I'm using another IDE before avrdude kicks in..
So then the original firmware attached to the black box, optiboot or whatever you said, should suffice.

Alright I'll scan the forum some more, thanks!

Oh the asterisks, I meant both AVR- and Atmel Studio so I chose asterisks to save room, and the letter A because they both start with it, and four letters in total so that you could match it to niether :D

sol i sinne - brun inne

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

(not sure what the differences are but I'll google it don't worry)

HEX only contains code, ELF has the potential to also contain fuse settings too.

Studio these days is unequivocally called "Atmel Studio" not just "AVR Studio" (as in the old days of version 4 and briefly version 5) because it caters for ARM and AVR (two variants) in one thing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No.. I still don't get it. In this guide they tell you to install the drivers for the Uno among others.. So Windows will fail to automatically install, and you have to choose manually, a file which you get with the Arduino IDE-package.

Is this where I can use FLIP instead? :s

sol i sinne - brun inne

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Flip/DFU/batchisp ARE A COMPLETE RED HERRING!!!

This is not rocket science. If you have an Arduino you probably already installed the Arduino IDE and I imagine you have built some sketches and transferred them into the Arduino board already? OK so you now have everything installed that is required to get programs to the Arduino board via it's bootloader (which has NOTHING to do with DFU or Flip!!).

All that changes now is that (a) you are going to write pain C/C++ in AS6 not use the Arduino IDE and (b) unlike the Arduino IDE that also does a "hidden" invocation of avrdude to get the built skteches to the board you are going to have to manually type an avrdude command yourself (or, as I say, setup a button in AS6 to do that each time after you build).

Assuming you have an Uno or other Arduno that uses a 155200baud bootloader (it probably does) the command is bascially going to be:

avrdude -p m328p -c arduino -P\\.\COMn -b 115200 -U flash:w:yourbuild.hex

This tells avrdude that it is programing a mega328P (thta is the chip on an Arduino Uno) that it should talk the Arduino protocol (stk500) that the COM port to use in "COMn" - replace "n" with the actual number of the com port where your Arduino appears (look under Device Manager in Windows) and that it should write a file called yourbuild.hex into the flash. Replace this with the name of the .hex file you are actually creating in Studio.

Some older Arduinos may require -b 57600 rather than -b 115200 and they my need something other than -p m328p

As I say you can find a 1,000 sites on the internet that tell you something similar to this - you are not the first to tread this path.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I give in - you clearly seem to have some understanding problem I cannot see and I fear I'm not the person who can help. Hopefully someone else will be along in a minute to try and help you.

(but did you even try that avrdude command I just suggested - what happened?).

Out.

EDIT: Hey the post I responded to just disappeared?!?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
EDIT: Hey the post I responded to just disappeared?!?

Yeah I deleted it when I saw you had responded!

I'm terribly sorry, I didn't see you had already answered, I just kept going :( You sir have been the most helpful source on the internet so far, I've asked on the Arduino forums aswell.

Ok, red herring, I won't be mentioning it again.

I haven't recieved my Arduino Uno yet, it's probably in the mail.
I'm not going to make any "sketches" and I won't use Arduino IDE, I've successfully used linux with avrdude before with an AT90CAN128 and windows with AS6 and the AVR Butterfly, using the AVRISPMkII in the latter case.

Please don't be mad at me :( The thing is I would just use the avrisp if I had one, but I don't! So I'm trying to figure out how to use the board without using the submitted IDE..

Maybe this will all clear up when I get my hands on it!

I'm sorry, it wasn't my intention to give you an aneurysm..

sol i sinne - brun inne