Tutorial  Updated

How to boot Linux on your Switch

THIS GUIDE IS DEPRECATED
THIS IS BETTER https://github.com/natinusala/painless-linux


I've successfully booted ArchLinux using ShofEL2. Here is a quick guide on how to do it - I'll assume you're computer literate and know how to use a terminal / Linux commands / git.
Everything is taken from the README of the ShofEL2 repo so if you want to go even faster, go read that instead.

Thanks to NightHammer1000 and Y2K-x for the help !

There is a simplified and faster version of this tutorial available here, with precompiled binaries so you don't have to build everything : https://github.com/SoulCipher/shofel2_linux

The result

Without a SD card ("waiting for root device mmcblk0p2") : https://photos.app.goo.gl/7y6ut5ObuHMUIMZg2
Stock Arch Linux : https://photos.app.goo.gl/yALqe3zMZRe2dSQf1
Arch Linux with LXDE : https://photos.app.goo.gl/xaEgRqeSi8jvAwpz5
RetroArch running : https://photos.app.goo.gl/vBLPo5wiBto1qiUH3
Arch Linux with GNOME : https://gbatemp.net/attachments/img_0005-jpg.121608/
Arch Linux with KDE : https://gbatemp.net/attachments/img_20180427_121605-jpg.121666/

What works / what doesn't
  • Desktop environment : Gnome, LXDE, KDE
  • Wi-Fi : works
    • You will need to reboot your Switch and run the exploit again to make the Wi-Fi work (it never works on the first boot)
    • Then enter the Network Manager Application and add your network from there
    • If it doesn't work, you will need to edit the configuration on the host computer (see the additional notes at the end of this post)
    • With LXDE : Can cause a kernel panic if used at the same time as Bluetooth
  • Bluetooth : works but Joy-Cons can't be paired
  • Touch screen : works, although LXDE is not very touch-friendly
  • Audio : doesn't work yet
  • GPU acceleration : works (via mesa), with OpenGL (and maybe Vulkan too ?)
  • Joy-Cons : not recognized
  • Volume buttons : working with Gnome but not doing anything since there is no audio device
  • Power button : doesn't do anything, no sleep mode, no graceful shutdown
  • USB : doesn't work
  • Dock : not tested yet, but I bet it doesn't do anything besides charging the battery
  • Power management / battery level : working with Gnome
