From 732ece678b3ce4c25a8cdbcbd728f41af1d20b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 22:30:31 +0200 Subject: [PATCH 01/15] Add new workflow files --- .github/workflows/kanso-cd.yml | 8 +++ .github/workflows/kanso-ci.yml | 2 +- .../releases/release-pine64_star64.yml | 58 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/releases/release-pine64_star64.yml diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index fc8c1db..d850d01 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -12,3 +12,11 @@ jobs: with: platform: ${{ matrix.platform }} + release: + strategy: + matrix: + include: ${{ fromJSON(vars.ReleaseTargets) }} + uses: ./.github/workflows/releases/release-${{ matrix.Id }} + secrets: inherit + with: + releaseTargetId: ${{ matrix.Id }} diff --git a/.github/workflows/kanso-ci.yml b/.github/workflows/kanso-ci.yml index 6ca42d1..7502f2d 100644 --- a/.github/workflows/kanso-ci.yml +++ b/.github/workflows/kanso-ci.yml @@ -32,5 +32,5 @@ jobs: uses: ./.github/workflows/kernel-build.yml secrets: inherit with: - platform: ${{ matrix.platform }} + platform: ${{ matrix }} diff --git a/.github/workflows/releases/release-pine64_star64.yml b/.github/workflows/releases/release-pine64_star64.yml new file mode 100644 index 0000000..e29d091 --- /dev/null +++ b/.github/workflows/releases/release-pine64_star64.yml @@ -0,0 +1,58 @@ +name: Kernel-Build +on: + workflow_call: + inputs: + platform: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + env: + PLATFORM: ${{ inputs.platform }} + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v2 + with: + version: "20.1.3" + env: true + + - name: Install CMake + uses: lukka/get-cmake@latest + + - name: Install QEMU + run: | + sudo apt-get update + sudo apt-get install -y qemu-system-${{ env.PLATFORM }} + curl -LO https://github.com/qemu/qemu/raw/master/pc-bios/opensbi-${{ env.PLATFORM }}-generic-fw_dynamic.bin + + - name: Build Kernel + run: | + cmake --preset ${{ env.PLATFORM }} -B build/${{ env.PLATFORM }} + cmake --build build/${{ env.PLATFORM }} + + - name: Test Kernel + run: | + set -euo pipefail + + ( + qemu-system-${{ env.PLATFORM }} \ + -machine virt \ + -kernel build/${{ env.PLATFORM }}/bin/kernel-test.elf \ + -serial stdio -monitor none -nographic -no-reboot + ) 2>&1 | tee qemu.log + + ! grep -q "\[ FAILED ]" qemu.log + + - name: Upload Kernel binaries + uses: actions/upload-artifact@v4 + with: + name: kernel-${{ env.PLATFORM }} + path: | + build/${{ env.PLATFORM }}/bin/kernel.elf + build/${{ env.PLATFORM }}/bin/kernel.bin From d645808eaa11ca4617a0e68b23f52d647c5e8b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 22:32:55 +0200 Subject: [PATCH 02/15] Update KernelMain --- src/Kernel/KernelMain.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Kernel/KernelMain.c b/src/Kernel/KernelMain.c index d66e401..5145290 100644 --- a/src/Kernel/KernelMain.c +++ b/src/Kernel/KernelMain.c @@ -29,7 +29,6 @@ void KernelMain() { auto platformInformation = PlatformGetInformation(); - // this is a test KernelConsolePrint(String("\n\n\x1b[36m%s\x1b[0m\n"), KernelLogo); KernelConsolePrint(String("Kanso OS 1.0-DEV1 ")); KernelConsolePrint(String("(%s %d-bit)\n\n"), platformInformation.Name.Pointer, platformInformation.ArchitectureBits); From 35de0e65129a8e8ac1e4c19d598b555dacea7b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 22:40:06 +0200 Subject: [PATCH 03/15] Move workflow files --- .github/workflows/kanso-cd.yml | 2 +- .github/workflows/kanso-ci.yml | 2 +- .github/workflows/{releases => }/release-pine64_star64.yml | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{releases => }/release-pine64_star64.yml (100%) diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index d850d01..7482f88 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: include: ${{ fromJSON(vars.ReleaseTargets) }} - uses: ./.github/workflows/releases/release-${{ matrix.Id }} + uses: ./.github/workflows/release-${{ matrix.Id }} secrets: inherit with: releaseTargetId: ${{ matrix.Id }} diff --git a/.github/workflows/kanso-ci.yml b/.github/workflows/kanso-ci.yml index 7502f2d..c1465fa 100644 --- a/.github/workflows/kanso-ci.yml +++ b/.github/workflows/kanso-ci.yml @@ -32,5 +32,5 @@ jobs: uses: ./.github/workflows/kernel-build.yml secrets: inherit with: - platform: ${{ matrix }} + platform: ${{ matrix.Platform }} diff --git a/.github/workflows/releases/release-pine64_star64.yml b/.github/workflows/release-pine64_star64.yml similarity index 100% rename from .github/workflows/releases/release-pine64_star64.yml rename to .github/workflows/release-pine64_star64.yml From 2a70ee8c9b0285218bf7a65bd864c3903ba6139f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 22:44:17 +0200 Subject: [PATCH 04/15] Update pipeline variables --- .github/workflows/kanso-cd.yml | 4 ++-- .github/workflows/kanso-ci.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index 7482f88..2ca7d9a 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -10,13 +10,13 @@ jobs: uses: ./.github/workflows/kernel-build.yml secrets: inherit with: - platform: ${{ matrix.platform }} + platform: ${{ matrix.Id }} release: strategy: matrix: include: ${{ fromJSON(vars.ReleaseTargets) }} - uses: ./.github/workflows/release-${{ matrix.Id }} + uses: ./.github/workflows/release-${{ matrix.Id }}.yml secrets: inherit with: releaseTargetId: ${{ matrix.Id }} diff --git a/.github/workflows/kanso-ci.yml b/.github/workflows/kanso-ci.yml index c1465fa..8ffeef7 100644 --- a/.github/workflows/kanso-ci.yml +++ b/.github/workflows/kanso-ci.yml @@ -32,5 +32,5 @@ jobs: uses: ./.github/workflows/kernel-build.yml secrets: inherit with: - platform: ${{ matrix.Platform }} + platform: ${{ matrix.Id }} From a4b814ffe6f303e986a7eb74575927bedd695224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 22:59:11 +0200 Subject: [PATCH 05/15] Update release pipeline --- .github/workflows/release-pine64_star64.yml | 54 ++++++++------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release-pine64_star64.yml b/.github/workflows/release-pine64_star64.yml index e29d091..1c1d096 100644 --- a/.github/workflows/release-pine64_star64.yml +++ b/.github/workflows/release-pine64_star64.yml @@ -2,7 +2,7 @@ name: Kernel-Build on: workflow_call: inputs: - platform: + releaseTargetId: required: true type: string @@ -10,49 +10,35 @@ jobs: build: runs-on: ubuntu-latest env: - PLATFORM: ${{ inputs.platform }} + RELEASE_TARGET_ID: ${{ inputs.releaseTargetId }} + CROSS_COMPILE: riscv64-linux-gnu- steps: - name: Checkout sources uses: actions/checkout@v4 - - name: Install LLVM and Clang - uses: KyleMayes/install-llvm-action@v2 + - name: Download kernel.bin artifact + uses: actions/download-artifact@v4 with: - version: "20.1.3" - env: true + name: kernel-riscv64 + path: kanso_kernel - - name: Install CMake - uses: lukka/get-cmake@latest - - - name: Install QEMU + - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y qemu-system-${{ env.PLATFORM }} - curl -LO https://github.com/qemu/qemu/raw/master/pc-bios/opensbi-${{ env.PLATFORM }}-generic-fw_dynamic.bin + sudo apt-get install -y \ + build-essential \ + gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu \ + device-tree-compiler bison flex libssl-dev bc \ + u-boot-tools genimage - - name: Build Kernel - run: | - cmake --preset ${{ env.PLATFORM }} -B build/${{ env.PLATFORM }} - cmake --build build/${{ env.PLATFORM }} + - name: Clone u-boot + run: git clone https://github.com/u-boot/u-boot.git u-boot - - name: Test Kernel - run: | - set -euo pipefail + - name: Clone OpenSBI + run: git clone https://github.com/riscv-software-src/opensbi.git opensbi - ( - qemu-system-${{ env.PLATFORM }} \ - -machine virt \ - -kernel build/${{ env.PLATFORM }}/bin/kernel-test.elf \ - -serial stdio -monitor none -nographic -no-reboot - ) 2>&1 | tee qemu.log + - name: Clone StarFive utilities + run: git clone https://github.com/starfive-tech/soft_3rdpart.git starfive_utils - ! grep -q "\[ FAILED ]" qemu.log - - - name: Upload Kernel binaries - uses: actions/upload-artifact@v4 - with: - name: kernel-${{ env.PLATFORM }} - path: | - build/${{ env.PLATFORM }}/bin/kernel.elf - build/${{ env.PLATFORM }}/bin/kernel.bin + From bc5a7c83dac2dac2d84daa3a3459a0e2b4e13e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 23:11:06 +0200 Subject: [PATCH 06/15] Update matrix parameters --- .github/workflows/kanso-cd.yml | 7 ++++++- .github/workflows/kanso-ci.yml | 2 +- .github/workflows/release-pine64_star64.yml | 4 ---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index 2ca7d9a..329dbf9 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -6,7 +6,7 @@ jobs: kernel-build: strategy: matrix: - include: ${{ fromJSON(vars.Platforms) }} + Platform: [ "riscv64", "riscv32" ] uses: ./.github/workflows/kernel-build.yml secrets: inherit with: @@ -20,3 +20,8 @@ jobs: secrets: inherit with: releaseTargetId: ${{ matrix.Id }} + + release-pine64_star64: + needs: kernel-build + uses: ./.github/workflows/release-pine64_star64.yml + secrets: inherit diff --git a/.github/workflows/kanso-ci.yml b/.github/workflows/kanso-ci.yml index 8ffeef7..ed2ad9c 100644 --- a/.github/workflows/kanso-ci.yml +++ b/.github/workflows/kanso-ci.yml @@ -28,7 +28,7 @@ jobs: if: ${{ needs.filter.outputs.kernel == 'true' || needs.filter.outputs.common == 'true' }} strategy: matrix: - include: ${{ fromJSON(vars.Platforms) }} + Platform: [ "riscv64", "riscv32" ] uses: ./.github/workflows/kernel-build.yml secrets: inherit with: diff --git a/.github/workflows/release-pine64_star64.yml b/.github/workflows/release-pine64_star64.yml index 1c1d096..b62b918 100644 --- a/.github/workflows/release-pine64_star64.yml +++ b/.github/workflows/release-pine64_star64.yml @@ -1,10 +1,6 @@ name: Kernel-Build on: workflow_call: - inputs: - releaseTargetId: - required: true - type: string jobs: build: From 0798f44182ccf226bcdd758316b861b8223ec12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 23:12:23 +0200 Subject: [PATCH 07/15] Remove old entry in CD pipeline --- .github/workflows/kanso-cd.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index 329dbf9..381c80c 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -12,15 +12,6 @@ jobs: with: platform: ${{ matrix.Id }} - release: - strategy: - matrix: - include: ${{ fromJSON(vars.ReleaseTargets) }} - uses: ./.github/workflows/release-${{ matrix.Id }}.yml - secrets: inherit - with: - releaseTargetId: ${{ matrix.Id }} - release-pine64_star64: needs: kernel-build uses: ./.github/workflows/release-pine64_star64.yml From 1ef92097a9ec7a2f45932926e668e5161f040c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Fri, 6 Jun 2025 23:15:54 +0200 Subject: [PATCH 08/15] Fix wrong matrix parameter in pipeline --- .github/workflows/kanso-cd.yml | 2 +- .github/workflows/kanso-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/kanso-cd.yml b/.github/workflows/kanso-cd.yml index 381c80c..b4817c2 100644 --- a/.github/workflows/kanso-cd.yml +++ b/.github/workflows/kanso-cd.yml @@ -10,7 +10,7 @@ jobs: uses: ./.github/workflows/kernel-build.yml secrets: inherit with: - platform: ${{ matrix.Id }} + platform: ${{ matrix.Platform }} release-pine64_star64: needs: kernel-build diff --git a/.github/workflows/kanso-ci.yml b/.github/workflows/kanso-ci.yml index ed2ad9c..f7b2951 100644 --- a/.github/workflows/kanso-ci.yml +++ b/.github/workflows/kanso-ci.yml @@ -32,5 +32,5 @@ jobs: uses: ./.github/workflows/kernel-build.yml secrets: inherit with: - platform: ${{ matrix.Id }} + platform: ${{ matrix.Platform }} From ceab2f09c64f020f86cf22e58d7a0744e54dce2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sat, 7 Jun 2025 08:48:35 +0200 Subject: [PATCH 09/15] Update Pine64 Star64 release --- .github/workflows/release-pine64_star64.yml | 34 +++++++++++++++++-- .../releases/pine64_star64/genimage.cfg | 19 +++++++++++ .../pine64_star64/star64-uboot-fit-image.its | 29 ++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/releases/pine64_star64/genimage.cfg create mode 100644 .github/workflows/releases/pine64_star64/star64-uboot-fit-image.its diff --git a/.github/workflows/release-pine64_star64.yml b/.github/workflows/release-pine64_star64.yml index b62b918..ebc2203 100644 --- a/.github/workflows/release-pine64_star64.yml +++ b/.github/workflows/release-pine64_star64.yml @@ -6,7 +6,6 @@ jobs: build: runs-on: ubuntu-latest env: - RELEASE_TARGET_ID: ${{ inputs.releaseTargetId }} CROSS_COMPILE: riscv64-linux-gnu- steps: @@ -37,4 +36,35 @@ jobs: - name: Clone StarFive utilities run: git clone https://github.com/starfive-tech/soft_3rdpart.git starfive_utils - + - name: Build U-Boot SPL and DTBs + run: | + make -C u-boot starfive_visionfive2_defconfig + make -C u-boot -j$(nproc) spl/u-boot-spl.bin + make -C u-boot -j$(nproc) dtbs + + - name: Pack SPL image with StarFive spl_tool + run: | + make -C starfive_utils/spl_tool + starfive_utils/spl_tool/spl_tool -c -f u-boot/spl/u-boot-spl.bin + + - name: Build OpenSBI firmware + run: | + make -C opensbi \ + PLATFORM=generic \ + FW_PAYLOAD_PATH=kanso_kernel/kernel.bin \ + FW_FDT_PATH=u-boot/dts/upstream/src/riscv/starfive/jh7110-pine64-star64.dtb \ + FW_TEXT_START=0x40000000 + + - name: Create Star64 FIT image + run: mkimage -f .github/workflows/releases/pine64_star64/star64-uboot-fit-image.its -A riscv -O u-boot -T firmware kernel.img + + - name: Run genimage + run: genimage --config .github/workflows/releases/pine64_star64/genimage.cfg --inputpath . --tmppath temp + + - name: Upload packaged Star64 image + uses: actions/upload-artifact@v4 + with: + name: star64-image + path: | + images/** # genimage output + kernel.img # FIT firmware diff --git a/.github/workflows/releases/pine64_star64/genimage.cfg b/.github/workflows/releases/pine64_star64/genimage.cfg new file mode 100644 index 0000000..7b14921 --- /dev/null +++ b/.github/workflows/releases/pine64_star64/genimage.cfg @@ -0,0 +1,19 @@ +image kanso_pine64_star64.img { + hdimage { + gpt = true + } + + partition spl { + image = "u-boot/spl/u-boot-spl.bin.normal.out" + partition-type-uuid = 2E54B353-1271-4842-806F-E436D6AF6985 + offset = 2M + size = 2M + } + + partition uboot { + image = "kernel.img" + partition-type-uuid = 5B193300-FC78-40CD-8002-E86C45580B47 + offset = 4M + size = 4M + } +} \ No newline at end of file diff --git a/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its b/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its new file mode 100644 index 0000000..2fa372f --- /dev/null +++ b/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its @@ -0,0 +1,29 @@ +/dts-v1/; + +/ { + description = "U-boot-spl FIT image for JH7110 Pine64 Star64"; + #address-cells = <2>; + + images { + firmware { + description = "u-boot"; + data = /incbin/("../opensbi/build/platform/generic/firmware/fw_payload.bin"); + type = "firmware"; + arch = "riscv"; + os = "u-boot"; + load = <0x0 0x40000000>; + entry = <0x0 0x40000000>; + compression = "none"; + }; + }; + + configurations { + default = "config-1"; + + config-1 { + description = "U-boot-spl FIT config for JH7110 Pine64 Star64"; + firmware = "firmware"; + }; + }; +}; + From 2c3e1a30bc01e8a5f1629c9e556249f487c36d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sat, 7 Jun 2025 08:59:53 +0200 Subject: [PATCH 10/15] Update missing dependency --- .github/workflows/release-pine64_star64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-pine64_star64.yml b/.github/workflows/release-pine64_star64.yml index ebc2203..873cd1d 100644 --- a/.github/workflows/release-pine64_star64.yml +++ b/.github/workflows/release-pine64_star64.yml @@ -24,7 +24,7 @@ jobs: sudo apt-get install -y \ build-essential \ gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu \ - device-tree-compiler bison flex libssl-dev bc \ + device-tree-compiler bison flex libssl-dev bc libgnutls28-dev \ u-boot-tools genimage - name: Clone u-boot From f86475d854def76d72341e3e9472e531566ae16d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sat, 7 Jun 2025 09:09:29 +0200 Subject: [PATCH 11/15] Fix opensbi path --- .github/workflows/release-pine64_star64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-pine64_star64.yml b/.github/workflows/release-pine64_star64.yml index 873cd1d..c396320 100644 --- a/.github/workflows/release-pine64_star64.yml +++ b/.github/workflows/release-pine64_star64.yml @@ -51,8 +51,8 @@ jobs: run: | make -C opensbi \ PLATFORM=generic \ - FW_PAYLOAD_PATH=kanso_kernel/kernel.bin \ - FW_FDT_PATH=u-boot/dts/upstream/src/riscv/starfive/jh7110-pine64-star64.dtb \ + FW_PAYLOAD_PATH=../kanso_kernel/kernel.bin \ + FW_FDT_PATH=../u-boot/dts/upstream/src/riscv/starfive/jh7110-pine64-star64.dtb \ FW_TEXT_START=0x40000000 - name: Create Star64 FIT image From c8229da92e2826b26cc0bf7a7c343091639cb9c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sat, 7 Jun 2025 09:18:10 +0200 Subject: [PATCH 12/15] Fix star64 uboot fit image --- .../workflows/releases/pine64_star64/star64-uboot-fit-image.its | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its b/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its index 2fa372f..eee17b6 100644 --- a/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its +++ b/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its @@ -7,7 +7,7 @@ images { firmware { description = "u-boot"; - data = /incbin/("../opensbi/build/platform/generic/firmware/fw_payload.bin"); + data = /incbin/("opensbi/build/platform/generic/firmware/fw_payload.bin"); type = "firmware"; arch = "riscv"; os = "u-boot"; From 5b9573d35d77b6ae31c6e88bdb7c5ea6e81bd04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sat, 7 Jun 2025 09:52:02 +0200 Subject: [PATCH 13/15] Test Changing its file --- .../releases/pine64_star64/star64-uboot-fit-image.its | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its b/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its index eee17b6..1a5e1cd 100644 --- a/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its +++ b/.github/workflows/releases/pine64_star64/star64-uboot-fit-image.its @@ -7,7 +7,7 @@ images { firmware { description = "u-boot"; - data = /incbin/("opensbi/build/platform/generic/firmware/fw_payload.bin"); + data = /incbin/("../../../../opensbi/build/platform/generic/firmware/fw_payload.bin"); type = "firmware"; arch = "riscv"; os = "u-boot"; @@ -16,7 +16,6 @@ compression = "none"; }; }; - configurations { default = "config-1"; From d7aa1fc7c4bf29f75f28b494f31007ee729e2926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sat, 7 Jun 2025 10:13:02 +0200 Subject: [PATCH 14/15] Update upload bin star64 --- .github/workflows/release-pine64_star64.yml | 5 ++--- src/Kernel/KernelMain.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-pine64_star64.yml b/.github/workflows/release-pine64_star64.yml index c396320..bced922 100644 --- a/.github/workflows/release-pine64_star64.yml +++ b/.github/workflows/release-pine64_star64.yml @@ -64,7 +64,6 @@ jobs: - name: Upload packaged Star64 image uses: actions/upload-artifact@v4 with: - name: star64-image + name: kanso_pine64_star64 path: | - images/** # genimage output - kernel.img # FIT firmware + images/kanso_pine64_star64.img diff --git a/src/Kernel/KernelMain.c b/src/Kernel/KernelMain.c index 5145290..9354a4b 100644 --- a/src/Kernel/KernelMain.c +++ b/src/Kernel/KernelMain.c @@ -30,7 +30,7 @@ void KernelMain() auto platformInformation = PlatformGetInformation(); KernelConsolePrint(String("\n\n\x1b[36m%s\x1b[0m\n"), KernelLogo); - KernelConsolePrint(String("Kanso OS 1.0-DEV1 ")); + KernelConsolePrint(String("Kanso OS 1.0-DEV1 - GitHubActions ")); KernelConsolePrint(String("(%s %d-bit)\n\n"), platformInformation.Name.Pointer, platformInformation.ArchitectureBits); //CpuSetSupervisorTrapHandler(&KernelSupervisorTrapHandler); From e0df81e2354b3132071fa5a2b9839e757814572d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Decroy=C3=A8re?= Date: Sat, 7 Jun 2025 16:20:30 +0200 Subject: [PATCH 15/15] Add versioning with incremental build numbers --- CMakeLists.txt | 12 +++++++++++ cmake/generate_version_header.cmake | 33 +++++++++++++++++++++++++++++ cmake/utils.cmake | 26 +++++++++++++++++++++++ src/Common/CMakeLists.txt | 5 ++++- src/Kernel/CMakeLists.txt | 2 ++ src/Kernel/KernelMain.c | 3 ++- src/Kernel/KernelTest.c | 6 ++++++ 7 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 cmake/generate_version_header.cmake create mode 100644 cmake/utils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 272308d..2330ff3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,5 +6,17 @@ project(Kanso LANGUAGES C ASM) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +include(cmake/utils.cmake) + +set(VERSION_HEADER_PATH "${CMAKE_BINARY_DIR}/src/Common/Version.h") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/src/Common") + +add_custom_target(generate_version_header ALL + COMMAND ${CMAKE_COMMAND} -DOUT_FILE=${VERSION_HEADER_PATH} + -P "${CMAKE_SOURCE_DIR}/cmake/generate_version_header.cmake" + COMMENT "Regenerating version.h from Git tag" +) + add_subdirectory(src/Common) add_subdirectory(src/Kernel) + diff --git a/cmake/generate_version_header.cmake b/cmake/generate_version_header.cmake new file mode 100644 index 0000000..67eac38 --- /dev/null +++ b/cmake/generate_version_header.cmake @@ -0,0 +1,33 @@ +execute_process( + COMMAND git describe --tags --abbrev=0 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +if(NOT GIT_TAG) + set(GIT_TAG "0.0.0-DEV") +endif() + +string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([A-Za-z0-9]+)$" _ "${GIT_TAG}") + +set(MAJOR ${CMAKE_MATCH_1}) +set(MINOR ${CMAKE_MATCH_2}) +math(EXPR BUILD "${CMAKE_MATCH_3} + 1") +set(LABEL ${CMAKE_MATCH_4}) + +set(VERSION_FULL "${MAJOR}.${MINOR}.${BUILD}-${LABEL}") + +file(WRITE "${OUT_FILE}" " +// Auto-generated version.h from Git tag ${GIT_TAG} + +#pragma once + +#define KANSO_VERSION_MAJOR ${MAJOR} +#define KANSO_VERSION_MINOR ${MINOR} +#define KANSO_VERSION_BUILD ${BUILD} +#define KANSO_VERSION_LABEL \"${LABEL}\" +#define KANSO_VERSION_FULL \"${VERSION_FULL}\" +") + diff --git a/cmake/utils.cmake b/cmake/utils.cmake new file mode 100644 index 0000000..8d6ccc9 --- /dev/null +++ b/cmake/utils.cmake @@ -0,0 +1,26 @@ +function(get_git_version OUT_PREFIX) + execute_process( + COMMAND git describe --tags --abbrev=0 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE _GIT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + + if(NOT _GIT_TAG) + set(_GIT_TAG "0.0.0-UNKNOWN") + endif() + + string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([A-Za-z0-9]+)$" _ "${_GIT_TAG}") + + set(${OUT_PREFIX}_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) + set(${OUT_PREFIX}_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) + set(${OUT_PREFIX}_BUILD "${CMAKE_MATCH_3}" PARENT_SCOPE) + set(${OUT_PREFIX}_LABEL "${CMAKE_MATCH_4}" PARENT_SCOPE) + + set(${OUT_PREFIX}_FULL + "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}-${CMAKE_MATCH_4}" + PARENT_SCOPE + ) +endfunction() + diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 8538637..a8980f7 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -1,3 +1,6 @@ add_library(Common INTERFACE) +add_dependencies(Common generate_version_header) + +target_include_directories(Common INTERFACE .) +target_include_directories(Common INTERFACE ${CMAKE_BINARY_DIR}/src/Common) -target_include_directories(Common INTERFACE .) \ No newline at end of file diff --git a/src/Kernel/CMakeLists.txt b/src/Kernel/CMakeLists.txt index 0bb5603..953783e 100644 --- a/src/Kernel/CMakeLists.txt +++ b/src/Kernel/CMakeLists.txt @@ -1,2 +1,4 @@ # TODO: Add the correct platform add_subdirectory(Platforms/RiscV) +add_dependencies(Kernel generate_version_header) +add_dependencies(KernelTest generate_version_header) diff --git a/src/Kernel/KernelMain.c b/src/Kernel/KernelMain.c index 9354a4b..630b31b 100644 --- a/src/Kernel/KernelMain.c +++ b/src/Kernel/KernelMain.c @@ -1,6 +1,7 @@ #include "Types.h" #include "String.h" #include "Memory.h" +#include "Version.h" #include "Platform.h" #include "KernelConsole.h" #include "Kernel.h" @@ -30,7 +31,7 @@ void KernelMain() auto platformInformation = PlatformGetInformation(); KernelConsolePrint(String("\n\n\x1b[36m%s\x1b[0m\n"), KernelLogo); - KernelConsolePrint(String("Kanso OS 1.0-DEV1 - GitHubActions ")); + KernelConsolePrint(String("Kanso OS %s "), KANSO_VERSION_FULL); KernelConsolePrint(String("(%s %d-bit)\n\n"), platformInformation.Name.Pointer, platformInformation.ArchitectureBits); //CpuSetSupervisorTrapHandler(&KernelSupervisorTrapHandler); diff --git a/src/Kernel/KernelTest.c b/src/Kernel/KernelTest.c index 38a9189..07bdedd 100644 --- a/src/Kernel/KernelTest.c +++ b/src/Kernel/KernelTest.c @@ -3,6 +3,7 @@ #include "String.h" #include "KernelConsole.h" #include "Platform.h" +#include "Version.h" const char* TEST_CONSOLE_RESET = "\x1b[0m"; const char* TEST_CONSOLE_GREEN = "\x1b[32m"; @@ -44,6 +45,11 @@ void KernelTestHandler(TestRunState state, ReadOnlySpanChar message, ...) void KernelMain() { + auto platformInformation = PlatformGetInformation(); + + KernelConsolePrint(String("\n\nKanso OS Kernel Tests %s "), KANSO_VERSION_FULL); + KernelConsolePrint(String("(%s %d-bit)\n\n"), platformInformation.Name.Pointer, platformInformation.ArchitectureBits); + TestRun(KernelTestHandler); BiosReset(BiosResetType_Shutdown, BiosResetReason_None); }