Adam @ Hilltop Cottage › Using Atmel Studio 6 IDE With Arduino (Uno and Leonardo)

8
Using Atmel Studio 6 IDE with Arduino (Uno and Leonardo) The benefits of the Atmel Studio 6 IDE (if you can get to grips with it) are described in various places so I won’t repeat them here. For my part, I began using it with an AVR Dragon board for programming micrcontrollers directly (i.e. not using the arduino or similar development boards). I have also started writing some libraries and found the Arduino IDE to be a bit limited. I wanted to be able to use Atmel Studio to create programs that would also be usable, ideally with no change, on Arduino boards with the Arduino IDE being used. A further complication is that I have both Uno and Leonardo boards, which have a different processor and so need separate code compilation. There are several guides to achieving this kind of thing (Google “atmel studio arduino”) but most seemed to be rather involved and not well suited to having boards with different processors. The best I found, which is not at all “involved”, was by Elco Jacobs. He approached the task with the kind of strategy I wanted and his account and example code saved me a lot of trial and error. There were a few points where I wanted to do things a little differently; this post is about the changes and some experiences along the way. It is partly written so I remember how it works… There are two main parts to getting things to work: compiling the code and uploading to the arduino. Although I do have an AVR Dragon and could have used in-system programming (ICSP), I wanted to be be able to use the normal process of using the serial upload over USB and to leave the bootloader intact. The end point of the following, which is not as complicated as it looks, is that a new Arduino IDE compatible “sketch” can be begun by clicking the New Project icon in the tool bar and selecting one of two templates according to the target board. 1 – compiling the code This is the easier part of the two. The approach taken can be broken down into two: configuring Atmel Studio and creating a C++ harness within which a verbatim Arduino sketch can be executed. Since there are differences between Uno and Leonardo, I created two versions of the following steps: one for each board. 1a) configuring Atmel Studio Start off creating a new Executable C++ project and choose the correct microcontroller type (ATmega328P for Uno and ATmega32U4 for Leonardo). Open the project properties and select the “toolchain” set of properties. Under “AVR/GNU C++ Compiler” you should see several groups of properties. Directories Add two entries to locate the source files for the Arduino core and be sure to un-check the “relative path” option. These are to be found wherever you installed the Arduino IDE. For me, and for the Uno, they are: C:\Program Files\Arduino\hardware\arduino\cores\arduino C:\Program Files\Arduino\hardware\arduino\variants\standard The second of these would have “leonardo” instead of “standard” for the Leonardo board. If you use any of the Arduno libraries, you must add additional entries to “Directories” for each one: e.g. “C:\Program Files\Arduino \libraries\EEPROM” Optimisation Set the compiler to optimise for size and check the -ffunction-sections option. In addition, under “AVR/GNU Linker”, set the optimisation to garbage collect unused sections. Symbols Add two entries (these are applicable for Uno and Leonardo; the first denotes “Arduno 1.0 libraries” and the second denotes a 16MHz clock): ARDUINO=100 F_CPU=16000000L 1b) the sketch harness Two C++ files are used. One will contain the sketch and one contains a few lines of code to hook in the Arduino core libraries and the main program from which the usual “setup()” and “loop()” components of a sketch are called. I named these “sketch.cpp” and “main.cpp” respectively. This arrangement means that if you want to compile the same sketch with different Arduino boards as the target you can use exactly the same sketch.cpp in two different Atmel Studio projects. The neatest approach would be to point both projects at the same file, rather than copying it, of course! sketch.cpp If you already have an arduino sketch (.ino or .pde) then the content of it may just be copied and renamed sketch.cpp. There are, however, two small extras that may be required at the top of the sketch: Adam @ Hilltop Cottage Adam @ Hilltop Cottage › Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w... 1 of 8 10/27/2014 8:02 PM

description

arduino

