From 300f4185e05d895ec950c43bfb7a0f441476205f Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Mon, 17 Jan 2022 04:42:53 -0600 Subject: [PATCH 01/19] Track LLVM --- .gitmodules | 4 ++++ system/packages/llvm | 1 + 2 files changed, 5 insertions(+) create mode 160000 system/packages/llvm diff --git a/.gitmodules b/.gitmodules index 3ddd11d..e1a2a01 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,7 @@ path = busybox url = https://git.busybox.net/busybox/ branch = refs/tags/1_35_0 +[submodule "system_packages_llvm"] + path = system/packages/llvm + url = https://github.com/llvm/llvm-project.git + branch = release/13.x diff --git a/system/packages/llvm b/system/packages/llvm new file mode 160000 index 0000000..fc043d8 --- /dev/null +++ b/system/packages/llvm @@ -0,0 +1 @@ +Subproject commit fc043d8a256b1e431aa1297dffba154a7dd46b25 From d48aaa84f973bf7b712954ce44cc621ffb5826ca Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Mon, 17 Jan 2022 04:43:32 -0600 Subject: [PATCH 02/19] modules: Document branch requirement --- .gitmodules | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitmodules b/.gitmodules index e1a2a01..f113c19 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ +# CI requires branch to be defined [submodule "rpi-usbboot"] path = rpi-usbboot url = https://github.com/raspberrypi/usbboot From bd3ea7c0dfa38689ba6ca9b0fe39edfa5383ca06 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Mon, 17 Jan 2022 04:49:59 -0600 Subject: [PATCH 03/19] Start system image with clang toolchain --- .github/workflows/build-and-test.yaml | 16 +++++++-- README.md | 21 ++++++++++++ system/.gitignore | 3 ++ system/build-scripts/stage1/llvm.sh | 40 ++++++++++++++++++++++ system/create-system-image.sh | 48 +++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 system/.gitignore create mode 100755 system/build-scripts/stage1/llvm.sh create mode 100755 system/create-system-image.sh diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 0729027..bb9c627 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -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 @@ -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: | @@ -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' }} @@ -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 diff --git a/README.md b/README.md index 52082e1..82a7096 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,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 @@ -54,6 +58,14 @@ The `eeprom` is programmed with secure boot and some hardware configuration. The 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. +### Required Host Software + +- cmake +- ninja +- xz-utils +- clang +- ccache + 1. The `eeprom` must be programmed. This can be done by building the `eeprom` image like so: - Build the `eeprom` image: @@ -77,3 +89,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. diff --git a/system/.gitignore b/system/.gitignore new file mode 100644 index 0000000..04e34e6 --- /dev/null +++ b/system/.gitignore @@ -0,0 +1,3 @@ +*.img.xz +system-mount/* +tmp-system* \ No newline at end of file diff --git a/system/build-scripts/stage1/llvm.sh b/system/build-scripts/stage1/llvm.sh new file mode 100755 index 0000000..08d49cf --- /dev/null +++ b/system/build-scripts/stage1/llvm.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e + +BUILD_TYPE=Release +ENABLE_ASSERTIONS=OFF + +if [ -n "$DEBUG" ]; then + DEBUG=-debug + BUILD_TYPE=Debug + ENABLE_ASSERTIONS=ON +fi + +cd packages/llvm + +mkdir -p build +cd build + +CXX=clang++ CC=clang cmake -G Ninja \ + -DLLVM_ENABLE_PROJECTS='clang;libcxx;libcxxabi;compiler-rt;lld' \ + -DCMAKE_INSTALL_PREFIX=$LFS/tools \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DLLVM_ENABLE_ASSERTIONS=$ENABLE_ASSERTIONS \ + -DLLVM_ENABLE_LTO=ON \ + -DLLVM_CCACHE_BUILD=ON \ + -DCMAKE_CROSSCOMPILING=ON \ + -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu \ + -DLLVM_TARGET_ARCH=AArch64 \ + -DLLVM_TARGETS_TO_BUILD=AArch64 \ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AArch64 \ + ../llvm + +# Build +cmake --build . + +# Test +cmake --build . --target check-all + +# Install +cmake --build . --target install diff --git a/system/create-system-image.sh b/system/create-system-image.sh new file mode 100755 index 0000000..4613ff5 --- /dev/null +++ b/system/create-system-image.sh @@ -0,0 +1,48 @@ +#!/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 + +# Create folder structure +sudo mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin} + +for i in bin lib sbin; do + sudo ln -sv usr/$i $LFS/$i +done + +# Special folder for toolchain +sudo mkdir -pv $LFS/tools + +# Stage 1 - cross toolchain +# LLVM +sudo env LFS=${LFS} ./build-scripts/stage1/llvm.sh + +# Unmount image +sudo umount system-mount +sudo losetup -d ${LOOP} + +xz -T0 -e -9 ${TMPFILE} +mv ${TMPFILE}.xz system${DEBUG}.img.xz From d7e97ef077d4ab92efd49092e7ec3122c734ec24 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Mon, 17 Jan 2022 17:32:02 -0600 Subject: [PATCH 04/19] Add binutils for LLVMgold.so --- .gitmodules | 4 +++ system/build-scripts/stage1/binutils-gold.sh | 33 ++++++++++++++++++++ system/create-system-image.sh | 8 ++++- system/packages/binutils | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 system/build-scripts/stage1/binutils-gold.sh create mode 160000 system/packages/binutils diff --git a/.gitmodules b/.gitmodules index f113c19..46ae7b2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -21,3 +21,7 @@ path = system/packages/llvm url = https://github.com/llvm/llvm-project.git branch = release/13.x +[submodule "system_packages_binutils"] + path = system/packages/binutils + url = https://sourceware.org/git/binutils-gdb.git + branch = binutils-2_37-branch diff --git a/system/build-scripts/stage1/binutils-gold.sh b/system/build-scripts/stage1/binutils-gold.sh new file mode 100755 index 0000000..6fa95fb --- /dev/null +++ b/system/build-scripts/stage1/binutils-gold.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# Builds binutils gold linker for LLVMgold.so plugin + +set -e + +if [ -n "$DEBUG" ]; then + DEBUG=-debug +fi + +COMMON_CFLAGS="-O2 -fstack-protector-strong -pie -fPIE -D_FORTIFY_SOURCE=2" +TARGET_CFLAGS="-march=armv8-a+crc -mcpu=cortex-a72 -mtune=cortex-a72" + +cd packages/binutils + +# AR=ar AS=as +LD="lld" CXX="ccache clang++" CFLAGS_FOR_TARGET="$COMMON_CFLAGS $TARGET_CFLAGS" CXXFLAGS_FOR_TARGET="$COMMON_CFLAGS $TARGET_CFLAGS" CFLAGS="$COMMON_CFLAGS" CC="ccache clang" CXXFLAGS="$COMMON_CFLAGS" ./configure \ + --enable-gold=default \ + --enable-plugins \ + --disable-werror \ + --enable-lto \ + --host=$LFS_HOST \ + --target=$LFS_TARGET \ + --prefix=$LFS/cross-tools \ + --with-sysroot=$LFS \ + --with-lib-path=$LFS/tools/lib \ + --disable-nls \ + --enable-threads \ + --disable-gdb \ + --disable-multilib + +make -j$(nproc) +sudo make install diff --git a/system/create-system-image.sh b/system/create-system-image.sh index 4613ff5..ef297a9 100755 --- a/system/create-system-image.sh +++ b/system/create-system-image.sh @@ -25,6 +25,9 @@ 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} $LFS/usr/{bin,lib,sbin} @@ -35,10 +38,13 @@ done # Special folder for toolchain sudo mkdir -pv $LFS/tools +sudo mkdir -pv $LFS/cross-tools # Stage 1 - cross toolchain +# Binutils for gold/LLVMgold.so plugin +sudo env LFS=${LFS} LFS_HOST=${LFS_HOST} LFS_TARGET=${LFS_TARGET} ./build-scripts/stage1/binutils-gold.sh # LLVM -sudo env LFS=${LFS} ./build-scripts/stage1/llvm.sh +sudo env LFS=${LFS} LFS_HOST=${LFS_HOST} LFS_TARGET=${LFS_TARGET} ./build-scripts/stage1/llvm.sh # Unmount image sudo umount system-mount diff --git a/system/packages/binutils b/system/packages/binutils new file mode 160000 index 0000000..182284d --- /dev/null +++ b/system/packages/binutils @@ -0,0 +1 @@ +Subproject commit 182284deb1958787f7982b36e60bc398b8a0ae8f From e60f9491bb500b55412aafe301fbe025c34bd98b Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Mon, 17 Jan 2022 17:32:14 -0600 Subject: [PATCH 05/19] Fixup LLVM building --- system/build-scripts/stage1/llvm.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/system/build-scripts/stage1/llvm.sh b/system/build-scripts/stage1/llvm.sh index 08d49cf..e4fafe7 100755 --- a/system/build-scripts/stage1/llvm.sh +++ b/system/build-scripts/stage1/llvm.sh @@ -2,12 +2,12 @@ set -e -BUILD_TYPE=Release +BUILD_TYPE=MinSizeRel ENABLE_ASSERTIONS=OFF if [ -n "$DEBUG" ]; then DEBUG=-debug - BUILD_TYPE=Debug + BUILD_TYPE=RelWithDebInfo ENABLE_ASSERTIONS=ON fi @@ -16,18 +16,26 @@ cd packages/llvm mkdir -p build cd build +COMMON_CFLAGS="-O2 -fstack-protector-strong -fPIE -D_FORTIFY_SOURCE=2" + CXX=clang++ CC=clang cmake -G Ninja \ -DLLVM_ENABLE_PROJECTS='clang;libcxx;libcxxabi;compiler-rt;lld' \ -DCMAKE_INSTALL_PREFIX=$LFS/tools \ + -DCMAKE_CXX_FLAGS="$COMMON_CFLAGS $TARGET_CFLAGS" \ + -DCMAKE_C_FLAGS="$COMMON_CFLAGS $TARGET_CFLAGS" \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DLLVM_ENABLE_ASSERTIONS=$ENABLE_ASSERTIONS \ -DLLVM_ENABLE_LTO=ON \ + -DLLVM_BUILD_DOCS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_USE_LINKER=lld \ -DLLVM_CCACHE_BUILD=ON \ -DCMAKE_CROSSCOMPILING=ON \ -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu \ -DLLVM_TARGET_ARCH=AArch64 \ -DLLVM_TARGETS_TO_BUILD=AArch64 \ -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AArch64 \ + -DLLVM_PARALLEL_LINK_JOBS=3 \ ../llvm # Build From d8d2013b8d5fae47879b3fe44a47e4fa069bd694 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 03:05:19 -0600 Subject: [PATCH 06/19] Remove packages in favor of @TheInternetBox/packages --- .gitmodules | 8 ---- system/build-scripts/stage1/binutils-gold.sh | 33 -------------- system/build-scripts/stage1/llvm.sh | 48 -------------------- system/packages/binutils | 1 - system/packages/llvm | 1 - 5 files changed, 91 deletions(-) delete mode 100755 system/build-scripts/stage1/binutils-gold.sh delete mode 100755 system/build-scripts/stage1/llvm.sh delete mode 160000 system/packages/binutils delete mode 160000 system/packages/llvm diff --git a/.gitmodules b/.gitmodules index 46ae7b2..eb06275 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,11 +17,3 @@ path = busybox url = https://git.busybox.net/busybox/ branch = refs/tags/1_35_0 -[submodule "system_packages_llvm"] - path = system/packages/llvm - url = https://github.com/llvm/llvm-project.git - branch = release/13.x -[submodule "system_packages_binutils"] - path = system/packages/binutils - url = https://sourceware.org/git/binutils-gdb.git - branch = binutils-2_37-branch diff --git a/system/build-scripts/stage1/binutils-gold.sh b/system/build-scripts/stage1/binutils-gold.sh deleted file mode 100755 index 6fa95fb..0000000 --- a/system/build-scripts/stage1/binutils-gold.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -# Builds binutils gold linker for LLVMgold.so plugin - -set -e - -if [ -n "$DEBUG" ]; then - DEBUG=-debug -fi - -COMMON_CFLAGS="-O2 -fstack-protector-strong -pie -fPIE -D_FORTIFY_SOURCE=2" -TARGET_CFLAGS="-march=armv8-a+crc -mcpu=cortex-a72 -mtune=cortex-a72" - -cd packages/binutils - -# AR=ar AS=as -LD="lld" CXX="ccache clang++" CFLAGS_FOR_TARGET="$COMMON_CFLAGS $TARGET_CFLAGS" CXXFLAGS_FOR_TARGET="$COMMON_CFLAGS $TARGET_CFLAGS" CFLAGS="$COMMON_CFLAGS" CC="ccache clang" CXXFLAGS="$COMMON_CFLAGS" ./configure \ - --enable-gold=default \ - --enable-plugins \ - --disable-werror \ - --enable-lto \ - --host=$LFS_HOST \ - --target=$LFS_TARGET \ - --prefix=$LFS/cross-tools \ - --with-sysroot=$LFS \ - --with-lib-path=$LFS/tools/lib \ - --disable-nls \ - --enable-threads \ - --disable-gdb \ - --disable-multilib - -make -j$(nproc) -sudo make install diff --git a/system/build-scripts/stage1/llvm.sh b/system/build-scripts/stage1/llvm.sh deleted file mode 100755 index e4fafe7..0000000 --- a/system/build-scripts/stage1/llvm.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -set -e - -BUILD_TYPE=MinSizeRel -ENABLE_ASSERTIONS=OFF - -if [ -n "$DEBUG" ]; then - DEBUG=-debug - BUILD_TYPE=RelWithDebInfo - ENABLE_ASSERTIONS=ON -fi - -cd packages/llvm - -mkdir -p build -cd build - -COMMON_CFLAGS="-O2 -fstack-protector-strong -fPIE -D_FORTIFY_SOURCE=2" - -CXX=clang++ CC=clang cmake -G Ninja \ - -DLLVM_ENABLE_PROJECTS='clang;libcxx;libcxxabi;compiler-rt;lld' \ - -DCMAKE_INSTALL_PREFIX=$LFS/tools \ - -DCMAKE_CXX_FLAGS="$COMMON_CFLAGS $TARGET_CFLAGS" \ - -DCMAKE_C_FLAGS="$COMMON_CFLAGS $TARGET_CFLAGS" \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DLLVM_ENABLE_ASSERTIONS=$ENABLE_ASSERTIONS \ - -DLLVM_ENABLE_LTO=ON \ - -DLLVM_BUILD_DOCS=OFF \ - -DLLVM_INCLUDE_EXAMPLES=OFF \ - -DLLVM_USE_LINKER=lld \ - -DLLVM_CCACHE_BUILD=ON \ - -DCMAKE_CROSSCOMPILING=ON \ - -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu \ - -DLLVM_TARGET_ARCH=AArch64 \ - -DLLVM_TARGETS_TO_BUILD=AArch64 \ - -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AArch64 \ - -DLLVM_PARALLEL_LINK_JOBS=3 \ - ../llvm - -# Build -cmake --build . - -# Test -cmake --build . --target check-all - -# Install -cmake --build . --target install diff --git a/system/packages/binutils b/system/packages/binutils deleted file mode 160000 index 182284d..0000000 --- a/system/packages/binutils +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 182284deb1958787f7982b36e60bc398b8a0ae8f diff --git a/system/packages/llvm b/system/packages/llvm deleted file mode 160000 index fc043d8..0000000 --- a/system/packages/llvm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fc043d8a256b1e431aa1297dffba154a7dd46b25 From 4d5e2133567f20d72780d6f9d7032f78ec223348 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 03:05:41 -0600 Subject: [PATCH 07/19] ci: have checkout work with recursive submodules --- .github/workflows/build-and-test.yaml | 2 +- .github/workflows/submodule-sync.yaml | 2 +- .github/workflows/update-github-actions.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index bb9c627..d9adf5f 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v2.4.0 with: token: ${{ secrets.GITHUB_TOKEN }} - submodules: true + submodules: recursive - name: Cache ccache uses: actions/cache@v2.1.7 diff --git a/.github/workflows/submodule-sync.yaml b/.github/workflows/submodule-sync.yaml index 1da194f..dab93ad 100644 --- a/.github/workflows/submodule-sync.yaml +++ b/.github/workflows/submodule-sync.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v2.4.0 with: token: ${{ secrets.PAT_TOKEN }} - submodules: true + submodules: recursive # Update references - name: Git submodule update diff --git a/.github/workflows/update-github-actions.yaml b/.github/workflows/update-github-actions.yaml index 83e2ee8..d6bb787 100644 --- a/.github/workflows/update-github-actions.yaml +++ b/.github/workflows/update-github-actions.yaml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v2.4.0 with: token: ${{ secrets.PAT_TOKEN }} - submodules: true + submodules: recursive - name: Install ghacu run: | From f1dd51c309a70f8b0666e83e8ef65fe92ccb786c Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 03:08:42 -0600 Subject: [PATCH 08/19] system: make rootfs a bit more appropriate --- system/create-system-image.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/system/create-system-image.sh b/system/create-system-image.sh index ef297a9..c44d3e9 100755 --- a/system/create-system-image.sh +++ b/system/create-system-image.sh @@ -28,17 +28,14 @@ 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} $LFS/usr/{bin,lib,sbin} +sudo mkdir -pv $LFS/{etc,var,tmp} $LFS/usr/{bin,lib,sbin} +sudo ln -sv lib $LFS/usr/lib64 -for i in bin lib sbin; do +for i in bin lib lib64 sbin; do sudo ln -sv usr/$i $LFS/$i done -# Special folder for toolchain -sudo mkdir -pv $LFS/tools -sudo mkdir -pv $LFS/cross-tools # Stage 1 - cross toolchain # Binutils for gold/LLVMgold.so plugin From 4f163313d3c6a836ddf52844e86a059fa84c82e3 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 03:09:02 -0600 Subject: [PATCH 09/19] system: Install kernel headers to /usr/include --- system/create-system-image.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/create-system-image.sh b/system/create-system-image.sh index c44d3e9..398d924 100755 --- a/system/create-system-image.sh +++ b/system/create-system-image.sh @@ -36,6 +36,10 @@ 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 # Stage 1 - cross toolchain # Binutils for gold/LLVMgold.so plugin From b000d3589415278e1514475be3848ad6bbc2d532 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 03:09:24 -0600 Subject: [PATCH 10/19] system: Use new @InternetBox/packages repo --- system/create-system-image.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/system/create-system-image.sh b/system/create-system-image.sh index 398d924..2117afb 100755 --- a/system/create-system-image.sh +++ b/system/create-system-image.sh @@ -41,11 +41,11 @@ 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 -# Stage 1 - cross toolchain -# Binutils for gold/LLVMgold.so plugin -sudo env LFS=${LFS} LFS_HOST=${LFS_HOST} LFS_TARGET=${LFS_TARGET} ./build-scripts/stage1/binutils-gold.sh -# LLVM -sudo env LFS=${LFS} LFS_HOST=${LFS_HOST} LFS_TARGET=${LFS_TARGET} ./build-scripts/stage1/llvm.sh +# Bootstrap packages +cd packages +echo PWD=$(pwd) +echo sudo env LFS_TARGET=$LFS_TARGET LFS_HOST=$LFS_HOST LFS=$LFS ./build.sh +cd - # Unmount image sudo umount system-mount From e1f1fc88e1e9c56a0644d407acc1f311558bda0d Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 03:31:45 -0600 Subject: [PATCH 11/19] Add packages submodules --- .gitmodules | 4 ++++ system/packages | 1 + 2 files changed, 5 insertions(+) create mode 160000 system/packages diff --git a/.gitmodules b/.gitmodules index eb06275..2e4881a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,3 +17,7 @@ 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 diff --git a/system/packages b/system/packages new file mode 160000 index 0000000..4c2dcad --- /dev/null +++ b/system/packages @@ -0,0 +1 @@ +Subproject commit 4c2dcad42712a68e466d35b05f2fc51d76cfd2d9 From 260987becde6a2d1b9660a11cbbf3bbab6c712b7 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 04:08:54 -0600 Subject: [PATCH 12/19] Update packages ref --- system/packages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/packages b/system/packages index 4c2dcad..ddb0182 160000 --- a/system/packages +++ b/system/packages @@ -1 +1 @@ -Subproject commit 4c2dcad42712a68e466d35b05f2fc51d76cfd2d9 +Subproject commit ddb0182b3076288051fa9cb74d0c24d9d4bab9c9 From 1527fa074dad1484110e921fa7d2640c0e3e6ac7 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 04:39:50 -0600 Subject: [PATCH 13/19] Update packages ref --- system/packages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/packages b/system/packages index ddb0182..1a2eb78 160000 --- a/system/packages +++ b/system/packages @@ -1 +1 @@ -Subproject commit ddb0182b3076288051fa9cb74d0c24d9d4bab9c9 +Subproject commit 1a2eb78e5451c2dbf37e2e5840a810af68b5a25b From 7036b670ecea6cc9d17b2a659308616567540412 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 17:58:44 -0600 Subject: [PATCH 14/19] .gitmodules: Move Linux URL to new upstream --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 2e4881a..b6ef656 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,8 +10,8 @@ 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 From 1c34c1d89dad19130f3805306a1122ccac059224 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 19:38:49 -0600 Subject: [PATCH 15/19] system: create script: stop echoing --- system/create-system-image.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/create-system-image.sh b/system/create-system-image.sh index 2117afb..78f7bc6 100755 --- a/system/create-system-image.sh +++ b/system/create-system-image.sh @@ -43,8 +43,7 @@ KBUILD_BUILD_TIMESTAMP='' sudo make -C ../boot-image/linux ARCH=arm64 CC="ccache # Bootstrap packages cd packages -echo PWD=$(pwd) -echo sudo env LFS_TARGET=$LFS_TARGET LFS_HOST=$LFS_HOST LFS=$LFS ./build.sh +sudo env LFS_TARGET=$LFS_TARGET LFS_HOST=$LFS_HOST LFS=$LFS ./build.sh cd - # Unmount image From 97e0329f228b4eb3255e715743de80584fc9d2ac Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 19:46:08 -0600 Subject: [PATCH 16/19] packages: Update ref --- system/packages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/packages b/system/packages index 1a2eb78..8d6b557 160000 --- a/system/packages +++ b/system/packages @@ -1 +1 @@ -Subproject commit 1a2eb78e5451c2dbf37e2e5840a810af68b5a25b +Subproject commit 8d6b5571a32bc53c25ddb90a3619dc174729a556 From b9e199899695836221ca773a25bdc0212624f550 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Tue, 18 Jan 2022 21:31:12 -0600 Subject: [PATCH 17/19] packages: Update ref --- system/packages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/packages b/system/packages index 8d6b557..c5439b4 160000 --- a/system/packages +++ b/system/packages @@ -1 +1 @@ -Subproject commit 8d6b5571a32bc53c25ddb90a3619dc174729a556 +Subproject commit c5439b4ffa15ffae413c4fc90ad155fa70d39504 From 9a7ace45ad896dd6a6e759e2ad4a1b6bb21948e4 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Sun, 23 Oct 2022 16:00:27 -0500 Subject: [PATCH 18/19] Update usbboot upstream --- rpi-usbboot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpi-usbboot b/rpi-usbboot index 8c8cbed..15aac0c 160000 --- a/rpi-usbboot +++ b/rpi-usbboot @@ -1 +1 @@ -Subproject commit 8c8cbeda4aa595a19e2f2a6c92ed4c41528ceaa0 +Subproject commit 15aac0cd08039ac28225d5820c38c4ce733f0cd8 From 596ce87afc41ee603f4b7f6cc00429192d289cf5 Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Sun, 23 Oct 2022 16:21:36 -0500 Subject: [PATCH 19/19] Update Linux --- boot-image/linux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot-image/linux b/boot-image/linux index a1bfb72..3b9a470 160000 --- a/boot-image/linux +++ b/boot-image/linux @@ -1 +1 @@ -Subproject commit a1bfb721bbc1a601993889308154043ecb6eefe6 +Subproject commit 3b9a4709e0578738e6401413bd234d4e6db96d29