[TUT][SOFT] AVR Studio 6 support for Arduino

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

This post describes how to use ATMEL Studio 6 instead of the Arduino IDE to build applications. It presumes a certain level of knowledge and experience.
EDIT : Ive updated this post to refer to Atmel Studio 6 instead of AVR Studio 5, so many of the posts below should be read with that in mind ( ie problems with 5.0)

On his excellent website, Smiley http://www.smileymicros.com tries to persuade us to leave behind the Arduino libraries, the vast numbers of samples, and to convert to a "better way". (Hope Im not misquoting him!) While I see some advantages in this approach, in my case I had already half developed some applications and I didn't want to start again.

So I could stick with the Arduino IDE, but it was driving me crazy. A great way to start: copy and paste some example code into my "sketch", press upload and then bingo, the LED fashes. But Ive grown to dislike it. Its slow. It has no intellisense. The IDE sucks. I disliked the extra pass it makes to change my code in strange ways. (Thats fixed now though). There's no debugger. There are other things i dislike but they are of a petty nature; the first five are enough. So I went looking for alternatives, and came to think there are two, Eclipse or Visual Studio (ATMEL Studio 6 to be precise).

First off those that like Eclipse have it sorted I believe. You can read how to use Eclipse for Arduino here: http://arduino.cc/forum/index.ph... Ive used Eclipse to write code for my wifes Android phone "“ its pretty good. If you want cross platform, thats an obvious winner. But Ive been writing C++ with Visual Studio for longer than I care to admit (been in computing since 1973, which would trump most of the readers of this forum I would think), and for me, Visual Studio and Visual Assist is a winning combination (Visual Assist is great but not free). So I wanted to use VS. I went down a lot of tangents because Google led me to a lot of information that is no longer relevant. I had to especially make sure I didn't bother too much reading about WinAVR AVRStudio 5 or anything related to AVRStudio4. I havent used VisualMicro recently but I cant see the need for it.

My original post decribed AVR Studio 5 and how to use it. But there were annoying bugs, these have been fixed in version 6.

ATMEL Studio 6 is a winner.

When AVR Studio 5 got launched it looked to be perfect for me. BUT, it didn't support C++ all that well. They've fixed that now ( very recently) "“just install the C++ Extension which as of August 2011 is a beta release. Installation is through AVR Studio 5 Tools menu:
Tools -> Extension Manager -> Online Gallery -> AVRGCC CPP(Beta)
Ive found two minor bugs "“ more on that later.

The biggest challenge was to work out how to use the core Arduino libraries. You need to tell it where to find the headers, and setting the directories was easy enough. I had originally installed the Arduino IDE(version 22) to C:\arduino, so I just added C:\arduino\hardware\arduino\cores\arduino to my directories for the C++ compiler (Properties of the solution/ Toolchain). While I was at it, I added the folder for each of the libraries I wanted to use. To start off, I took a copy of the main source file with the PDE extension and gave it a CPP extension).

Almost there, but getting it to link proved harder.

Now when you use the Arduino IDE it builds a library from all the core source code "“ eg the code for Serial. This library gets built each time ( did I mention that I dislike how slow it is), and squirrels it away into a funny place that is difficult to find.(look for a folder with a name like C:\Users\fred\AppData\Local\Temp\build5690015305384173079.tmp) I grabbed a copy of it from there so I could use it as part of my VS project. Its name is libcore.a and I copied it to a place where all my projects live C:\Users\fred\Documents\Arduino

I then went to the "Toolchain\AVR/GNU C++ Linker\Miscellaneous" tab and added this
-Wl,-lcore -Wl,-L"C:\Users\fred\Documents\Arduino"

In version 5, one had to tweak the makefile to get past linker errors, but thankfully that is a thing of the past.

Now after adding this one line:
Serial.println("Start of loop");
everything builds.

Soooo close now.

The next thing is to get the program onto my hardware (Arduino UNO). I defined an external tool:
Command: C:\arduino\hardware/tools/avr/bin/avrdude.exe
Arguments: -CC:\arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM3 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

