Nintendo 3DS (nintendo-ctr)

The Nintendo 3DS is a handheld video game console released by Nintendo in 2011. A later revision, the New Nintendo 3DS, was released in 2014.
== Contributors ==
* knuxify
== Maintainer(s) ==
* knuxify
== Users owning this device ==
== Status ==
The device boots with the APKBUILDs from this pmaports fork. Unfortunately, due to the lack of SD card write support, pretty much nothing works (notably, it is impossible to log in in the console).
Support for the ARM11 MPCore chips, including the CPU in the Nintendo 3DS, has recently been dropped from the Linux kernel. Updating the kernel to the latest version would require bringing back support for these chips.
== Software used ==
This port makes use of the 3DS Linux fork, arm9linuxfw and firm_linux_loader maintained by members of the linux-3ds organization on GitHub.
== Installation ==
This will not overwrite your 3DS's internal memory. The kernel is loaded off the SD card by the firm_linux_loader (which can be triggered at startup from Luma3DS's firmware selection menu).
In pmbootstrap init, choose:
* nintendo-ctr if you own an Old 3DS, Old 3DS XL or Old 2DS.
* nintendo-ktr if you own a New 3DS, New 3DS XL or New 2DS XL
Then, choose one of the following installation methods:
=== Method 1 - repartitioning your existing SD card ===
postmarketOS expects the SD card to have two partitions: a boot partition and a root partition. Since Linux and the main 3DS OS share the entire SD card, we need to repartition it to satisfy both of them.
Using your favorite repartitioning tool (explaining how to use them is out-of-scope for this guide - for starters, check out GParted, which is available in pretty much every Linux distro), modify the partitions on your SD card as such:
* First partition - FAT32, label: pmOS_boot - this partition will function as the main 3DS SD card storage as well as the postmarketOS boot partition.
* Second partition - ext4, label: pmOS_root - this is the root partition for postmarketOS.
The labels are important! They allow the postmarketOS initramfs to find the necessary partitions.
Once you're done with the re-partitioning:
* Run pmbootstrap install and pmbootstrap export.
* Run dd bs=512 skip=499712 if=/tmp/postmarketOS-export/nintendo-ctr.img of=/tmp/3ds-rootfs to extract the rootfs from the device image (replace ctr with ktr if you're using a New Nintendo 3DS.) Note that this assumes you have the boot partition size set to the default value of 256MB; if that is not the case, you can run fdisk -l /tmp/postmarketOS-export/nintendo-ctr.img and replace the skip value with the start value of the second partition.
* Finally, run sudo dd bs=512 if=/tmp/3ds-rootfs of=/dev/mmcblk0p2 (replace mmcblk0 with your SD card's block device).
Now, we need to add the files necessary for booting. Mount the pmOS_boot partition, as we will be adding files to it.
The following commands will prepare a folder named "linux3ds" in your home directory ($HOME), which will contain all the necessary files:
codename="ctr" # replace with ctr or ktr depending on your console 
mkdir ~/linux3ds
mkdir ~/linux3ds/linux
mkdir -p ~/linux3ds/luma/payloads
pmbootstrap export
cp /tmp/postmarketOS-export/vmlinuz ~/linux3ds/linux/zImage
cp /tmp/postmarketOS-export/initramfs ~/linux3ds/linux/initramfs.cpio.gz
cp ~/.local/var/pmbootstrap/chroot_rootfs_nintendo-*tr/boot/nintendo3ds_*tr.dtb ~/linux3ds/linux
cp ~/.local/var/pmbootstrap/chroot_rootfs_nintendo-*tr/lib/firmware/3ds/arm9linuxfw.bin ~/linux3ds/linux
cp ~/.local/var/pmbootstrap/chroot_rootfs_nintendo-*tr/lib/firmware/3ds/firm_linux_loader.firm ~/linux3ds/luma/payloads
cp /tmp/postmarketOS-export/initramfs-extra ~/linux3ds/initramfs-extra
Copy the contents of the linux3ds folder to the root of the pmOS_boot partition.
=== Method 2 - on a separate SD card ===
This method uses a separate SD card just for postmarketOS, and allows us to use pmbootstrap install to partition the SD card.
Replace /dev/mmcblk0 in the following commands with your SD card's block device name.
* Run pmbootstrap install --sdcard=/dev/mmcblk0.
* Once it's done, run pmbootstrap export
* Copy the necessary Luma3DS boot files (boot.firm, etc.) and the files necessary to boot postmarketOS (see the commands in the previous method) to the pmOS_boot partition.
== Booting ==
While booting your 3DS (on the Luma3DS splash screen, if enabled) hold the Start button. If you only have one payload installed (luma/payloads only has firm_linux_loader.firm in it), Linux will boot automatically. Otherwise, a menu will pop up allowing you to select a firmware. Choose firm_linux_loader from the list.
You'll first see garbage on the screen, and after a few seconds the kernel logs should appear.
== See also ==
* linux-3ds organization on GitHub
* Close to mainline kernel fork
* WIP pmaports fork with 3DS-related packages
Category:Game Console