Hacking SXOS Loading xci's over the network with a raspberry pi

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
I'm not sure if anyone else might find this interesting, but having finally achieved some success I thought I might post about it.

One day while I was playing with a raspberry pi zero in usb host mode (so it appears to be different types of devices to whatever its plugged into), I got the idea to try to build what would appear to be a usb mass storage device, but would not actually have a hard drive or sd card in it per se... It would mount an NFS or CIFS/SMB share and make that appear to be a USB drive to whatever it was plugged in to. That particular dream hasn't worked out very well because the USB host mode gadget ( g_mass_storage ) needs a block device.

But along the way I found out about iSCSI. So what I did was create a 2TB iSCSI target on my Linux server, and configure the Raspberry pi to use open-iscsi to connect to that drive, then it appears as /dev/sda on the raspberry pi. From there I can do this on the pi while it's plugged into the dock of my switch:

Code:
$ modprobe g_mass_storage file=/dev/sda stall=0

and all of the xci's on the iSCSI target appear in the sxos Games and Installer menus as soon as I do that. Wonderful.

It seems like xci cartridge emulation doesn't work for some reason, on the pi everything just hangs, and dmesg shows:

Code:
[ 4195.555978] dwc2 20980000.usb: dwc2_hsotg_ep_sethalt(ep ebba9a1b ep1in, 0)
[ 4195.556501] dwc2 20980000.usb: dwc2_hsotg_ep_sethalt(ep 2a080014 ep1out, 0)

However, installing xci's seems to work fine. It's slow over wifi, but with ethernet added to the pi, it seems to work as well as my external usb hdd.

I hope to figure out why it hangs with xci emulation, and I also plan to figure out if somehow the pi can realize what it's being plugged into and connect to different iSCSI targets accordingly. Like if it's plugged into a switch, mount switch roms. If its plugged into a Wii-U, mount those. If it's plugged into an android device, mount movies and tv? It can also do neat things like scan the filesystem for errors before it makes the drive available to the switch, and switch to a different iSCSI target without unplugging anything.

I thought I would put it out there for discussion if anyone is interested, let me know. It also seems that a USB Y cable is a very good idea because the switch will cause the pi to reboot when it goes to sleep or wakes up.
 

P3T3

Well-Known Member
Member
Joined
Oct 15, 2018
Messages
130
Trophies
0
Age
41
XP
292
Country
United Kingdom
You should be able to inject payload... But pointless as pc and kits do strait out of box..
 

der:Tom

Well-Known Member
Member
Joined
Oct 3, 2008
Messages
187
Trophies
1
XP
682
Country
Austria
Pretty cool, gonna give this a try when im back from home from holiday.
Pls give an update if you manage to mount xcis, that would be awesome ;)
 

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
Pretty cool, gonna give this a try when im back from home from holiday.
Pls give an update if you manage to mount xcis, that would be awesome ;)

Will do, I'll keep this thread updated if I make more progress. This morning I tried using nbd (network block disk) instead of iSCSI and had basically the same results. I'm not sure where to take my troubleshooting next, basically the same thing happens when I try to do xci mounting on the switch, or loading roms on a wii with wiiflow, or loading roms on xbox360 with a modchip. So this leads me to believe the configuration on the pi is the issue, maybe there's some clues in the dwc2 driver. I'll see what I can figure out.
 

justencase6

Well-Known Member
Newcomer
Joined
Jun 22, 2018
Messages
63
Trophies
0
Age
43
XP
449
Country
United States
Have you tried a small size xci. It may be problem with it needing to cach on the Pi first

Sent from my POCOPHONE F1 using Tapatalk
 

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
Sorry, I havent had much time to work on this lately.. I will definitely do a tutorial eventually if I can find something more useable. One thing I do notice is with the pi, using it in host mode and transferring data to a PC and just watching it's speed it will dip to nothing for a second or two every once in a while. It seems data transfer to something like a PC works fine, it's able to resume from that, but the switch won't it locks up when trying to use a mounted xci image when the data transfer stalls, and the pi sits there waiting for the switch to ask for some more when its over.