I got this command from a verbose output from the Arduino IDE. But wow, I don't know why so many ""“v"options, where did they come from and what are they for? Anyway, it works, and so I made a button to do the upload and now its a simple click.

Finally I got nifty with the source code, so I can still compile things in the Arduino IDE if I really want to. ( Basically I gutted the source file with the PDE suffix and put everything in other source files)

In summary, was this worth the effort? Quite honestly, yes it was. My new environment is much faster and much more productive. The niggly problems got sorted by the AVR team - thanks - and now I have the best of both worlds.

A win!

This gives you a quick overview "“ Ive left out an awful lot of detail. And since this original post, others have described the process in more detail - eg http://www.jayconsystems.com/tut...

Suffice to say it is well worth doing.

[this is great stuff so I made it into a permanent tutorial - moderator]

Last Edited: Fri. Jul 27, 2012 - 08:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

frankeden

Great post. I did all you said, but I'm still getting the undefined reference errors during link. I moved the -Wl, -lcore etc etc to the end of the Makefile, but stil the errors are there. Any other things I can try ?

thanks!
mark

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

frankeden wrote:
On his excellent website, Smiley http://www.smileymicros.com tries to persuade us to leave behind the Arduino libraries, the vast numbers of samples, and to convert to a “better way”. (Hope Im not misquoting him!) While I see some advantages in this approach, in my case I had already half developed some applications and I didn’t want to start again.
The blog entry is at:
http://smileymicros.com/blog/201...
And I want to be clear, I love the Arduino and I think it is absolutely the best solution for the novice and even for the professional wanting to make quick tests. That said, I felt that the Arduino libraries were lacking some important functionality that in order to implement one really needed to move on to regular C programming and the standard tools: AVRStudio, WinAVR, and avrdude.

I've been too scared to try AS5 so I'll have to take this tutorial as validation that it actually works on something. The other issue here is C++ which I've yet to be convinced makes sense for >me< in a microcontroller environment, though frankly some of the Arduino libraries have come close to convincing me to move on up. Time will tell. Also since AS5 accepts .NET plugins I've been thinking that someone could go ahead and add a DTR pulse to reset the Arduino and let avrdude upload to the board and pretty much entirely replace the Arduino IDE for more advanced work. Now if I can just find time...

Smiley

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

Hi Mark,
You said you

Quote:
moved the -Wl, -lcore etc etc to the end of the Makefile
What you need to do, is to move it to the end of the line that it was on. That way the order of the parameters for the linker is better.
So here are the steps:
1. Uncheck the option "Use External Makefile"
2. Add the -Wl,-lcore -Wl,-L"C:\Arduino" (or similar) to "Other Linker Flags"
3. Check the option "Use External Makefile"
4. Edit the makefile, search for the string you entered at step 2, move it to the end of that line and save the file
All done!
BTW, AVR Support have acknowledged this as a bug, so I expect it will get fixed at some stage.

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

Very Thks smileymicros

Very useful post of great help for me

Giorgio

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

Hi,

Thank you very much for this. However, I still get "undefined references".

1) core.a is located at C:\Users\computer\Documents\Arduino
2) Using external Makefile: C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug\Makefile
3) moved the "-Wl, lcore etc." to the end of the line (see below)

	$(QUOTE)$(AVR_APP_PATH)avr-g++.exe$(QUOTE) -funsigned-char -funsigned-bitfields -I"C:\arduino\arduino-0022\hardware\arduino\cores\arduino" -I"C:\arduino\arduino-0022\libraries\EEPROM" -I"C:\arduino\arduino-0022\libraries\Streaming"  -O0 -fpack-struct -fshort-enums -g2 -Wall -c -mmcu=atmega1280   -MD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" -Wl,-lcore -Wl,-L"C:\Users\computer\Documents\Arduino"

Here's the build output:

------ Build started: Project: ArduinoTest, Configuration: Debug AVR ------
Build started.
Project "ArduinoTest.avrgccproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files\Atmel\AVR Studio 5.0\Vs\AvrGCC.targets" from project "C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\ArduinoTest.avrgccproj" (target "Build" depends on it):
	Task "RunAvrGCC"
		C:\Program Files\Atmel\AVR Studio 5.0\AVR ToolChain\bin\make.exe -C "C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug" -f "Makefile2" all 
		make: Entering directory `C:/Users/computer/Documents/AVRStudio/ArduinoTest/ArduinoTest/Debug'
		Building target: ArduinoTest.elf
		Invoking: AVR/GNU C/C++ Linker
		"C:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe"  -mmcu=atmega1280  -Wl,-Map=ArduinoTest.map -o ArduinoTest.elf  ArduinoTest.o  
		c:/program files/atmel/avr studio 5.0/avr toolchain/bin/../lib/gcc/avr/4.5.1/../../../../avr/lib/avr51/crtm1280.o: In function `__vectors':
/home/tools/hudson/workspace/avr8-gnu-toolchain/src/avr-libc/crt1/gcrt1.S(52,1): undefined reference to `main'
		ArduinoTest.o: In function `operator<<(Print&, _EndLineCode)':
C:\arduino\arduino-0022\libraries\Streaming/Streaming.h(81,1): undefined reference to `Print::println()'
		ArduinoTest.o: In function `loop':
C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug/.././ArduinoTest.cpp(4,1): undefined reference to `Serial'
C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug/.././ArduinoTest.cpp(4,1): undefined reference to `Serial'
C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug/.././ArduinoTest.cpp(5,1): undefined reference to `delay'
		ArduinoTest.o: In function `setup':
C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug/.././ArduinoTest.cpp(9,1): undefined reference to `Serial'
C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug/.././ArduinoTest.cpp(9,1): undefined reference to `Serial'
C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug/.././ArduinoTest.cpp(9,1): undefined reference to `HardwareSerial::begin(long)'
		ArduinoTest.o: In function `Print& operator<< (Print&, char const*)':
C:\arduino\arduino-0022\libraries\Streaming/Streaming.h(30,1): undefined reference to `Print::print(char const*)'
		collect2: ld returned 1 exit status
		make: *** [ArduinoTest.elf] Error 1
		make: Leaving directory `C:/Users/computer/Documents/AVRStudio/ArduinoTest/ArduinoTest/Debug'
	Done executing task "RunAvrGCC" -- FAILED.
Done building target "CoreBuild" in project "ArduinoTest.avrgccproj" -- FAILED.
Done building project "ArduinoTest.avrgccproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

What am I doing wrong? Any pointers?

BTW, I'm still geeked - in just a day I've moved from simple Arduino programming with "println" debugging up to using an AVR Dragon with JTAG debugging and AVR Studio 5 with breakpoints. Very cool! Now, if I can get this part working I can ditch the Arduino IDE and have a much smoother workflow...

Again - many thanks!

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

Hmm, I could have sworn that those additional commands appear on the compiler. But, it's the linker step isn't it? I moved that line to the linker line.

