Solved: A-Star and Atmel Studio 7

Hello, All:

I downloaded and installed Studio 7 (version 7.0.594) on a Win7 system, and would like use it to program the A-Star Mini ULV. Programming the A* in the Arduino environment works fine, but I like to have more control.

After spending some time on the web, I believe this is possible. I now have Studio 7 partially configured to use an external tool which I named “avrdude”. I studied the procedure used by Arduino, and followed the basic outline for configuring Studio 6 here: engblaze.com/tutorial-using- … -projects/ (modified for atmega32u4).
Command:

Arguments:

-CC:\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -patmega32u4 -cavr109 -P\\.\COM18 -b57600 -D Uflash:w:"$(ProjectDir)Debug\$(TargetName).hex":i(Check “Use Output Window” in the external tool configuration box, to get verbose output.)

Avrdude is executed properly, but can’t talk to the A*. Upload fails as shown below. Judging from the behavior of the yellow LED on the A*, bootloader mode is never entered.

Using the verbose option in Arduino IDE (version 1.0.5-r2), programmer type -cavr109 is selected, 57600 baud, and the hex file uploads to the A* as expected. Strangely, the Arduino IDE reports that a Leonardo is found on COM19 instead of COM18 before executing avrdude. Naturally, COM19 doesn’t work with Studio 7.

Output from Studio 7:

[quote]avrdude.exe: Version 5.11, compiled on Sep 2 2011 at 19:38:36
Copyright © 2000-2005 Brian Dean, bdmicro.com/
Copyright © 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"

         Using Port                    : \\.\COM18
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       1024    8      0  9000  9000 0x00 0x00
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = “ÿ”"; type = F
Software Version = E.
avrdude.exe: error: buffered memory access not supported. Maybe it isn’t a butterfly/AVR109 but a AVR910 device?
[/quote]

I’ve tried a few other options, like -carduino, -cwiring -cavr910, but those fail with stk500_getsync: not in sync, resp=0x00, etc.

I’ve also tried pushing the reset button on the A* before uploading, but that doesn’t work.

Studio 7 will list the programmers it recognizes; shown below. None seem more appropriate than the ones I’ve already tried.

Suggestions appreciated!

(Note that there is a long thread on this topic on the AVRFreaks forum, with no obvious resolution: avrfreaks.net/forum/atmel-st … bootloader)

(Studio 7) Valid programmers are:
  c2n232i  = serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:998]
  dasa3    = serial port banging, reset=!dtr sck=rts mosi=txd miso=cts [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:985]
  dasa     = serial port banging, reset=rts sck=dtr mosi=txd miso=cts [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:972]
  siprog   = Lancos SI-Prog <http://www.lancos.com/siprogsch.html> [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:959]
  ponyser  = design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:946]
  89isp    = Atmel at89isp cable            [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:913]
  frank-stk200 = Frank STK200                   [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:899]
  blaster  = Altera ByteBlaster             [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:886]
  ere-isp-avr = ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf> [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:876]
  atisp    = AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/>  [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:866]
  dapa     = Direct AVR Parallel Access cable [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:855]
  xil      = Xilinx JTAG cable              [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:842]
  futurlec = Futurlec.com programming cable. [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:824]
  abcmini  = ABCmini Board, aka Dick Smith HOTCHIP [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:814]
  picoweb  = Picoweb Programming Cable, http://www.picoweb.net/ [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:804]
  sp12     = Steve Bolt's Programmer        [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:793]
  alf      = Nightshade ALF-PgmAVR, http://nightshade.homeip.net/ [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:777]
  bascom   = Bascom SAMPLE programming cable [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:767]
  dt006    = Dontronics DT006               [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:757]
  pony-stk200 = Pony Prog STK200               [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:745]
  stk200   = STK200                         [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:729]
  bsd      = Brian Dean's Programmer, http://www.bsdhome.com/avrdude/ [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:718]
  pavr     = Jason Kyle's pAVR Serial Programmer [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:710]
  dragon_pdi = Atmel AVR Dragon in PDI mode   [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:703]
  dragon_dw = Atmel AVR Dragon in debugWire mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:695]
  dragon_hvsp = Atmel AVR Dragon in HVSP mode  [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:687]
  dragon_pp = Atmel AVR Dragon in PP mode    [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:679]
  dragon_isp = Atmel AVR Dragon in ISP mode   [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:671]
  dragon_jtag = Atmel AVR Dragon in JTAG mode  [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:663]
  jtag2pdi = Atmel JTAG ICE mkII PDI mode   [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:655]
  jtag2avr32 = Atmel JTAG ICE mkII im AVR32 mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:647]
  jtagmkII_avr32 = Atmel JTAG ICE mkII im AVR32 mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:639]
  jtag2dw  = Atmel JTAG ICE mkII in debugWire mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:631]
  jtag2isp = Atmel JTAG ICE mkII in ISP mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:623]
  jtag2    = Atmel JTAG ICE mkII            [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:615]
  jtag2fast = Atmel JTAG ICE mkII            [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:607]
  jtag2slow = Atmel JTAG ICE mkII            [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:599]
  jtagmkII = Atmel JTAG ICE mkII            [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:591]
  jtag1slow = Atmel JTAG ICE (mkI)           [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:584]
  jtag1    = Atmel JTAG ICE (mkI)           [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:576]
  jtagmkI  = Atmel JTAG ICE (mkI)           [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:568]
  butterfly_mk = Mikrokopter.de Butterfly       [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:562]
  mkbutterfly = Mikrokopter.de Butterfly       [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:556]
  avr911   = Atmel AppNote AVR911 AVROSP    [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:549]
  avr109   = Atmel AppNote AVR109 Boot Loader [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:543]
  butterfly = Atmel Butterfly Development Board [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:537]
  usbtiny  = USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/ [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:531]
  usbasp   = USBasp, http://www.fischl.de/usbasp/ [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:525]
  avr910   = Atmel Low Cost Serial Programmer [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:519]
  stk600hvsp = Atmel STK600 in high-voltage serial programming mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:513]
  stk600pp = Atmel STK600 in parallel programming mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:507]
  stk600   = Atmel STK600                   [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:501]
  stk500hvsp = Atmel STK500 V2 in high-voltage serial programming mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:495]
  stk500pp = Atmel STK500 V2 in parallel programming mode [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:489]
  stk500v2 = Atmel STK500 Version 2.x firmware [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:483]
  mib510   = Crossbow MIB510 programming board [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:477]
  stk500v1 = Atmel STK500 Version 1.x firmware [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:471]
  stk500   = Atmel STK500                   [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:465]
  buspirate = The Bus Pirate                 [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:455]
  avrisp2  = Atmel AVR ISP mkII             [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:449]
  avrispmkII = Atmel AVR ISP mkII             [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:443]
  avrispv2 = Atmel AVR ISP V2               [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:437]
  avrisp   = Atmel AVR ISP                  [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:431]
  jtagkey  = Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2 [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:408]
  2232HIO  = FT2232H based generic programmer [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:382]
  avrftdi  = FT2232D based generic programmer [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:355]
  arduino  = Arduino                        [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:335]
  wiring   = Wiring                         [C:\Arduino\hardware/tools/avr/etc/avrdude.conf:329]

