1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SPIKE プライム のファームウェアを抽出する方法

Last updated at Posted at 2023-01-16

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
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?