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

未关闭 适合新手
#419 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
70/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
linux, raspberry-pi, shell
领域
embedded-iot

调研方向

LUN 属性在 mass-storage-gadget64 rootfs 覆盖层中的 configure-gadgets shell 脚本里设置,大约在第 69-73 行。该 issue 在 buildroot 分支上链接了这个文件,因此应检查那个仓库,而不是这个仓库。将那里 lun.0 的设置与内核对 removable 的默认值进行比较,找出缺少的属性。完成的标志是 Windows 将 eMMC 识别为固定介质,并且 Raspberry Pi Imager 能够写入 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 分钟
30 天内合并 PR
6

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

raspberrypi/usbboot 的其他 Issue

查看 raspberrypi/usbboot 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。