TorizonCore USB mass storage (client)

As I’m starting to use Linux / Toradex, and there are a lot of things to learn, so what might be obvious, is not really for me.

I’ve installed open embedded in Colibri iMX6, and following the instructions in USB device mode, I managed to create a virtual drive that can be accessed by a Windows 10 computer when I plug it to the USB client connector on Colibri Eval board.

Now, I’m trying to do the same with TorizonCore, but I don’t know how to do it. I have tried to follow the same guide lines, but I end up with permissions problem even when using sudo.

Note: I’ve look at dts file and USB port is defined as a host, not client. How so I change/edit it?

I would like the USB not to be part of the container, but rather the system (OS) as I would like to have any container accessing it, if required.

The idea is to have future apps running on containers to be able to access a folder and write log file(s).

By plugging the computer to the Colibri module, user would be able to retrieve (read) log files.

Could you please give some guidance as what would be the best approach in doing this?

Thank you very much.

Greetings @red,

Let’s try to tackle this step by step first. First let’s try and resolve the permissions issue you get on Torizon. On Torizon there’s some work still being done on device/peripheral permission management. As such you run into issues like this where even sudo is of no help. However running as root user should squelch any permissions related issue.

While normally on Torizon we don’t allow users to login as root due to security reasons, there’s still a way to run as root. After you login as the default torizon user run sudo -i. This command should swap your active user to root. Try executing your commands as root and let me know how it works out. Once we’ve overcome the permissions issue we can then try and tackle the other issues you’ve mentioned.

Best Regards,
Jeremias

@jeremias.tx ,

Thanks for the reply.

Even as a root, I can’t create file/folder.

Ok I’m able to confirm a similar result on my side. What’s strange is that you shouldn’t need to make the usb_gadget directory. As in this directory should be there by default if the right kernel configs are enabled which they seem to be in Torizon. You are also correct that in our non-Torizon BSP this is a non-issue. Which is odd seeing as Torizon builds on top of this BSP.

In other words I believe you may have found some Torizon specific regression/bug regarding usb gadget functionality. Let me report this and see what I get back, it may just be a matter of it needs to be re-enabled/re-implemented on the Torizon side.

Best Regards,
Jeremias

Thanks for the feedback. I will wait for your update on this matter.

Regards,
@red

Alright this bug report has been submitted internally. I don’t have any timeline on this yet but I’ll try and keep you updated with any findings/fixes.

Best Regards,
Jeremias

Hi @red,

The team had a closer look and it seems the main issue is that in Torizon certain required kernel modules need to be loaded as they are not built in like in our non-Torizon BSP.

Please try to run sudo modprobe libcomposite on the device. This should restore usb gadget functionality. And for the future you can also have this kernel module loaded on boot by default.

Best Regards,
Jeremias

Hi @jeremias.tx ,

First, thanks for the update.

I have tried following the instructions on USB device mode, but I get an error as dosfstools package is not installed. How can I install packages in Torizon?

Second, could you please give some guidance on how to have this kernel module loaded on boot, by default. I’m going to need that functionality working.

As I have said, I’m really a beginner so any help is appreciated.

Thank you.

Regards,
red

First of all in order to load any kernel module on boot, you can create a config file on the system itself. For a more detailed explanation see here: modules-load.d

On Torizon you’ll want to create this conf file in /etc/modules-load.d/. As a note you’ll need sudo privileges to create/write files in this directory.

For your next question in order to install any package on Torizon, you can do so in a container. Pull and run any of our pre-made Debian-based containers: Debian Containers for Torizon | Toradex Developer Center

Then in the container you can just use the typical Debian package manager of apt. What you must keep in mind however is that this installs packages in the container not on the base system. So you should eventually create your own container based that has all the packages you require. This will let you quickly pull your needed packages via container on any device.

Best Regards,
Jeremias

@jeremias.tx ,

Thanks for the prompt response.

I will take a look at the configuration file to see if can get it to work with Torizon.

Regarding containers, as I have stated in my initial post, the plan is to have different applications (containers) writing data to the virtual USB flash drive, which could be retrieved by plugging the computer to the USB port of the Colibri IMX6 module.

Having said that, what would be the best (or correct way) to do it? Create a container with USB virtual flash drive and allow the other containers to write to it? Or allow each application (container) to have its own USB virtual flash drive implemented? Or maybe none of the above?

I would appreciate if you could give some information on how to implement it.

Thank you.

Regards,

@red

If you want a drive or some kind of folder accessible by multiple containers the best approach would be to have this drive/folder exist on the host OS outside of the containers. Especially if you want persistent data/storage.

This leads to 2 different container mechanism that do approximately the same thing in slightly different ways. The mechanisms you want to look into are bind mounts and volumes. We have some documentation on this on our developer site here: Run and Manage Containers with Portainer and the Command-line on Torizon | Toradex Developer Center

But this is a feature of Docker container themselves, so for further reading/research I’d suggest checking their documentation out on this as well. The mechanisms are fairly flexible depending on your use case.

Best Regards,
Jeremias

Hi @jeremias.tx (It’s been a while since),
I know this is an old thread but I have run into the same question. I learned how to manage the USB client interface in regular Linux by generating a g1.schema file and putting that file in the /etc/usbg directory. But that doesn’t seem to work on Torizon. How do I enable the USB client interface on Torizon?
Mike

Hi @MikeS,

Since this post is rather old and outdated, could you please open a new post with your question.

In this new post please make sure to include additional information like:

  • What hardware you are using
  • What version of TorizonCore you are running
  • What steps you performed so that we may reproduce the issue if needed.

Best Regards,
Jeremias