Wednesday, November 18, 2015

Arch Linux Chroot on Steam Link (Easy Setup)

Alright, this should be a much more user-friendly method of getting an Arch Linux chroot going on your steam link. But by doing it this way you're going to have to have some trust in me as we're going to be downloading and running a shell script that could potentially screw up your Steam Link. Its very un-likely though, more likely is losing important data on any storage devices you may have plugged into the Link.

So first things first you're going to need a USB HDD or pendrive that you don't care about as all of the data on it needs to be wiped. After you're certain that this storage device has nothing important on it plug it into the steam link. Then you're going to need SSH access to your steam link, after you've SSH'd into your steam link do `busybox sh` to switch to a better shell with tab auto-completion. Now do `cd` to enter /home/steam/ then do `wget` to download my script that will automate turning the storage device you have plugged in into the chroot 'system'. Next do `chmod +x` this will make the script executable. Now if you're a little Linux savvy make sure that you only have one device in /dev/block/sd* if you have anything other than sda[1-9] then you might want to double check that nothing else is plugged into the Steam Link. If you don't know what any of that means or you're sure that nothing else is plugged into the Link do `./ /dev/block/sda` this will start the script on your plugged in device. It will ask you to type yes in order to continue, do so when you're ready to wipe the plugged in device (last chance!).

Now it will proceed to partition and format the drive. Then it will install my pre-built chroot environment onto it. This may take a while but after its done you can do `cd /mnt/chroot` and then do `./` and you'll be in a Arch Linux environment. When you're done hit Ctrl+D until you get 'Syncing filesystem...' this will make sure you don't lose any data in the chroot when you're done.

After you power-off the Steam Link /mnt/chroot won't exist anymore. To re-mount it do `mkdir /mnt/chroot` and then `mount /dev/block/sda1 /mnt/chroot`. Now you can `cd /mnt/chroot` and `./` again.

As a side note anyone with Linux experience might notice the /home/steam/usbip folder. In it is usbip for the Linux 3.8.13 kernel which is on the Steam Link. I'm still working on how to get it working with windows but if you already know what usbip is feel free to try it out.

Arch Linux Chroot on Steam Link (Manual Setup)

Note: If you don't have access to a Linux desktop you can use this method instead.

I'm going to try and help you guys setup an Arch Linux chroot environment on your steam link. If you don't know what SSH or Linux is then this post isn't for you. First things first you'll need to have ssh access to your steam link. Below I'm going to detail setting this up with my pre-created tar file on a Linux desktop, if you don't want to use my premade one I'll detail how I made it at the end. If you're on Windows just wait it out, I'll do a post for it later.

First you'll need a separate pendrive or usb hdd to run the chroot environment on. You need to format this harddrive/pendrive to have an ext4 partition on it that the chroot will be on. You'll need to make this partition at least 1GB, the extracted tar file is roughly 700Mb but you'll want some spare room for pacman updates ect. After you've created your ext4 partition mount it on your desktop and un-tar the steamlink-chroot.tar.gz above onto the new ext4 partition. So the root of the ext4 partition will have one file and one folder: chrootdir and 

After you've correctly done the above you can un-mount the ext4 formatted drive and insert it into your steam link. Then SSH into the Link and do `busybox sh` this will switch you to the busybox shell instead of the ash shell which doesn't have tab completion. So now any directories or commands you need to type in you can hit tab to auto-complete them. Now `cd /mnt` to go into the mnt directory and create a folder to mount your drive onto (`mkdir chroot`). Then `cd chroot` to go into the drive and do `ls` to make sure your script is there. Now you can do `./dochroot` and it should drop you into your new Arch Linux chroot. `pacman -Syu` will update your install. When you're done with the chroot hit Ctrl+D until it says 'Syncing filesystem...' that way you wont lose any data in your chroot. Now you can close the SSH session.

Be sure to read the Arch Linux Wiki for any questions about Arch Linux.

So the reason why I had to tar up a bootstrap for you guys is because the Steam Link doesn't ship with bash so the arch-bootstrap script doesn't run on the vanilla system. In order to get it to run to setup the initial bootstrap I had to download bash and all its dependencies from the archlinuxarm site. If you want to setup the bootstrap yourself without my premade tar file then download: bash, glibc, ncurses, and readline from the archlinuxarm site above. Then set your LD_LIBRARY_PATH to /lib and the usr/lib from the packages downloaded above. Now you should be able to do ./usr/bin/bash -a arm to create your initial bootstrap. After that's done you'll want to use my file in the steamlink-chroot.tar or manually mount dev, proc, and sys into your chroot environment. A fun note for those who notice, /home/steam/usbip has the usbip userspace tools and the kernel modules in it. In the future I'll try and make a post about using usbip to use any USB device with your steam link. Like headsets and maybe even the xbox one controller if I can get usbip to cooperate on windows. Basically anything that already works on your host machine through BPM should work through usbip. 

Thursday, November 12, 2015

Disabling Steam Link Auto-Standby

There was a reddit post a week or two ago that was having trouble keeping their Link on while watching youtube. I posted a fix in there but forgot to make it more public for others with the same issue to find. So if your Steam Link is automatically turning off / hibernating / standby / shutdown / suspending whatever you want to call it there is a temporary fix until Valve adds a setting for it.

The steam link is set to enter a suspended state after 15 minutes of inactivity by default, the defaults can be changed with two files though. Create two files, name one `suspend_timeout_idle.txt` and the other `suspend_timeout_interactive.txt`. These two files will contain the number of seconds before the Link will ask if you're still using the device, and the other file is the time before the Link will auto-standby without asking. I still haven't entirely figured out why there's two files yet but by default both of them are set to 900 seconds so I just keep them the same value with no issues. It seems to use the interactive one first to ask the user and then the idle one has a clamped minimum of ~60 seconds before it will auto-standby; after asking the user if they're still there.