Solved.

The Leonardo/A-Star bootloader auto-increments the port address, so -cavr109 -P\\.\COM19 is correct (if the board initially comes up as COM18).

The trick is to rapidly push the A-Star RESET button twice to put it into bootloader mode, then quickly run the upload command in Studio 7.

It would be nice if this could be automated, as the Arduino IDE somehow manages!

PS: I like the optimism of Studio 7. Your program is identified as the “Solution”. It is usually the “Problem”.

The requisite blinky “Solution”:

/*
 * test1.c
 *
 * Created: 10/20/2015 7:03:09 PM
 * Author : Jim Remington
 * ATmega32u4
 */ 
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    DDRC |= (1 << DDC7); // Arduino pin 13 as output.
    while(1)
    {
	    PORTC |= (1 << PORTC7); // Turn the LED on.
	    _delay_ms(400);
	    PORTC &= ~(1 << PORTC7); // Turn the LED off.
	    _delay_ms(600);
    }
}

Hello, Jim.

Thank you for your interest in the A-Star 32U4. The bootloader has a different set of USB descriptors than the running sketch, so it will generally be assigned to a different COM port than the sketch. The bootloader has no control over what COM port number is assigned to it; that number is chosen by Windows, and will typically be one greater than the highest previously-assigned COM port number.

When you click the Upload button in the Arduino IDE, it typically sends a special USB command to the running sketch on the A-Star that tells it to stop running and get into bootloader mode. This command is sent by simply opening the sketch’s COM port, setting the baud rate to 1200, and then closing it. The Arduino IDE then waits for a new COM port to appear before running AVRDUDE. You can see the details of this operation by enabling verbose upload output in the Preferences window, and you can see the Arduino core code that handles the request in CDC.cpp.

As far as we know, AVRDUDE itself does not have any of the features needed to get the A-Star into bootloader mode or to wait for the bootloader’s COM port to appear. So we recommend that you follow the instructions from the “Programming using avr-gcc and AVRDUDE” section of the A-Star 32U4 user’s guide if you want to use avrdude without the Arduino IDE. It looks like you already figured that out though.

–David

Hi, David:

The A Star User Guide is very professional and extremely well done. I did find it very useful and highly recommend it. Great work! The WinAVR examples are fine, but much of the advice did not seem relevant to configuring Studio 7.

Unfortunately I missed the line suggesting to push the reset button twice, but figured that out by reading the description of the bootloader startup in the User Guide. Finally, the Blink example came from the guide (Studio 7 automatically adds the author/date headers).

Cheers, Jim

1 Like