Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcotw2/e3cf66bc2a69c499a5b36cf659674a14 to your computer and use it in GitHub Desktop.
Save marcotw2/e3cf66bc2a69c499a5b36cf659674a14 to your computer and use it in GitHub Desktop.
3DS Linux build instructions

I made a few scripts to make customizations easier.

You can find them here: https://github.com/marcotw2/linux_3ds_scripts

Step 1: Compiling or Downloading the toolchain

Step 1.a: If you chose to download a pre-compiled toolchain (only for Linux x86-64)

  • Go to https://toolchains.bootlin.com
  • Select arch: armv6-eabihf
  • Select libc: glibc
  • Download bleeding-edge
  • Uncompress it (for example to /opt)
  • Add the extracted directory of the toolchain to $PATH
    • Command: export PATH=$PATH:/opt/armv6-eabihf--glibc--bleeding-edge-2020.08-1

Step 1.b: If you chose to compile the toolchain:

  • git clone https://github.com/crosstool-ng/crosstool-ng.git
  • Run: autoconf && ./configure --enable-local && make install
  • Run ./ct-ng ct-ng menuconfig
  • Go to Target options
  • Target Architecture -> Select arm
  • Floating point -> Select Hardware (FPU)
  • Emit assembly for CPU -> Write mpcore
  • Exit -> Exit -> Save? -> Yes
  • Run ./ct-ng build

Step 2: Build buildroot

Step 2.a: Build buildroot

  • git clone https://github.com/buildroot/buildroot.git
  • Download Buildroot .config to buildroot/.config
  • (You can add your scripts to output/target/)
  • Set toolchain path (in my case /opt/armv6-eabihf--glibc--bleeding-edge-2020.02-2/):
    • make menuconfig
    • Navigate to Toolchain --->
    • Properly set the Toolchain path, save and exit
  • Run make (-j N)
    • If you get an error regarding a missing rootfs-overlay folder, create the folder and run make again

Step 2.b: Customize welcome message (Optional)

From buildroot/.config

  • To change the Welcome Message modify this: Line 373 > BR2_TARGET_GENERIC_ISSUE="Welcome to Buildroot"

Step 3.: Build Linux

Step 3.a: Build Linux

  • git clone https://github.com/xerpi/linux_3ds.git
  • Copy buildroot/output/images/rootfs.cpio.gz to linux_3ds/
  • Run ./make_3ds.sh
  • Copy arch/arm/boot/zImage to sd:/linux/
  • Copy arch/arm/boot/dts/nintendo3ds_ctr.dtb to sd:/linux/

Step 3.b: Customize keyboard color and font size (Optional)

From linux_3ds/drivers/input/misc/nintendo3ds_codec_hid.c

  • To change highlight color modify this: Line 48 > #define HIGHLIGHT_COLOR COLOR_BLUE
  • To change keyboard color (not highlighted) modify this: Line 120 > color = COLOR_WHITE;
  • To change font size modify this: Line 125, Line 128, Line 134, Line 137 > row * vkb->font->height * 2
    • This will only increase/decrease font size and you will still need to click in the previus position of the letters (which make this useless...)

Step 4: Build arm9linuxfw (optional, but needed for SD card support)

Step 4.a: Build arm9linuxfw (optional, but needed for SD card support)

  • git clone https://github.com/xerpi/arm9linuxfw
  • Run make
  • Copy arm9linuxfw.bin to sd:/linux/

Step 4.b: Change poweoff combination (Optional)

From /arm9linuxfw/source/main.c

  • To change poweroff combination modify this: Line 9 > #define POWEROFF_MASK (BUTTON_L | BUTTON_R | BUTTON_DOWN | BUTTON_B)

Step 5: Build FIRM Linux Loader

Step 5: Build FIRM Linux Loader

  • git clone https://github.com/xerpi/firm_linux_loader
  • Run make
  • Copy firm_linux_loader.firm to the payloads/ folder of 3DS

Step 5: Add a custom boot message (Optional)

From firm_linux_loader/arm9/source/main.c

  • To add a custom boot message add a line after this: Line 60 > Debug("custom boot message");
  • To add a colored custom boot message add a line after this: Line 60 DebugColor(COLOR_EXAMPLE, "custom boot message");

From firm_linux_loader/arm9/include/draw.h

  • Color list:

    • #define COLOR_BLACK RGB(0x00, 0x00, 0x00)
    • #define COLOR_WHITE RGB(0xFF, 0xFF, 0xFF)
    • #define COLOR_RED RGB(0xFF, 0x00, 0x00)
    • #define COLOR_GREEN RGB(0x00, 0xFF, 0x00)
    • #define COLOR_BLUE RGB(0x00, 0x00, 0xFF)
    • #define COLOR_CYAN RGB(0x00, 0xFF, 0xFF)
    • #define COLOR_MAGENTA RGB(0xFF, 0x00, 0xFF)
    • #define COLOR_YELLOW RGB(0xFF, 0xFF, 0x00)
    • #define COLOR_GREY RGB(0x77, 0x77, 0x77)
    • #define COLOR_TRANSPARENT RGB(0xFF, 0x00, 0xEF)
  • You can define other colors, read here: http://enchantia.com/graphapp/doc/tutorial/colours.htm

@jamesy0ung
Copy link

Also I then did the linux step and executed the script after changing the toolchain version in the script. There is some compilation error now: https://pastebin.com/VyjGrMZK

@marcotw2
Copy link
Author

Also I then did the linux step and executed the script after changing the toolchain version in the script. There is some compilation error now: https://pastebin.com/VyjGrMZK

install the openssl dev package by running:

sudo apt-get install libssl-dev if on debian derivates.

sudo yum/dnf install openssl-devel if on Fedora.

@akatsukilevi
Copy link

On step 3.b, to change the font size you also need to change on line 388 and 389 for the taps to respond on the right place

@akatsukilevi
Copy link

akatsukilevi commented Mar 31, 2021

For example:

screen_touch_y >= j * vkb->font->height * 5 &&
screen_touch_y < (j + 1) * vkb->font->height * 5) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment