hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1k stars 176 forks source link

Support Loop Devices (flashing to file) #102

Closed u8sand closed 6 years ago

u8sand commented 6 years ago

I got this working by applying this patch to flash:

diff -Naur orig/flash new/flash
--- orig/flash  2017-09-20 11:36:11.953099540 -0400
+++ new/flash   2017-09-20 11:30:56.619773917 -0400
@@ -277,6 +277,8 @@

 if beginswith /dev/mmcblk "${disk}" ;then
   dev="${disk}p1"
+elif beginswith /dev/loop "${disk}" ;then
+  dev="${disk}p1"
 else
   dev="${disk}1"
 fi

And using the following approach:

# wrapper.sh [...]
qemu-img create -f raw test.img 4G
disk=$(sudo losetup --show -Pf test.img)
sudo bash ./flash -d $disk $@
sudo losetup -d $disk

Later I could test it with qemu-system-arm

Perhaps this could be integrated in the script?

StefanScherer commented 6 years ago

The change looks good. Just send a pull request. Thanks