Transcript of Adam @ Hilltop Cottage › Using Atmel Studio 6 IDE With Arduino (Uno and Leonardo)

  • Using Atmel Studio 6 IDE with Arduino (Uno and Leonardo)The benefits of the Atmel Studio 6 IDE (if you can get to grips with it) are described in various places so I wont repeat them here. For mypart, I began using it with an AVR Dragon board for programming micrcontrollers directly (i.e. not using the arduino or similardevelopment boards). I have also started writing some libraries and found the Arduino IDE to be a bit limited. I wanted to be able to useAtmel Studio to create programs that would also be usable, ideally with no change, on Arduino boards with the Arduino IDE being used.A further complication is that I have both Uno and Leonardo boards, which have a different processor and so need separate codecompilation.

    There are several guides to achieving this kind of thing (Google atmel studio arduino) but most seemed to be rather involved and notwell suited to having boards with different processors. The best I found, which is not at all involved, was by Elco Jacobs. He approachedthe task with the kind of strategy I wanted and his account and example code saved me a lot of trial and error. There were a few pointswhere I wanted to do things a little differently; this post is about the changes and some experiences along the way. It is partly written so Iremember how it works

    There are two main parts to getting things to work: compiling the code and uploading to the arduino. Although I do have an AVR Dragonand could have used in-system programming (ICSP), I wanted to be be able to use the normal process of using the serial upload over USBand to leave the bootloader intact.

    The end point of the following, which is not as complicated as it looks, is that a new Arduino IDE compatible sketch can bebegun by clicking the New Project icon in the tool bar and selecting one of two templates according to the target board.

    1 compiling the codeThis is the easier part of the two. The approach taken can be broken down into two: configuring Atmel Studio and creating a C++ harnesswithin which a verbatim Arduino sketch can be executed. Since there are differences between Uno and Leonardo, I created two versions ofthe following steps: one for each board.

    1a) configuring Atmel StudioStart off creating a new Executable C++ project and choose the correct microcontroller type (ATmega328P for Uno and ATmega32U4 forLeonardo).

    Open the project properties and select the toolchain set of properties. Under AVR/GNU C++ Compiler you should see several groupsof properties.

    Directories

    Add two entries to locate the source files for the Arduino core and be sure to un-check the relative path option. These are to be foundwherever you installed the Arduino IDE. For me, and for the Uno, they are:

    C:\Program Files\Arduino\hardware\arduino\cores\arduinoC:\Program Files\Arduino\hardware\arduino\variants\standard

    The second of these would have leonardo instead of standard for the Leonardo board.

    If you use any of the Arduno libraries, you must add additional entries to Directories for each one: e.g. C:\Program Files\Arduino\libraries\EEPROM

    Optimisation

    Set the compiler to optimise for size and check the -ffunction-sections option.

    In addition, under AVR/GNU Linker, set the optimisation to garbage collect unused sections.

    Symbols

    Add two entries (these are applicable for Uno and Leonardo; the first denotes Arduno 1.0 libraries and the second denotes a 16MHzclock):

    ARDUINO=100F_CPU=16000000L

    1b) the sketch harnessTwo C++ files are used. One will contain the sketch and one contains a few lines of code to hook in the Arduino core libraries and themain program from which the usual setup() and loop() components of a sketch are called. I named these sketch.cpp and main.cpprespectively.

    This arrangement means that if you want to compile the same sketch with different Arduino boards as the target you can use exactly thesame sketch.cpp in two different Atmel Studio projects. The neatest approach would be to point both projects at the same file, rather thancopying it, of course!

    sketch.cpp

    If you already have an arduino sketch (.ino or .pde) then the content of it may just be copied and renamed sketch.cpp.

    There are, however, two small extras that may be required at the top of the sketch:

    Adam @ Hilltop Cottage

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    1 of 8 10/27/2014 8:02 PM

  • if there are any functions other than void setup() and void loop() then it is necessary to add a function prototype. This means that ifthere is a function void serialMessage() then you must add void serialMessage(); at the head of sketch.cpp in addition to thefunction itself. Google arduino function prototype to find out more.

    1.

    if a library such as EEPROM is used then it may be necessary to change the #include to point to the .cpp file rather than the .h file.If EEPROM.h does NOT contain a #include then you need to point to EEPROM.cpp from the sketch otherwisethe compiler will not find the definition of EEPROM. Wire and SD libraries are even more tedious in that there are 1 or moreadditional files to include check the error messages, add the #include and if necessary also add a new directory in the C++Compiler options.

    2.

    Keep these extras together and above the body of the sketch with an appropriate comment line if you intend to share the code (or justwant to be neat, keep sane).

    As an alternative to adding prototypes manually, it is possible to compile and upload in the Arduino IDE and then to grab the C++ codethat the IDE creates during its compile process. To find where this is, go to File|Preferences and set the Arduino IDE to Show verboseoutput during: [x] compilation. This will cause the temporary directory containing the C++, all compiled intermediates and the .hex fileused by the uploader to be revealed. The .cpp should be the same as the sketch but with a few extra lines near the top of the listing.Replace the template sketch.cpp with this.

    main.cpp

    This is really just a combination of two of Elco Jacobs files with a few edits. Since things are a little different for Uno and Leonardo, themain.cpp file differs between the two versions. Remember that the end point is a separate template for each board so two versions arecreated rather than having to comment out or uncomment code blocks according to the board in use.

    NB: You may have to uncomment or add one or mode .cpp or .h files from the Arduino core libraries. See the "//Unused sourcefiles" but also be aware there may be some not listed in that section.

    main.cpp for Uno12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455

    #define ARDUINO_MAIN // Disable some warnings for the Arduino files#pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wsign-compare"#pragma GCC diagnostic ignored "-Wattributes"#pragma GCC diagnostic ignored "-Wunused-variable"#pragma GCC diagnostic ignored "-Wuninitialized" #include extern "C"{

    #include }

    // Standard Arduino source files for serial:#include // Other source files, depends on your program which you need#include #include #include #include #include //analog read/write functions#include #include #include // Unused source files://#include //#include //#include //#include //#include // Restore original warnings configuration#pragma GCC diagnostic pop

    int main(void){

    init();

    setup();

    for (;;) {loop();if (serialEventRun) serialEventRun();

    }return 0;

    }

    main.cpp for Leonardo1234

    #define ARDUINO_MAIN // Disable some warnings for the Arduino files#pragma GCC diagnostic push

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    2 of 8 10/27/2014 8:02 PM

  • 56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263

    #pragma GCC diagnostic ignored "-Wsign-compare"#pragma GCC diagnostic ignored "-Wattributes"#pragma GCC diagnostic ignored "-Wunused-variable"#pragma GCC diagnostic ignored "-Wuninitialized" #include extern "C"{

    #include }

    // Arduino Leonardo source files for serial:#define USB_VID 0x2341#define USB_PID 0x8036#include #include #include // Other source files, depends on your program which you need#include #include #include #include #include //analog read/write functions#include #include #include // Unused source files://#include //#include //#include //#include //#include // Restore original warnings configuration#pragma GCC diagnostic pop

    int main(void){

    init();

    #if defined(USBCON)USBDevice.attach();#endif

    setup();

    for (;;) {

    loop();if (serialEventRun) serialEventRun();

    }return 0;

    }

    Try it!

    Given the above, it should be possible to cut and paste the blink sketch into sketch.cpp and compile using F7 or the Build menu.

    2 uploadingUploading can be a bit of a pig. The smooth way the Arduino IDE works is, for me, its main redeeming feature. There are several optionsand I began by using the rather nice MegunoLink tool (which may be downloaded for free and a donation made). MegunoLink allows youto locate the .hex file that is created after compilation and to upload it with ease. It uses avrdude behind the scenes, just as the ArduinoIDE does. MegunoLink also includes a rather nice plotting feature, where you can send formatted data over Serial and plot it in real time.Nice! The MegunoLink site also gives an alternative recipe for using AtmelStudio alongside MegunoLink.

    For better integration of avrdude with Atmel Studio, you have to do a bit of fiddling. A lot more fiddling was required to get a usableapproach for the Leonardo. The end point is upload over the normal USB connection by the click of a mouse or keyboard shortcut insideAtmel Studio.

    Setting up for Uno

    Tools > External Tools

    Add a new tool, give it a title like Uno Serial Upload and set it up something like this (you may need to change the file paths to matchwhere you installed the Arduino IDE to and you may need to change COM3):

    Command = C:\Program Files\Arduino\hardware\tools\avr\bin\avrdude.exeArguments = -C"C:\Program Files\Arduino\hardware\tools\avr\etc\avrdude.conf" -patmega328p -carduino -P\\.\COM3 -b115200-Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":iI also checked the Use Output window option, which causes the avrdude messages to appear where compiler messages usuallydo.

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    3 of 8 10/27/2014 8:02 PM

  • A new external tool should be accessible from the Tools menu on saving this data. In use it is essential to first select (click on) the projectin the Project Explorer window. This is so that the $(ItemFilenName) is correct. If you have sketch.cpp selected then Atmel Studio tries toinvoke avrdude to upload sketch.hex, which does not exist.

    Setting up for Leonardo

    It would have been nice if the same recipe as for the Uno could be followed, with a simple change to the -p and -c flags in the argumentslist. Sadly, the Leonardo needs to be given a kick before it is ready to receive avrdude. This is pretty ugly design IMO. The kick is givenby making a connection at 1200 Baud, waiting a while for the Leonardo to run its bootloader and get ready and only then trying to useavrdude. The COM port usually changes after the kick and changes back when avrdude finishes. Usually! Yes, usually: sometimes Ifound it didnt change back after running avrdude if there was an error condition. You can watch this happening in the Device Manager orupload a sketch in the Arduino IDE with verbose output enabled (go to Preferences to enable verbose output) to see the alternative COMport.

    The easiest option was to adapt Elco Jacobs Python code, which is what the following code shows. Alternatively, you could just followElcos approach but NB that I had problems due to space characters in the path to my Arduino IDE directory (i.e. Program Files).

    Serial Uploader.py1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465

    import sysimport subprocess as subfrom time import sleep # command line arguments are:# first is the arduino IDE installation dir# second is the arduino board type# third is the .hex file# fourth is the upload port# fifth *** only used if Leonardo; omit otherwise *** serial port used to put leonardo into bootloader mode arduinoPath = sys.argv[1]boardType = sys.argv[2]hexFile = sys.argv[3]port2 = sys.argv[4] if(boardType == 'leonardo'): import serial port = sys.argv[len(sys.argv)-1] avrconf = arduinoPath + '/hardware/tools/avr/etc/avrdude.conf'avrdude = arduinoPath + '/hardware/tools/avr/bin/avrdude'avrsize = arduinoPath + '/hardware/tools/avr/bin/avr-size' boardsFile = open(arduinoPath + '/hardware/arduino/boards.txt', 'rb').readlines() boardSettings = {} for line in boardsFile: if(line.startswith(boardType)): # strip board name, period and \n setting = line.replace(boardType + '.', '', 1).strip() [key, sign, val] = setting.rpartition('=') boardSettings[key] = val # check program size against maximum sizep = sub.Popen([avrsize,hexFile], stdout=sub.PIPE, stderr=sub.PIPE)#, shell=True)output, errors = p.communicate()if errors != "": print 'avr-size error: ' + errors + '\n' exit print ('Progam size: ' + output.split()[7] + ' bytes out of max ' + boardSettings['upload.maximum_size'] + '\n') programCommand = [avrdude, '-C'+avrconf, '-F' , '-p'+boardSettings['build.mcu'] , '-c'+ boardSettings['upload.protocol'] , '-b' + boardSettings['upload.speed'] , '-P'+port2, '-Uflash:w:'+hexFile+':i'] # open and close serial port at 1200 baud. This resets the Arduino Leonardoif(boardType == 'leonardo'): ser = serial.Serial(port, 1200) ser.close() sleep(4) # give the bootloader time to start up p = sub.Popen(programCommand, stdout=sub.PIPE, stderr=sub.PIPE)#, shell=True)output, errors = p.communicate()# avrdude only uses stderr, append itprint errors

    The idea is to call this bit of python code as an External Tool, similar to the way avrdude was called in the Uno example. You will need toinstall Python and pySerial. You may also need to change the PATH to include the directory into which Python was installed. I put theSerial Uploader.py in the Atmel Studio solutions directory.

    This time set up the external tool like this:

    Command = python.exeArguments = C:\Documents and Settings\Adam\My Documents\Atmel Studio\Serial Uploader.py C:\Program Files\Arduino

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    4 of 8 10/27/2014 8:02 PM

  • leonardo $(ProjectDir)Debug\$(ItemFileName).hex COM6 COM7I also checked the Use Output window option, which causes the avrdude or python messages to appear where compiler messagesusually do.

    The final argument, COM7 in my case, is the one the Leonardo is attached to when you plug it in. i.e. the COM port you would use inthe Arduino IDE. COM6 is the one that is switched to after the kick. You will find that there is quite a lot of delay when using thisscript see the sleep(4) command so do not panic if nothing appears to happen at first.

    Obviously, the same python code could also have been used for the Uno case but having already got that one working, I left it alone.

    Configuring toolbar and keyboard shortcuts

    I dont like stumbling through menus. Use Tools > Customise then select the Commands tab and follow your nose to add a toolbar buttonor keyboard shortcut for the External Tool x.

    3 a nice-to-have creating project templatesAtmel Studio allows you to create template projects, which you can select when creating a new project. The template includes all of thecompiler options, the processor type and the C++ files. I created a template for each of Uno and Leonardo. And if you just want to grab thetemplates (bearing in mind they contain the paths to my Arduino installation): Arduino Uno Arduino Leonardo (copy these into AtmelStudio\Templates\ProjectTemplates or use File|Import menu). Ive also done a similar job for a library template but with some VisualStudio placeholders (Atmel Studio is basically Microsoft Visual Studio under a bit of customisation), but only for Uno: Uno LibraryTemplate. The library does not, of course, use the main/sketch convention. Note that, for a reason I cannot fathom, the compileroptimisation setting (-Os) is not correct when a template is used. It looks OK in the template project file but something goes wrong whencreating a project from the template.

    Once you have parts 1 and 2 completed and working (e.g. using the blink example), all you have to do to create a template is File >Export Template and follow your nose

    My templates have no libraries to keep things minimal by default . Hence, when I create a project using a template, any libraries will needentries in Directories as in step 1a {edit: it might have been better to include them all and to delete lines when not needed}.

    4 a recommended Atmel Studio ExtensionThere is an extension for Atmel Studio that essentially does the same as the Arduino IDE Serial Monitor. It is called Terminal Windowand it can be installed using Tools > Extension Manager. This is not a command window, in spite of what the icon appears to show.Once installed, the terminal window can be started from the View menu. I chose to dock mine to the bottom of the Atmel Studio window,which causes it to become a tab alongside the compiler output and errors/warnings tabs.

    Licence etcElco made his code available under GPL v3 and you should consider the source code given above to be distrubuted under the same termssince it is a derivative of his work.

    * Copyright 2012 Adam Cooper, based heavily on the work of Elco Jacobs.* See http://www.elcojacobs.com/easy-to-use-atmel-studio-project-for-arduino-and-programming-the-arduino-from-python/** This is free software: you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation, either version 3 of the License, or* (at your option) any later version.** This software is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** See: GNU General Public License

    This was written by Adam. Posted on Saturday, December 1, 2012, at 9:23 pm.

    Filed under Arduino, Microcontrollers. Bookmark the permalink. Follow

    comments here with the RSS feed. Post a comment or leave a trackback.

    14 Comments

    Elco Jacobs wrote:

    Great work Adam. I will merge your additions into my code if you are OK with that.

    I will also make switching between UNO and Leonardo automatic, by checking if USBCON is defined.

    Did you fork it on GitHub?

    Saturday, December 1, 2012 at 9:50 pm | Permalink

    1.

    Adam wrote:

    @Elco no I did not fork it. I should have done but I wasnt thinking properly!Adam

    Saturday, December 1, 2012 at 10:04 pm | Permalink

    2.

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    5 of 8 10/27/2014 8:02 PM

  • Pete wrote:

    Hey this is a pretty good walkthrough, Im struggling with step 1b I think. I am struggling to see how to fit the sketch harness intothe main program. I tried building the main program (using leonardo) but get undefined reference to setup/loop error. Is thereperhaps an example of how you include sketch.cpp or you could possibly give a bit more guidance at these steps. Thank you

    Wednesday, December 26, 2012 at 1:20 pm | Permalink

    3.

    Adam wrote:

    @Pete

    OK Ill have a go tho its always hard to diagnose problems remotely and I might have got the wrong end of the stick!

    To add sketch.cpp (or any number of supplementary files, for that matter) you can use the menu: Project | Add New Item . Thenchoose CPP file and give it a name. You can also get the same result other ways.

    You should also be able to just paste the same sketch code into the end of main.cpp instead of having a separate sketch.cpp(remembering the notes about function prototypes).

    Cheers, Adam

    Wednesday, December 26, 2012 at 9:00 pm | Permalink

    4.

    Richard Waterman wrote:

    Only had Arduino a few days and hate its IDE. Ive programmed in other languages and miss their editors. The python script is justused for uploading? You can still program with regular example code of Arduino? (other than the function prototype) I was using asikuli library in java and would want to continue to use it here. Should be no problem? And also what about Processing? Can this bedone for that as well? I really cant see how people like these editors lol.

    Saturday, February 23, 2013 at 12:58 am | Permalink

    5.

    Adam wrote:

    Yes, the python is just for uploading. There are other approaches you can use to upload too: have a look at Megunolink. Yes, regulararduino code will work so long as you add the function prototypes and make sure the libraries are referenced. This is dependent onthe compiler and linker rather than the IDE per se. As for the rest, I have no idea

    Adam

    Saturday, February 23, 2013 at 5:44 pm | Permalink

    6.

    Chris John wrote:

    stared should be started

    {yes corrected, thanks. Adam}

    Sunday, May 26, 2013 at 2:43 pm | Permalink

    7.

    Antonello wrote:

    With the blink sketch Ive received the following errors:OUTPUT was not declared in this scopepinMode was not declared in this scopeHIGH was not declared in this scopedigitalWrite was not declared in this scopedelay was not declared in this scopeLOW was not declared in this scope

    Then Ive include the Arduino.h inside sketch.cpp and everything worked.Is that normal ?

    Tuesday, June 18, 2013 at 9:22 am | Permalink

    8.

    Adam wrote:

    Yes, you do need to include the Arduino libraries; these functions and constants are not considered standard by the compiler. Thisis the case for all of the functions documented on the Arduino Language Reference page http://arduino.cc/en/Reference/HomePage.

    Thursday, June 20, 2013 at 1:59 pm | Permalink

    9.

    Chris Fisher wrote:

    Excellent guide, thank you for posting.I have the Arduino Micro.Arduino IDE allows the upload of Blink program example to test functionality. I manipulated the time delays to the LED, whileobserving on the scope. So the hardware and software is working correctly thru uploading.

    I followed the setup and successfully compiled Blink in Studio 6.1 all files generated no errors. When I run the AVRDude tool in6.1 I get the following error:

    avrdude.exe: Version 5.11, compiled on Sep 2 2011 at 19:38:36

    10.

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    6 of 8 10/27/2014 8:02 PM

  • Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/Copyright (c) 2007-2009 Joerg Wunsch

    System wide configuration file is C:\avrdude.conf

    Using Port : \\.\COM8Using Programmer : arduinoOverriding Baud Rate : 57600avrdude.exe: stk500_getsync(): not in sync: resp=000

    avrdude.exe done. Thank you.

    The yellow LED flashes a few times when I run the Upload tool.I have hi-res photos of the scope the Arduino micro and the Studio 6.1.Not sure what causes the stk500_getsync(): not in sync: resp=000 Error within AVRDude. I really appreciate any guidence.Thanks,Chris

    Monday, January 20, 2014 at 12:21 am | Permalink

    Adam wrote:

    Chris -Im a bit hazy about the workings of avrdude; I follow standard recipes.

    In your case, it looks like the baud rate might be wrong. I think you should be using 115200 baud. See the section Setting up forUno on my post.I think when you upload from the Arduino IDE it picks this up from a boards.txt (somewhere inside C:\Program Files\Arduino)otherwise getting default values from C:\avrdude.conf if it exists.

    Sometimes Windows messes up COM ports. Try a reboot, check port assignments etc if the above does not get you there.

    hth, Adam

    Thursday, January 23, 2014 at 9:29 pm | Permalink

    11.

    Chris Fisher wrote:

    Thank you for providing some guidance.Iam still unable to successfully deploy.Here is the output window, if you notice anything obvious, please let me know.Thanks,ChrisDeploy scriptExecuting local-deploy99.bat-Deploying P1BLINKAM2 Build 5The system cannot find the path specified.CANNOT Find output file C:\Users\C\Documents\Atmel Studio\6.1\P1BLINKAM2\P1BLINKAM2\scripts\output.txt" Aborting script

    C:\Arduino\hardware\tools\avr\bin\avrdude.exe -CC:\Arduino\hardware\tools\avr\etc\avrdude.conf -v -patmega32u4 -cavr109-PCOM9 -Uflash:w:C:\Users\C\Documents\Atmel Studio\6.1\P1BLINKAM2\P1BLINKAM2\Debug\P1BLINKAM2.hex:i

    avrdude.exe: Version 5.11, compiled on Sep 2 2011 at 19:38:36Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/Copyright (c) 2007-2009 Joerg Wunsch

    System wide configuration file is C:\Arduino\hardware\tools\avr\etc\avrdude.conf

    Using Port : COM9Using Programmer : avr109AVR Part : ATmega32U4Chip Erase delay : 9000 usPAGEL : PD7BS2 : PA0RESET disposition : dedicatedRETRY pulse : SCKserial program mode : yesparallel program mode : yesTimeout : 200StabDelay : 100CmdexeDelay : 25SyncLoops : 32ByteDelay : 0PollIndex : 3PollValue : 053Memory Detail :

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

    12.

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    7 of 8 10/27/2014 8:02 PM

  • calibration 0 0 0 0 no 1 0 0 0 0 000 000signature 0 0 0 0 no 3 0 0 0 0 000 000

    Programmer Type : butterflyDescription : Atmel AppNote AVR109 Boot Loader

    Connecting to programmer: .Found programmer: Id = w(; type = Software Version = E.avrdude.exe: error: buffered memory access not supported. Maybe it isnta butterfly/AVR109 but a AVR910 device?Deployment FailedECHO is off.

    Sunday, January 26, 2014 at 2:34 pm | Permalink

    Adam wrote:

    Hmmmwell, one thing I failed to notice at first was that you are not using an Uno, so my comments on baud rate were wrong.

    Maybe try to run avrdude from a command line (DOS Window) and see if that works.

    This looks a bit odd: CANNOT Find output file C:\Users\C\Documents\Atmel Studio\6.1\P1BLINKAM2\P1BLINKAM2\scripts\output.txt Aborting scriptIt might be a symptom of anti-virus software getting in the way. Ive certainly had problems with compilation due to my AV. Trydisabling it and see if things improve.

    Adam

    Saturday, February 1, 2014 at 5:49 pm | Permalink

    13.

    David Perrin wrote:

    Hi, Do you add the sketch.cpp to your project ? It tells me that OUTPUT is not declared in this scope.

    Can you show me an example of your File explorer ? (picture)

    Thanks a lot !

    Monday, August 25, 2014 at 3:52 pm | Permalink

    14.

    4 Trackbacks/Pingbacks

    Adam @ Hilltop Cottage Simulating Arduino Code using Atmel Studio 6 on Saturday, May 11, 2013 at 2:20 pm

    [...] This starts off as just a case of compiling the code in Atmel Studio so you can set break-points or step line-by-line through thecode to see what happens. See an earlier post of mine for how to get an Arduno sketch to become an Atmel Studio 6 project. [...]

    1.

    Adam @ Hilltop Cottage Debugging Arduino using debugWire (+ Atmel Studio and an AVR Dragon) on Saturday, May 11, 2013at 4:14 pm

    [...] is basically just a case of compiling the code for the Arduino in Atmel Studio as Ive previously described. It is NOT necessaryto upload the compiled code using avrdude because Atmel Studio will do this [...]

    2.

    How to: Step by step guide to setting up Atmel Studio (AVR Studio 6) for Arduino | aSensar on Sunday, June 23, 2013 at 3:23 pm

    [...] Using Atmel Studio 6 IDE with Arduino (Uno and Leonardo) http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-with-arduino-uno-and-leonardo/ [...]

    3.

    Step by step guide to setting up Atmel Studio for Arduino development - Inspired by Nature on Monday, July 15, 2013 at 5:38 am

    [...] Using Atmel Studio 6 IDE with Arduino (Uno and Leonardo) http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-with-arduino-uno-and-leonardo/ [...]

    4.

    Adam @ Hilltop Cottage Using Atmel Studio 6 IDE with Arduino (U... http://www.hilltop-cottage.info/blogs/adam/using-atmel-studio-6-ide-w...

    8 of 8 10/27/2014 8:02 PM