Ubuntu 18.04 on a Switch

Discussion in 'Switch - Exploits, Custom Firmwares & Soft Mods' started by cmsj, Apr 26, 2018.

  1. cmsj
    OP

    cmsj Advanced Member

    Newcomer
    2
    Apr 25, 2018
    United Kingdom
    Current version: 2.0
    Download pre-built images: https://github.com/cmsj/switch_linux_kit/releases/tag/2.0

    There are download/install instructions on the download page :)

    This is now being distributed as a pre-built exploit chain, and a pre-built SD card image, so it should be a lot easier to install/run than before. You can still build it all from scratch of course, if you want to (https://github.com/cmsj/switch_linux_kit is the repo and there are instructions in the README.md)

    Old post content below:

    I've written a script to build a full Ubuntu Desktop image for the Switch (see a screenshot below). There are some instructions here, but be aware that you'll need a Linux machine to both build and run the boot exploit, and to build the Ubuntu image if you don't want to download my image.

    First of all, you need to get the fail0verflow exploit/boot chain working. There's a good tutorial for doing the whole thing here or there is a good Docker image you can run that will do the work for you (but you still need the tegra_mtc.bin file (download here courtest of @CptPotato ). This is non-optional whether you want to use a pre-built Ubuntu image or not.

    Next, either clone my git repo and run ./build-image.sh or download the bionic.tgz tarball from here. As with all the other systems, you need a micro SD card that is partitioned with one small (formatted) FAT32 partition, and a large (formatted) ext4 partition. Once you have the SD card ready, extract bionic.tgz to it with something like: tar xvf /path/to/bionic.tgz -C /mountpoint/of/SDcard

    Then boot the Switch with the exploit as in other tutorials, or if you used the Docker image linked above, run bash -x 02_exploit.sh wait a few seconds then run bash -x 03_uboot.sh and the Switch should boot Linux and after a few seconds, switch to a graphical interface. At the first boot it'll be in portrait mode. Tap on the icon at the very top right of the screen, open the preferences window and you can change the rotation in the display settings.

    What works:
    • 3D acceleration (although it seems slower than it should be, but this code only landed in Mesa *very* recently)
    • WiFi (but you need to tell Ubuntu to reboot and when the screen goes black, re-run the full exploit chain)
    • touchscreen
    • Bluetooth (somewhat, it seems to be a bit unreliable)
    • Light sensor (but you'll probably want to turn that off in the system preferences, because it's very annoying!)
    What doesn't work:
    • Audio
    • Joycons
    One final note, if you tell Linux to shut down, it will do so, but doesn't actually power the Switch off completely, so when the screen goes black, hold down the Switch's power button for ~15 seconds and then press it again to make sure it boots into the Nintendo OS.

    [​IMG]
     
    Last edited by cmsj, May 10, 2018
  2. itsharman

    itsharman Member

    Newcomer
    2
    Apr 25, 2018
    United States
    Whattt, I wish I could do that :/
     
  3. cherryduck

    cherryduck GBAtemp Regular

    Member
    4
    Jul 1, 2007
    The far side of the moon
    Care to share an image of your SD card? Is WiFi, HW acceleration etc working?
     
    CptPotato likes this.
  4. tomman321

    tomman321 GBAtemp Regular

    Member
    2
    Feb 4, 2016
    United States
    Please teach me how to do this
     
    unvaluablespace likes this.
  5. LightyKD

    LightyKD Future CEO of OUYA Inc.

    Member
    9
    Jun 25, 2008
    United States
    Angel Grove, CA
    I just want Android but I'll gladly take a Linux variant that can launch and play Android apps! Might make me ditch my Chromebook!
     
  6. cmsj
    OP

    cmsj Advanced Member

    Newcomer
    2
    Apr 25, 2018
    United Kingdom
    This is the bare bones so far. No WiFi (although there seems to be a general problem there anyway) and no HW acceleration. No bluetooth. Volume buttons work out of the box, the ambient light sensor works (annoyingly, it keeps massively over-reacting the screen brightness). It's almost unusuably slow, but I'm going to keep chipping away at it, and I'll post an image somewhere when it's at least vaguely usable.
     
    weatMod, Quantumcat, Jayro and 15 others like this.
  7. blinkzane

    blinkzane Panic at your moms house

    Member
    5
    GBAtemp Patron
    blinkzane is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Jul 24, 2012
    United States
    Florida
    let me know if you need help, I have a decent background in linux and ubuntu.
     
    MeowMeowMeow likes this.
  8. ShroomKing

    ShroomKing Mr. Nice ( ͡° ͜ʖ ͡°)

    Member
    3
    Mar 3, 2017
    United States
    Another World
    FYI:

    this: https://gist.github.com/ChristophHaag/11f6e7ef577d6f35a2debd64963fdbdf is for hardware acceleration on the tegra x1. I'm using it with arch and team f0f seem to be using it with debian, i'm not very familiar with ubuntu but it *probably* works on there too.

    and this: https://chromium.googlesource.com/c...e28cabf8d658bcb52b/brcm/brcmfmac4356-pcie.txt is for wifi. When using wget on that link the file will come encoded as base64 for whatever reason, make sure you decode it or it won't work.

    Just a quick heads up =)
     
  9. Natehaxx

    Natehaxx GBAtemp Maniac

    Member
    8
    Jul 26, 2017
    Eritrea
    maybe try to install mesa about the HW thing
     
  10. cmsj
    OP

    cmsj Advanced Member

    Newcomer
    2
    Apr 25, 2018
    United Kingdom
    Thanks. Building mesa from git is on the roadmap, I'm just trying to get some other things nailed down first (having gotten it to boot into X, I'm now trying to work out why my touchscreen configs aren't being applied properly :)
    (also thanks for the reminder about the pcie.txt. I had seen that discussed before, but forgot to include it in my image)

    Edit: even with that broadcom textfile, wifi still doesn't appear without a warm reboot, and even with the file the firmware load errors are still in dmesg. It's not really changed anything AFAICS.
     
    Last edited by cmsj, Apr 27, 2018
  11. cmsj
    OP

    cmsj Advanced Member

    Newcomer
    2
    Apr 25, 2018
    United Kingdom
  12. EclipseSin

    EclipseSin Ignorant Wizard

    Member
    9
    Apr 1, 2015
    United Kingdom
    221b Baker Street
    Is the wifi hardware detected on the first boot even though it's not working? Driver loaded? Restarting the network manager can fix that with some chips. I haven't setup linux yet.

    sudo service network-manager restart
     
  13. cmsj
    OP

    cmsj Advanced Member

    Newcomer
    2
    Apr 25, 2018
    United Kingdom
    It's nothing to do with network manager, the kernel just doesn't see the device. Presumably some quirk in the setup for the chip that happens to be right after a warm reboot.
     
    Maufeat and EclipseSin like this.
  14. Maufeat

    Maufeat Member

    Newcomer
    2
    Sep 3, 2015
    Germany
    WebDev
    Cool! I've tried your build script but it didn't work.
    I've formatted my first partiton to FAT32 and my second partition (rootfs) to ext4 and then I've put bionic.tgz which got generated by executing the script.
    While booting it stucks here:
    [​IMG]
     
    Last edited by Maufeat, Apr 27, 2018
  15. guily6669

    guily6669 GbaTemp is my Drug

    Member
    5
    Jun 3, 2013
    United States
    Doomed Island
    Nice one there, but do you think Ubuntu distro would really be the best 4 it? It is kinda too much desktop mac like for my taste ;). But still looks awesome :grog:
     
  16. cmsj
    OP

    cmsj Advanced Member

    Newcomer
    2
    Apr 25, 2018
    United Kingdom
    Did you just copy the bionic.tgz onto the ext4 partition? You need to extract it there: tar xvf /path/to/bionic.tgz -C /mountpoint/of/ext4/partition/
     
  17. Maufeat

    Maufeat Member

    Newcomer
    2
    Sep 3, 2015
    Germany
    WebDev
    That is exactly what I did. :/
     
  18. ry755

    ry755 idk what to write here

    Member
    3
    Nov 29, 2017
    United States
    California
    It says "Exec format error" which means the programs are compiled for the wrong architecture
     
  19. cmsj
    OP

    cmsj Advanced Member

    Newcomer
    2
    Apr 25, 2018
    United Kingdom
    Yeah that's an odd error - there's no compiling in my build script, but I think it's mostly just that he/she copied bionic.tgz to the SD card without extracting it. What it's actually doing is far far cooler...
    It installs qemu-user-static and debootstrap.

    debootstrap is a very helpful old Debian tool that lets you download and install a complete Debian-like OS in a directory. But wait, you might say, how is that going to work on an x86_64 host?! All the little binaries in the packages are aarch64 so all the postinstall scripts will fail! Aha no, I say, qemu-user-static installs a qemu binary that emulates syscalls rather than spin up a whole ARM/PPC/MIPS/whatever VM, and configures the kernel's binfmt system to use it automatically when you run a foreign binary.

    So what the script is actually doing is like a mini OS install by executing a load of ARM binaries in a chroot. It's very cool stuff :)

    root@gnubert:~# uname -p
    x86_64
    root@gnubert:~# chroot /var/chroot/ubuntu_arm64_bionic/ uname -p
    aarch64
    root@gnubert:~#

    (Edit: I'd love to take credit for this cool hack, but if you look at my github repo, you'll see it's forked from a repo that is used to build multi-arch-multi-OS docker images. I've just stripped out all of the multi-arch stuff and the incomplete Debian support, and added in various extra bits needed by the Switch)
     
    Last edited by cmsj, Apr 27, 2018
    ry755 likes this.
  20. Maufeat

    Maufeat Member

    Newcomer
    2
    Sep 3, 2015
    Germany
    WebDev
    Maybe it helps to show the exact steps that I've done:

    Code:
    git clone https://github.com/cmsj/nintendo-switch-ubuntu-builder.git ubuntu
    cd ubuntu
    ./make_build.sh
    gparted ( Created a 300MB FAT32 partition then filled the rest of the sd card with a second ext4 partition labled "rootfs" )
    mount /dev/sdn2 /mnt/sdcard
    tar xvf bionic.tgz -C /mnt/sdcard
    cp bionic.tgz /mnt/sdcard/root
     
    Natehaxx likes this.
Loading...