Then in those two files (suspend_timeout_idle.txt and suspend_timeout_interactive.txt) put the number of seconds you want your Link to be on before it goes into standby. I use 7200 for 2 hours but you can use any integer value, if you want you can even use 43200 for 12 hours; doesn't matter.

Then put those two files onto a pendrive in these folders /steamlink/config/system/ So you'll have three folders, the two txt files need to go into the system folder, which is in the config folder, which is in the steamlink folder.

From there just un-plug your Link and insert the pendrive. Then re-plug in your Link and after it boots it should read the two files and stop standing by after 15 minutes. This should persist permanently unless you do a factory reset or a future update removes the support for it or the files themselves.

Wednesday, October 21, 2015

Removing Steam Link Bandwidth Limit

A reddit thread brought to my attention that there is a bandwidth limit on the steam link. I've finally figured out where the stream settings are saved and how to read / write them.You will also have to make one file called streaming_args.txt, I'll explain below.

streaming_settings.bin This config file has its maximum_bitrate_kbps set to 0. Which signifies no limit.
streaming_settings_100000.bin This config file has its maximum_bitrate_kbps set to 100,000 for 100mbps.

To use these you can either scp them into your /mnt/config/system/ folder as streaming_settings.bin or you can put the file on a USB pendrive as /steamlink/config/system/streaming_settings.bin and reboot with the pendrive inserted. (Note: You need to hard 'reboot' un-plug and re-plug the power, you should see the steamlink on a blue background icon thing.)

To see if it worked goto your Streaming settings and press Y to go into Advanced Settings. If it worked your Bandwidth Limit row will be blank. You can change any other settings but just make sure you don't go left/right and change the setting on the Bandwidth Limit or you'll need to replace the streaming_settings.bin again.

Now to disable the 25mbps hardware encoding limit inside the streaming_client binary you need to create a file called `streaming_args.txt` inside that file put `--hardwarebitratelimit 0` (Note: 0 will disable the limit but you may get black flickering, setting it to 35000 seems to work the best for me) and save it either with scp to /mnt/config/system/ or with a USB drive at /steamlink/config/system/.

Those two changes will allow you to exceed 25mbps bandwidth limit in the hardware encoder. Another interesting thing to play with is in the streaming_args.txt you can specify other arguments. Like --novsync. Below is a full list of the supported arguments that you can put in the streaming_args.txt

--scale [1?]
--quality [1-3]
--captureres [WxH]
--framerate [N]
--hardwarebitratelimit [N (Kbit/s)]
--bitrate [N (Kbit/s)]
--burst [N (Kbit/s)]
--server [IP:PORT]
--settings [PATH]
--gameid ?

Tuesday, October 20, 2015

Steam Link Developer Builds

Notice for anyone that hasn't found the dev_build.txt and the two indev builds 'available' to the public right now. I've been neglecting to post the dev_builds.txt just to avoid anyone from grabbing the 337 and 341 and flashing them to their links. The 337 build works fine but I see no notable changes, the 341 build actually fails to run on the steam link. On startup the 341 build gives you an error telling you to contact a internal valve employee. The message is a little more specific but I'm trying to avoid names. 

But if you're feeling technical and comfortable in your ability to fix your steam link should something mess up then you can flash the 337 and 341 builds manually with a USB drive, see the S01config script in /etc/init.d/startup in there you can see how to change your update branch to dev and flash the dev images. Once again I'm being ambiguous just to avoid hand-holding anyone into messing something up. All in all though the two dev builds don't hold anything useful to the public, the 341 is fairly interesting with its error message though. 

Also 04_2015 is a valid hardware branch, but I doubt any of those SystemUpdate images will cooperate on our public 06_2015 hardware. Tinker carefully my friends.

Saturday, October 17, 2015

Root and SSH Access on the Steam Link

Alright this was a lot easier than I expected. Thanks Valve!

After digging through the full 332 update zip I found that Valve left their developer init scripts in /etc/init.d/startup. Not sure if they did this intentionally or not but I like it. So first and foremost I was wrong about the Android AOSP thing, it looks like its just a custom linux and the android stuff I was seeing earlier was just from them using the android signing utility for their updates. Basically they use signapk on their zip files which leaves some android stuff in META-INF. So sorry about the false alarm there.

As for enabling ssh on your Steam Link its very easy. All you need to do is get a pendrive and make this file in these folders: /steamlink/config/system/enable_ssh.txt (Note: the file must have some data in it, if enable_ssh.txt is empty it will not work)

Then reboot the Steam Link with the pendrive inserted, after its done connecting to the network you can ssh into the Steam Link as root with the password `steamlink123`

Have fun!

If you want to dig into it some more look in the /etc/init.d/startup/S01config, in there you can see that you can overwrite any system files or flash a older/custom firmware with a usb pendrive.

Steam Link Software Update System

Currently looking into the updater system for the Steam Link.

As for the update system its fairly simple, the first thing the Link does is send a request to.

That returns a newline delimited list of the 'public' Steam Link builds. If there is a higher version in that list somewhere then it will send a request to[current_version]_[latest_version].zip

That will download the delta update and the system will reboot. Its actually pretty well thought out how they designed the update system, it uses bsdiff to keep the updates small. 

Also after some trial and error I found that[version].zip is also available for full updates, these zips even contain the recovery/bootloader files.