QEMU is an open source machine emulator and virtualizer that can emulate various CPU architectures like x86, PowerPC, ARM, MIPS and SPARC. This document discusses extending QEMU to add support for a new I2C accelerometer hardware and simulating it in QEMU. It describes registering a new device type in QEMU to represent the accelerometer, implementing read/write callbacks to emulate the device behavior, and testing it works with a simple application both in QEMU and on a real Raspberry Pi board.
3. 3 CONFIDENTIAL
Goals:
• How to add support of new hardware to the QEMU (I2C
Accelerometer)
• How to simulate of the new hardware
• Write a simple application to work with Accelerometer
• Demonstrate that it works on the real platform as well as under
QEMU
4. 4 CONFIDENTIAL
Environment:
• Ubuntu Linux on Host PC
• QEMU for ARM architecture
• Raspbian Linux on Raspberry Pi and QEMU
• QEMU-ready Linux kernel 3.6.11 for the ARM1176JZF-S (RPi)
• Raspberry Pi rev.B
• I2C Accelerometer ADXL345
5. 5 CONFIDENTIAL
What is QEMU ?
− QEMU (short for "Quick EMUlator") is a free and open-source machine
emulator and virtualizer written originally by Fabrice Bellard
− Can emulate 80386, 80486, Pentium, Pentium Pro, AMD64 – from x86
architecture
− PowerPC, ARM, MIPS, SPARC, SPARC64
− Work on FreeBSD, FreeDOS, Linux, Windows 9x, Windows 2000, Mac
OS X, QNX, Android
14. 14 CONFIDENTIAL
Read/write registers
Emulate control registers behavior
Create server socket
Read data from socket and fill data registers
adxl345 emulation
15. 15 CONFIDENTIAL
− Python
− Linux user space ( python-smbus library)
− Linux kernel ( /dev/i2c-0 )
− Linux i2c protocol driver
− Linux i2c-versatile.c driver
− write to Memory Mapped I/O
− Qemu MMIO callback (versatile_i2c.c )
− Qemu i2c slave protocol implementation (bitbang_i2c.c )
− Qemu i2c core ( hw/i2c/core.c )
– For address=0x53 : call our callbacks. ( read, write, event )
adxl345 emulation process
17. 17 CONFIDENTIAL
Raspberry Pi
The Raspberry Pi is a credit-card-sized single-board computer
Raspberry Pi Model B
Target Price$35
SoCBroadcom BCM2835 (CPU, GPU, DSP, SDRAM, USB)
CPU700 MHz ARM1176JZF-S core (ARM11 family, ARMv6 instruction set)
GPUBroadcom VideoCore IV @ 250 MHz
SDRAM512 MB (shared with GPU)
USB 2.0 ports2 via 3-port USB hub
Video outComposite RCA (PAL and NTSC), HDMI, raw LCD Panels via DSI
Audio out3.5 mm jack, HDMI, and I²S audio
StorageSD / MMC / SDIO card slot
Network10/100 Ethernet
Peripherals8 × GPIO, UART, I²C bus, SPI, I²S audio, +3.3 V, +5 V, ground
Power700 mA (3.5 W)
Power Source5 volt via MicroUSB, GPIO header
Size86 x 54 mm
Weight45g
OS
Arch Linux ARM, Debian GNU/Linux, Gentoo, Fedora, FreeBSD,
NetBSD, Plan 9, Raspbian OS, RISC OS, Slackware Linux
18. 18 CONFIDENTIAL
Raspberry Pi on QEMU
Emulating Raspberry Pi – The easy way (XEC DESIGN)
http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way
20. 20 CONFIDENTIAL
QEMU: Open source processor emulator:
http://wiki.qemu.org/Manual
QEMU – Compiling for ARM (1176) emulation (XEC DESIGN):
http://xecdesign.com/compiling-qemu/
Compiling an ARM1176 kernel for QEMU (XEC DESIGN):
http://xecdesign.com/compiling-a-kernel/
QEMU – Emulating Raspberry Pi the easy way (XEC DESIGN):
http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
Hardware virtualization with QEMU:
http://alien.slackbook.org/dokuwiki/doku.php?id=slackware:qemu
KVM Forum 2013: Implementing New Block Drivers: A QEMU Developer Primer by Jeff Cody
https://www.youtube.com/watch?v=ybNaEeQ2jgo
HOWTO: Virtual Raspbian on Qemu in Ubuntu Linux 12.10:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=37386
Raspberry Pi Wiki:
http://elinux.org/RPi_Hub
Links:
TITLE PAGE
– Headline 36pt Arial in WHITE
– Sub-head 18pt Arial Reg in GREY
– Do not include client logos on title page
– TEXT ONLY
***It’s not recommended to use any sort of graphic animation. Although in some cases it may be appropriate to apply “Appear” effect to slide sections to show sections one-by-one on the slide***
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Subtitle 20pt Arial Reg in ORANGE
– Body copy & bulleted text 20pt Arial Reg in GRAY; body copy not to go below 16 pt
– Left-justify all text and design elements
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element
TITLE AND TEXT
– Headline 32pt Arial in BLACK
– Body copy & bulleted text 12pt Arial Reg in GRAY; body copy not to go below 10 pt
– Left-justify all text and design element