Skip to content

Instantly share code, notes, and snippets.

@hfreire
Last active February 4, 2025 00:47

Revisions

  1. hfreire renamed this gist Nov 28, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. hfreire revised this gist Nov 28, 2015. 1 changed file with 10 additions and 7 deletions.
    17 changes: 10 additions & 7 deletions qemu_rpi.sh
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,19 @@
    # install QEMU OSX port with ARM support
    # Install QEMU OSX port with ARM support
    sudo port install qemu +target_arm
    export QEMU=$(which qemu-system-arm)

    # dowload kernel
    # Dowload kernel and export location
    curl -OL \
    https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
    export RPI_KERNEL=./kernel-qemu-4.1.7-jessie

    # download filesystem
    # Download filesystem and export location
    curl -o 2015-11-21-raspbian-jessie.zip \
    -L http://downloads.raspberrypi.org/raspbian/images/raspbian-2015-11-24/2015-11-21-raspbian-jessie.zip
    unzip 2015-11-21-raspbian-jessie.zip
    export RPI_FS=./2015-11-21-raspbian-jessie.img

    # tweak filesystem: start qemu with init flag, switch to guest window to execute tweak and close window afterwards
    # Tweak filesystem: start qemu with init flag, switch to guest window to execute tweak and close window afterwards
    $QEMU -kernel $RPI_KERNEL \
    -cpu arm1176 -m 256 \
    -M versatilepb -no-reboot -serial stdio \
    @@ -23,13 +23,16 @@ $QEMU -kernel $RPI_KERNEL \
    sed -i -e 's/^/#/' /etc/ld.so.conf
    sed -i -e 's/^/#/' /etc/fstab

    # emulate Raspberry Pi
    # Emulate Raspberry Pi
    $QEMU -kernel $RPI_KERNEL \
    -cpu arm1176 -m 256 \
    -M versatilepb -no-reboot -serial stdio \
    -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
    -hda $RPI_FS \
    -redir tcp:5022::22

    # ssh to Raspberry Pi
    ssh -p 5022 pi@localhost
    # Login to Raspberry Pi
    ssh -p 5022 pi@localhost

    # Referenced from OSX raspberry pi emulation via QEMU - https://gist.github.com/JasonGhent/e7deab904b30cbc08a7d
    # Referenced from Emulating Jessie image with 4.1.7 kernel - https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki/Emulating-Jessie-image-with-4.1.7-kernel
  3. hfreire revised this gist Nov 28, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions qemu_rpi.sh
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,9 @@ $QEMU -kernel $RPI_KERNEL \
    -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" \
    -hda $RPI_FS

    sed -i -e 's/^/#/' /etc/ld.so.conf
    sed -i -e 's/^/#/' /etc/fstab

    # emulate Raspberry Pi
    $QEMU -kernel $RPI_KERNEL \
    -cpu arm1176 -m 256 \
  4. hfreire revised this gist Nov 28, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion qemu_rpi.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # install qemu OSX port with ARM support
    # install QEMU OSX port with ARM support
    sudo port install qemu +target_arm
    export QEMU=$(which qemu-system-arm)

  5. hfreire renamed this gist Nov 28, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. hfreire created this gist Nov 28, 2015.
    32 changes: 32 additions & 0 deletions instructions.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    # install qemu OSX port with ARM support
    sudo port install qemu +target_arm
    export QEMU=$(which qemu-system-arm)

    # dowload kernel
    curl -OL \
    https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
    export RPI_KERNEL=./kernel-qemu-4.1.7-jessie

    # download filesystem
    curl -o 2015-11-21-raspbian-jessie.zip \
    -L http://downloads.raspberrypi.org/raspbian/images/raspbian-2015-11-24/2015-11-21-raspbian-jessie.zip
    unzip 2015-11-21-raspbian-jessie.zip
    export RPI_FS=./2015-11-21-raspbian-jessie.img

    # tweak filesystem: start qemu with init flag, switch to guest window to execute tweak and close window afterwards
    $QEMU -kernel $RPI_KERNEL \
    -cpu arm1176 -m 256 \
    -M versatilepb -no-reboot -serial stdio \
    -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" \
    -hda $RPI_FS

    # emulate Raspberry Pi
    $QEMU -kernel $RPI_KERNEL \
    -cpu arm1176 -m 256 \
    -M versatilepb -no-reboot -serial stdio \
    -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
    -hda $RPI_FS \
    -redir tcp:5022::22

    # ssh to Raspberry Pi
    ssh -p 5022 pi@localhost