Skip to content

Instantly share code, notes, and snippets.

@ilyaluk
Created July 12, 2026 21:44
Show Gist options
  • Select an option

  • Save ilyaluk/36f754a6b490687aa3661d57bdab4d0c to your computer and use it in GitHub Desktop.

Select an option

Save ilyaluk/36f754a6b490687aa3661d57bdab4d0c to your computer and use it in GitHub Desktop.
#!/bin/bash
# Dirtywave M8 (M:02, fw 6.5.2C) disk-mode crash repro.
# Alternates a valid block read with an unsupported SCSI command (ATA IDENTIFY
# passthrough, as sent by fwupd) until the firmware stops responding and drops
# out of disk mode. Run as root with the M8 in USB disk mode.
disk=${1:-/dev/sda} sg=${2:-/dev/sg0} n=0
[ -b "$disk" ] || { echo "no block device $disk"; exit 1; }
[ -e "$sg" ] || { echo "no sg device $sg"; exit 1; }
lsusb -d 16c0:0630 >/dev/null || { echo "M8 in disk mode (16c0:0630) not found"; exit 1; }
while dd if=$disk of=/dev/null bs=512 count=1 iflag=direct; do
n=$((n + 1))
echo "attempt $n: block read OK, sending unsupported CDB 0xA1"
sg_raw -t 15 -r 512 $sg a1 08 0e 00 01 00 00 00 40 ec 00 00
sleep 1
done
for _ in $(seq 10); do lsusb -d 16c0:048a >/dev/null && break; sleep 1; done
if lsusb -d 16c0:048a >/dev/null; then
echo "reproduced after $n attempts: M8 crashed out of disk mode, re-enumerated as normal mode (16c0:048a)"
else
echo "disk gone after $n attempts but M8 (16c0:048a) did not re-enumerate - check lsusb/dmesg"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment