Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Zero/dev/usb-mass-storage

< Zero‎ | dev
 Radxa Zero >  Development >  USB Mass Storage

Description

This guide describes how to setup USB Mass Storage on Radxa Zero.

Requirement

  • Radxa Zero
  • Host PC with Ubuntu
  • USB Male A to C or USB C to C cable
    • The USB cable is used for powering the Radxa Zero as well as data transmission from your host PC to the Zero. Depends on the USB port on host PC, you may need USB A to C(host PC is USB A) or USB C to C(host PC is USB C) cable.
  • Mouse, monitor and HDMI Cable
    • To access Radxa Zero
  • USB to TTL serial cable
    • To access Radxa Zero

Enable USB mass storage on Radxa Zero

Step 0: Make sure that kernel version is at least version 5.10.69-6-amlogic. Otherwise, you can upgrade the kernel with the following commands:

rock@zero:~$ sudo apt update
rock@zero:~$ sudo apt install -y linux-headers-5.10.69-6-amlogic-g775a46783ad8
rock@zero:~$ sudo apt install -y inux-image-5.10.69-6-amlogic-g775a46783ad8

Step 1: Disable amlogic-adbd service. It will interfere with USB mass storage mode:

rock@zero:~$ sudo systemctl disable amlogic-adbd

Step 2: Reboot the device:

rock@zero:~$ sudo reboot

Step 3: Create a file backing for mass storage, and format it in FAT32:

rock@zero:~$ sudo dd if=/dev/zero of=/home/rock/share bs=1M count=512 status=progress # Create a 512M file as /home/rock/share
rock@zero:~$ sudo apt-get install dosfstools # dosfstools contains mkfs.fat
rock@zero:~$ sudo mkfs.fat /home/rock/share -F 32 -I

Step 4: Enable USB mass storage on our backing file and create test.txt file:

rock@zero:~$ sudo modprobe g_mass_storage file=/home/rock/share stall=0 removable=1
rock@zero:~$ sudo mount /home/rock/share /mnt/
rock@zero:~$ sudo touch  /mnt/test.txt
rock@zero:~$ echo "hello radxa" | sudo tee /mnt/test.txt
hello radxa
rock@zero:~$ cat /mnt/test.txt
hello radxa

Accessing storage device from Ubuntu PC

After executing command sudo modprobe g_mass_storage file=/home/rock/share stall=0 removable=1 on Radxa Zero, a new USB storage device will be detected on your host computer:

radxa@x86-64:~$ lsblk
...
sdd           8:48   1   512M  0 disk /media/radxa/5A81-B2F
...

Here we have to remount the share space:

radxa@x86-64:~$ sudo umount /media/radxa/5A81-B2F
radxa@x86-64:~$ sudo mount /dev/sdd /mnt/
radxa@x86-64:~$ cd /mnt/
radxa@x86-64:/mnt$ ls
test.txt
radxa@x86-64:/mnt$ cat test.txt
hello radxa