This repo is transitioning to https://github.com/TheInternetBox/core
A POC router OS for RPI CM4 + The DFRobot Router Board
This is a POC, but a predecessor of this appliance has been running in my network for about a year. https://github.com/USA-RedDragon/charch
- Utilize a Raspberry PI CM4 and a DFRobot Router board as an internet gateway. The typical setup is modem on eth0, and lan out to eth1.
- Optional WIFI access point (not yet implemented). The hardware will work, just don't expect a the same performance as a dedicated WiFi access point.
- Secure boot to avoid the loading of unsigned kernels
- DM-Verity to ensure the validity of the system
- Provide an automatic delta update of the system
- Routing appliances are a solved problem, I don't want to reinvent the wheel, just make it shinier.
- Provide VPN connections either from external to internal LAN, or from LAN with the VPN as a gateway (tunneling).
- Minimize the amount of custom code I add, and build all dependencies from source, with CI pushing new builds as soon as the upstream dependencies release updates.
- Provide a recursive DNS resolver with caching and ad blocking via AdGuard Home.
- Make IPv6 support a first-class citizen.
- Provide a backup mechanism.
- Dynamic Firewall (for NAT reflection) https://github.com/USA-RedDragon/redwall
boot-image
- Tools and templates used to make the FAT32boot.img
with the items typically contained within theboot
partition, andboot.sig
for secure boot. Thisboot.img
should be placed on a FAT32 partition within the EMMC.firmware
- The upstream https://github.com/raspberrypi/firmware/tree/stable for boot binaries.linux
- The Linux kernel. This project utilizes the latest upstream kernel with a few defconfig changes for this project. See https://github.com/USA-RedDragon/linux for more details.bootfs.tpl
- Contains templates for boot.img filesystem contents. The .tpl files are parsed withenvsubst
increate_boot_image.sh
.ramdisk-image
- Contains a secondary stage bootloader with the goal of managing a "bootloader" unlock of sorts, setting up dm-verity, selinux, and passing control to userspace.
rpi-usbboot
- The upstream https://github.com/raspberrypi/usbboot for the scripts and binariessecure-boot
- Contains eeprom programming in order to support secure boot and locking down for potentially future shipping units.eeprom
- Contains eeprom programming and configurationkeys
- Contains secure boot keys. Generate your own in the PEM format :)lockdown
- Burns the eeprom withprogram_pubkey
andrevoke_devkey
, andprogram_jtag_lock
. Only use this if you want to lock the bootloader
- Hardened kernel configuration
- Almost always up to date with upstream bug and security fixes
- SELinux access restrictions
- No ability to disable secure boot after the fact (you as the device owner are not locked out, and may unlock your device to run boot images)
- EEPROM reprogramming is only available to a system daemon used for updates, Alternatively, users may keep EEPROM completely write protected and update eeprom manually.
- AppArmour
- LoadPin, a kernel option only allowing kernel modules from the same filesystem (the signed boot.img in this case)
The eeprom
is programmed with secure boot and some hardware configuration. The emmc
contains 3 partitions:
- Data - A FAT32 filesystem containing persistent data and user configuration. Backups are taken of this partition.
- Boot - A FAT32 filesystem with the
boot.img
andboot.sig
. They contain the kernel, cmdline, config.txt, the boot binaries, and the secondary bootloader. - System - An EXT4 filesystem with the main system image. System updates are delta diffs of this filesystem.
Since this project makes significant use of submodules, the clone command is a bit different:
git clone --recurse-submodules -j<JOBS> https://github.com/TheInternetBox/core
Note: -j
is the number of parallel jobs. Adjustment may be needed depending on the hardware at use and the internet bandwidth. 4
is usually a good start.
If the repo has already been cloned, this command should work to trigger submodule checkouts:
cd <cloned repo>
git submodule update --recursive --init
Note: If you want to build the debuggable version with kernel console via uart on GPIO pins, run export DEBUG=true
in your shell before running any scripts.
-
The
eeprom
must be programmed. This can be done by building theeeprom
image like so:-
Build the
eeprom
image:cd secure-boot/eeprom/ ./build-eeprom.sh
-
This will build an
out.rpiboot
folder in whichflash-eeprom.sh
will read. Follow its instructions to flash the EEPROM.
-
-
The
boot.img
andboot.sig
must be placed onto theemmc
on the boot partition]-
Build the
boot.img
andboot.sig
images:cd boot-image ./create_boot_image.sh
-
This will build the
boot.img
andboot.sig
. These will need to be placed in theemmc
FAT32 boot partition.
-
-
The
system.img
must be placed onto theemmc
system partition.