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