How to use g_mass_storage/usb_f_mass_storage on luckfox pico?

  • Hello, I haven't tested simulating a UMS device on the Luckfox Pico under Ubuntu, but I have successfully implemented it under Buildroot. After configuring g_mass_storage and usb_f_mass_storage in the kernel (make sure they are not compiled as modules), modify /etc/init.d/S0usbdevice to set UMS_EN=on, and then restart the system
  • Thanks for the reply and can you provide an example on to emulate UMS on luckfox pico pro?
  • I have only performed some basic tests, using the Buildroot system on the Luckfox Pico Ultra platform (using SPI flash might cause file system compatibility issues). The kernel is already configured by default, and I mainly modified /etc/init.d/S50usbdevice. The configuration is as follows, with other configurations using the defaults:

    Code: Select all

    UMS_EN=on
    UMS_BLOCK_SIZE=10
    UMS_BLOCK_TYPE=ext4 # You can also use fat, provided that mkfs.fat is added in Buildroot
    
    After restarting the Windows computer, the Luckfox USB device will be recognized as a USB drive. At this point, you still need to mount /userdata/ums_shared.img to the root file system in order to see the contents of UMS on the Luckfox Pico. The UMS_BLOCK_AUTO_MOUNT in S50usbdevice does not work successfully.

    Code: Select all

    losetup /dev/loop1 /userdata/ums_shared.img
    mount /dev/loop1 /mnt/ums
    
    The current problem is that changes to the files on the USB drive are not updated in real-time. After making changes, you need to remount the drive to sync the changes.
  • Thanks for the reply, its working. It would have been nice if the mounting was real-time. For the project im working on it needs to be in real time.
  • Crocodile wrote: 2024-08-12 9:58 I have only performed some basic tests, using the Buildroot system on the Luckfox Pico Ultra platform (using SPI flash might cause file system compatibility issues). The kernel is already configured by default, and I mainly modified /etc/init.d/S50usbdevice. The configuration is as follows, with other configurations using the defaults:

    Code: Select all

    UMS_EN=on
    UMS_BLOCK_SIZE=10
    UMS_BLOCK_TYPE=ext4 # You can also use fat, provided that mkfs.fat is added in Buildroot
    
    After restarting the Windows computer, the Luckfox USB device will be recognized as a USB drive. At this point, you still need to mount /userdata/ums_shared.img to the root file system in order to see the contents of UMS on the Luckfox Pico. The UMS_BLOCK_AUTO_MOUNT in S50usbdevice does not work successfully.

    Code: Select all

    losetup /dev/loop1 /userdata/ums_shared.img
    mount /dev/loop1 /mnt/ums
    
    The current problem is that changes to the files on the USB drive are not updated in real-time. After making changes, you need to remount the drive to sync the changes.
    After modifying a file in /mnt/ums, the Windows side cannot synchronize the update.How can I fix it?