I am using gadget api to use my jetson xavier nx as a mass storage and display only my non-confidential data and keep my confidential data hidden, so I am creating one gadget in the directory:
/sys/kernel/config/usb_gadget/
I did all the configurations and created mass storage function for the same, but l4t gadget is already there in the same directory and it is bound to UDC, so I am not able to bind newly created gadget to UDC. and if I unbind l4t from UDC, then I am not able to access jetson using USB OTG port. Is there any way I can bind my new gadget to UDC?
I can’t answer, but I want to add a note that the gadget L4T services are actually “modular”. If you just disable the L4T gadget, then it stops all of those services. If instead you edit the individual services in “/opt
” leading up to the L4T gadget services, then it becomes possible to edit only the mass storage and leave the other parts alone.
The existing mass storage, found in human-readable bash
script content, is merely a loopback covered file pretending to be a partition. To edit this to point at something other than the given loopback device, e.g., to point at an actual partition, or perhaps a different loopback covered file, is likely to do what you want. All you would lose is that read-only README file.
Note that you could copy the relevant subdirectory of “/opt
”, temporarily disable the service run from the original directory, and edit your copy to start everything except mass storage. Separate out the “other” parts of the service, and put the existing README gadget to its own file. The goal is to run what already exists, but to be able to segregate the service start/stop for the “other” content from a start/stop which handles only the “README” content. At that point you could edit the “README” start/stop content to instead name your content.
If you look closely at that content, then you’ll see it is simply a start or stop script with a wrapper for use in the systemd
start/stop.
@linuxdev ,
Thank you for your comment.
I will try to implement what you have suggested.
But still I want to ask if there is any way I can make this possible by creating a new gadget without making any changes in L4T. I have read about the dummy_hcd kernel module, which combines an emulated host controller with an emulated device controller, by using which, even if we don’t have access to hardware UDC, we can use gadgets. So, can you give me some idea about that? or any other way I can make this possible?
Thank you so much.
You need the kernel driver. That seems to be present since the NVIDIA sample with the README file is present. I have no experience with creating a separate unrelated Gadget filesystem mount, but I see no reason why you couldn’t do this. However, it is more complicated than people think since you must emulate low level USB code; the sample code is a wonderful tutorial and example.
If you copy that NVIDIA Gadget content into a new directory, then there is no reason you cannot edit this to remove everything except the part performing the README loopback filesystem mount. Then edit, which means you are only using the NVIDIA content as a template, and not as a replacement. You are free to learn this from scratch, but the start/stop scripts and other content is something you’d have to reinvent from scratch. This isn’t a kernel module, this is the metadata and support on the user side, and I don’t think adding a kernel module will change anything. This does not modify Ubuntu other than using it (and L4T is just Ubuntu with NVIDIA drivers…it is Ubuntu, there is nothing special about the scripts used for Gadget).
I don’t have any experience with the dummy_hcd module, but I will say I don’t think it is needed. There is also no reason you couldn’t use this if it is your preferred method of access. Anything you see related to this on Linux would apply to the Jetson. Anything you see on this specifically targeting Ubuntu is better.
I made changes in /opt/nvidia/l4t-usb-device-mode/ directory. I changed filesystem.img with my own .img file, so now I am able to see a large volume instead of L4T-README(16MB). So, can you suggest me how can I hide my confidential data and show only non-confidential data by using this or in shortly how can I control media access on my jetson?
That’s a few volumes of books. One of the most basic is that you can encrypt the filesystem on the filesystem.img
. All of the normal/usual documentation on this for Linux and Ubuntu apply. The only difference is that you make any changes to the loopback file covering the “partition” instead of naming a partition directly. Any computer trying to mount this will require the ability to mount this encryption scheme, along with any credentials.
Once you get into trying to make all of the requirements on the Jetson itself (and not having the person on the other end mount an encrypted system) you will have a lot more to deal with, e.g., secure web server services; in that case you wouldn’t need the gadget, you’d need something else. So my above comment is one of assuming you want it to work with a partition as a whole.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.