Jump to content

USB Gadget - mass storage - Network access


jakoob

Recommended Posts

Hi guys,

I'm trying to solve a very specific problem in our company and after reading several tutorials I'm still not sure, how to achieve my goal. It would nice, if anyone can share his code or help me, however I will also to try to finish it and post the solution here.

 

Idea/Issue:

We've upgraded a very old cutting machine with plasma cutter, however there is only a USB port on the device, therefore our colleagues have to go several times per day from office to workshop and swap flashdrives. Thanks to size of our plant this isn't very good solution. Idea is to take Orange Pi One and connect it to the machine through OTG port, therefore it will act as Flashdrive. Then using Ethernet (FTP) we will send files over network.

 

What to buy/download:

  • Orange Pi One
  • SD Card
  • Wall charger
  • USB phone sync cable
  • Latest Armbian

 

Steps:

  • Install Armbian, etc (done)
  • Activate mass storage on OrangePi (done)
  • Create partition, format as FAT32 and mount it (not working yet)
  • Test behavior - mainly writing data over network while connected to plasma cutter (on hold)

 

 

 

 

Link to comment
Share on other sites

Armbian will expand its filesystem to the size of the sdcard on first boot.

So you may want to look into gparted for editing partitions, or you could setup armbian on a 8GB card,

then dd it to a 16GB card after firstboot and use the now unused space.

Also FTP is a crutch, old and not secure, you can transfer files securely over ssh, via scp or sshfs

depending on your needs.

 

best, gnasch

Link to comment
Share on other sites

Can be done the way outlined by @gnasch. Simply use a 2nd FAT formatted partition. The basics can be found eg here: http://forum.pine64.org/showthread.php?tid=2237

 

Some FTP daemons can call post-upload scripts (pureftpd for example) so in case these are always single file uploads the whole process could easily be automated. But you could also try out first whether you can share the partition as USB mass storage gadget all the time and changes there made by FTP (or Samba) will result in new files being accessible from your cutting machine.

Link to comment
Share on other sites

But you could also try out first whether you can share the partition as USB mass storage gadget all the time ...

 

Well, this is the question I asked me when reading this post : can a FAT partition be shared or does it need to be unmounted by the usbstorage client in order to be accessed locally ?

 

And then what is the client OS and how to handle unmount/reread/usb disconnect ?

 

(There are numerous use cases : you could "recycle" an old "photo frame" to display anything by this way)

Link to comment
Share on other sites

Well, this is the question I asked me when reading this post : can a FAT partition be shared or does it need to be unmounted by the usbstorage client in order to be accessed locally ?

I don't think it can be shared (at least in some easy way), but it should be possible to remount it between board (for network access) and USB gadget driver either manually (i.e. by running a script via SSH) or using event handlers from FTP or SMB servers.

Link to comment
Share on other sites

I did a quick test with FAT32 and OS X (no Windows, sorry). It works to mount the FAT partition locally while also sharing it as USB Mass storage gadget. 'Works' as in 'no errors reported' ;)

 

But both mechanisms work against each other so I fear it's necessary to automate this since the FAT partition can either be mounted/accessed locally or shared in gadget mode (tbc). For my use case (the original question inspired me -- tnx!) that's ok but requires some scripting since it seems the following order is necessary: mount partition, copy changes, umount, load module, change otg_role (now partition/device appears on PC) and then reverse order. In case PC should also write the module's backing store will only be closed when unloading the module.

 

BTW: my use case is close to moronic: by using USB mass storage mode we could integrate a workflow server based on OS X in a customer's network since local IT stuff can only implement virus scanning for local and not network disks. Already curious whether they accept the ugly workaround :)

Link to comment
Share on other sites

Guys, thank you very much for your responses so far. I will do some "cooking" tomorrow and hopefully will solve this. FAT is maybe not the only way. The plasma cutter seems to be rocking some version of Fedora distribution, so it might be better to use other format.

Link to comment
Share on other sites

Guys, thank you very much for your responses so far. I will do some "cooking" tomorrow and hopefully will solve this. FAT is maybe not the only way. The plasma cutter seems to be rocking some version of Fedora distribution, so it might be better to use other format.

 

Then, you probably have a serial port. You should be able to connect to the host for mounting/unmountig with a $4 adapter. You could even try PPP.

Link to comment
Share on other sites

The plasma cutter seems to be rocking some version of Fedora distribution.

 

Using g_ether module on OPI will give you an USB ethernet connection between CutterBox and OPI.

 

Steps :

 

1. OPI : enable g_ether module, configure static IP for new interface usb0, uplink OPI via LAN to systems providing data files

2. Cutterbox : configure static IP for new interface usb0

3. Cutterbox : Write small script to fetch data files via network into target directory on Cutterbox

 

Have fun !

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines