View: 3260|Reply: 4

NEED ASSISTANCE: OrangePi Zero 2 as USB Mass Storage Gadget / dwc2 overlay

[Copy link]

1

threads

1

posts

11

credits

Novice

Rank: 1

credits
11
Published in 2023-4-3 11:11:20 | Show all floors |Read mode
Trying to utilize a OrangePi Zero 2 as a usb thumb drive that's connectable over the network.  I've done the same with Raspberry Pi devices in the past, but it doesn't look the same here.  What do I need to put into the orangepiEnv.txt to get dwc2 enabled?  What about any requirements outside of the env file?  I'm not familiar with the allwinner overlays and noticed a usbhost one, but when I try to enable it, I get an error:
  1. $ sudo orangepi-add-overlay sun50i-h5-usbhost0.dtbo
  2. Overlay source file name should have the .dts extension
Copy code
Does someone have a HOWTO on getting mass storage working on these?  I know of the sunxi howto that libre devices use, but I don't think that one applies to this architecture.

Based on various other platforms' documentation, I'm guessing the steps would be to enable the overlay, prepare a file with dd/fdisk, mount the file via the overlay, then populate it over usb.  Any guidance would be helpful and appreciated.  Reddit's r/orangepi had no answers for me at all.



0

threads

2

posts

12

credits

Novice

Rank: 1

credits
12
Published in 2023-4-12 05:35:36 | Show all floors
This post was finally edited by mookeyj79 at 2023-4-12 05:59

Okay……………………………...

I've been beating my head against the wall trying to figure this out the last few days. The short answer is: “There is no overlay that you can apply that will enable g_mass_storage. The kernel is just not configured correctly to allow it to work.”

That being said, you can build your own custom kernel with the required capabilities pretty easily and I can even walk you through it!
** PRE-WARNING: I am not an expert. I am an enthusiast who managed to scrap pieces of insight together from actual geniuses that managed to get a working product. **

Before starting, we have a couple of things that we need to consider.

First consideration – Powering the Device: On the Orange Pi Zero 2 (henceforth OPZ2), there is only one OTG port, which is required for 'g_mass_storage' to work, and it happens to be the USB-C port used to power the device. In order to free up the USB-C port, you will have to make a custom power cord to power the device from the GPIO instead. I modified an old USB cable and ran the 5V and GND line to the respective GPIO Pins, and it worked like a charm.

Second consideration – The Build Environment: You will need to setup a fresh Ubuntu 20.04 (Focal) Build environment. The build script that we will be using states that it supports a few different distributions, but specifies that Focal is the only "fully" supported environment. I used the Desktop version of Focal in VirtualBox VM.

With those considerations out of the way, let's build a new kernel!

First step is to download and run the build scripts required:
  1. $ sudo apt install -y git
  2. $ git clone https://github.com/orangepi-xunlong/orangepi-build.git
  3. $ cd orangepi-build
  4. $ ./build.sh
Copy code


0

threads

2

posts

12

credits

Novice

Rank: 1

credits
12
Published in 2023-4-12 05:37:19 | Show all floors
This post was finally edited by mookeyj79 at 2023-4-12 06:12

Select the following menu options:
  • Full OS Image for flashing
  • Orangepizero2 (or whatever board you are using)
  • Current Mainline
  • *User’s choice* (I only tested the Debian release, but I can’t imagine why the other wouldn’t work)
  • *User’s choice* (I chose the Sever variant)
  • *User’s choice* (I went with Standard, your mileage may vary)

Now grab some coffee because the script is going to download some required packages needed to setup the development environment. It will take a minute. If you get a popup for AptCatcherNG, just say yes.

After the setup is done, we need to modify the device’s .DTS file to set the USB-C port to OTG mode. Open a new terminal and type the following:
  1. $ sudo nano kernel/orange-pi-5.13-sunxi64/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
Copy code
** Note this file is specific the OPZ2 board! If you are compiling a for a different Orange Pi, you will need to find the .DTS file associated with your board. Use the chart on https://github.com/orangepi-xunlong/orangepi-build to help you find the right subfolder and .DTS file in the ‘dts’ folder above.**

Change 'dr_mode = "peripheral"' to 'dr_mode = "otg"'

Back in the setup script, set the following options:
*** Please take note of the ‘*’ or ‘M’ before the option. Change by selecting “Select”. Go back to the previous menu by selecting “Exit” ***
  1. Device Drivers
  2.     USB support
  3.         <M>Inventra Highspeed Dual Role Controller
  4.             MUSB Mode Selection
  5.                 (X)Dual Role mode
  6.             Disable DMA (always use PIO)
  7.     USB Physical Layer drivers
  8.         <M>NOP USB Transceiver Driver
  9.     <M>USB Gadget Suppor
  10.         [*] RNDIS
  11.         USB Gadget precomposed configurations
  12.             <M> Mass Storage Gadget
Copy code

Once done, select 'Save', 'OK', then 'Exit'.

Make any other tweaks you would like to make at this point, then select 'Exit' until out of the menu system. Don’t forget to save your changes before exiting!

Grab some more coffee and wait for the kernel to be built, configured, and updated. This part took over an hour for me.

Finally once that is done, you will have an image file located in 'orangepi-build/output/images/<buildversion>'. Use your favorite image burner, or the built in Disk Image Writer in Ubuntu to write it to a SD card.

There! We have an Orange Pi image with a customized kernel!

For the rest of the steps, I would follow this guide starting at step 7, modifying the steps as necessary:
    https://magpi.raspberrypi.com/articles/pi-zero-w-smart-usb-flash-drive  <= This site is also saved on the WayBack Machine in case it ever goes down.
Or you could follow this site starting at 'Preparing shared storage device':
    https://linux-sunxi.org/USB_Gadget/Mass_storage<== Also on the WayBack Machine
I found a combination of the two worked best for creating the block device.

One final important note: Enabling the official Debian sources for apt and doing a dist-upgrade overwrites this kernel, losing the 'g_mass_storage' capability. I mean, yeah, duh, of course it does, but someone …. I …. had to learn this the hard way.

Sources:

0

threads

8

posts

28

credits

Novice

Rank: 1

credits
28
Published in 2024-1-4 15:35:22 | Show all floors
Snow Rider 3D is more than just a downhill thrill ride. It's a game that rewards practice and perseverance. As you master the controls, conquer slopes, and collect coins, you'll unlock new sleds, each with its own unique personality and performance.

0

threads

80

posts

216

credits

Intermediate member

Rank: 3Rank: 3

credits
216
Published in 2024-1-22 16:56:10 | Show all floors
the path to success in snaptik is fraught with challenges. A single wrong turn or a missed obstacle can spell disaster, sending your virtual sledder tumbling down the mountain.
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list