But now it says it can't fine -lcore

		"C:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe"  -mmcu=atmega1280 -Wl,-Map=ArduinoTest.map -o ArduinoTest.elf  ArduinoTest.o   -Wl,-lcore -Wl,-L"C:\Users\computer\Documents\Arduino" 
		make: Leaving directory `C:/Users/computer/Documents/AVRStudio/ArduinoTest/ArduinoTest/Debug'
C:\Users\computer\Documents\AVRStudio\ArduinoTest\ArduinoTest\Debug(1,1): cannot find -lcore

Progress?

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

Yeah - I got it up running. Fought with the same error as you.

What I did beside Franks instructions:

* Find the core.a file in the \buildXXXXXX.tmp directory.
* put it in a known directory (e.g. C:\Lib)
- RENAME it to libcore.a (found out via this page: http://gcc.gnu.org/onlinedocs/gc...)
* Make sure that all directories you added according the the original instructions are added as full paths (NOT relative)
* No reason to use external makefile here. It works fine both with the additional linker flags, but also if i add the lib (core) and directory (c:\lib) (still not as relative path) under the libraries tab under GNU/C++ Linker.

Thanks to Frank for the initial post!

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

Quote:

* No reason to use external makefile here. It works fine both with the additional linker flags, but also if i add the lib (core) and directory (c:\lib) (still not as relative path) under the libraries tab under GNU/C++ Linker.


Just to note that there's currently a bug in AS5 that means this will work if you are building a C project that links to libcore.a but the library will not be found if you are building a C++ project as the -Wl,-l option does not seem to be passed.

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

clawson wrote:
Just to note that there's currently a bug in AS5 that means this will work if you are building a C project that links to libcore.a but the library will not be found if you are building a C++ project as the -Wl,-l option does not seem to be passed.

That's true - I see that now. And it seems that I also needed to insert a:

extern "C" void __cxa_pure_virtual() { while (1); }

when building as a C++ project.

Anyway - this is so cool - being able to use the Arduino libraries and still have a _real_ integrated development environment! :)

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

Hello,
I am trying to follow this step by step but I am not able to compile.
The error that is showing is:

Quote:
'pinMode' was not declared in this scope
.././AVRGCC1.cpp: In function 'void loop()':
'HIGH' was not declared in this scope
'digitalWrite' was not declared in this scope
'delay' was not declared in this scope
'LOW' was not declared in this scope

The code I'm trying to compile is:

void setup() {
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(1000);              // wait for a second
}

The output is:

Quote:
------ Rebuild All started: Project: AVRGCC1, Configuration: Debug AVR ------
Build started.
Project "AVRGCC1.avrgccproj" (ReBuild target(s)):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreRebuild" in file "C:\Program Files (x86)\Atmel\AVR Studio 5.0\Vs\AvrGCC.targets" from project "C:\Users\Z80\Documents\AVRStudio\AVRGCC1\AVRGCC1\AVRGCC1.avrgccproj" (target "ReBuild" depends on it):
Task "RunAvrGCC"
C:\Program Files (x86)\Atmel\AVR Studio 5.0\AVR ToolChain\bin\make.exe clean all
.././AVRGCC1.cpp: In function 'void setup()':
C:\Users\Z80\Documents\AVRStudio\AVRGCC1\AVRGCC1\AVRGCC1.cpp(4,15): 'OUTPUT' was not declared in this scope
rm -rf AVRGCC1.o AVRGCC1.d libAVRGCC1.a AVRGCC1.hex AVRGCC1.eep AVRGCC1.lss AVRGCC1.map
AVRGCC1.cpp
Invoking: AVR/GNU CPP Compiler
"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -I"C:/Arduino/hardware/arduino/cores/arduino" -O0 -fpack-struct -fshort-enums -g2 -Wall -c -save-temps -mmcu=atmega328p -MD -MP -MF"AVRGCC1.d" -MT"AVRGCC1.d" -o"AVRGCC1.o" ".././AVRGCC1.cpp"
C:\Users\Z80\Documents\AVRStudio\AVRGCC1\AVRGCC1\AVRGCC1.cpp(4,21): 'pinMode' was not declared in this scope
.././AVRGCC1.cpp: In function 'void loop()':
C:\Users\Z80\Documents\AVRStudio\AVRGCC1\AVRGCC1\AVRGCC1.cpp(8,20): 'HIGH' was not declared in this scope
C:\Users\Z80\Documents\AVRStudio\AVRGCC1\AVRGCC1\AVRGCC1.cpp(8,24): 'digitalWrite' was not declared in this scope
C:\Users\Z80\Documents\AVRStudio\AVRGCC1\AVRGCC1\AVRGCC1.cpp(9,13): 'delay' was not declared in this scope
C:\Users\Z80\Documents\AVRStudio\AVRGCC1\AVRGCC1\AVRGCC1.cpp(10,20): 'LOW' was not declared in this scope
make: *** [AVRGCC1.o] Error 1
Done executing task "RunAvrGCC" -- FAILED.
Done building target "CoreRebuild" in project "AVRGCC1.avrgccproj" -- FAILED.
Done building project "AVRGCC1.avrgccproj" -- FAILED.

Build FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Where am I wrong?
This image show my configuration. I put libcore.a in the same folder of arduino core code.

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

You are missing a header file inclusion.

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

Ok, i include this line in the first line of my program.

#include 

and now the error is

Quote:
undefined reference to `pinMode'
undefined reference to `digitalWrite'
undefined reference to `digitalWrite'

