Skip to content

Instantly share code, notes, and snippets.

@marius137
Created July 29, 2021 01:07
Show Gist options
  • Save marius137/4205310639616c026b7c248854d4a6a1 to your computer and use it in GitHub Desktop.
Save marius137/4205310639616c026b7c248854d4a6a1 to your computer and use it in GitHub Desktop.
Build Script for 3ds Linux
basedir=$(pwd)
REQUIRED_PKG="git build-essential flex bison gcc-arm-linux-gnueabi libssl-dev bc gcc-arm-none-eabi python3-pip rsync"
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
echo Checking for $REQUIRED_PKG: $PKG_OK
if [ "" = "$PKG_OK" ]; then
echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
sudo apt-get --yes install $REQUIRED_PKG
fi
echo "installing firmtool"
pip3 install -U git+https://github.com/TuxSH/firmtool.git
echo "Creating folders"
mkdir -p $basedir/3dslinux
mkdir -p $basedir/output/linux
mkdir -p $basedir/output/luma/payloads
cd $basedir/3dslinux
echo "Cloning repos"
git clone https://github.com/linux-3ds/arm9linuxfw.git
git clone https://github.com/linux-3ds/linux.git --depth=1
git clone https://github.com/linux-3ds/buildroot.git
git clone https://github.com/linux-3ds/firm_linux_loader.git
echo "Building initrd"
cd $basedir/3dslinux/buildroot
make nintendo3ds_defconfig
make all
echo "Copying initrd"
cp $basedir/3dslinux/buildroot/output/images/rootfs.cpio.gz $basedir/3dslinux/linux
echo "Building linux"
cd $basedir/3dslinux/linux
ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make -j$(nproc) nintendo3ds_defconfig all
echo "Building Linux Loader"
cd $basedir/3dslinux/firm_linux_loader
CC=arm-none-eabi-gcc make
echo "Building arm9linuxfw"
cd $basedir/3dslinux/arm9linuxfw
make
echo "Moving files to output directory"
cp $basedir/3dslinux/linux/arch/arm/boot/zImage $basedir/output/linux
cp $basedir/3dslinux/linux/arch/arm/boot/dts/nintendo3ds_ctr.dtb $basedir/output/linux
cp $basedir/3dslinux/linux/arch/arm/boot/dts/nintendo3ds_ktr.dtb $basedir/output/linux
cp $basedir/3dslinux/arm9linuxfw/arm9linuxfw.bin $basedir/output/linux
cp $basedir/3dslinux/firm_linux_loader/firm_linux_loader.firm $basedir/output/luma/payloads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment