Coder Social home page Coder Social logo

m0rf30 / simonpi Goto Github PK

View Code? Open in Web Editor NEW
66.0 8.0 9.0 43 KB

A quick & dirty script to emulate Raspberry PI family devices on your laptop.

Home Page: https://m0rf30.github.io/simonpi

License: GNU General Public License v3.0

Shell 99.45% Dockerfile 0.55%
raspberry-pi rpi emulation archlinux qemu-kernel qemu virtio uefi-boot aarch64 armv7

simonpi's Introduction

SimOnPI

simonpi-logo

Description

A quick & dirty script to emulate Raspberry family devices on your laptop. It generates a valid sdcard image that can be deployed on real hardware and used as virtual storage for QEMU.

Some features

  • Preliminary support for custom images generated by third parties, adopting the classic Raspberry Pi partition table.
  • Use OVMF UEFI images for rpi-2, rpi-3 & rpi-4
  • Almost full KVM acceleration for aarch64
  • Latest stable Linux kernels for every supported platform
  • Basic Networking support
  • Docker image and example docker-compose file for quick deploy
  • SSH guest access

Powered with ❤️ by Arch Linux Arm images

Instructions

Required runtime dependencies

  • coreutils
  • dnsmasq
  • dosfstools
  • e2fsprogs
  • file
  • grep
  • iproute2
  • iptables
  • libarchive
  • procps-ng
  • qemu-arch-extra
  • sudo
  • util-linux
  • curl

From sources

  1. Download the sources and go into the simonpi directory

    git clone https://github.com/M0Rf30/simonpi.git

    cd simonpi

  2. Set permissions for QEMU bridge interface

    sudo echo "allow rasp-br0 >> /etc/qemu/bridge.conf

  3. Download the required EDK2-AVMF images:

    and place them respectively in the follow path:

    /usr/share/edk2-armvirt/aarch64/QEMU_EFI.fd

  4. Type:

    ./simonpi -h for details

and follow the help guidelines

For Arch Linux users

You can find sim-on-pi on AUR

Type:

yaourt -S simonpi

or

yaourt -S simonpi-git

for latest development changes

and that's all!

Docker image

See the How to into docker folder

Deployment

All the assets (disk images, downloaded archives..) are saved in ~/.simonpi by default.

You can transfer your sd img on a valid sdcard using programs like Etcher or this simple command:

dd if=sd-arch-MODEL-qemu.img of=/dev/sdX bs=4M

where MODEL could be:

  • rpi
  • rpi-2
  • rpi-3
  • rpi-4 and theorically next upgrades and X could be mmcblk0 or other block devices

PR

  • Fork it
  • Modify it
  • TEST it
  • Do a Pull Request

Any suggestions are welcome

Used Kernels

Take a look here for adopted Kernel images:

simonpi's People

Contributors

m0rf30 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simonpi's Issues

Enable networking

It's me again having some trouble... (using virtual machines for the first time)

How can I get the virtual rpi connected to the internet? I can boot into archlinuxarm for rpi4 but without networking it feels like I am locked in ;)
Is there a simple trick to use the host network interface in the virtual machine?

No internet connection.

Hi first of all this is really great I have been trying to emulate raspi with some issues however i don't have any internet connection before I was able to connect to internet using

-device e1000,netdev=net0
-netdev user,hostfwd=tcp:127.0.0.1:22355-:22,hostfwd=tcp:127.0.0.1:12334-:12334,id=net0
-net nic \

Tools in /sbin and /usr/sbin are not reached by users on all systems

I'm trying out this on Gentoo, and hit some errors because it is assumed that losetup and sysctl in in path for users. For instance,
CUSTOMIMG=$(losetup -l | cut -d " " -f 15 | tail -n +2 | head -n +1) [in simonpiemu/scripts/storage]
won't work, and neither will
IPFORWARD=$(sysctl -n net.ipv4.ip_forward) [in simonpiemu/scripts/network]
because sysctl and losetup are sbin binaries, which are not in path for standard users on my system.

Can't get network to work

Hey,
So trying to get network to work.

as requested in : #2 (comment)

$ ss -ntl | grep 53
LISTEN     0      128          *:5355                     *:*                  
LISTEN     0      32     192.168.122.1:53                       *:*                  
LISTEN     0      32     127.0.0.1:53                       *:*                  
LISTEN     0      128         :::5355                    :::*    

Need some help to get started

Thank you a lot for providing this very handy script!

I created an rpi4 image by calling simonpi rpi-4 -s 6 and got a file called sd-arch-rpi-4-qemu at the end. Then I launched it with QEMU (using virtual machine manager gui) by selecting this image file, telling the virtual machine that it is archlinux and by creating a 20gb virtual drive.
Unfortunately, when booting the virtual machine, I only get a message stating that no bootable device was found.
Do you have an idea what I might be doing wrong?

[FAILED] Please specify a size in GB

$ docker run -ti --privileged -v /dev:/dev -v ~/.simonpi:/root/.simonpi m0rf30/simonpi s
imonpi rpi-X -s Y
[ WARN ] rpi-X/boot folder is present
[ WARN ] rpi-X/root folder is present
[FAILED] Please specify a size in GB

[Fail] No more loopback device available running on ubuntu 18.04

Hello!
I'm using your fantastic project to emulate a set of RPI to work on automatic cluster configuration.

I'm launching several qemu instances using a docker-compose file and your simonpi docker image. I supply the latest raspbian-light image; and run the command
simonpi rpi-3 -i /root/.simonpi/${SEED_IMAGE_FILENAME} -s 8

It works great on ubuntu 17.10 (the emulators start as intended); but the same config fails on ubuntu 18.04 with "[Fail] No more loopback device available running"

In simonpiemu/scripts/storage I found this line (l43):

if [ ${DEVICE2##*/loop} -gt 5  ]; then
  echo -e "[$FAIL] No more loopback devices available"
  exit 1
fi

And indeed, before I even attempt to rurn the emulators, there are at least 16 /dev/loopXX in my ubuntu 18.04 machine (lots of snaps use loopback devices apparently); while there are less than 5 on my ubuntu 17.10 machine.
So my question is why limit the number of loopback devices to 5? Can it be increased? What would be the best way to tackle the issue?

Download Error Arch image

Hi,

i tried to use your script, but with debug (set -x) enabled i get the following error:

  • downloadArchImage
  • for i in "${FILES[@]}"
  • '[' -f /root/.simonpi/rpi-3/ArchLinuxARM-rpi-3-latest.tar.gz ']'
  • echo -e '[\e[0;32m OK \e[0m] Downloading ...'
    [ OK ] Downloading ...
  • curl -# -L -C - http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz -o /root/.simonpi/rpi-3/ArchLinuxARM-rpi-3- latest.tar.gz

It seems they changed the download url to (https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4)
RPI3/4:
http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz

I tried to edit the files manually, but im not good in that. I also tried to add another target like "rpi-armv7" so it will replace all "rpi-3" entries, but i dont know where to change this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.