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

Aperta Adatta ai principianti
#419 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
linux, raspberry-pi, shell
Ambito
embedded-iot

Direzione di ricerca

Gli attributi della LUN sono impostati nello script shell configure-gadgets, nell'overlay rootfs di mass-storage-gadget64, intorno alle righe 69-73. L'issue collega quel file sul branch buildroot, quindi controlla quel repository e non questo. Confronta le impostazioni di lun.0 lì con il valore predefinito del kernel per removable e trova l'attributo mancante. Il lavoro è completo quando Windows segnala la eMMC come supporto fisso e Raspberry Pi Imager riesce a scrivere un'immagine GPT, cosa che richiede di ricostruire boot.img e di confermarla sull'hardware.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
C
Stelle
1.4k
Fork
318
Merge medio
15h 55m
PR unite (30g)
6

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di raspberrypi/usbboot

Tutte le issue di raspberrypi/usbboot

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.