From eb36e7f26a18be89d50ee046af015be59e1bd181 Mon Sep 17 00:00:00 2001 From: Vivian Yu Date: Mon, 1 Sep 2025 21:31:41 +0800 Subject: [PATCH 1/3] Bump Alpine Linux in Docker final stage Commit 37c9838 ("Bump Alpine Linux for Docker image") updated only the build stage but left the final stage unchanged. This commit completes the version bump by upgrading the final stage as well. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 48ee4bea..69275020 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ COPY . . RUN make RUN make tool -FROM alpine:3.19 AS final +FROM alpine:3.21 AS final # copy in elf files COPY ./build/*.elf /home/root/rv32emu/build/ From 0f860ce119b0d2bd0a00cdc44b9354227b87feaf Mon Sep 17 00:00:00 2001 From: Vivian Yu Date: Mon, 1 Sep 2025 21:34:42 +0800 Subject: [PATCH 2/3] Enhance Docker image with rv32emu-user, -system, and -histogram binaries Include three executables in the Docker image: - rv32emu-user: for user-mode emulation - rv32emu-system: for system-mode emulation - rv32emu-histogram: for statistical analysis This enhancement enables the Docker image to support both user-mode and system-mode emulation. Close #581 --- Dockerfile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 69275020..f686a634 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,18 @@ FROM alpine:3.21 AS base_gcc -RUN apk add --update alpine-sdk git wget sdl2-dev sdl2_mixer-dev +RUN apk add --update alpine-sdk git wget sdl2-dev sdl2_mixer-dev dtc # copy in the source code WORKDIR /home/root/rv32emu COPY . . -# generate execution file for rv32emu and rv_histogram -RUN make -RUN make tool +# build and rename executables: rv32emu-user, rv32emu-system, and rv32emu-histogram +RUN make -j"$(nproc)" +RUN make tool -j"$(nproc)" +RUN mv ./build/rv32emu ./build/rv32emu-user +RUN mv ./build/rv_histogram ./build/rv32emu-histogram +RUN make distclean +RUN make ENABLE_SYSTEM=1 INITRD_SIZE=32 -j"$(nproc)" FROM alpine:3.21 AS final @@ -18,8 +22,9 @@ COPY ./build/*.elf /home/root/rv32emu/build/ # get rv32emu and rv_histogram binaries and lib of SDL2 and SDL2_mixer COPY --from=base_gcc /usr/include/SDL2/ /usr/include/SDL2/ COPY --from=base_gcc /usr/lib/libSDL2* /usr/lib/ -COPY --from=base_gcc /home/root/rv32emu/build/rv32emu /home/root/rv32emu/build/rv32emu -COPY --from=base_gcc /home/root/rv32emu/build/rv_histogram /home/root/rv32emu/build/rv_histogram +COPY --from=base_gcc /home/root/rv32emu/build/rv32emu-user /home/root/rv32emu/build/rv32emu-user +COPY --from=base_gcc /home/root/rv32emu/build/rv32emu /home/root/rv32emu/build/rv32emu-system +COPY --from=base_gcc /home/root/rv32emu/build/rv32emu-histogram /home/root/rv32emu/build/rv32emu-histogram ENV PATH=/home/root/rv32emu/build:$PATH From e5e97c87955668b6f3673112d6b801fc33f1de1e Mon Sep 17 00:00:00 2001 From: Vivian Yu Date: Mon, 1 Sep 2025 21:39:43 +0800 Subject: [PATCH 3/3] Update README for Docker image artifacts Document how to fetch and run user-mode and system-mode artifacts from the rv32emu-prebuilt repository when using the Docker image. Link: https://github.com/sysprog21/rv32emu-prebuilt --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 3efc805d..b8414b1c 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,40 @@ The usage and limitations of Doom and Quake demo are listed in [docs/demo.md](do ### Docker image The image containing all the necessary tools for development and testing can be executed by `docker run -it sysprog21/rv32emu:latest`. It works for both x86-64 and aarch64 (e.g., Apple's M1 chip) machines. +To keep the Docker image minimal, executables and prebuilt images are not embedded. Follow the steps below to fetch the required artifacts. + +##### User-Mode +Fetch and extract the latest prebuilt user-mode ELF artifacts: +```shell +$ wget $(wget -qO- 'https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases?per_page=100' \ + | grep browser_download_url | grep ELF | head -n 1 | cut -d '"' -f4) + +$ tar -xzvf rv32emu-prebuilt.tar.gz +``` +To run `rv32emu-user`, consider the following examples: +```shell +# Run a local ELF program +build/rv32emu-user build/hello.elf + +# Run a prebuilt user-mode program (e.g., pi) +build/rv32emu-user rv32emu-prebuilt/riscv32/pi +``` + +##### System-Mode +Fetch and extract the latest prebuilt system-mode Linux image artifacts: +```shell +$ wget $(wget -qO- 'https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases?per_page=100' \ + | grep browser_download_url | grep Linux-Image | head -n 1 | cut -d '"' -f4) + +$ tar -xzvf rv32emu-linux-image-prebuilt.tar.gz +``` +To run `rv32emu-system`, use the following: +```shell +$ build/rv32emu-system \ + -k rv32emu-linux-image-prebuilt/linux-image/Image \ + -i rv32emu-linux-image-prebuilt/linux-image/rootfs.cpio +``` + ### Customization `rv32emu` is configurable, and you can override the below variable(s) to fit your expectations: * `ENABLE_RV32E`: RV32E Base Integer Instruction Set