From a5d3ac7e449067133ffb72320ed711f6257092c5 Mon Sep 17 00:00:00 2001 From: Diego Nehab <1635557+diegonehab@users.noreply.github.com> Date: Wed, 15 Apr 2026 21:00:14 +0100 Subject: [PATCH 1/6] feat: build kernels with UIO support --- .github/workflows/main.yml | 4 +++- Makefile | 4 ++-- shasumfile | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01f6298..886c421 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,12 +62,13 @@ jobs: cache-from: type=gha,scope=regular cache-to: type=gha,mode=max,scope=regular project: ${{ vars.DEPOT_PROJECT }} + token: ${{ secrets.DEPOT_TOKEN }} - name: Export linux.bin artifact run: make copy - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: artifacts/* @@ -106,3 +107,4 @@ jobs: cache-from: type=gha,scope=regular cache-to: type=gha,mode=max,scope=regular project: ${{ vars.DEPOT_PROJECT }} + token: ${{ secrets.DEPOT_TOKEN }} diff --git a/Makefile b/Makefile index 0509b8c..d0faf2c 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ .PHONY: all build download push run pull share copy clean checksum MAJOR := 0 -MINOR := 20 +MINOR := 21 PATCH := 0 LABEL := IMAGE_KERNEL_VERSION?= $(MAJOR).$(MINOR).$(PATCH)$(LABEL) @@ -30,7 +30,7 @@ TOOLCHAIN_TAG ?= 0.17.0 DEP_DIR := dep -KERNEL_VERSION ?= 6.5.13-ctsi-1 +KERNEL_VERSION ?= 6.5.13-ctsi-2-uio-test1 KERNEL_SRCPATH := $(DEP_DIR)/linux-${KERNEL_VERSION}.tar.gz OPENSBI_VERSION ?= 1.3.1-ctsi-2 diff --git a/shasumfile b/shasumfile index 461b2b0..3457462 100644 --- a/shasumfile +++ b/shasumfile @@ -1,2 +1,2 @@ -24f3326aad2aa630c6fb2192305b70963ca67c03b0218cdcd09033cbefc9e52d dep/linux-6.5.13-ctsi-1.tar.gz +c48702a977d74556037230c083b8416578b378d90554bae60e5ef3ade0c5799e dep/linux-6.5.13-ctsi-2-uio-test1.tar.gz 35082380131117aa8424d1b81ca9e6e0280baa9bffbcf3f46080a652e4cb4385 dep/opensbi-1.3.1-ctsi-2.tar.gz From 3d11955066c25033562579e794a294962914122d Mon Sep 17 00:00:00 2001 From: Diego Nehab <1635557+diegonehab@users.noreply.github.com> Date: Thu, 16 Apr 2026 15:00:16 +0100 Subject: [PATCH 2/6] refactor: remove image-toolchain dependency --- .github/workflows/main.yml | 4 ---- Dockerfile | 47 ++++++++++++++++++++++++++++++++++---- Makefile | 31 +------------------------ build.mk | 6 +---- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 886c421..0e00174 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,8 +53,6 @@ jobs: push: false load: true build-args: | - TOOLCHAIN_REPOSITORY=${{ env.TOOLCHAIN_REPOSITORY }} - TOOLCHAIN_VERSION=${{ env.TOOLCHAIN_VERSION }} KERNEL_VERSION=${{ env.KERNEL_VERSION }} KERNEL_TIMESTAMP=${{ env.KERNEL_TIMESTAMP }} IMAGE_KERNEL_VERSION=${{ env.IMAGE_KERNEL_VERSION }} @@ -98,8 +96,6 @@ jobs: push: true load: false build-args: | - TOOLCHAIN_REPOSITORY=${{ env.TOOLCHAIN_REPOSITORY }} - TOOLCHAIN_VERSION=${{ env.TOOLCHAIN_VERSION }} KERNEL_VERSION=${{ env.KERNEL_VERSION }} KERNEL_TIMESTAMP=${{ env.KERNEL_TIMESTAMP }} IMAGE_KERNEL_VERSION=${{ env.IMAGE_KERNEL_VERSION }} diff --git a/Dockerfile b/Dockerfile index ca50af1..a374dd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,7 @@ # limitations under the License. # -ARG TOOLCHAIN_REPOSITORY=cartesi/toolchain -ARG TOOLCHAIN_VERSION=latest -FROM ${TOOLCHAIN_REPOSITORY}:${TOOLCHAIN_VERSION} +FROM debian:trixie-20250811 ARG KERNEL_VERSION=0.0.0-ctsi-y ARG KERNEL_TIMESTAMP="Thu, 01 Jan 1970 00:00:00 +0000" @@ -24,13 +22,52 @@ ARG OPENSBI_VERSION=0.0.0-ctsi-y ENV DEBIAN_FRONTEND=noninteractive -ENV OLDPATH=$PATH - +ENV BASE=/opt/riscv ENV BUILD_BASE=$BASE/kernel +# install cross-compiler and build dependencies +# ------------------------------------------------------------------------------ +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \ + bc \ + bison \ + build-essential \ + flex \ + gcc-riscv64-linux-gnu \ + python3 \ + genext2fs \ + libc6-dev-riscv64-cross \ + rsync \ + xz-utils \ + && \ + rm -rf /var/lib/apt/lists/* + +# build and install xgenext2fs +# ------------------------------------------------------------------------------ +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \ + autoconf \ + automake \ + ca-certificates \ + libarchive-dev \ + wget \ + && \ + wget -q https://github.com/cartesi/genext2fs/archive/refs/tags/v1.5.6.tar.gz && \ + echo "34bfc26a037def23b85b676912462a3d126a87ef15c66c212b3500650da44f9e v1.5.6.tar.gz" | sha256sum -c - && \ + tar -xzf v1.5.6.tar.gz && \ + cd genext2fs-1.5.6 && \ + ./autogen.sh && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf genext2fs-1.5.6 v1.5.6.tar.gz && \ + rm -rf /var/lib/apt/lists/* + # setup dirs # ------------------------------------------------------------------------------ RUN \ + useradd developer && \ mkdir -p ${BUILD_BASE}/artifacts && \ chown -R developer:developer ${BUILD_BASE} && \ chmod go+w ${BUILD_BASE} diff --git a/Makefile b/Makefile index d0faf2c..9bb8882 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ # limitations under the License. # -.PHONY: all build download push run pull share copy clean checksum +.PHONY: all build download push pull copy clean checksum MAJOR := 0 MINOR := 21 @@ -25,8 +25,6 @@ IMAGE_KERNEL_VERSION?= $(MAJOR).$(MINOR).$(PATCH)$(LABEL) UNAME:=$(shell uname) TAG ?= devel -TOOLCHAIN_REPOSITORY ?= cartesi/toolchain -TOOLCHAIN_TAG ?= 0.17.0 DEP_DIR := dep @@ -36,8 +34,6 @@ KERNEL_SRCPATH := $(DEP_DIR)/linux-${KERNEL_VERSION}.tar.gz OPENSBI_VERSION ?= 1.3.1-ctsi-2 OPENSBI_SRCPATH := $(DEP_DIR)/opensbi-${OPENSBI_VERSION}.tar.gz -CONTAINER_BASE := /opt/cartesi/kernel - IMG ?= cartesi/linux-kernel:$(TAG) BASE:=/opt/riscv @@ -53,14 +49,6 @@ ifneq ($(IMAGE_KERNEL_VERSION),) BUILD_ARGS += --build-arg IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION) endif -ifneq ($(TOOLCHAIN_REPOSITORY),) -BUILD_ARGS += --build-arg TOOLCHAIN_REPOSITORY=$(TOOLCHAIN_REPOSITORY) -endif - -ifneq ($(TOOLCHAIN_TAG),) -BUILD_ARGS += --build-arg TOOLCHAIN_VERSION=$(TOOLCHAIN_TAG) -endif - ifneq ($(KERNEL_VERSION),) BUILD_ARGS += --build-arg KERNEL_VERSION=$(KERNEL_VERSION) endif @@ -85,28 +73,11 @@ push: pull: docker pull $(IMG) -run: - docker run --hostname toolchain-env -it --rm \ - -e USER=$$(id -u -n) \ - -e GROUP=$$(id -g -n) \ - -e UID=$$(id -u) \ - -e GID=$$(id -g) \ - -v `pwd`:$(CONTAINER_BASE) \ - -w $(CONTAINER_BASE) \ - $(IMG) $(CONTAINER_COMMAND) - -run-as-root: - docker run --hostname toolchain-env -it --rm \ - -v `pwd`:$(CONTAINER_BASE) \ - $(IMG) $(CONTAINER_COMMAND) - env: @echo KERNEL_VERSION="$(KERNEL_VERSION)" @echo KERNEL_TIMESTAMP="$(KERNEL_TIMESTAMP)" @echo IMAGE_KERNEL_VERSION="$(IMAGE_KERNEL_VERSION)" @echo OPENSBI_VERSION="$(OPENSBI_VERSION)" - @echo TOOLCHAIN_REPOSITORY="$(TOOLCHAIN_REPOSITORY)" - @echo TOOLCHAIN_VERSION="$(TOOLCHAIN_TAG)" @make -srf build.mk \ KERNEL_VERSION=$(KERNEL_VERSION) \ KERNEL_TIMESTAMP="$(KERNEL_TIMESTAMP)" \ diff --git a/build.mk b/build.mk index b9f5326..59ec73a 100644 --- a/build.mk +++ b/build.mk @@ -1,4 +1,4 @@ -TOOLCHAIN_PREFIX := riscv64-cartesi-linux-gnu +TOOLCHAIN_PREFIX := riscv64-linux-gnu OPENSBI_DIR := work/opensbi OPENSBI_BUILD_DIR := $(OPENSBI_DIR)/build @@ -114,8 +114,4 @@ clone: git@github.com:cartesi/opensbi.git $(OPENSBI_DIR) || \ cd $(OPENSBI_DIR) && git pull -run: IMG=cartesi/toolchain:devel -run: - $(MAKE) run IMG=$(IMG) - .PHONY: $(OPENSBI_BUILD_DIR)/Makefile $(LINUX_DIR)/vmlinux $(ARTIFACTS) From cba4a090bb526daf4cf298bc4d557e8250f8812f Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 3 Aug 2026 14:29:02 -0300 Subject: [PATCH 3/6] fix: adjust run-selftest to work with newer emulator --- .gitignore | 1 + build.mk | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 6178382..8a840d7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ artifacts/* dep/* *.tar.gz cartesi-linux-config +work \ No newline at end of file diff --git a/build.mk b/build.mk index 59ec73a..3165d9d 100644 --- a/build.mk +++ b/build.mk @@ -94,13 +94,13 @@ clean: @rm -rf $(OPENSBI_BUILD_DIR) run-selftest: - cartesi-machine.lua --rollup \ - --append-rom-bootargs=debug \ - --remote-address=localhost:5001 \ - --checkin-address=localhost:5002 \ + cartesi-machine.lua \ + --append-bootargs=debug \ --ram-image=`realpath $(LINUX)` \ - --flash-drive=label:selftest,filename:`realpath $(SELFTEST)` \ - -- $(CMD) + --flash-drive=label:selftest,data_filename:`realpath $(SELFTEST)` \ + --user=root \ + --workdir=/mnt/selftest \ + -- ./run_kselftest.sh # clone (for non CI environment) # ------------------------------------------------------------------------------ From c7e767b3a3f5758222c720769ca9a3eae91f28e3 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 3 Aug 2026 15:05:15 -0300 Subject: [PATCH 4/6] chore: adjust outdated information in README.md --- Makefile | 8 +------- README.md | 46 +++++++--------------------------------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index 9bb8882..ed95d3a 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ # limitations under the License. # -.PHONY: all build download push pull copy clean checksum +.PHONY: all build env download copy clean distclean depclean checksum MAJOR := 0 MINOR := 21 @@ -67,12 +67,6 @@ all: build copy build: download docker build -t $(IMG) $(BUILD_ARGS) . -push: - docker push $(IMG) - -pull: - docker pull $(IMG) - env: @echo KERNEL_VERSION="$(KERNEL_VERSION)" @echo KERNEL_TIMESTAMP="$(KERNEL_TIMESTAMP)" diff --git a/README.md b/README.md index 560ed1e..f1f6abe 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Cartesi Machine Image Linux Kernel +# Cartesi Machine Linux Image -The Cartesi Image Linux Kernel is the repository that provides the Docker configuration files to build the Linux kernel `linux.bin` image. This is used to run a Linux environment on the Cartesi Machine Emulator reference implementation. The current image is based on the `cartesi/toolchain` that uses Ubuntu 22.04. The `linux.bin` is built from the Linux 5.5.x source, targeting the RISC-V RV64IMA with ABI LP64 architecture. +The Cartesi Machine Linux Image is the repository that provides the Docker configuration files to build the Linux kernel `linux.bin` image. This is used to run a Linux environment on the Cartesi Machine Emulator reference implementation. The `linux.bin` is built from the Linux source, targeting `riscv64`. ## Getting Started ### Requirements -- Docker 18.x +- Docker >= 18.x - GNU Make >= 3.81 ### Build @@ -34,7 +34,7 @@ $ make -f build.mk ``` There is also a `run-selftest` target to run the kernel tests. -To use it, start a `remote-cartesi-machine` process from the emulator repository, then run: +To use it, run: ```bash $ make -f build.mk run-selftest @@ -44,39 +44,8 @@ $ make -f build.mk run-selftest The following options are available as `make` targets: -- **build**: builds the docker image-kernel image -- **copy**: builds the imgae-kernel image and copy it's artifact to the host -- **run**: runs the generated image with current user UID and GID -- **run-as-root**: runs the generated image as root -- **push**: pushes the image to the registry repository - -#### Makefile container options - -You can pass the following variables to the make target if you wish to use different docker image tags. - -- TAG: image-roofs image tag -- TOOLCHAIN\_TAG: toolchain image tag - -``` -$ make build TAG=mytag -$ make build TOOLCHAIN_TAG=mytag -``` - -It's also useful if you want to use pre-built images: - -``` -$ make run TAG=latest -``` - -## Usage - -The purpose of this image is to build the `linux.bin` artifact so it can be used with the emulator. For instructions on how to do that, please see the emulator documentation. - -If you want to play around on the environment you can also do: - -``` -$ make run -``` +- **build**: builds the docker linux-kernel image +- **copy**: builds the docker linux-kernel image and copy it's artifact to the host ## Contributing @@ -86,8 +55,7 @@ Please note we have a [Code of Conduct](CODE_OF_CONDUCT.md), please follow it in ## Authors -* *Diego Nehab* -* *Victor Fusco* +See [AUTHORS](AUTHORS) file. ## License From 53cd100b78aa1c186143b7ea2c58a212b2d96538 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 3 Aug 2026 15:12:54 -0300 Subject: [PATCH 5/6] chore: release 0.21.0 --- CHANGELOG.md | 11 ++++++++++- Makefile | 2 +- shasumfile | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cae452..d4da0ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.21.0] - 2026-08-03 +### Changed +- Updated Linux Kernel to v6.5.13-ctsi-2 +- Removed image-toolchain dependency + +### Added +- Enabled UIO to support NVRAM memory ranges + ## [0.20.0] - 2024-04-15 ### Changed - Updated Linux Kernel to v6.5.13-ctsi-1 @@ -113,7 +121,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [0.2.0] - [0.1.0] -[Unreleased]: https://github.com/cartesi/image-kernel/compare/v0.20.0...HEAD +[Unreleased]: https://github.com/cartesi/image-kernel/compare/v0.21.0...HEAD +[0.21.0]: https://github.com/cartesi/image-kernel/releases/tag/v0.21.0 [0.20.0]: https://github.com/cartesi/image-kernel/releases/tag/v0.20.0 [0.19.1]: https://github.com/cartesi/image-kernel/releases/tag/v0.19.1 [0.19.0]: https://github.com/cartesi/image-kernel/releases/tag/v0.19.0 diff --git a/Makefile b/Makefile index ed95d3a..04074a7 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ TAG ?= devel DEP_DIR := dep -KERNEL_VERSION ?= 6.5.13-ctsi-2-uio-test1 +KERNEL_VERSION ?= 6.5.13-ctsi-2 KERNEL_SRCPATH := $(DEP_DIR)/linux-${KERNEL_VERSION}.tar.gz OPENSBI_VERSION ?= 1.3.1-ctsi-2 diff --git a/shasumfile b/shasumfile index 3457462..ef92811 100644 --- a/shasumfile +++ b/shasumfile @@ -1,2 +1,2 @@ -c48702a977d74556037230c083b8416578b378d90554bae60e5ef3ade0c5799e dep/linux-6.5.13-ctsi-2-uio-test1.tar.gz +7570adeda0dd69b070ad003ec1ba01bdf7767d0bce03226030bb5fce247a83be dep/linux-6.5.13-ctsi-2.tar.gz 35082380131117aa8424d1b81ca9e6e0280baa9bffbcf3f46080a652e4cb4385 dep/opensbi-1.3.1-ctsi-2.tar.gz From b0875912282cd67a45f3433c4a28ca9860a67db6 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 3 Aug 2026 16:11:18 -0300 Subject: [PATCH 6/6] ci: remove DEPOT_TOKEN secret from workflows --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e00174..116b1dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,6 @@ jobs: cache-from: type=gha,scope=regular cache-to: type=gha,mode=max,scope=regular project: ${{ vars.DEPOT_PROJECT }} - token: ${{ secrets.DEPOT_TOKEN }} - name: Export linux.bin artifact run: make copy @@ -103,4 +102,3 @@ jobs: cache-from: type=gha,scope=regular cache-to: type=gha,mode=max,scope=regular project: ${{ vars.DEPOT_PROJECT }} - token: ${{ secrets.DEPOT_TOKEN }}