Skip to content

Commit

Permalink
Bump kernel to 6.5.9 and replace BBL with OpenSBI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmikhalevich committed Nov 29, 2023
1 parent e114b82 commit 6517bd2
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
KERNEL_VERSION=${{ env.KERNEL_VERSION }}
KERNEL_TIMESTAMP=${{ env.KERNEL_TIMESTAMP }}
IMAGE_KERNEL_VERSION=${{ env.IMAGE_KERNEL_VERSION }}
RISCV_PK_VERSION=${{ env.RISCV_PK_VERSION }}
OPENSBI_VERSION=${{ env.OPENSBI_VERSION }}
cache-from: type=gha,scope=regular
cache-to: type=gha,mode=max,scope=regular
project: ${{ vars.DEPOT_PROJECT }}
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
TOOLCHAIN_VERSION=${{ env.TOOLCHAIN_VERSION }}
KERNEL_VERSION=${{ env.KERNEL_VERSION }}
IMAGE_KERNEL_VERSION=${{ env.IMAGE_KERNEL_VERSION }}
RISCV_PK_VERSION=${{ env.RISCV_PK_VERSION }}
OPENSBI_VERSION=${{ env.OPENSBI_VERSION }}
cache-from: type=gha,scope=regular
cache-to: type=gha,mode=max,scope=regular
project: ${{ vars.DEPOT_PROJECT }}
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM ${TOOLCHAIN_REPOSITORY}:${TOOLCHAIN_VERSION}

ARG KERNEL_VERSION=0.0.0-ctsi-y
ARG KERNEL_TIMESTAMP="Thu, 01 Jan 1970 00:00:00 +0000"
ARG RISCV_PK_VERSION=0.0.0-ctsi-y
ARG OPENSBI_VERSION=0.0.0-ctsi-y

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -40,17 +40,17 @@ USER developer

# copy kernel
# ------------------------------------------------------------------------------
COPY --chown=developer:developer linux-${KERNEL_VERSION}.tar.gz ${BUILD_BASE}/dep/
COPY --chown=developer:developer dep/linux-${KERNEL_VERSION}.tar.gz ${BUILD_BASE}/dep/
RUN tar xzf ${BUILD_BASE}/dep/linux-${KERNEL_VERSION}.tar.gz \
--strip-components=1 --one-top-level=${BUILD_BASE}/work/linux && \
rm ${BUILD_BASE}/dep/linux-${KERNEL_VERSION}.tar.gz

# copy riscv-pk
# copy opensbi
# ------------------------------------------------------------------------------
COPY --chown=developer:developer riscv-pk-${RISCV_PK_VERSION}.tar.gz ${BUILD_BASE}/dep/
RUN tar xzf ${BUILD_BASE}/dep/riscv-pk-${RISCV_PK_VERSION}.tar.gz \
--strip-components=1 --one-top-level=${BUILD_BASE}/work/riscv-pk && \
rm ${BUILD_BASE}/dep/riscv-pk-${RISCV_PK_VERSION}.tar.gz
COPY --chown=developer:developer dep/opensbi-${OPENSBI_VERSION}.tar.gz ${BUILD_BASE}/dep/
RUN tar xzf ${BUILD_BASE}/dep/opensbi-${OPENSBI_VERSION}.tar.gz \
--strip-components=1 --one-top-level=${BUILD_BASE}/work/opensbi && \
rm ${BUILD_BASE}/dep/opensbi-${OPENSBI_VERSION}.tar.gz

COPY cartesi-linux-config ${BUILD_BASE}/work/linux/.config

Expand Down
47 changes: 27 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ UNAME:=$(shell uname)
TAG ?= devel
TOOLCHAIN_REPOSITORY ?= cartesi/toolchain
TOOLCHAIN_TAG ?= 0.15.0
KERNEL_VERSION ?= 5.15.63-ctsi-2
KERNEL_SRCPATH := linux-$(KERNEL_VERSION).tar.gz
RISCV_PK_VERSION ?= 1.0.0-ctsi-1
RISCV_PK_SRCPATH := riscv-pk-$(RISCV_PK_VERSION).tar.gz
KERNEL_VERSION ?= linux-6.5.9-ctsi-y
KERNEL_SRCPATH := dep/linux-${KERNEL_VERSION}.tar.gz
OPENSBI_VERSION ?= opensbi-1.3.1-ctsi-y
OPENSBI_SRCPATH := dep/opensbi-${OPENSBI_VERSION}.tar.gz
KERNEL_CONFIG ?= configs/default-linux-config

CONTAINER_BASE := /opt/cartesi/kernel
Expand All @@ -44,6 +44,12 @@ else
KERNEL_TIMESTAMP ?= $(shell date -Rud @$(shell git log -1 --format=%ct 2> /dev/null || date +%s))
endif

HEADERS := linux-headers-$(KERNEL_VERSION).tar.xz
IMAGE := linux-nobl-$(KERNEL_VERSION).bin
LINUX := linux-$(KERNEL_VERSION).bin
LINUX_ELF:= linux-$(KERNEL_VERSION).elf
SELFTEST := linux-selftest-$(KERNEL_VERSION).ext2

BUILD_ARGS :=

ifneq ($(IMAGE_KERNEL_VERSION),)
Expand All @@ -66,8 +72,8 @@ ifneq ($(KERNEL_TIMESTAMP),)
BUILD_ARGS += --build-arg KERNEL_TIMESTAMP="$(KERNEL_TIMESTAMP)"
endif

ifneq ($(RISCV_PK_VERSION),)
BUILD_ARGS += --build-arg RISCV_PK_VERSION=$(RISCV_PK_VERSION)
ifneq ($(OPENSBI_VERSION),)
BUILD_ARGS += --build-arg OPENSBI_VERSION=$(OPENSBI_VERSION)
endif

.NOTPARALLEL: all
Expand Down Expand Up @@ -120,25 +126,26 @@ cartesi-linux-config:
cp $(KERNEL_CONFIG) ./cartesi-linux-config

$(KERNEL_SRCPATH):
wget -O $@ https://github.com/cartesi/linux/archive/v$(KERNEL_VERSION).tar.gz

$(RISCV_PK_SRCPATH):
wget -O $@ https://github.com/cartesi/riscv-pk/archive/v$(RISCV_PK_VERSION).tar.gz

checksum: $(KERNEL_SRCPATH) $(RISCV_PK_SRCPATH)
shasum -ca 256 shasumfile

shasumfile: $(KERNEL_SRCPATH) $(RISCV_PK_SRCPATH)
@shasum -a 256 $^ > $@

download: checksum
wget -O $@ https://github.com/cartesi/linux/archive/refs/heads/$(KERNEL_VERSION).tar.gz

clean-config:
rm -f ./cartesi-linux-config

clean: clean-config
rm -rf artifacts/
rm -f $(HEADERS) $(IMAGE) $(LINUX) $(SELFTEST)

depclean: clean
rm -f \
$(KERNEL_SRCPATH) $(RISCV_PK_SRCPATH)
$(KERNEL_SRCPATH) $(OPENSBI_SRCPATH)

checksum: $(KERNEL_SRCPATH) $(OPENSBI_SRCPATH)
shasum -ca 256 shasumfile

shasumfile: $(KERNEL_SRCPATH) $(OPENSBI_SRCPATH)
@shasum -a 256 $^ > $@

download: checksum

$(OPENSBI_SRCPATH): URL=https://github.com/cartesi/opensbi/archive/refs/heads/${OPENSBI_VERSION}.tar.gz
$(OPENSBI_SRCPATH): | dep
T=`mktemp` && wget "$(URL)" -O $$T && mv $$T $@ || rm $$T
41 changes: 16 additions & 25 deletions build.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TOOLCHAIN_PREFIX := riscv64-cartesi-linux-gnu

RISCV_PK_DIR := work/riscv-pk
RISCV_PK_BUILD_DIR := $(RISCV_PK_DIR)/build
OPENSBI_DIR := work/opensbi
OPENSBI_BUILD_DIR := $(OPENSBI_DIR)/build

LINUX_DIR := work/linux
LINUX_TEST_DIR := $(LINUX_DIR)/tools/testing/selftests
Expand Down Expand Up @@ -65,23 +65,13 @@ native-deb: # HOST == riscv64
find $(DESTDIR) -exec touch -d "$(KERNEL_TIMESTAMP)" {} \;
SOURCE_DATE_EPOCH="1" dpkg-deb -Zxz --root-owner-group --build $(DESTDIR) $(NATIVE_DEB_FILENAME)

# configure riscv-pk
# build linux w/ opensbi
# ------------------------------------------------------------------------------
$(RISCV_PK_BUILD_DIR)/Makefile: $(LINUX_DIR)/vmlinux $(LINUX_DIR)/.config
@mkdir -p $(RISCV_PK_BUILD_DIR)
cd $(RISCV_PK_BUILD_DIR) && ../configure \
--with-payload=$(abspath $<) \
--disable-fp-emulation \
--host=$(TOOLCHAIN_PREFIX)

# build linux w/ bbl
# ------------------------------------------------------------------------------
$(LINUX): $(RISCV_PK_DIR)/build/Makefile $(LINUX_DIR)/vmlinux
mkdir -p artifacts
$(MAKE) $(JOBS) -rC $(RISCV_PK_BUILD_DIR) bbl
$(TOOLCHAIN_PREFIX)-objcopy \
-O binary $(RISCV_PK_BUILD_DIR)/bbl $@
truncate -s %4096 $@
OPENSBI_OPTS=$(JOBS) FW_PAYLOAD_PATH=$(abspath $(IMAGE)) FW_PAYLOAD=y FW_OPTIONS=0x01 PLATFORM=cartesi CROSS_COMPILE=$(TOOLCHAIN_PREFIX)-
$(LINUX): $(IMAGE)
@mkdir -p artifacts
$(MAKE) -rC $(OPENSBI_DIR) $(OPENSBI_OPTS)
@cp $(OPENSBI_BUILD_DIR)/platform/cartesi/firmware/fw_payload.bin $@

# build linux tests
# ------------------------------------------------------------------------------
Expand All @@ -97,7 +87,8 @@ $(SELFTEST):

clean:
$(MAKE) -rC $(LINUX_DIR) $(LINUX_OPTS) clean
$(MAKE) $(JOBS) -rC $(RISCV_PK_BUILD_DIR) clean
$(MAKE) $(JOBS) -rC $(OPENSBI_DIR) clean
@rm -rf $(OPENSBI_BUILD_DIR)

run-selftest:
cartesi-machine.lua --rollup \
Expand All @@ -110,18 +101,18 @@ run-selftest:

# clone (for non CI environment)
# ------------------------------------------------------------------------------
clone: LINUX_BRANCH ?= linux-5.15.63-ctsi-y
clone: RISCV_PK_BRANCH ?= v1.0.0-ctsi-1
clone: LINUX_BRANCH ?= linux-6.5.9-ctsi-y
clone: OPENSBI_BRANCH ?= opensbi-1.3.1-ctsi-y
clone:
git clone --depth 1 --branch $(LINUX_BRANCH) \
[email protected]:cartesi/linux.git $(LINUX_DIR) || \
cd $(LINUX_DIR) && git pull
git clone --depth 1 --branch $(RISCV_PK_BRANCH) \
[email protected]:cartesi/riscv-pk.git $(RISCV_PK_DIR) || \
cd $(RISCV_PK_DIR) && git pull
git clone --depth 1 --branch $(OPENSBI_BRANCH) \
[email protected]:cartesi/opensbi.git $(OPENSBI_DIR) || \
cd $(OPENSBI_DIR) && git pull

run: IMG=cartesi/toolchain:devel
run:
$(MAKE) run IMG=$(IMG)

.PHONY: $(RISCV_PK_BUILD_DIR)/Makefile $(LINUX_DIR)/vmlinux $(ARTIFACTS)
.PHONY: $(OPENSBI_BUILD_DIR)/Makefile $(LINUX_DIR)/vmlinux $(ARTIFACTS)
4 changes: 2 additions & 2 deletions shasumfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
e8d4d1882632eac7fd8e433b4eb4db014fd56e645fdad3b89be7d1ca4f20ca07 linux-5.15.63-ctsi-2.tar.gz
9a873345b9914940e7bf03a167da823910c8a2acadd818b780ffbd1a3edcc4c5 riscv-pk-1.0.0-ctsi-1.tar.gz
ac235221a482701959e7a1b5dcef95c2b9bbd3c387170a11c2c43cc84a9c24c2 dep/linux-linux-6.5.9-ctsi-y.tar.gz
68388abd01e2dc2705f0dedd6525c6aa11fe3446480647310a57ef7a9ad5b5ce dep/opensbi-opensbi-1.3.1-ctsi-y.tar.gz

0 comments on commit 6517bd2

Please sign in to comment.