1

I'm trying to understand the "programmer-id" concept, as specified in -c avrdude's option.

avrdude asks me to choose a "programmer-id" among many it knows of. Let's say (just as an example) I have a Arduino 2560 to which I connect via USB, and I want to program it using the bootloader. Then, in this scenario, is one programmer-id and just one supposed to work?

More in general, one has

1) some particular board (MCU, -p in avrdude)

2) some particular programming method/connection (JTAG, ISP, development board, USB/serial, etc)

3) (if using bootloader) some particular bootloader code in Flash.

How are these things related with the programmer selection? I guess that some (most?) programmers-ids are specific to some programmer connection/method (AND probably with some hardware family?), and they have nothing to do with the bootloader. What is the programmer to use for a standard Arduino with bootloader, connected via USB? What more can be said?

Furthermore, the Arduino IDE lets me choose "Upload" and "Upload Using Programmer" (the first works for me, the second doesn't). Why this distinction? Isn't a programmer always used? What does the IDE do, under the hood (does it call avrdude?) when choosing "Upload" ?

3

If you are using the bootloader, you are not using a programmer. The programmer, when used, is connected to the ICSP pins on the Arduino. The bootloader however expects a well-defined sequence of data from the Arduino through the serial port immediately after reset. The bootloader recognizes that (if received) and reprograms the flash.

If you turn on verbose mode for uploading you will see the programmer type:

-carduino

That is, the Arduino is using the bootloader programming method.

See my post here: What happens when code is uploaded using the bootloader?


Furthermore, the Arduino IDE lets me choose "Upload" and "Upload Using Programmer" (the first works for me, the second doesn't).

Yes, with "Upload Using Programmer" you need a programmer, such as the AVRISP which you would plug into your USB port, and then select that as the type of programmer to use. In this case, your Arduino does not need to be plugged into the USB as the serial port is not used for programming.

Note that some programmers supply Vcc (ie. +5V) to the Arduino and some don't. The AVRISP doesn't.


Furthermore, it seems that that "Optiboot" is a different bootloader than the standard included in the Arduino.

As far as I know, recent Arduino Unos (and probably others) ship with Optiboot. Its main advantage is that it is smaller (only 512 bytes).

More in general, do avrdude need to know the particular bootloader?

I think the smaller boards use STK500 protocol (see links below) and the larger ones (eg. the Mega) use STK500 Version 2. That is because they have a larger address space. So yes, it needs to know the protocol.

When I switched my board type to Mega2560 the "-c" option changed to:

-cwiring

I am guessing from that, the "arduino" is code for "STK500" and "wiring" is code for "STK500 V2".

Protocols

  • Thanks! "The bootloader however sends a well-defined... " should be "The bootloader... expects ..."? Furthermore, I see "-cwiring" in my IDE (1.6.9) instead of "-carduino" – leonbloy Jun 20 '16 at 23:45
  • Furthermore, it seems that that "Optiboot" is a different bootloader than the standard included in the Arduino. Are they compatible, or should one change the "-c" option ? More in general, do avrdude need to know the particular bootloader? – leonbloy Jun 20 '16 at 23:54
  • You are right, it "expects" the protocol. I amended the reply. Your other questions addressed in the amended reply. – Nick Gammon Jun 21 '16 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.