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

Difference between revisions of "Zero/dev/usb-mass-storage"

< Zero‎ | dev
(Operations on Ubuntu PC)
m (fix typo)
 
(One intermediate revision by one other user not shown)
Line 17: Line 17:
 
** To access Radxa Zero
 
** To access Radxa Zero
  
=== Support ===
+
=== Enable USB mass storage on Radxa Zero ===
Support hardware platform:
+
* All Radxa Zero
+
  
You'd better follow the installation steps.
+
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:
 
+
=== Operations on Radxa Zero ===
+
 
+
Step 1: Make sure that kernel version is at least version 5.10.69-6-amlogic. Otherwise, do the following steps to upgrade kernel.
+
  
 
  rock@zero:~$ sudo apt update
 
  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 linux-headers-5.10.69-6-amlogic-g775a46783ad8
  rock@zero:~$ sudo apt install -y inux-image-5.10.69-6-amlogic-g775a46783ad8
+
  rock@zero:~$ sudo apt install -y linux-image-5.10.69-6-amlogic-g775a46783ad8
  
Disable amlogic-adbd service.
+
Step 1: Disable amlogic-adbd service. It will interfere with USB mass storage mode:
  
 
  rock@zero:~$ sudo systemctl disable amlogic-adbd
 
  rock@zero:~$ sudo systemctl disable amlogic-adbd
  
Step 2: Reboot the device.
+
Step 2: Reboot the device:
 +
 
 
  rock@zero:~$ sudo reboot
 
  rock@zero:~$ sudo reboot
  
Step 3: Create a file to be a shared space and make it FAT32 type.
+
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
+
 
  rock@zero:~$ sudo apt-get install dosfstools
+
  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
 
  rock@zero:~$ sudo mkfs.fat /home/rock/share -F 32 -I
  
Step 4: Enable usb mass storage with the file and create test.txt file.
+
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 modprobe g_mass_storage file=/home/rock/share stall=0 removable=1
 
  rock@zero:~$ sudo mount /home/rock/share /mnt/
 
  rock@zero:~$ sudo mount /home/rock/share /mnt/
Line 52: Line 49:
 
  hello radxa
 
  hello radxa
  
=== Operations on Ubuntu PC ===
+
=== 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,
+
After executing command <code>sudo modprobe g_mass_storage file=/home/rock/share stall=0 removable=1</code> on Radxa Zero, a new USB storage device will be detected on your host computer:
we would see that one device is mounted. That one is Radxa Zero share space.
+
  
  $ lsblk
+
  radxa@x86-64:~$ lsblk
 
  ...
 
  ...
 
  sdd          8:48  1  512M  0 disk /media/radxa/5A81-B2F
 
  sdd          8:48  1  512M  0 disk /media/radxa/5A81-B2F
 
  ...
 
  ...
  
Here we have to remount the share space.
+
Here we have to remount the share space:
  
 
  radxa@x86-64:~$ sudo umount /media/radxa/5A81-B2F
 
  radxa@x86-64:~$ sudo umount /media/radxa/5A81-B2F
Line 71: Line 67:
 
  radxa@x86-64:/mnt$ cat test.txt
 
  radxa@x86-64:/mnt$ cat test.txt
 
  hello radxa
 
  hello radxa
 
=== Troubleshooting ===
 
 
* If you have issue with USB Mass Storage, start a new post on the forum. https://forum.radxa.com/c/zero.
 

Latest revision as of 04:44, 27 May 2022

 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 linux-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