What you'll need
  • A computer running Linux with a blue USB SuperSpeed port, or a Mac
    • A Linux VM can work in theory, but it depends on how the USB passthrough is implemented (apparently VMWare works, VirtualBox doesn't)
  • A USB A-to-C cable (with data support, obviously)
    • be careful as cheap cables were reported to work randomly / not work at all
  • Some time (you know, Linux is kinda large)

Prep work

First, you'll need to install the required toolchains. Open this link and download the tar.gz binaries for
  • aarch64-linux-gnu
  • arm-linux-gnueabi
Be careful to choose the right architecture for your PC (for me it was x86_64 so "gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz").

Once you have them, extract them somewhere nice and add the "bin" (not "lib" as I previously stated) folder of both toolchains to your PATH ("$ export PATH=$PATH:/path/to/toolchain1/lib:/path/to/toolchain2/lib"). The building process won't work otherwise.

Then, install those dependencies (how to install them and their name might depend on your distribution) :
  • build-essential (sorry I didn't add it it was obvious to me)
  • libssl-dev
  • swig
  • bison
  • pkg-config
  • flex
  • zlib1g-dev
  • python3
  • python-dev
  • python3-pip
  • pyusb 1.0.0 : "$ sudo pip3 install pyusb==1.0.0"
  • libusb-1.0-0-dev

Compiling

Clone each required repository :

Code:
$ git clone https://github.com/fail0verflow/shofel2.git
$ git clone --recursive --depth=1 https://github.com/fail0verflow/switch-coreboot.git coreboot
$ git clone https://github.com/fail0verflow/switch-u-boot.git u-boot
$ git clone --depth=1 https://github.com/fail0verflow/switch-linux.git linux
$ git clone https://github.com/boundarydevices/imx_usb_loader.git

You can grab a coffee or two because Linux has more than 5 million files to download.

Then, build everything :

Code:
$ cd shofel2/exploit
$ make

Code:
$ cd u-boot
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ make nintendo-switch_defconfig
$ make

Code:
$ cd coreboot
$ make nintendo_switch_defconfig
$ make iasl
$ make

If you have a tegra_mtc.bin file error, you'll have to extract it from a Pixel C stock image :
"$ ./build/util/cbfstool/cbfstool bootloader-dragon-google_smaug.7900.97.0.img extract -n fallback/tegra_mtc -f tegra_mtc.bin"

Or you can download it directly from here : https://0w0.st/tegra_mtc.bin (thanks to @CptPotato for uploading this)

You'll have to put it in the "coreboot/src/soc/nvidia/tegra210" directory.

Code:
$ cd imx_usb_loader
$ git reset --hard 0a322b01cacf03e3be727e3e4c3d46d69f2e343e
$ make

The big one :

Code:
$ cd linux
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ make nintendo-switch_defconfig
$ make

If you encounter issues about a missing rule "/lib/firmware/nvidia/tegra210/vic04_ucode.bin" for the target "firmware" you'll have to :
  • install the firmware-misc-nonfree package
  • if you can't install it, or if it still doesn't work, download the package manually from debian sid and extract the file "/lib/firmware/nvidia/tegra210/vic04_ucode.bin" (from the root of your PC, not on the cloned repo) from the DEB (and chmod it if needed)
If you encounter issues about a missing rule "/lib/firmware/brcm/brcmfmac4356-pcie.txt", download this file and put it in "/lib/firmware/brcm/" (from the root of your PC, not on the cloned repo)

Building the rootfs

This is the annoying part. Download the archive / image corresponding to the distribution you want to use :
If it's a tarball you just downloaded

While it's downloading, you'll have to take a microSD card and, using the software of your choice (I used GParted) :
  • remove every existing partition to only have unallocated space on it (do I need to tell you that you're going to loose everything on the card ?)
  • create a tiny FAT32 partition (I chose 200mb but it doesn't matter) - that'll be mmcbkl0p1, you can label it "garbage"
  • create an ext4 partition on the remaining part of the card - that'll be mmcblk0p2, you can label it "rootfs"
  • it's important that the FAT32 partition comes first and the ext4 one comes after - on the Switch, Linux will look for mmcblk0p2, the second partition, if you have scrolling boot logs and then back to RCM it means you did it wrong
Once the rootfs tarball is downloaded, you can simple extract it to the mounting point of the ext4 partition you just created :

Code:
$ tar xvf ArchLinuxARM-aarch64-latest.tar.gz -C /mounting/point/of/ext4/partition && sync
$ cp ArchLinuxARM-aarch64-latest.tar.gz /mounting/point/of/ext4/partition/root && sync

("/mounting/point/of/ext4/partition/root" is the "root" directory on the partition)

Don't forget to properly eject the SD Card !

If "tar xvf" doesn't work for you you can install "bsdtar" and use "bsdtar -xpf" instead

Then you can put the SD card in the console.

If it's a img / bin file you just downloaded

You can simply write it on your SD card using :
  • If you're on Windows, Ether or Win32DiskImager
  • If you're on Linux / Mac OS : "sudo dd if=yourimage.img of=/dev/sdX && sync" where /dev/sdX is the device of your SD card (unmounted)
You will probably want to open a partition manager to resize the ext4 partition once it's flashed, so that it fits your SD card.

Then you can put the SD card in the console.

Booting linux

Run the exploit :

Code:
$ cd shofel2/exploit
$ sudo ./shofel2.py cbfs.bin ../../coreboot/build/coreboot.rom

Your terminal should now be waiting for the Switch to enter RCM mode.

To do so : (I don't have pictures but that's the same method as fusée gelée, just look at some video tutorials)
  • plug the Switch on your PC using the USB A-to-C cable - use a blue SuperSpeed port if you have one
  • shut it down
  • remove the right joy-con
  • using a method of your choice, short the 10th pin of the right joy-con (the last pin on the right, away from the screen, closer to the back) with the ground : that can be pin 1, 2 or 7, that can also be a screw on the joy-con rack or the console's fan - I personnaly stick a RPi jumper wire in the fan and touch the 10th pin on the other side, works everytime (like this)
  • keep the pins shorted and power the Switch while pressing the volume UP button
If it worked, the console will show a black screen and you'll see the exploit running on your terminal. If you see the Nintendo logo, it has failed. You can power off the console and try again.

Then, run those last commands :

Code:
$ cd shofel2/usb_loader
$ ../../u-boot/tools/mkimage -A arm64 -T script -C none -n "boot.scr" -d switch.scr switch.scr.img
$ sudo ../../imx_usb_loader/imx_usb -c .

Linux should then boot on your console - first the boot logs with the penguins, and then an ArchLinux login prompt. Voilà !
Again, if you have the boot logs and then a black screen, it means you did the SD card part wrong.

Additional notes

Hardware graphics acceleration


The most recents image already contain this fix.

To add mesa drivers install this package using pacman :
https://0w0.st/mesa-full-tegra-r101876.bf5e0276b6-1-aarch64.pkg.tar.xz

You will need a working internet connection to do so.

Then, use this script to choose your power profile : https://0w0.st/power.sh

Full speed RAM


According to the blog post ("Linux on Switch boot chain" section), you need to extract a file from a Pixel C factory image in order to have the RAM working at full speed. I didn't do it so I won't cover it here.

Fixing calibration issues of the touch screen (thanks to @Wizardy)

To fix calibration issues of the touch screen, edit the file /usr/share/X11/xorg.conf.d/10-evdev.confg (of the rootfs)

And change the InputClass section to :

Code:
Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "InvertX" "no"
        Option "InvertY" "yes"
        Option "SwapAxes" "yes"
        Option "Calibration" "0 1279 0 719"
EndSection

Wi-Fi

To setup Wi-Fi, mount the rootfs partition on your host PC and edit the configuration for your network in the file "/etc/NetworkManager/system-connections" (if it doesn't exist, take Gigaspot).

To have a working Wi-Fi you must reboot your Switch and run the exploit again each time you power it off

Moving the rootfs to another partition

If you want to move the rootfs to another partition on your SD card, edit the "shofel2/usb_loader/switch.scr" file and replace "/dev/mmcblk0p2" by the partition you want to use.
 
Last edited by natinusala,

Faiz Saleem

Member
Newcomer
Joined
Jun 26, 2014
Messages
14
Trophies
0
Age
24
Location
Nottingham, United Kingdom
XP
145
Country
United Kingdom
Yo, Finally I got my SD Card to work correctly.

I'm using the provided ArchLinuxARM-aarch64-latest.tar.gz

is there a way to login without having a Keyboard connected to the Switch (don't know how to connect one anyways).

Right now, I see:
Arch Linux 4.16.0-rc1-g01b404c21120 (tty1)
alarm login: _


is there a way to add a virtual keyboard or let it boot with GUI?

Same here.
Anyone who can help us to login into Linux, probably with sharing their added/modified files?

No GUI is currently available out-of-the-box, nor is there any way to input text.

You're pretty much running a barebones Arch installation - no desktop environment is installed. You could always chroot that installation and install a desktop environment - then you'd have a GUI - but things like hardware acceleration, Wi-Fi and touch input won't work out of the box.

I recommend you wait until a prebuilt image is released - I imagine that'll be some time tomorrow.
 

robozman

Member
Newcomer
Joined
Apr 25, 2018
Messages
7
Trophies
0
Age
33
XP
68
Country
United States
No GUI is currently available out-of-the-box, nor is there any way to input text.

You're pretty much running a barebones Arch installation - no desktop environment is installed. You could always chroot that installation and install a desktop environment - then you'd have a GUI - but things like hardware acceleration, Wi-Fi and touch input won't work out of the box.

I recommend you wait until a prebuilt image is released - I imagine that'll be some time tomorrow.

To be fair, touch input worked out of the box for me and I've heard the wifi drivers are in there too.
 

ExploitTnT

Devy | YT: DevRin | dev_settings
Member
Joined
Jul 30, 2017
Messages
150
Trophies
0
XP
270
Country
Austria
Guys i used L4T (Linux for Tegra)
and this Touch Screen calibration code (Edit the 10-evdev.conf file)
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "InvertX" "no"
Option "InvertY" "yes"
Option "SwapAxes" "yes"
Option "Calibration" "0 1279 0 719"
EndSection
Hopefully this can help you guys a little bit more
 
Last edited by ExploitTnT,

robozman

Member
Newcomer
Joined
Apr 25, 2018
Messages
7
Trophies
0
Age
33
XP
68
Country
United States
Guys i used
and this Touch Screen calibration code (Edit the 10-evdev.conf file)
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "InvertX" "no"
Option "InvertY" "yes"
Option "SwapAxes" "yes"
Option "Calibration" "0 1279 0 719"
EndSection
Hopefully this can help you guys a little bit more
You used their image in place of the arch arm one? What distro is it based on?
 
Last edited by robozman,

00Cancer

Well-Known Member
Newcomer
Joined
Feb 1, 2017
Messages
67
Trophies
0
Age
20
XP
103
Country
United States
I still have not been able to get the switch to detect the root partition. I have followed the guide exactly, but it still does not work.
 

Eastonator12

Well-Known Member
Member
Joined
Aug 16, 2016
Messages
630
Trophies
0
Age
23
XP
999
Country
United States
Are you sure you've correctly added the two required toolchains to $PATH?
So I have gotten pretty far into it now, but for some reason imx usb loader doesn't want to compile. I get this:

cc -o imx_usb imx_usb.o imx_sdp.o `pkg-config --libs libusb-1.0`
/bin/sh: 1: pkg-config: not found
imx_usb.o: In function `print_devs':
/home/easton/imx_usb_loader/imx_usb.c:61: undefined reference to `libusb_get_device_descriptor'
/home/easton/imx_usb_loader/imx_usb.c:67: undefined reference to `libusb_get_config_descriptor'
/home/easton/imx_usb_loader/imx_usb.c:71: undefined reference to `libusb_get_device_address'
/home/easton/imx_usb_loader/imx_usb.c:71: undefined reference to `libusb_get_bus_number'
/home/easton/imx_usb_loader/imx_usb.c:87: undefined reference to `libusb_free_config_descriptor'
imx_usb.o: In function `find_imx_dev':
/home/easton/imx_usb_loader/imx_usb.c:193: undefined reference to `libusb_get_bus_number'
/home/easton/imx_usb_loader/imx_usb.c:194: undefined reference to `libusb_get_device_address'
/home/easton/imx_usb_loader/imx_usb.c:196: undefined reference to `libusb_get_device_descriptor'
imx_usb.o: In function `transfer_hid':
/home/easton/imx_usb_loader/imx_usb.c:262: undefined reference to `libusb_control_transfer'
/home/easton/imx_usb_loader/imx_usb.c:274: undefined reference to `libusb_interrupt_transfer'
imx_usb.o: In function `transfer_bulk':
/home/easton/imx_usb_loader/imx_usb.c:321: undefined reference to `libusb_bulk_transfer'
imx_usb.o: In function `do_work':
/home/easton/imx_usb_loader/imx_usb.c:419: undefined reference to `libusb_get_configuration'
/home/easton/imx_usb_loader/imx_usb.c:422: undefined reference to `libusb_kernel_driver_active'
/home/easton/imx_usb_loader/imx_usb.c:423: undefined reference to `libusb_detach_kernel_driver'
/home/easton/imx_usb_loader/imx_usb.c:425: undefined reference to `libusb_claim_interface'
/home/easton/imx_usb_loader/imx_usb.c:485: undefined reference to `libusb_release_interface'
imx_usb.o: In function `do_autodetect_dev':
/home/easton/imx_usb_loader/imx_usb.c:504: undefined reference to `libusb_init'
/home/easton/imx_usb_loader/imx_usb.c:508: undefined reference to `libusb_get_device_list'
/home/easton/imx_usb_loader/imx_usb.c:517: undefined reference to `libusb_free_device_list'
/home/easton/imx_usb_loader/imx_usb.c:560: undefined reference to `libusb_open_device_with_vid_pid'
/home/easton/imx_usb_loader/imx_usb.c:583: undefined reference to `libusb_close'
/home/easton/imx_usb_loader/imx_usb.c:594: undefined reference to `libusb_exit'
collect2: error: ld returned 1 exit status
Makefile:29: recipe for target 'imx_usb' failed
make: *** [imx_usb] Error 1
i have libusb installed.
Try adding the export PATH line to your .bashrc.
 

Kobigov

Well-Known Member
Member
Joined
Jan 10, 2018
Messages
129
Trophies
0
Age
44
XP
300
Country
United States
I still have not been able to get the switch to detect the root partition. I have followed the guide exactly, but it still does not work.
Like booting it on the switch? If you get the penguins but it just spits out a log while waiting for the partition use a microSD of 8GB or less. I don't think it likes sdhc cards or whatever the name is.
 

Gren22

Well-Known Member
Newcomer
Joined
Apr 24, 2018
Messages
63
Trophies
0
Age
26
XP
210
Country
United States
Like booting it on the switch? If you get the penguins but it just spits out a log while waiting for the partition use a microSD of 8GB or less. I don't think it likes sdhc cards or whatever the name is.
Think it might be possible to do something to the SD to trick it into working or nah?
 

flagrama

Active Member
Newcomer
Joined
Jan 23, 2011
Messages
29
Trophies
0
XP
179
Country
United States
Like booting it on the switch? If you get the penguins but it just spits out a log while waiting for the partition use a microSD of 8GB or less. I don't think it likes sdhc cards or whatever the name is.
Up to 2GB is usually SD, 2GB-32GB SDHC (I used a 32GB card and everything works for me and I consistently can get the arch login prompt), and 64GB+ is currently SDXC. But yeah, try a different SD card. Sometimes an SD card will work fine for most usages, but will not work for some weird reason trying to do something in particular.
 

00Cancer

Well-Known Member
Newcomer
Joined
Feb 1, 2017
Messages
67
Trophies
0
Age
20
XP
103
Country
United States
Up to 2GB is usually SD, 2GB-32GB SDHC (I used a 32GB card and everything works for me and I consistently can get the arch login prompt), and 64GB+ is currently SDXC. But yeah, try a different SD card. Sometimes an SD card will work fine for most usages, but will not work for some weird reason trying to do something in particular.
Thats really weird because I am using a 32gb sdcard as well.
 

Gren22

Well-Known Member
Newcomer
Joined
Apr 24, 2018
Messages
63
Trophies
0
Age
26
XP
210
Country
United States
Up to 2GB is usually SD, 2GB-32GB SDHC (I used a 32GB card and everything works for me and I consistently can get the arch login prompt), and 64GB+ is currently SDXC. But yeah, try a different SD card. Sometimes an SD card will work fine for most usages, but will not work for some weird reason trying to do something in particular.
I am using 3 different SD cards, 2 16 GB and 1 64 GB.... All run into the same problem.
 

Kobigov

Well-Known Member
Member
Joined
Jan 10, 2018
Messages
129
Trophies
0
Age
44
XP
300
Country
United States
Up to 2GB is usually SD, 2GB-32GB SDHC (I used a 32GB card and everything works for me and I consistently can get the arch login prompt), and 64GB+ is currently SDXC. But yeah, try a different SD card. Sometimes an SD card will work fine for most usages, but will not work for some weird reason trying to do something in particular.
I could only get my 4GB one and 8GB one to load up to the login.
 

flagrama

Active Member
Newcomer
Joined
Jan 23, 2011
Messages
29
Trophies
0
XP
179
Country
United States
Thats really weird because I am using a 32gb sdcard as well.
This very same SD card I'm using for this does NOT work in an adapter for WiiU homebrew, so yeah. sometimes they just don't work for some reason.
I am using 3 different SD cards, 2 16 GB and 1 64 GB.... All run into the same problem.
If three different cards don't work then yeah, I'd expect it to be something going wrong with the setup rather than a card just not working.

You both definitely have two partitions on your SD card right? A small FAT32 one, and a larger ext4 one that actually has the rootfs on it?

EDIT: Also, it has an MBR partition table and not a GPT one right?
 
Last edited by flagrama,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Xdqwerty
    what are you looking at?
  • BakerMan
    I rather enjoy a life of taking it easy. I haven't reached that life yet though.
  • BigOnYa
  • BigOnYa @ BigOnYa:
    Diddy - "I never touched her, that bitch is crazy." Video is released. Diddy - " Ok I did it, i am remorseful for my actions during my darkest times." Lol
  • SylverReZ @ SylverReZ:
    @BigOnYa, Glad that the Diddler got caught once again.
    +1
  • K3Nv2 @ K3Nv2:
    Iran ran out of options
  • K3Nv2 @ K3Nv2:
    Thought I saw my ex on that new kingdom of the Apes poster
  • BigOnYa @ BigOnYa:
    I thought I saw a puttie snatch...
  • BigOnYa @ BigOnYa:
    I'm so pumped, NCAA football video game is back after a 10 year hiatus, coming to SeriesS/X, PS5 in July.
  • BigOnYa @ BigOnYa:
    Wish they would let us play the NCAA football 14 on newer xbox, its one of the only games I love and own on disc still, that is not back compatible, bs.
  • AdenTheThird @ AdenTheThird:
    @BigOnYa My dad recently bought a spare Series X off of me, got game pass, and saw Madden '24 on Game Pass, decided to try it out.

    ...He was a bit taken aback by the 60GB download size. Poor guy's still living in the 90s!
    +1
  • SylverReZ @ SylverReZ:
    @AdenTheThird, Bro's still in the PS2 age.
  • K3Nv2 @ K3Nv2:
    Lol charging your dad's classic unless he's the type that doesn't like taking things like that
  • AdenTheThird @ AdenTheThird:
    @K3Nv2 He was looking into consoles for his house anyway (for my younger siblings and himself) and I had a spare XSX and Switch I ended up selling him at pretty steep cuts. I would just give them to him, but I did buy them with the intent to sell them... and college is super expensive.
  • BigOnYa @ BigOnYa:
    A little yeah...
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, [insert wut here]
    +1
  • BigOnYa @ BigOnYa:
    I'm a little hi, but bout to fix that.
    +1
  • BigOnYa @ BigOnYa:
    Now I'm low, i was upstairs in my wifeys kitchen, now I'm downstairs in my dungeon.(My basement)
    +1
  • BakerMan @ BakerMan:
    do you mind? i snuck in with amiibo and jars, and am trying to do my thing brony style
  • BakerMan @ BakerMan:
    have you ever regretted saying something immediately after saying it?
    +1
  • BakerMan @ BakerMan:
    nah what i was doing was trying to cure my ever-so-apparent crabs
    SylverReZ @ SylverReZ: https://www.youtube.com/watch?v=4U32Hl4uSBs