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 1376ca4b58Szhaolichangtimer devices, enough 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 200abd386dSThomas Huth- Continuous non interrupted execution:: 21c0a659f9SThomas Huth 220abd386dSThomas Huth qemu-system-avr -machine mega2560 -bios demo.elf 23c0a659f9SThomas Huth 240abd386dSThomas Huth- Continuous non interrupted execution with serial output into telnet window:: 25c0a659f9SThomas Huth 260abd386dSThomas Huth qemu-system-avr -M mega2560 -bios demo.elf -nographic \ 27*c2387413SDaniel P. Berrangé -serial tcp::5678,server=on,wait=off 280abd386dSThomas Huth 290abd386dSThomas Huth and then in another shell:: 300abd386dSThomas Huth 310abd386dSThomas Huth telnet localhost 5678 320abd386dSThomas Huth 3376ca4b58Szhaolichang- Debugging with GDB debugger:: 340abd386dSThomas Huth 350abd386dSThomas Huth qemu-system-avr -machine mega2560 -bios demo.elf -s -S 360abd386dSThomas Huth 370abd386dSThomas Huth and then in another shell:: 380abd386dSThomas Huth 390abd386dSThomas Huth avr-gdb demo.elf 400abd386dSThomas Huth 410abd386dSThomas Huth and then within GDB shell:: 420abd386dSThomas Huth 430abd386dSThomas Huth target remote :1234 440abd386dSThomas Huth 450abd386dSThomas Huth- Print out executed instructions (that have not been translated by the JIT 460abd386dSThomas Huth compiler yet):: 470abd386dSThomas Huth 480abd386dSThomas Huth qemu-system-avr -machine mega2560 -bios demo.elf -d in_asm 49