2
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ 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, or consider buying advertisements: See stackexchange.com/about/contact \$\endgroup\$ Jan 24, 2012 at 20:25
  • \$\begingroup\$ 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? \$\endgroup\$
    – Leeron
    Jan 24, 2012 at 21:16
  • \$\begingroup\$ Please note the new webpage (after the arduino.com.au domain was transferred to the Arduino team) : 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. \$\endgroup\$
    – user24008
    May 17, 2013 at 3:42
  • \$\begingroup\$ Seems to be Windows only. Which is a shame :/ \$\endgroup\$
    – MadMike
    Aug 11, 2015 at 7:30
1
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ 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) \$\endgroup\$
    – Leeron
    Jan 24, 2012 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.