Last active
February 23, 2020 19:03
-
-
Save yunqu/7fd7ad6c1fdbc8e85dffd2d8dfbb4442 to your computer and use it in GitHub Desktop.
Script to turn on or off the QEMU environment for PYNQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# adjust the following 3 variables if needed | |
board="ZCU104" | |
pynq_path="/opt/builds/PYNQ_20180529" | |
image="${pynq_path}/sdbuild/output/ZCU104-2.5.img" | |
if [[ $(sudo losetup -a | head -c1 | wc -c) -ne 0 ]]; then | |
echo "Image is mounted. Unmounting it..." | |
mounted=1 | |
else | |
echo "Image is not mounted. Mounting it..." | |
mounted=0 | |
fi | |
if [[ ${mounted} -eq 0 ]]; then | |
# mount images and drives | |
mkdir -p ${pynq_path}/sdbuild/build/bionic.${board} | |
./scripts/mount_image.sh ${image} \ | |
${pynq_path}/sdbuild/build/bionic.${board} | |
sudo mount -o bind /proc ${pynq_path}/sdbuild/build/bionic.${board}/proc | |
sudo mount -o bind /dev ${pynq_path}/sdbuild/build/bionic.${board}/dev | |
sudo mount -o bind /run ${pynq_path}/sdbuild/build/bionic.${board}/run | |
# create large tmp dir | |
sudo mkdir -p ${pynq_path}/sdbuild/build/bionic.${board}/local/tmp | |
sudo mount -o bind /tmp \ | |
${pynq_path}/sdbuild/build/bionic.${board}/local/tmp | |
else | |
# unmount images and drives | |
sudo umount -l ${pynq_path}/sdbuild/build/bionic.${board}/proc | |
sudo umount -l ${pynq_path}/sdbuild/build/bionic.${board}/dev | |
sudo umount -l ${pynq_path}/sdbuild/build/bionic.${board}/run | |
sudo umount -l ${pynq_path}/sdbuild/build/bionic.${board}/local/tmp | |
sudo umount ${pynq_path}/sdbuild/build/bionic.${board}/boot | |
sudo umount ${pynq_path}/sdbuild/build/bionic.${board} | |
sudo kpartx -d ${image} | |
fi | |
# Use bash command: | |
# | |
# $ sudo -E chroot /opt/builds/PYNQ_20180529/sdbuild/build/bionic.ZCU104 bash | |
# | |
# to log onto QEMU environment | |
# Use bash command: | |
# | |
# $ exit | |
# | |
# to log off QEMU |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment