Skip to content

Commit 4adcb3d

Browse files
committed
Enhance docker image
This commit updates the Docker image to include the following executables: - rv32emu-user: for user-mode emulation - rv32emu-system: for system-mode emulation - rv_histogram: for statistical analysis To keep the image compact, build artifacts are excluded from the final image. Instructions for retrieving prebuilt binaries are added to the README. Close #581
1 parent d0f0394 commit 4adcb3d

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM alpine:3.21 AS base_gcc
22

3-
RUN apk add --update alpine-sdk git wget sdl2-dev sdl2_mixer-dev
3+
RUN apk add --update alpine-sdk git wget sdl2-dev sdl2_mixer-dev dtc
44

55
# copy in the source code
66
WORKDIR /home/root/rv32emu
@@ -9,17 +9,22 @@ COPY . .
99
# generate execution file for rv32emu and rv_histogram
1010
RUN make
1111
RUN make tool
12+
RUN mv ./build/rv32emu ./build/rv32emu-user
13+
RUN mv ./build/rv_histogram ./build/tmp_rv_histogram
14+
RUN make distclean
15+
RUN make ENABLE_SYSTEM=1 INITRD_SIZE=32
1216

13-
FROM alpine:3.19 AS final
17+
FROM alpine:3.21 AS final
1418

1519
# copy in elf files
1620
COPY ./build/*.elf /home/root/rv32emu/build/
1721

1822
# get rv32emu and rv_histogram binaries and lib of SDL2 and SDL2_mixer
1923
COPY --from=base_gcc /usr/include/SDL2/ /usr/include/SDL2/
2024
COPY --from=base_gcc /usr/lib/libSDL2* /usr/lib/
21-
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu /home/root/rv32emu/build/rv32emu
22-
COPY --from=base_gcc /home/root/rv32emu/build/rv_histogram /home/root/rv32emu/build/rv_histogram
25+
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu-user /home/root/rv32emu/build/rv32emu-user
26+
COPY --from=base_gcc /home/root/rv32emu/build/rv32emu /home/root/rv32emu/build/rv32emu-system
27+
COPY --from=base_gcc /home/root/rv32emu/build/tmp_rv_histogram /home/root/rv32emu/build/rv_histogram
2328

2429
ENV PATH=/home/root/rv32emu/build:$PATH
2530

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,40 @@ The usage and limitations of Doom and Quake demo are listed in [docs/demo.md](do
143143
### Docker image
144144
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.
145145
146+
To keep the Docker image minimal, executables and prebuilt images are not embedded. Follow the steps below to fetch the required artifacts.
147+
148+
##### User-Mode
149+
Fetch and extract the latest prebuilt user-mode ELF artifacts:
150+
```shell
151+
$ wget $(wget -qO- 'https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases?per_page=100' \
152+
| grep browser_download_url | grep ELF | head -n 1 | cut -d '"' -f4)
153+
154+
$ tar -xzvf rv32emu-prebuilt.tar.gz
155+
```
156+
To run `rv32emu-user`, consider the following examples:
157+
```shell
158+
# Run a local ELF program
159+
build/rv32emu-user build/hello.elf
160+
161+
# Run a prebuilt user-mode program (e.g., pi)
162+
build/rv32emu-user rv32emu-prebuilt/riscv32/pi
163+
```
164+
165+
##### System-Mode
166+
Fetch and extract the latest prebuilt system-mode Linux image artifacts:
167+
```shell
168+
$ wget $(wget -qO- 'https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases?per_page=100' \
169+
| grep browser_download_url | grep Linux-Image | head -n 1 | cut -d '"' -f4)
170+
171+
$ tar -xzvf rv32emu-linux-image-prebuilt.tar.gz
172+
```
173+
To run `rv32emu-system`, use the following:
174+
```shell
175+
$ build/rv32emu-system \
176+
-k rv32emu-linux-image-prebuilt/linux-image/Image \
177+
-i rv32emu-linux-image-prebuilt/linux-image/rootfs.cpio
178+
```
179+
146180
### Customization
147181
`rv32emu` is configurable, and you can override the below variable(s) to fit your expectations:
148182
* `ENABLE_RV32E`: RV32E Base Integer Instruction Set

0 commit comments

Comments
 (0)