Arduino Libraries With AVR Studio

Hello, I'am starting with arduino and i have to thank you for this great platform. (many thanks)

I have a couple of questions:

1 - Is it possivel to use the arduino libraries in the AVR Studio enviroment, and debug de code with the simulator? (then upload without the bootloader of course) whats the best way of doing this?

2 - Why did you use C++ as the "language" for the libraries and not plain C? what is the penalty in terms of RAM and ROM?

I thinks does are 2 valid questions... :stuck_out_tongue:

Today i have some spare time so, i will look into changing the makefile in the AVR Studio / GCC environment just to try and make it work... :-/

The second question was just curiosity... if someone wants to say something about this it would be nice... :sunglasses:

From the GCC AVR FAQ: "When programming C++ in space- and runtime-sensitive environments like microcontrollers, extra care should be taken to avoid unwanted side effects of the C++ calling conventions like implied copy constructors that could be called upon function invocation etc. These things could easily add up into a considerable amount of time and program memory wasted. Thus, casual inspection of the generated assembler code (using the -S compiler option) seems to be warranted."

Ok, after spending some hours with this here r my conclusions:

  1. Maybe the simplest way of debugging one sketch is to simply load the compiled .elf file into AVR Studio and step through the sketch.cpp file generated?
  2. I've tried to work around a makefile based on “hardware\cores\arduino\MakeFile“.
    a. Use the same approach as the arduino environment - i.e procuce a .cpp file from my .c files (AVR Studio does not like cpp extentions); create a main(void) function from “hardware\cores\arduino\main.cxx “; etc.
    b. Write some makefile to use the arduino libraries, compile .o files and link

I have some problems with the last approach (.2) everything compiles ok but AVR Studio doesn't like the elf file produced:

Coordinator: The object file does not contain source code information.
Debugger: 'Break at line sketch.c:25' has been disabled. Unable to bind line 25 in file "sketch.c" to a program memory address.
Loaded objectfile: C:\Users\pedro\Documents\Code\AVR\ sketch \ sketch.elf
The curious thing is that if I load the .elf file into a new instance of AVR Studio the source files appear in the IDE (“Source [read only]” folder) and I can step through the code...

Anyway, I'll look into this again if have the time?