SPIKE プライム のファームウェアを抽出する
バックアップとして残しておきたいのでファームウェアを抽出する必要があったので、その方法を備忘録としてまとめました。
事前準備
WSL2でUbuntuを起動できるようにしておく。
dfu-utilを使えるようにインストールする。
sudo apt-get install -y dfu-util
ubuntuにusbipdをインストールする
sudo apt install linux-tools-virtual hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip $(ls /usr/lib/linux-tools/*/usbip | tail -n1) 20
windowsにusbipd-winをインストールする
Ubuntuとスパイクプライムの接続
SPIKE プライムをDFUモードでPCに接続する。
その後、Windowsで
usbipd wsl list
を実行後、SPIKEのbusidを調べ、Ubuntuにマウントする。
usbipd wsl attach --busid 3-1
Ubuntuでの操作
SPIKE プライムが接続しているかどうか確認する。
sudo dfu-util --list
ファームウェアを読み出す。
sudo dfu-util --alt 0 --dfuse-address 0x08000000:1048576 --upload ~/firmware.bin
Take ownership of the file created by the dfu-util program.
sudo chown $(whoami) ~/firmware.bin
Remove the first 0x8000 bytes, as these are before the firmware starts.
fallocate -c -o 0 -l 32768 ~/firmware.bin
Remove the trailing bytes that have the value 0xFF, as these are unnecessary.
sed -i '$ s/\xFF*$//' ~/firmware.bin
Rename the firmware to the md5 hash of itself.
mv ~/firmware.bin ~/$(md5sum ~/firmware.bin | awk '{ print $1 }').bin