2

I'd like to debug my Arduino Atmega 2560 project on the AVR Studio 5 Simulator. The thing is, as I understand it, Arduino code doesn't run on the Atmega chip by itself, it uses a bootloader - In my case Stk 500 v2.

So, is it possible to run it on the simulator? and if so, how?

Can I load the bootloader hex file to the simulator, then communicate the project hex to it via serial? Or is there an even easier way to do it?

Leeron
  • 41
  • 1
  • 2

2 Answers2

2

Here is an Arduino Simulator. There's a "Pro" version, which costs $5 now but will later cost $50, as well as a free version with a time-delayed startup but otherwise full functionality.

This isn't a way to debug on the AVR Studio 5 Simulator, but it offers similar functionality within its own IDE:

screenshot from http://www.arduino.com.au/Images/SFA%20Screenshot.jpg

According to the linked website, it includes the following features:

  • Steps through the program line by line. If a new line is selected, the program will continue from that point.
  • Performs digitalWrite, digitalRead and PinMode for pins 0-21
  • analogRead for pins 0-5 and analogWrite for digital pins 0-13
  • Serial output data and input emulation for Serial, Serial1 and SoftSerial
  • Emulates LCD output
  • If,while,for loop functionality
  • Subroutines (multi-level) with arguments
  • View variables in real-time
  • Step Into, Step Over, Step Out of or AutoStep run mode
  • Ability to edit sketch or open in Arduino IDE
  • #include code
  • Undock output emulation Serial and LCD windows
  • Context-sensitive help

See the software datasheet for more information.

Kevin Vermeer
  • 19,989
  • 8
  • 57
  • 102
  • That's a pretty neat product! It looks like you're the author, or at least affiliated - Is that correct? If so, you should take a look at [our rules for self-promotion](http://electronics.stackexchange.com/faq#promotion), or consider buying advertisements: See http://stackexchange.com/about/contact – Kevin Vermeer Jan 24 '12 at 20:25
  • I sure will give it a try, but it looks like it's intended on simulating the Uno board and not the Mega 2560. Am I right? – Leeron Jan 24 '12 at 21:16
  • Please note the new webpage (after the arduino.com.au domain was transferred to the Arduino team) : http://virtronics.com.au/Simulator-for-Arduino.html The cost is now $11.99 and will increase to $14.99 later this year but there is a free version with an 8 day trial period. –  May 17 '13 at 03:42
  • Seems to be Windows only. Which is a shame :/ – MadMike Aug 11 '15 at 07:30
1

The bootloader is a separate program that runs out of a separate memory space from your main program. You can most likely safely ignore it for purposes of simulation. When you compile your sketch in the Arduino environment you can get it to show you the temporary folder where your compilation artifacts are stored.

In pre-1.0 versions of the IDE you did this by holding down the shift-key when you click the compile button. In 1.0 there is a check box under File => Preferences to "Show verbose output during: compilation" that has the same affect.

I haven't used AVR Studio 5 Simulator, but assuming it takes a HEX file as an input, you should be able to get it from that directory.

vicatcu
  • 22,499
  • 13
  • 79
  • 155
  • Hi vicatcu, thanks for your answer. I know where my .hex (and .elf) files are, but I haven't find a way to use the simulator for code complied outside of AVR Studio - and can't get my code to compile properly in AVR Studio. (See my [other question](http://electronics.stackexchange.com/questions/25590/arduino-code-compiles-both-on-eclipse-and-on-avr-studio-5-but-only-eclipse-vers)) – Leeron Jan 24 '12 at 15:21