diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01f6298..116b1dd 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 }} @@ -67,7 +65,7 @@ jobs: run: make copy - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: artifacts/* @@ -97,8 +95,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/.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/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/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 0509b8c..04074a7 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,10 @@ # limitations under the License. # -.PHONY: all build download push run pull share copy clean checksum +.PHONY: all build env download copy clean distclean depclean checksum MAJOR := 0 -MINOR := 20 +MINOR := 21 PATCH := 0 LABEL := IMAGE_KERNEL_VERSION?= $(MAJOR).$(MINOR).$(PATCH)$(LABEL) @@ -25,19 +25,15 @@ IMAGE_KERNEL_VERSION?= $(MAJOR).$(MINOR).$(PATCH)$(LABEL) UNAME:=$(shell uname) TAG ?= devel -TOOLCHAIN_REPOSITORY ?= cartesi/toolchain -TOOLCHAIN_TAG ?= 0.17.0 DEP_DIR := dep -KERNEL_VERSION ?= 6.5.13-ctsi-1 +KERNEL_VERSION ?= 6.5.13-ctsi-2 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 @@ -79,34 +67,11 @@ all: build copy build: download docker build -t $(IMG) $(BUILD_ARGS) . -push: - docker push $(IMG) - -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/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 diff --git a/build.mk b/build.mk index b9f5326..3165d9d 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 @@ -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) # ------------------------------------------------------------------------------ @@ -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) diff --git a/shasumfile b/shasumfile index 461b2b0..ef92811 100644 --- a/shasumfile +++ b/shasumfile @@ -1,2 +1,2 @@ -24f3326aad2aa630c6fb2192305b70963ca67c03b0218cdcd09033cbefc9e52d dep/linux-6.5.13-ctsi-1.tar.gz +7570adeda0dd69b070ad003ec1ba01bdf7767d0bce03226030bb5fce247a83be dep/linux-6.5.13-ctsi-2.tar.gz 35082380131117aa8424d1b81ca9e6e0280baa9bffbcf3f46080a652e4cb4385 dep/opensbi-1.3.1-ctsi-2.tar.gz