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

Abierto Apto para principiantes
#419 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
linux, raspberry-pi, shell
Área
embedded-iot

Línea de trabajo

Los atributos de la LUN se establecen en el script de shell configure-gadgets, en el overlay de rootfs de mass-storage-gadget64, alrededor de las líneas 69-73. El issue enlaza ese archivo en la rama buildroot, así que revisa ese repositorio y no este. Compara la configuración de lun.0 allí con el valor predeterminado del kernel para removable y encuentra el atributo que falta. Está terminado cuando Windows informa la eMMC como medio fijo y Raspberry Pi Imager puede escribir una imagen GPT, lo que requiere reconstruir boot.img y confirmarlo con el hardware.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C
Estrellas
1.4k
Forks
318
Merge medio
15 h 55 min
PR fusionados (30 d)
6

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de raspberrypi/usbboot

Todos los issues de raspberrypi/usbboot

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.