I've found mixed results when trying to troubleshoot this on the pi, it seems to me that some sort of caching or adjusting block sizes should fix this, but it doesn't seem to. I know there is a couple versions of the Odroid hardware that has usb OTG/Host mode ability and apparently much better driver support. At some point I'll get a Odroid C2 or something and try on that I guess.

If anyone wants to try this, the idea I had was to take one the many versions of this sort of project:
https://www.raspberrypi.org/magpi/pi-zero-w-smart-usb-flash-drive/

What they do is a create an image file on the sd card and when you plug the pi into a pc it makes that image file available to pc as a usb drive. It serves media files to a TV which can play video stored on a thumb drive, so they can copy files to the pi with windows file/print sharing or whatever instead of walking over and unplugging the thing and putting new files on it. Basically the same thing I want to do, but why not just put the storage on a SAN device instead of on the sd card. So, what I'm trying to do is instead of that image file, use an iscsi target as the "image file".. So it's that tutorial, plus any sort of iscsi setup tutorial.

This sort of thing will do:
https://www.server-world.info/en/note?os=Debian_9&p=iscsi&f=3

Small xci or big xci, doesn't seem to make any difference it fails either way but will install and run fine from sd or internal storage.
 
Last edited by Curtman,
  • Like
Reactions: infadown

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
An update...

In trying to figure out what is going on with the raspberry pi, I found that the state of the otg driver for the raspberry pi is not good. For most things, there is a usb driver for its hardware that works well but it doesn't support otg. Therefor you have to force it to use the old upstream driver dwc2, which is buggy and broken for a lot of things.

So I decided to try something else with otg, and chose the RockPi 4. I was going to purchase an Odroid to test, but went with the RockPi to get usb3.0 otg. It arrived the other day and I did some testing. xci mounting worked with very little effort! :switch:

I installed the ubuntu server image on an sd card, booted it up, mounted my raid via nfs, and did "modprobe g_mass_storage file=myroms.img" (which is the same 512GB test file I was testing with iSCSI before). The roms image showed up on my switch, and the games we played worked flawlessly!

Huzzah!

:toot:
 

bsteed641

New Member
Newbie
Joined
Jul 20, 2019
Messages
2
Trophies
0
Age
43
XP
73
Country
Barbados
Thanks for the info, sounds great.

I just ordered my RockPi4 :)
I'm going to try mounting the USB drive directly on the RockPi then sharing it with Samba.

A few things I'm wondering (and too lazy to work out right now!):
1. Will I be able to mount the drive to the local filesystem and write to it at the same time it's mounted to the OTG port?
2. Will the RockPi4 be able to power my USB drive?
3. Will I get full USB 3.0 speeds through my new Pi USB proxy?
4. Will it help solve the USB drive issues in the Switch dock, such as the USB drive switching off and on repeatedly when the Switch is removed from the dock etc.?

I'm also curious what the current drain will be on the Switch USB port, but probably not trivial to measure...
 
Last edited by bsteed641,

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
Thanks for the info, sounds great.

I just ordered my RockPi4 :)
I'm going to try mounting the USB drive directly on the RockPi then sharing it with Samba.

A few things I'm wondering (and too lazy to work out right now!):
1. Will I be able to mount the drive to the local filesystem and write to it at the same time it's mounted to the OTG port?
2. Will the RockPi4 be able to power my USB drive?
3. Will I get full USB 3.0 speeds through my new Pi USB proxy?
4. Will it help solve the USB drive issues in the Switch dock, such as the USB drive switching off and on repeatedly when the Switch is removed from the dock etc.?

I'm also curious what the current drain will be on the Switch USB port, but probably not trivial to measure...

Hi there,

