Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions .github/workflows/kanso-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ jobs:
kernel-build:
strategy:
matrix:
include: ${{ fromJSON(vars.Platforms) }}
Platform: [ "riscv64", "riscv32" ]
uses: ./.github/workflows/kernel-build.yml
secrets: inherit
with:
platform: ${{ matrix.platform }}
platform: ${{ matrix.Platform }}

release-pine64_star64:
needs: kernel-build
uses: ./.github/workflows/release-pine64_star64.yml
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/kanso-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ 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:
platform: ${{ matrix.platform }}
platform: ${{ matrix.Platform }}

69 changes: 69 additions & 0 deletions .github/workflows/release-pine64_star64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Kernel-Build
on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
env:
CROSS_COMPILE: riscv64-linux-gnu-

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Download kernel.bin artifact
uses: actions/download-artifact@v4
with:
name: kernel-riscv64
path: kanso_kernel

- name: Install build dependencies
run: |
sudo apt-get update
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 libgnutls28-dev \
u-boot-tools genimage

- name: Clone u-boot
run: git clone https://github.com/u-boot/u-boot.git u-boot

- name: Clone OpenSBI
run: git clone https://github.com/riscv-software-src/opensbi.git opensbi

- 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: kanso_pine64_star64
path: |
images/kanso_pine64_star64.img
19 changes: 19 additions & 0 deletions .github/workflows/releases/pine64_star64/genimage.cfg
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/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";
};
};
};

12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

33 changes: 33 additions & 0 deletions cmake/generate_version_header.cmake
Original file line number Diff line number Diff line change
@@ -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}\"
")

26 changes: 26 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
@@ -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()

5 changes: 4 additions & 1 deletion src/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 .)
2 changes: 2 additions & 0 deletions src/Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions src/Kernel/KernelMain.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -29,9 +30,8 @@ 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("Kanso OS %s "), KANSO_VERSION_FULL);
KernelConsolePrint(String("(%s %d-bit)\n\n"), platformInformation.Name.Pointer, platformInformation.ArchitectureBits);

//CpuSetSupervisorTrapHandler(&KernelSupervisorTrapHandler);
Expand Down
6 changes: 6 additions & 0 deletions src/Kernel/KernelTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down