mass-storage-gadget64: eMMC is exported as removable media, so Windows cannot write a GPT image

オープン 初心者向け
#419 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
linux, raspberry-pi, shell
領域
embedded-iot

調査の方向性

LUNの属性は、mass-storage-gadget64のrootfsオーバーレイにあるシェルスクリプトconfigure-gadgetsの69〜73行目付近で設定されています。issueはこのファイルをbuildrootブランチへのリンクで示しているので、このリポジトリではなくそちらを確認してください。そこにあるlun.0の設定を、removableに対するカーネルのデフォルト値と比較し、欠けている属性を見つけてください。Windowsがeゼロ MMCを固定メディアとして認識し、Raspberry Pi GPTイメージを書き込めれば完了です。これにはboot.imgの再ビルドが必要で、実機での確認も必要です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

configure-gadgets in the mass-storage-gadget64 initramfs sets cdrom, ro and nofua for the LUN, but not removable:

https://github.com/raspberrypi/buildroot/blob/mass-storage-gadget64/board/raspberrypi64-mass-storage-gadget/rootfs_overlay/usr/local/bin/configure-gadgets#L69-L73

removable therefore stays at the kernel default 1. Windows does not read a GPT on removable media: it mounts the whole eMMC as one "superfloppy" volume and rejects every raw write with ERROR_INVALID_FUNCTION. Raspberry Pi Imager, balenaEtcher, Win32DiskImager and diskpart all fail the same way, without any progress. Writing the same image from Linux works.

Adding one line next to the others fixes it:

echo 0 > functions/mass_storage.usb${id}/lun.0/removable

With that line, Windows shows the GPT with all partitions and Imager writes the image (13.5 GiB in about 14 minutes). We have been shipping a repacked boot.img with exactly this change; kernel, firmware and device trees are untouched.

Steps to reproduce the behaviour
  1. CM4 with eMMC, nRPIBOOT and USB_OTG jumpers fitted, USB connected to a Windows PC.
  2. rpiboot -d mass-storage-gadget64 (current boot.img from this repository).
  3. Write any image with a GPT partition table to the exported disk with Raspberry Pi Imager.
  4. The write fails immediately; Disk Management shows one volume spanning the whole disk instead of the GPT partitions.

Workaround without rebuilding: on the gadget's serial console (USB COM port), detach the gadget, clear the bit and attach it again (re-attaching drops the console too, hence nohup):

G=/sys/kernel/config/usb_gadget/rpimsg
nohup sh -c "sleep 4; echo > $G/UDC; sleep 2; \
  echo 0 > $G/functions/mass_storage.usb0/lun.0/removable; sleep 1; \
  echo fe980000.usb > $G/UDC" > /tmp/fix.log 2>&1 &

Afterwards Get-CimInstance Win32_DiskDrive | Where-Object { $_.Model -match 'mmcblk' } | Select-Object Model, MediaType reports External hard disk media instead of Removable Media, and Imager writes.

Device(s)

Raspberry Pi CM4

Compute Module IO board.

Custom carrier board

RPIBOOT logs

No response

Kernel logs

No response

Device UART logs

No response

主要言語
C
スター
1.4k
フォーク
318
平均マージ
15時間 55分
マージ済み PR(30日)
6

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

raspberrypi/usbboot のほかの issue

raspberrypi/usbboot の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。