1. the problem you will run into is that mounting the same filesystem on two different devices (usually) is a problem (at the very least, one of them needs to be read only which is fine the switch doesn't need write access). I believe the tutorial I linked to up there, ( https://www.raspberrypi.org/magpi/pi-zero-w-smart-usb-flash-drive/ ) is what you are looking for. He's using a raspi to serve files to a television instead of a switch but he handles the problems you are going to have. So that when you transfer a file to your storage, it needs to "remove and reinsert" the device so that switch will read it's contents again to see the new file. I would imagine "bad things" would happen if you were to delete a file as sxos was trying to read it, things like that.. But it should work well for what you are doing. Also keep in mind that your rockpi will have eMMC media (if you ordered some), so use that to boot and you have an empty micro SD slot that you can use to serve files to the switch if you want. When you insert the g_mass_storage kernel module, the "file=" parameter can take more than one image or drive or whatever, so you can specify your usb drive first, then sd slot, then network iscsi storage, etc.. I don't know if sxos can be made to see all of them, but when you plug the rockpi into a pc you'll see all the devices you specify as separate drives.

2. I've had a 2.5" drive plugged into mine, it seems to work fine. Mine came with a pretty beefy power supply compared to what the Pi came with so I'd imagine it would be fine.

3. It seems in my testing that using the rockpi as a "proxy" to the usb hard drive is the same speed as just transfering to/from the hard drive. Using an iSCSI target located on my RAID is quite a bit faster, I'm unsure on the exact speed I'm getting. But what I do notice is that plugging in a large USB drive full of xci's takes a very long to load in sxos, but the iscsi network drive loads very fast.

4. I would would imagine it definitely would solve that. I think with the rockpi, it doesn't matter if the usb drive is plugged into the rockpi or plugged into some desktop pc on your lan. Then you can set the drive power saving features on the rockpi or the pc or turn them off completely if you want.

Another thing to try is, instead of using "g_mass_storage", try using "g_multi" module instead. It takes the same parameters as g_mass_storage, and it'll appear to the switch to be a usb stick, an ethernet card, and a serial port instead of just a usb stick. I haven't played with that much yet, but it looks fun.

What I'm working on now, is creating some kind of a nice node.js interface for it. I've never done anything with node.js yet, so its a bit of learning curve. My plan is to have the rockpi boot up, load the nodejs app and then you can connect to it with your phone or pc or whatever. Then you'd be able to change media on the fly, have a nice graph showing transfer speeds..

As far as power consumption goes, you shouldn't sink any power from the switch through the rockpi at all. Your rock pi's power supply will power the board and any usb peripherals you plug into it. As far I understand, the OTG port (which you need a USB male to USB male cable to use) can draw power from the switch, but you have to enable that through the /sys interface of the udc driver on the rockpi.
 
Last edited by Curtman,

bsteed641

New Member
Newbie
Joined
Jul 20, 2019
Messages
2
Trophies
0
Age
43
XP
73
Country
Barbados
Thanks Curtman for doing the groundwork on this solution, I've been using it for months. The RockPi4 has been great.

There's a bug accessing exfat as a Samba share. File copy works for files up to roughly 6GB, anything over that will cause Windows to timeout (something to do with preallocation).
There's no known solution. The workaround is to use a tool like WinSCP for larger files.

Be sure to keep SX OS and SX Installer up to date. I've had relatively few issues with FW 9.1.0, SX OS v2.9.3 Beta, SX Installer 3.0.2 and Autoloader 1.30.
 

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
Thanks Curtman for doing the groundwork on this solution, I've been using it for months. The RockPi4 has been great.

There's a bug accessing exfat as a Samba share. File copy works for files up to roughly 6GB, anything over that will cause Windows to timeout (something to do with preallocation).
There's no known solution. The workaround is to use a tool like WinSCP for larger files.

Be sure to keep SX OS and SX Installer up to date. I've had relatively few issues with FW 9.1.0, SX OS v2.9.3 Beta, SX Installer 3.0.2 and Autoloader 1.30.

I've been using it as well, but I've been using disk images shared over NFS so I haven't run into any issues with >6GB. Recently I switched to Atmosphere instead of SXOS, which I discovered doesn't have the ability to use USB mass storage devices in the same way as SXOS. I find the Rockpi works well for an XBox360 that I modded for the kids to play with also, so we've been mostly using it for that these days. I also purchased something called an Orange Pi, which was much cheaper and works pretty well too, its USB2 instead of the Rockpi's USB3, but I'm not sure that even makes a difference unless its connected to a USB3 host. The switch seems to put it into USB3 mode, but the 360 uses USB2.

I've been experimenting with an idea I had to run a Nodejs server app on the rockpi which would allow nice easy configuration of different "profiles" for different consoles. It could display a transfer speed graph and other things.. Maybe in "Atmosphere" mode, the user could open the nodejs address in a browser on a PC or phone, they would see a list of available NSPs with some scraped meta data and it would send to tinfoil/goldleaf with a couple clicks.. It seems the rockpi is a fairly decent media player as well, so I imagine something like a kodi plugin to configure it would work as well. I'm new to nodejs, and sort of using this as an excuse to learn it, but how much time I can spend on it is pretty limited. Hopefully I'll have something usable to share soonish.
 
Last edited by Curtman,

Armandooooo

Member
Newcomer
Joined
Mar 28, 2019
Messages
16
Trophies
0
Age
44
XP
118
Country
Switzerland
Hi Curtman,

I see your thread very interesting. I have been looking over the past months for a way to stream my games rather than copying them through different support. The usual way is now to copy them to a sd card and play and this is what everybody is doing in the retrogaming. However all my games are stored in a NAS and all my consoles are staying at the same place (original xbox, xbox 360 and switch). Network seems to me to right place to store and read especially for old consoles.

Rockpi is appareny the only one witb usb3 otg enable out there and as you mentionned raspb pi zero, orange pi and some other.

I am looking at this and will work also on a few things to try out.
Did you make some tests on speed you acheive with you different solution?

Thanks
Armandooooo
 

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
Hi Curtman,

I see your thread very interesting. I have been looking over the past months for a way to stream my games rather than copying them through different support. The usual way is now to copy them to a sd card and play and this is what everybody is doing in the retrogaming. However all my games are stored in a NAS and all my consoles are staying at the same place (original xbox, xbox 360 and switch). Network seems to me to right place to store and read especially for old consoles.

Rockpi is appareny the only one witb usb3 otg enable out there and as you mentionned raspb pi zero, orange pi and some other.

I am looking at this and will work also on a few things to try out.
Did you make some tests on speed you acheive with you different solution?

Thanks
Armandooooo

I don't currently have SXOS on any of my switches so I can't really test speed with that at the moment, with gigabit ethernet to the rockpi, and USB3 mass storage serving a FAT32 file image which is located on my RAID6, I get about 90MB/s when the rockpi is connected to my Macbook at USB3 speed.


Curtiss-MacBook-Pro:NO NAME curtis$ gdd conv=sync bs=1024 if=foo.img of=~/Desktop/foo.img status=progress
2229248+0 records in
2229248+0 records out
2282749952 bytes (2.3 GB, 2.1 GiB) copied, 24.767 s, 92.2 MB/s


The real convenience for us was having a single repository of all of our games which we could play on either switch without installing on the console. You have to be sure to make them read-only if you do mount the images on more than one console at a time though. Bad things happen if two different systems start writing to the same filesystem.

It doesn't really do much of anything for Atmosphere etc, there's no USB mass storage support at this time it seems, only SXOS.
 

Armandooooo

Member
Newcomer
Joined
Mar 28, 2019
Messages
16
Trophies
0
Age
44
XP
118
Country
Switzerland
Hi Curtman,

Thanks again for sharing. Is it possible also for you to test the same for your orange Pi and the raspberry pi zero?

I have sx os and a 360 with a xkey i could use and I would like to find the best ratio between performance and consumption.

Thanks,
Armandooooo
 

Curtman

Member
OP
Newcomer
Joined
Dec 31, 2015
Messages
24
Trophies
0
Age
46
XP
320
Country
Canada
Hi Curtman,

Thanks again for sharing. Is it possible also for you to test the same for your orange Pi and the raspberry pi zero?

I have sx os and a 360 with a xkey i could use and I would like to find the best ratio between performance and consumption.

Thanks,
Armandooooo

Sorry for the late reply. It's difficult to get any reliable speed testing on the console, but I can say for sure the switch and the 360 only use USB2 mode on the rockpi. I would recommend the OrangePi, speed seems the same except for connecting to a PC, but it would be faster to just use the network on the PC instead. The other thing I like about the OrangePi is it has a dedicated OTG port (micro usb) which appears to be more reliable. The RockPi has a USB-A port that can be either OTG or a standard USB3 port (You need a USB3 A to A cable to use it - doesn't come with it). People on the RockPi forums report that it does weird things sometimes, I do notice that the RockPi wont work when plugged into the front USB3 port on my PC case (some sort of hub involved), but does when plugged into the back port directly on its motherboard for example. The OrangePi works on both (but only in USB2 mode). Both seem to work equally well on the 360 or the switch. OrangePi wins on price too though.

