xref: /qemu/docs/system/target-avr.rst (revision c0a659f9de8230289f6d1906b6a24c7d228c12de)
1*c0a659f9SThomas Huth.. _AVR-System-emulator:
2*c0a659f9SThomas Huth
3*c0a659f9SThomas HuthAVR System emulator
4*c0a659f9SThomas Huth-------------------
5*c0a659f9SThomas Huth
6*c0a659f9SThomas HuthUse the executable ``qemu-system-avr`` to emulate a AVR 8 bit based machine.
7*c0a659f9SThomas HuthThese can have one of the following cores: avr1, avr2, avr25, avr3, avr31,
8*c0a659f9SThomas Huthavr35, avr4, avr5, avr51, avr6, avrtiny, xmega2, xmega3, xmega4, xmega5,
9*c0a659f9SThomas Huthxmega6 and xmega7.
10*c0a659f9SThomas Huth
11*c0a659f9SThomas HuthAs for now it supports few Arduino boards for educational and testing purposes.
12*c0a659f9SThomas HuthThese boards use a ATmega controller, which model is limited to USART & 16-bit
13*c0a659f9SThomas Huthtimer devices, enought to run FreeRTOS based applications (like
14*c0a659f9SThomas Huthhttps://github.com/seharris/qemu-avr-tests/blob/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf
15*c0a659f9SThomas Huth).
16*c0a659f9SThomas Huth
17*c0a659f9SThomas HuthFollowing are examples of possible usages, assuming demo.elf is compiled for
18*c0a659f9SThomas HuthAVR cpu
19*c0a659f9SThomas Huth
20*c0a659f9SThomas Huth - Continuous non interrupted execution:
21*c0a659f9SThomas Huth   ``qemu-system-avr -machine mega2560 -bios demo.elf``
22*c0a659f9SThomas Huth
23*c0a659f9SThomas Huth - Continuous non interrupted execution with serial output into telnet window:
24*c0a659f9SThomas Huth   ``qemu-system-avr -machine mega2560 -bios demo.elf -serial
25*c0a659f9SThomas Huth   tcp::5678,server,nowait -nographic``
26*c0a659f9SThomas Huth   and then in another shell
27*c0a659f9SThomas Huth   ``telnet localhost 5678``
28*c0a659f9SThomas Huth
29*c0a659f9SThomas Huth - Debugging wit GDB debugger:
30*c0a659f9SThomas Huth   ``qemu-system-avr -machine mega2560 -bios demo.elf -s -S``
31*c0a659f9SThomas Huth   and then in another shell
32*c0a659f9SThomas Huth   ``avr-gdb demo.elf``
33*c0a659f9SThomas Huth   and then within GDB shell
34*c0a659f9SThomas Huth   ``target remote :1234``
35*c0a659f9SThomas Huth
36*c0a659f9SThomas Huth - Print out executed instructions:
37*c0a659f9SThomas Huth   ``qemu-system-avr -machine mega2560 -bios demo.elf -d in_asm``
38