I try to edit Makefile but it's recreate when I click on "Rebuild projet".
Sorry for not having knowledge of avr studio and visual studio.

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

"undefined reference" means that none of the .o or .a files provided to the linker contain those functions. So you either need to add a library or some .c/.cpp source files (I haven't read the whole of this thread but I suspect it's a lib in fact)

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

It's a lib. But apparently the AVR Studio C + + has a bug that does not put the lib even though she set in the project properties (see the image of my first post).

The command that should run AVR Studio is:

Quote:
avr-g++.exe -mmcu=atmega328p -Wl,-Map=AVRGCC1.map -o AVRGCC1.elf AVRGCC1.o -Wl,-L"C:/Arduino/hardware/arduino/cores/arduino" -Wl,-lcore

But when it generates the Makefile, the command is generated:
Quote:
avr-g++.exe -Wl,-L"C:/Arduino/hardware/arduino/cores/arduino" -Wl,-lcore -mmcu=atmega328p -Wl,-Map=AVRGCC1.map -o AVRGCC1.elf AVRGCC1.o

Note that the argument "-Wl,-L"C:/Arduino/hardware/arduino/cores/arduino" -Wl,-lcore" is in a different place.

In this post speaks to modify the Makefile. But when I compile, the Makefile is rewritten.

How do I make the AVR Studio does not recreate the Makefile?
What are the ways to add a lib to a project?

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

Quote:

How do I make the AVR Studio does not recreate the Makefile?

Tick the "use external makefile" box (wherever they've now hidden that in AS5).

BTW I did post this in the thread above.

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

I struggled with adding the LiquidCrystal library for a few hours... due to inexperience with C++, but got it figured out, so I thought I would share...Order of the object files in the linker command are important, as stated above.

To include the LiquidCrystal library I put the LiquidCrystal.o object file from the Arduino temp directory in the same location as the libcore.a library. Then I added it before the libcore.a library in command below. Any library that LiquidCrystal.o depends on goes before it in the command below and their corresponding object files need to be copied into the common location.

$(QUOTE)$(AVR_APP_PATH)avr-g++.exe$(QUOTE) -mmcu=atmega328p  -Wl,-Map=$(MAP_FILE_PATH_AS_ARGS) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) C:\Users\Nick\Documents\Arduino\Print.o C:\Users\Nick\Documents\Arduino\WMath.o C:\Users\Nick\Documents\Arduino\WString.o  C:\Users\Nick\Documents\Arduino\LiquidCrystal.o -Wl,-lcore -Wl,-L"C:\Users\Nick\Documents\Arduino" 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had some trouble using the Windows "search" to find core.a, but method below may help someone:
1. Locate the Sketch Preferences.txt (instructions on the Arduino website)
2. Add the following lines (I think only one is needed, but I added both of them oh well):

link.verbose=true
build.verbose=true

3. Then verify and compile an example sketch.

4. Look in the bottom of the sketch where the output is stored and search for core.a

5. Copy core.a from the path selected and you can rename it to libCore.a or something if desired and reference it from the project.

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

Quote:

link.verbose=true
build.verbose=true


You do know that holding down [Shift] when you verify a sketch does the same thing?

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

Hello,

I succeeded using Arduino language within Studio 5.

You can find the procedure I followed here:

http://arduino.cc/forum/index.php/topic,82577.0.html

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

smileymicros wrote:
Also since AS5 accepts .NET plugins I've been thinking that someone could go ahead and add a DTR pulse to reset the Arduino and let avrdude upload to the board and pretty much entirely replace the Arduino IDE for more advanced work. Now if I can just find time...

I just created a batch file with MODE COM3 DTR=ON on a line preceding AVRDUDE

Works for my Arduino Mega

Andy

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

This is good to hear. I'm waiting for 5.1 before doing anything more with it, but when that comes out I'll try your solution.