Radxa who makes the RockPi also have this thing out now too, which I think is cheaper than the OrangePi.

https://wiki.radxa.com/RockpiS
 
Last edited by Curtman,

Armandooooo

Member
Newcomer
Joined
Mar 28, 2019
Messages
16
Trophies
0
Age
44
XP
118
Country
Switzerland
Hello Curtman,
Considering your 93MB/s acheived with a rockPi 1Gbps Eth and USB3, I don't see how Orange Pi or RockPi S can even compete. The limiting factor won't be the USB 2 interface but the 100Mbps Eth interface maxing out at 12 MB/s. If we would have a 1Gbps Eth and USB 2 we would get above 30MB/s as the USB 2 maxes out at 60MB/s theoritically.

Do you have any other experience with board having 1Gbps and OTG?

Thank you,
Armandooooo
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • SylverReZ @ SylverReZ:
    Had a ton of bugs and often crashed. It even didn't support DOS compatibility with older games. :feelsbadman:
  • SylverReZ @ SylverReZ:
    I only grew up with Windows XP because I was lucky.
  • RedColoredStars @ RedColoredStars:
    I downloaded XP on dialup when it came out. Overnights for like a week. cuz I couldn't tie up the phone line during the day. It was so awesome and worked so great going from ME to XP.
  • K3Nv2 @ K3Nv2:
    Vga pins were a dick
  • K3Nv2 @ K3Nv2:
    I kind of want down a large pizza at 10am then crash out
  • ZeroT21 @ ZeroT21:
    Having pizza all day? done it
  • K3Nv2 @ K3Nv2:
    Nah pizza hut open at 10:30
  • ZeroT21 @ ZeroT21:
    just buy a stack of pizza and keep the rest you don't need yet frozen
  • K3Nv2 @ K3Nv2:
    Or buy frozen pizza
  • ZeroT21 @ ZeroT21:
    I buy the regular kind, not the frozen stuff
  • ZeroT21 @ ZeroT21:
    supermarket pizza is ass
  • K3Nv2 @ K3Nv2:
    x65 would just yell at me
  • ZeroT21 @ ZeroT21:
    sounds ok, he didn't pull a gun out ,so...
  • K3Nv2 @ K3Nv2:
    $12 large any style pizza deal
  • K3Nv2 @ K3Nv2:
    Each bite is a $1 well spent
  • SylverReZ @ SylverReZ:
    @ZeroT21, Agreed. I hate oven pizza, only from pizza place.
    +1
  • K3Nv2 @ K3Nv2:
    Nah I can still go for totinos
  • RedColoredStars @ RedColoredStars:
    i like totinos party pizzas. lol.
  • RedColoredStars @ RedColoredStars:
    the cracker-like crust is great on those
  • RedColoredStars @ RedColoredStars:
    My neighbor and I are going to make this next month....
  • SylverReZ @ SylverReZ:
    Tiger crust is great.
  • K3Nv2 @ K3Nv2:
    I'm beefing with a neighbor currently each time I ask him for help with something he makes bs excuses then ignores my calls text but seems to randomly speak when I'm done with the project after doing things to help him
  • RedColoredStars @ RedColoredStars:
    DiGiorno Crispy Pan Pizza tasted pretty dang close to Pizza hut pan pizza, but Im not sure if theyve been discontinued or not. Havent seen them locally for a couple of months now.
  • RedColoredStars @ RedColoredStars:
    The croissant crust is still available though, but not quite as good imo.
    RedColoredStars @ RedColoredStars: The croissant crust is still available though, but not quite as good imo.