├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coreboot 2 | imx_usb_loader 3 | librecore-utils 4 | linux 5 | ryu-mxb48j* 6 | shofel2 7 | u-boot 8 | tegra_mtc.bin 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM base/devel 2 | 3 | ENV GCC_64 https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz 4 | ENV GCC_ARM https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabi/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz 5 | ENV BRCM_URL https://chromium.googlesource.com/chromiumos/third_party/linux-firmware/+/f151f016b4fe656399f199e28cabf8d658bcb52b/brcm/brcmfmac4356-pcie.txt?format=TEXT 6 | 7 | ENV PATH $PATH:/opt/toolchain/aarch64-linux-gnu/bin:/opt/toolchain/arm-linux-gnueabi/bin 8 | 9 | RUN pacman -Sy --noconfirm \ 10 | unzip \ 11 | swig \ 12 | python3 \ 13 | python-pyusb \ 14 | bc \ 15 | cmake \ 16 | git \ 17 | wget 18 | 19 | # Download / Install toolchain 20 | RUN mkdir /opt/toolchain && cd /opt/toolchain && \ 21 | wget -O brcmfmac4356-pcie.txt -nv "$BRCM_URL" && \ 22 | wget -O gcc_aarch64-linux-gnu.tar.gz -nv "$GCC_64" && \ 23 | wget -O gcc_arm-linux-gnueabi.tar.gz -nv "$GCC_ARM" && \ 24 | mv brcmfmac4356-pcie.txt /lib/firmware/brcm/ && \ 25 | tar -xf gcc_aarch64-linux-gnu.tar.gz && \ 26 | tar -xf gcc_arm-linux-gnueabi.tar.gz && \ 27 | ln -s gcc*aarch64-linux-gnu aarch64-linux-gnu && \ 28 | ln -s gcc*arm-linux-gnueabi arm-linux-gnueabi && \ 29 | rm *.tar.gz 30 | 31 | VOLUME /source 32 | WORKDIR /source 33 | 34 | CMD bash 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Derek W. Stavis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export PATH /opt/toolchain/aarch64-linux-gnu/bin:$(PATH) 2 | export PATH /opt/toolchain/arm-linux-gnueabi/bin:$(PATH) 3 | 4 | CLONE := git clone --depth=1 5 | 6 | MAKE := make -j1 7 | XMAKE := CROSS_COMPILE=aarch64-linux-gnu- $(MAKE) 8 | X64MAKE := ARCH=arm64 $(XMAKE) 9 | 10 | RUN := docker run --privileged -ti --rm -v $(shell pwd):/source switch-linux-toolchain:latest 11 | 12 | librecore-utils: 13 | test -d librecore-utils || $(CLONE) https://github.com/librecore-org/librecore-utils.git librecore-utils 14 | ls -lah librecore-utils 15 | mkdir -p librecore-utils/build 16 | cd librecore-utils/build && cmake .. 17 | $(MAKE) librecore-utils/build 18 | 19 | shofel2: 20 | test -d shofel2 || $(CLONE) https://github.com/fail0verflow/shofel2.git 21 | make -C shofel2/exploit 22 | 23 | u-boot: 24 | test -d u-boot || $(CLONE) https://github.com/fail0verflow/switch-u-boot.git u-boot 25 | $(XMAKE) -C u-boot nintendo-switch_defconfig 26 | $(XMAKE) -C u-boot 27 | 28 | coreboot: u-boot 29 | test -d coreboot || $(CLONE) --recursive https://github.com/fail0verflow/switch-coreboot.git coreboot 30 | $(XMAKE) tegra_mtc 31 | $(XMAKE) -C coreboot nintendo_switch_defconfig 32 | $(XMAKE) -C coreboot iasl 33 | $(XMAKE) -C coreboot 34 | 35 | imx_usb_loader: 36 | test -d imx_usb_loader || $(CLONE) https://github.com/boundarydevices/imx_usb_loader.git 37 | $(MAKE) -C imx_usb_loader 38 | 39 | linux: 40 | test -d linux || $(CLONE) https://github.com/fail0verflow/switch-linux.git linux 41 | $(X64MAKE) -C linux nintendo-switch_defconfig 42 | $(X64MAKE) -C linux 43 | 44 | tegra_mtc: librecore-utils 45 | unzip -f ryu-mxb48j-factory-*.zip 46 | librecore-utils/build/cbfstool/cbfstool ryu-mxb48j/bootloader-dragon-google_smaug.7132.260.0.img extract -n fallback/tegra_mtc -f coreboot/tegra_mtc.bin 47 | 48 | build: shofel2 coreboot u-boot linux imx_usb_loader tegra_mtc 49 | 50 | toolchain: 51 | docker build . -ti switch-linux-toolchain 52 | 53 | shofel2-run: 54 | $(RUN) bash -c 'cd shofel2/exploit && \ 55 | python shofel2.py cbfs.bin ../../coreboot/build/coreboot.rom' 56 | @sleep 3 57 | 58 | usb-loader: 59 | $(RUN) bash -c 'cd shofel2/usb_loader && \ 60 | ../../u-boot/tools/mkimage -A arm64 -T script -C none -n "boot.scr" -d switch.scr switch.scr.img && \ 61 | ../../imx_usb_loader/imx_usb -c .' 62 | 63 | run: shofel2-run usb-loader 64 | 65 | console: 66 | $(RUN) bash 67 | 68 | all: 69 | $(RUN) $(MAKE) build 70 | 71 | .PHONY: all shofel2 coreboot u-boot linux imx_usb_loader librecore-utils exploit 72 | 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Switch Run Linux 2 | 3 | This repo contains a script which can be used to run Linux on Nintendo 4 | Switch using failoverfl0w ShofEL2 exploit. The instructions to load Linux 5 | is scattered between the blog post and ShofEL2 repo so I decided to create 6 | this repo to ease build and run process. 7 | 8 | To run Linux on your Switch follow this simple instructions: 9 | 10 | 1. Clone the repo: 11 | 12 | ``` 13 | git clone https://github.com/derekstavis/switch-runlinux 14 | ``` 15 | 16 | 2. Download the Pixel C factory image [from here][pixel-c-image]. 17 | 3. Place the downloaded file inside `switch-runlinux` repository. 18 | 4. Build the toolchain (you need Docker installed): 19 | 20 | ``` 21 | make toolchain 22 | ``` 23 | 24 | 5. Build the needed tools: 25 | 26 | ``` 27 | make build 28 | ``` 29 | 30 | 6. Have the Switch into RCM mode and run the exploit: 31 | 32 | ``` 33 | make run 34 | ``` 35 | 36 | [pixel-c-image]: https://developers.google.com/android/images#ryu 37 | --------------------------------------------------------------------------------