Professional Documents
Culture Documents
CoursI 2 3
CoursI 2 3
ISA LAB, NATIONAL SCHOOL OF APPLIED SCIENCES ENSA, IBN TOFAIL UNIVERSITY UIT, KENITRA ISA LAB, NATIONAL SCHOOL OF APPLIED SCIENCES ENSA, IBN TOFAIL UNIVERSITY UIT, KENITRA
UNIVERSITY SEASON 2021-2022 UNIVERSITY SEASON 2021-2022
AGENDA
Introduction EMBEDDED KERNEL. Emulating the RASPBERRY Pi
Introduction OS ON QEMU
1
10/29/2022
EMBEDDED KERNEL. Emulating the RASPBERRY Pi EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU OS ON QEMU
CHAPTER I. QEMU EMULATION CHAPTER I. QEMU EMULATION
Raspberry Pi OS Emulation Raspberry Pi OS Emulation
Starting Emulation Starting Emulation
CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION
LibVirt Librariy LibVirt Librariy
Platform Developement Platform Developement
First, get the latest Debian/Ubuntu version and run it in a VM: https://www.ubuntu.com/download/desktop $ mkdir ~/qemu_vms/
For the QEMU emulation you will need the following: Download and place the Raspbian Jessie image to ~/qemu_vms/.
A Raspbian Image: http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-04-10/ (other versions
might work, but Jessie is recommended) Download and place the qemu-kernel to ~/qemu_vms/.
Latest qemu kernel: https://github.com/dhruvvyas90/qemu-rpi-kernel
$ sudo apt-get install qemu-system
$ unzip <image-file>.zip
$ fdisk -l <image-file>
EMBEDDED KERNEL. Emulating the RASPBERRY Pi EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU OS ON QEMU
CHAPTER I. QEMU EMULATION CHAPTER I. QEMU EMULATION
Raspberry Pi OS Emulation Raspberry Pi OS Emulation
Starting Emulation Starting Emulation
CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION
LibVirt Librariy LibVirt Librariy
Platform Developement Platform Developement
File Componnents Mounting the .img2 file system and Configuring the file ld.so.preload
We apply the following command to experience the image file components : You see that the filesystem (.img2) starts at sector 137216. Now take that value and multiply it by 512, in this case it’s 512 * 137216 =
$ fdisk -lu <image-file> 70254592 bytes. Use this value as an offset in the following command to mount the image system in the folder /mnt/raspbian:
Doing that, you should see something like this:
Disk 2017-03-02-raspbian-jessie.img: 4.1 GiB, 4393533440 bytes, 8581120 sectors $ sudo mkdir /mnt/raspbian
Units: sectors of 1 * 512 = 512 bytes $ sudo mount -v -o offset=70254592 -t ext4 ~/qemu_vms/<your-img-file.img> /mnt/raspbian
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes $ sudo nano /mnt/raspbian/etc/ld.so.preload
Disklabel type: dos
Disk identifier: 0x432b3940 Comment out every entry in that file with ‘#’, save and exit with Ctrl-x » Y.
2
10/29/2022
EMBEDDED KERNEL. Emulating the RASPBERRY Pi EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU OS ON QEMU
CHAPTER I. QEMU EMULATION CHAPTER I. QEMU EMULATION
Raspberry Pi OS Emulation Raspberry Pi OS Emulation
Starting Emulation Starting Emulation
CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION
LibVirt Librariy LibVirt Librariy
Platform Developement Platform Developement
Unmounting the image file system Starting the RASPBERRY PI OS Emulation on QEMU
Then open the filesystem configuration file, fstab using the following commands. Now you can emulate it on Qemu in a ARM based processors by using the following command and managing the qemu kernel, cpu, memory size,
$ sudo nano /mnt/raspbian/etc/fstab raspberry pi os image,:
IF you see anything with mmcblk0 in fstab, then: $ qemu-system-arm -kernel ~/qemu_vms/<your-kernel-qemu>
-cpu arm1176
Replace the first entry containing /dev/mmcblk0p1 with /dev/sda1 -m 256
Replace the second entry containing /dev/mmcblk0p2 with /dev/sda2, save and exit -M versatilepb
-serial stdio
Then unmount the image from its mount folder using the following commands.
-append "root=/dev/sda2 rootfstype=ext4 rw"
$ cd ~
-hda ~/qemu_vms/<your-jessie-image.img>
$ sudo umount /mnt/raspbian
-redir tcp:5022::22
-no-reboot
EMBEDDED KERNEL. Emulating the RASPBERRY Pi EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU OS ON QEMU
CHAPTER I. QEMU EMULATION CHAPTER I. QEMU EMULATION
Raspberry Pi OS Emulation Raspberry Pi OS Emulation
Starting Emulation Starting Emulation
CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION
LibVirt Librariy LibVirt Librariy
Platform Developement Platform Developement
For a more advanced network setup see the “Advanced Networking” paragraph below.
3
10/29/2022
ISA LAB, NATIONAL SCHOOL OF APPLIED SCIENCES ENSA, IBN TOFAIL UNIVERSITY UIT, KENITRA
UNIVERSITY SEASON 2021-2022
EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU
INTRODUCTION TO INTERNET OF THINGS IOT
APPLYING IA & CYBERSECURITY BLOCKCHAIN TO IOT CHAPTER I. QEMU EMULATION
CONNECTED AUTOMOTIVE EMBEDDED SYSTEMS Raspberry Pi OS Emulation
INDUSTRIAL INTERNET OF THINGS/ IDUSTRY 4.0 Starting Emulation
AUTONYMOUS DRIVING VEHICLE
If your mouse doesn’t move in the emulated Pi, click <Windows>, arrow down to Accessories, arrow right, arrow down to Terminal, enter.
EMBEDDED KERNEL. Emulating the RASPBERRY Pi EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU OS ON QEMU
CHAPTER I. QEMU EMULATION CHAPTER I. QEMU EMULATION
Raspberry Pi OS Emulation Raspberry Pi OS Emulation
Starting Emulation Starting Emulation
CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION
LibVirt Librariy LibVirt Librariy
Platform Developement Platform Developement
4
10/29/2022
EMBEDDED KERNEL. Emulating the RASPBERRY Pi EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU OS ON QEMU
CHAPTER I. QEMU EMULATION CHAPTER I. QEMU EMULATION
Raspberry Pi OS Emulation Raspberry Pi OS Emulation
Starting Emulation Starting Emulation
CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION
LibVirt Librariy LibVirt Librariy
Platform Developement Platform Developement
ISA LAB, NATIONAL SCHOOL OF APPLIED SCIENCES ENSA, IBN TOFAIL UNIVERSITY UIT, KENITRA
UNIVERSITY SEASON 2021-2022
EMBEDDED KERNEL. Emulating the RASPBERRY Pi
OS ON QEMU
INTRODUCTION TO INTERNET OF THINGS IOT
CHAPTER I. QEMU EMULATION APPLYING IA & CYBERSECURITY BLOCKCHAIN TO IOT
Raspberry Pi OS Emulation CONNECTED AUTOMOTIVE EMBEDDED SYSTEMS
Starting Emulation INDUSTRIAL INTERNET OF THINGS/ IDUSTRY 4.0
AUTONYMOUS DRIVING VEHICLE
CHAPTER II. QEMU/LIBVIRT NETWORK VIRTULIZATION Presented by Pr A. BAJIT
LibVirt Librariy
Platform Developement
SECTION III. VIRTUALIZING NETWORK USING RASPBERRY Pi OS LIBVIRT
AGENDA
Troubleshooting the emulation CHAPTER I. QEMU EMULATION
If everything went well, you should be able to reach open ports on the GUEST (Raspbian) from your HOST (Ubuntu) system. You can test this with a Raspberry Pi OS Emulation
netcat (nc) tool (see an example below).
Starting Emulation