diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4650806..060a1a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,6 @@ on: workflow_dispatch: env: - KERNEL_FAMILY: 6.x KERNEL_VERSION: 6.12.25 PICORE_VERSION_MAJOR: 16 PICORE_VERSION_MINOR: 0 @@ -202,104 +201,13 @@ jobs: name: rootfs-${{matrix.package}} path: "${{github.workspace}}/artifacts/rootfs-${{matrix.package}}-${{env.PICORE_VERSION_MAJOR}}.${{env.PICORE_VERSION_MINOR}}.gz" - build-kernel-qemu: - runs-on: ubuntu-24.04-arm - steps: - - name: 'Login to GitHub Container Registry' - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/asssaf/picore-kernel-qemu - tags: "type=raw,value=${{ env.TAG }},priority=2000" - - - name: build deps - if: false - uses: docker/build-push-action@v6 - with: - file: docker/Dockerfile.kernel-qemu - platforms: linux/arm64/v8 - target: deps - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: build kernel - if: false - uses: docker/build-push-action@v6 - with: - file: docker/Dockerfile.kernel-qemu - platforms: linux/arm64/v8 - target: build - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: output kernel - uses: docker/build-push-action@v6 - with: - file: docker/Dockerfile.kernel-qemu - platforms: linux/arm64/v8 - target: kernel - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - outputs: "type=local,dest=${{github.workspace}}/artifacts" - - - name: upload kernel for qemu - uses: actions/upload-artifact@v4 - with: - name: kernel8-qemu-${{ env.KERNEL_VERSION }} - path: "${{github.workspace}}/artifacts/Image-${{ env.KERNEL_VERSION }}" - - - name: upload config for qemu - uses: actions/upload-artifact@v4 - with: - name: config-kernel8-qemu-${{ env.KERNEL_VERSION }} - path: "${{github.workspace}}/artifacts/config-${{ env.KERNEL_VERSION }}" - - - name: output modules - if: false - uses: docker/build-push-action@v6 - with: - file: docker/Dockerfile.kernel-qemu - platforms: linux/arm64/v8 - target: modules - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - outputs: "type=tar,dest=${{github.workspace}}/artifacts/modules-${{ env.KERNEL_VERSION }}.tar" - - - name: upload modules for qemu - if: false - uses: actions/upload-artifact@v4 - with: - name: modules-qemu-${{ env.KERNEL_VERSION }} - path: "${{github.workspace}}/artifacts/modules-${{ env.KERNEL_VERSION }}.tar" test: strategy: matrix: package: [piCore, piCore64] runs-on: ubuntu-24.04 - needs: [build, build-kernel-qemu] + needs: [build] steps: - name: checkout uses: actions/checkout@v4 @@ -309,12 +217,6 @@ jobs: sudo apt update sudo apt install -y qemu-system-arm - - name: download-kernel - uses: actions/download-artifact@v4 - with: - name: kernel8-qemu-${{ env.KERNEL_VERSION }} - path: "${{github.workspace}}" - - name: download-tce-disk uses: actions/download-artifact@v4 with: @@ -334,6 +236,9 @@ jobs: run: | set -euxo pipefail + docker create --name rpi-kernel --platform linux/arm64/v8 ghcr.io/asssaf/rpi-kernel:${{ env.KERNEL_VERSION }}-default true + docker cp rpi-kernel:/Image-${{ env.KERNEL_VERSION }} . + scripts/run-tc.sh |& tee qemu.out & until sshpass -p piCore ssh -o StrictHostKeychecking=no -p 2223 tc@127.0.0.1 echo hi diff --git a/docker/Dockerfile.kernel-qemu b/docker/Dockerfile.kernel-qemu deleted file mode 100644 index 866c106..0000000 --- a/docker/Dockerfile.kernel-qemu +++ /dev/null @@ -1,66 +0,0 @@ -FROM debian:bookworm AS deps - -RUN apt update -RUN apt install -y curl fakeroot git kernel-wedge quilt ccache flex bison libssl-dev dh-exec rsync libelf-dev bc crossbuild-essential-arm64 - -ARG KERNEL_FAMILY=6.x -ARG KERNEL_VERSION=6.12.25 - -RUN curl -sL https://cdn.kernel.org/pub/linux/kernel/v${KERNEL_FAMILY}/linux-${KERNEL_VERSION}.tar.xz | tar -xvJ - -WORKDIR /linux-${KERNEL_VERSION} - -# Download and apply patches -RUN ( \ - PATCHES="$(curl -s http://tinycorelinux.net/16.x/aarch64/release/src/kernel/patches-6.12.y/ | grep -oP 'href="\K[^"]*\.patch' | sed 's/\"//g')" \ - && for PATCH in $PATCHES; \ - do \ - curl -s $PATCH | patch -Np1; \ - done; \ -) - -# create a .config file -RUN curl -sLo - http://tinycorelinux.net/16.x/aarch64/release/src/kernel/${KERNEL_VERSION}-piCore-v8_.config.xz | xzcat > .config - -# Use the kvm_guest config as the base defconfig, which is suitable for qemu -RUN ARCH=arm64 CROSS_COMPILE=/bin/aarch64-linux-gnu- make kvm_guest.config - -# required for arm virt board, but missing https://qemu-project.gitlab.io/qemu/system/arm/virt.html#linux-guest-kernel-configuration -RUN echo "CONFIG_PCI_HOST_GENERIC=y" >> extra.config - -# required for loading extensions -RUN echo "CONFIG_SQUASHFS=y" >> extra.config - -RUN scripts/kconfig/merge_config.sh -m -r .config extra.config - -# ensure dependencies are met -RUN ARCH=arm64 CROSS_COMPILE=/bin/aarch64-linux-gnu- make oldconfig - - -FROM deps AS build - -# Build the kernel -RUN ARCH=arm64 CROSS_COMPILE=/bin/aarch64-linux-gnu- make Image -j8 - - -FROM build AS build-modules - -# Build the modules -RUN ARCH=arm64 CROSS_COMPILE=/bin/aarch64-linux-gnu- make modules modules_install - -RUN apt install -y kmod -RUN depmod -a ${KERNEL_VERSION}-piCore-v8 - -FROM scratch AS kernel - -ARG KERNEL_VERSION=6.12.25 - -COPY --from=build linux-${KERNEL_VERSION}/arch/arm64/boot/Image /Image-${KERNEL_VERSION} -COPY --from=build linux-${KERNEL_VERSION}/.config /config-${KERNEL_VERSION} - - -FROM scratch AS modules - -ARG KERNEL_VERSION=6.12.25 - -COPY --from=build-modules /lib/modules /lib/modules diff --git a/extensions/recovery/extension/usr/local/etc/init.d/services/recovery/run b/extensions/recovery/extension/usr/local/etc/init.d/services/recovery/run index ea21234..523aff9 100755 --- a/extensions/recovery/extension/usr/local/etc/init.d/services/recovery/run +++ b/extensions/recovery/extension/usr/local/etc/init.d/services/recovery/run @@ -6,16 +6,50 @@ exec 2>&1 BOOT="/etc/sysconfig/tcedir/../bootattempt" DELAY=30 +MAX_ATTEMPTS=2 -while [ -e "$BOOT" ] +cmdline="$(cat /proc/cmdline)" + +for i in $cmdline do - echo "Previous boot failed - remove $BOOT to continue" - sleep 5 + case $i in + recovery=*) + MAX_ATTEMPTS=${i#*=} + ;; + esac done -echo "Booting second partition in $DELAY seconds ..." -sleep $DELAY -touch "$BOOT" -sync -tryboot "2" -sleep $DELAY + +loop() { + if [ ! -e "${BOOT}" ] + then + echo "${BOOT} doesn't exist - create it to start recovery auto boot" + return 0 + fi + + ATTEMPT="$(cat "$BOOT")" + case "$ATTEMPT" in + ''|*[!0-9]*) ATTEMPT=0 ;; + esac + + if [ "$ATTEMPT" -ge "$MAX_ATTEMPTS" ] + then + echo "${ATTEMPT} boot attempt(s) failed, ${MAX_ATTEMPTS} allowed - write 0 to ${BOOT} to restart" + return 0 + fi + + ACTUAL_DELAY="$(($DELAY*2**${ATTEMPT}))" + echo "Booting second partition in $ACTUAL_DELAY seconds ..." + sleep $ACTUAL_DELAY + echo "$((ATTEMPT+1))" > "$BOOT" + sync + echo "Booting now..." + tryboot "2" + sleep $DELAY +} + +while true +do + loop + sleep 5 +done