Thanks,
Smiley

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

I followed your instruction but the AVR Studio 5 could not recognize arduino's datatype "boolean", where sould I add typedef to get rid of this problem?

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

The standard type in C is "bool" not "boolean". Just make sure to:

#include 

Note that on an 8bit AVR micro this is not necessarily the most efficient way to implement two state variables. The AVRs (for about 6-7 years) have had GPIOR0 which is the perfect place to store eight very fast access bool variables by casting a struct of 1-bit bitfields onto the location (as explained in another tutorial here in fact)

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

Hi everybody,

First thanks for this post, super useful for debugging step by step with JTAG on AVR Studio!

Here is my issue, I have a perfect setup on one computer, everything works perfectly, from compiling to debugging. I did the same setup on another computer (both computers run wndows 7 64-bits), got the compiling working well, AVR Studio code transfer runs but debug fails (F5 command).
There is no explicit error, only that the status goes to "Running" then "Ready" but the code isn't executed, breakpoints are not reached and when I pause the program AVR Studio opens a "No Source Available" page. So it seems like my code isn't transfered properly. I erased the memory many times and tried a AVR C++ project without arduino code, latest works OK. I took my main CPP file, converted it to ".pde" file (Arduino Software version 0022), compiled it, uploaded it, code works fine.

I checked again and again the GNU directories and libraries path to check that everything was correct, indeed it seems to be as compiling is fine.

I am now running out of ideas to know where the issue is.
Does anybody has any opinion on this one?

Thanks in advance for further help :)

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

Quote:

when I pause the program AVR Studio opens a "No Source Available" page.

You are talking about AS5 aren't you? See the MANY threads about this exact same issue there.

Stick to AS4+WinAVR until they release the final beta of AS5.

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

Yes I am talking about AVR Studio 5, but not the beta version, the final one (version 5.0.1223). Only the C++ compiler is still on Beta, do we know about any released date for the final version?

I was posting on this thread as this issue happens only with Arduino code...
For now I'll stick to the Arduino software.

Thanks

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

Quote:

but not the beta version, the final one (version 5.0.1223).

No, no, no. Atmel lied to you - the version that is currently issued hardly qualifies as a beta let alone a release version. It's a piece of crap and should be treated as such.
Quote:

Only the C++ compiler is still on Beta,

So untrue - the toolchain is completely FUBAR and that includes the C compiler and the lib.

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

My bad, so it seems that Atmel lies to everybody...

Thanks for the update!

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

I just finished downloading avr studio 5.0 and followed your instructions, for some reason the board is still giving me the "timeout" error when I run the serial program. Is there a solution for this?

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

Quatar wrote:
I just finished downloading avr studio 5.0 and followed your instructions, for some reason the board is still giving me the "timeout" error when I run the serial program. Is there a solution for this?
You'll definitely want to use 5.1. I had 5.1 beta working ok, but the final 5.1 works much better in terms of linking and other things.

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

Hi,

I have a question regarding the post on Dec 21, 2011 by Cisco25. I am working on Arduino on AVR Studio and only include additional Arduino library (such as AndroidAccessory) I have same issue. no source available page when I pose program. Break point does not work neither. However, I have no issue when I don't use any library. I believe that my library is correctly included, but this point I have no way to check with any experts.

Does anyone has some idea with my issue?

Thank you in advance,

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

ymmttmy,

Perhaps if I explain how source level debugging works you'll see what's going on?

First for a code to even be debuggable it has to be built with the -g option (often either -gdwarf-2 or just -g1/2/3). What this says is "for each block of opcodes generated make a note of which file on disk and which line number within it contains the source that generated this block". So if you have:

1: #include 
2:
3: int main(void) {
4:    DDRB = 0xFF;
5:    while(1) {
6:      PORTB ^= 0xFF;
7:    }
8: }

in a file main.c then the DDRB line will generate two opcodes to load R24 with 0xFF and then OUT that value to the DDRB address. The PORTB line will generate maybe four opcodes to load a register with 0xFF (actually the value from the first code may be re-used) then IN from PORTB, EOR with that 0xFF value then OUT back to PORTB.

