Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
300f418
Track LLVM
USA-RedDragon Jan 17, 2022
d48aaa8
modules: Document branch requirement
USA-RedDragon Jan 17, 2022
bd3ea7c
Start system image with clang toolchain
USA-RedDragon Jan 17, 2022
d7e97ef
Add binutils for LLVMgold.so
USA-RedDragon Jan 17, 2022
e60f949
Fixup LLVM building
USA-RedDragon Jan 17, 2022
d8d2013
Remove packages in favor of @TheInternetBox/packages
USA-RedDragon Jan 18, 2022
4d5e213
ci: have checkout work with recursive submodules
USA-RedDragon Jan 18, 2022
f1dd51c
system: make rootfs a bit more appropriate
USA-RedDragon Jan 18, 2022
4f16331
system: Install kernel headers to /usr/include
USA-RedDragon Jan 18, 2022
b000d35
system: Use new @InternetBox/packages repo
USA-RedDragon Jan 18, 2022
2343d51
Merge branch 'main' into llvm
USA-RedDragon Jan 18, 2022
e1f1fc8
Add packages submodules
USA-RedDragon Jan 18, 2022
260987b
Update packages ref
USA-RedDragon Jan 18, 2022
1527fa0
Update packages ref
USA-RedDragon Jan 18, 2022
a5e9561
Merge branch 'main' into packages
USA-RedDragon Jan 18, 2022
22d1a10
Merge branch 'main' into packages
USA-RedDragon Jan 18, 2022
7036b67
.gitmodules: Move Linux URL to new upstream
USA-RedDragon Jan 18, 2022
1c34c1d
system: create script: stop echoing
USA-RedDragon Jan 19, 2022
97e0329
packages: Update ref
USA-RedDragon Jan 19, 2022
b9e1998
packages: Update ref
USA-RedDragon Jan 19, 2022
9a7ace4
Update usbboot upstream
USA-RedDragon Oct 23, 2022
596ce87
Update Linux
USA-RedDragon Oct 23, 2022
40b15cd
Merge branch 'main' into packages
USA-RedDragon Oct 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v3.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
submodules: true
submodules: recursive

- name: Cache ccache
uses: actions/cache@v3.0.11
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Setup build dependencies
run: |
sudo apt update
sudo apt install -y lsb-release wget software-properties-common build-essential python gcc-aarch64-linux-gnu python3 xz-utils libusb-1.0-0-dev ccache
sudo apt install -y cmake ninja-build lsb-release wget software-properties-common build-essential python gcc-aarch64-linux-gnu python3 xz-utils libusb-1.0-0-dev ccache
python3 -m pip install pycryptodomex
ccache -M 2G
ccache -F 0
Expand Down Expand Up @@ -96,7 +96,15 @@ jobs:

- name: Build system image
run: |
echo "We're not quite to system images yet. :)"
cd $GITHUB_WORKSPACE/system
./create-system-image.sh

- name: Build debug system image
env:
DEBUG: 'true'
run: |
cd $GITHUB_WORKSPACE/system
./create-system-image.sh

- name: Collect artifacts
run: |
Expand All @@ -109,6 +117,8 @@ jobs:
cp $GITHUB_WORKSPACE/boot-image/boot.sig /tmp/artifacts/boot.sig
cp $GITHUB_WORKSPACE/boot-image/boot-debug.img /tmp/artifacts/boot-debug.img
cp $GITHUB_WORKSPACE/boot-image/boot-debug.sig /tmp/artifacts/boot-debug.sig
cp $GITHUB_WORKSPACE/system/system.img.xz /tmp/artifacts/system.img.xz
cp $GITHUB_WORKSPACE/system/system-debug.img.xz /tmp/artifacts/system-debug.img.xz

- name: Release artifacts
if: ${{ github.event_name == 'push' }}
Expand All @@ -127,6 +137,8 @@ jobs:
/tmp/artifacts/boot.sig
/tmp/artifacts/boot-debug.img
/tmp/artifacts/boot-debug.sig
/tmp/artifacts/system.img.xz
/tmp/artifacts/system-debug.img.xz

### Begin Tests

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/submodule-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v3.1.0
with:
token: ${{ secrets.PAT_TOKEN }}
submodules: true
submodules: recursive

# Update references
- name: Git submodule update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v3.1.0
with:
token: ${{ secrets.PAT_TOKEN }}
submodules: true
submodules: recursive