The first two ocodes will be tagged in the ELF file as "main.c line 4" and the four opcodes as "main.c line 6".

As long as main.c remains in the same place on your hard drive then when you load the ELF file into the debugger it sees the "main.c:4 " and "main.c:6" information (DWARF2) and so loads main.c and extracts lines 4 an 6 and puts those against the blocks of opcodes in the debugger.

If you either delete main.c or if someone gives you some prebuilt code that either was not built with -g or that contains references to files on their system where the lib was built and not a current location on your system then when the debugger encounters those files it will say "source not found".

So were the libs you are using built on your own system? Are the source files used still in the same place? Was the library built with a -g option?

Knowing a little of how Arduino works I believe:

(a) they may not specify -g. Why would they? You don't normally load Arduino code into a debugger

(b) the build usually occurs in %TEMP% with source files being copied there just during the build then deleted afterwards. As such the source may no longer exist in the location used during the build even if -g is used.

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

Anyone has an AS6 arduino "template" solution/project and would like to share it? Even better to upload it to the projects section?

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

Is there anyway we can avoid using core.a file and instead directly make use of source files from hardware\arduino\avr\cores\arduino? 

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

Note that Atmel Studio 7 can directly import Arduino sketches

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

awneil wrote:
Note that Atmel Studio 7 can directly import Arduino sketches

 

Can I start a new Arduino project in AS7 and have all the Arduino libraries available automatically?  I don't use Arduino, but some of the libraries are tempting.  Or is that selection when starting a new project in AS7 only for importing an existing Arduino sketch.  It seems even in that case the Arduino libraries must be available to AS7.

 

Thanks for your help

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

Create it first in Arduino then import the INO. 

 

But start by asking what AS7 actually offers that you don't get in Arduino anyway? 

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

clawson wrote:
But start by asking what AS7 actually offers that you don't get in Arduino anyway? 

 

It's true.  I can build an Arduino sketch in Arduino and then compile it Verbose and install the .exe with my ICE if I wanted to use the Arduino libraries.  

 

I was just being curious.  If I modify the imported sketch in AS7 and add a call to some function in an Arduino library not in my sketch will AS7 know what to do?

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

If you imported any sketch (even an empty one) into AS7,  the Core library is added to the project.

 

So you will always be able to use Serial, ADC, digitalWrite, ...

 

But if you want to use any non-core library e.g. SPI,  you need to specifically add the SPI library.

 

AS7 will show what libraries are available when you "Add Arduino Library".

You tick the boxes.    AS7 copies those libraries to your project.   AS7 add the paths to the Search list.   AS7 compiles the libraries.

AS7 ensure the Linker puts all the components together.

 

This is a lot more fiddly than simply saying:

#include "SPI.h"

Of course your source code still needs the include statement.   But with AS7 you need to click on the "Add Arduino Library" as well.

And if you subsequently don't need that library,   AS7 is still going to build it.   The Arduino IDE is a lot more intelligent.

 

Unless you have a very good reason,   the Arduino IDE is a lot more convenient to use.

 

David.

Last Edited: Tue. Aug 8, 2017 - 08:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks so much, David.  That is what I wanted to know.  I think the only Arduino library I would likely use is the SoftwareSerial, if I needed an additional UART channel with a Mega that only has one.  Most of the other stuff I have my own code I use.  I was just curious how much AtmelStudio had integrated with Arduino when I saw the option of an Arduino sketch in AS7 for new projects.

 

Thanks again,

mark

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

MarkThomas wrote:
I think the only Arduino library I would likely use is the SoftwareSerial, if I needed an additional UART channel with a Mega that only has one.
Is it worth tying yourself up in knots simply to get access to a soft-UART? Have a look in the Projects section here - there are several available. Some by "danni" I think so they are bound to be good (talking of which, what has happened to Peter Danneger ?)

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

clawson wrote:
Is it worth tying yourself up in knots simply to get access to a soft-UART? 

 

You are probably right, Cliff.  I have avoided ArduinoLand this long.  I sort of like working closer to the processor.  I will look for the project you suggest.