- name: Install ghacu
run: |
Expand Down
9 changes: 7 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# CI requires branch to be defined
[submodule "rpi-usbboot"]
path = rpi-usbboot
url = https://github.com/raspberrypi/usbboot
Expand All @@ -9,10 +10,14 @@
shallow = true
[submodule "boot-image_linux"]
path = boot-image/linux
url = https://github.com/USA-RedDragon/linux
branch = rpi-router
url = https://github.com/TheInternetBox/linux
branch = internetbox
shallow = true
[submodule "busybox"]
path = busybox
url = https://git.busybox.net/busybox/
branch = refs/tags/1_35_0
[submodule "system_packages"]
path = system/packages
url = https://github.com/TheInternetBox/packages
branch = main
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ This is a POC, but a predecessor of this appliance has been running in my networ
- `eeprom` - Contains eeprom programming and configuration
- `keys` - Contains secure boot keys. Generate your own in the PEM format :)
- `lockdown` - Burns the eeprom with `program_pubkey` and `revoke_devkey`, and `program_jtag_lock`. Only use this if you want to lock the bootloader
- `system` - Contains the actual system components, including packages
- `build-scripts` - Contains the scripts used to build various components of the OS
- `stage1` - Scripts pertaining to building a toolchain appropriate for cross-compiling the rest of the OS
- `stage2` - Scripts pertaining to using the stage1 toolchain to build OS packages

## Security Enhancments

Expand Down Expand Up @@ -74,6 +78,14 @@ cd <cloned repo>
git submodule update --recursive --init
```

### Required Host Software

- cmake
- ninja
- xz-utils
- clang
- ccache

### Building the imges

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.
Expand Down Expand Up @@ -101,3 +113,12 @@ Note: If you want to build the debuggable version with kernel console via uart o
- This will build the `boot.img` and `boot.sig`. These will need to be placed in the `emmc` FAT32 boot partition.

3. The `system.img` must be placed onto the `emmc` system partition.

- Build the `system.img.xz` image:

```bash
cd system
./create-system-image.sh
```

- This will build the `system.img.xz`. This will need to be flashed in the `emmc`. It contains an ext4 system partition.
2 changes: 1 addition & 1 deletion boot-image/linux
Submodule linux updated from a1bfb7 to 3b9a47
3 changes: 3 additions & 0 deletions system/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.img.xz
system-mount/*
tmp-system*
54 changes: 54 additions & 0 deletions system/create-system-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Loosely based on LFS systemd

set -e

if [ -n "$DEBUG" ]; then
DEBUG=-debug
fi

TMPFILE=tmp-system

# Create 2gb raw ext4 image file
dd if=/dev/zero of=${TMPFILE} bs=1M count=2048
mkfs.ext4 ${TMPFILE}

# Grab blkid for dm-verity
SYSTEM_PARTITION_UUID=$(blkid ${TMPFILE} | awk '{ print $2 }' | sed -E 's/UUID="(.*)"/\1/g')
export MAKEFLAGS="-j$(nproc)"

# Mount ext4 image
sudo mkdir -p system-mount
LOOP=$(sudo losetup -f)
sudo losetup -f ${TMPFILE}
sudo mount ${LOOP} system-mount/

LFS=$(pwd)/system-mount
LFS_HOST="x86_64-pc-linux-gnu"
LFS_TARGET="aarch64-linux-gnu"

# Create folder structure
sudo mkdir -pv $LFS/{etc,var,tmp} $LFS/usr/{bin,lib,sbin}
sudo ln -sv lib $LFS/usr/lib64

for i in bin lib lib64 sbin; do
sudo ln -sv usr/$i $LFS/$i
done

# Kernel Headers
DEFCONFIG="rpi_cm4_io_router_defconfig"
KBUILD_BUILD_TIMESTAMP='' make -C ../boot-image/linux ARCH=arm64 CC="ccache clang" LLVM=1 CROSS_COMPILE=aarch64-linux-gnu- ${DEFCONFIG}
KBUILD_BUILD_TIMESTAMP='' sudo make -C ../boot-image/linux ARCH=arm64 CC="ccache clang" LLVM=1 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_HDR_PATH=$LFS/usr headers_install

# Bootstrap packages
cd packages
sudo env LFS_TARGET=$LFS_TARGET LFS_HOST=$LFS_HOST LFS=$LFS ./build.sh
cd -

# Unmount image
sudo umount system-mount
sudo losetup -d ${LOOP}

xz -T0 -e -9 ${TMPFILE}
mv ${TMPFILE}.xz system${DEBUG}.img.xz
1 change: 1 addition & 0 deletions system/packages
Submodule packages added at c5439b