Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EXPOSE 2222

# Install all needed packages
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates git wget build-essential ninja-build libglib2.0-dev libpixman-1-dev u-boot-qemu unzip libslirp-dev && \
apt-get install -y --no-install-recommends ca-certificates git wget build-essential ninja-build libglib2.0-dev libpixman-1-dev u-boot-qemu unzip libslirp-dev python3-venv && \
# clean up the temp files
apt-get autoremove -y && \
apt-get clean && \
Expand All @@ -18,9 +18,16 @@ mkdir /root/qemu/build && cd /root/qemu/build && \
# clean up the git repo and build artifacts after installed
rm /root/qemu -r

#Add QEMU CPU and Memory params as env variables to allow a bit more customisation
ARG QM_RAM
ENV QM_RAM=2G

ARG QM_CPU
ENV QM_CPU=2

# Get RISC-V Debian image
WORKDIR "/root"
RUN wget https://gitlab.com/api/v4/projects/giomasce%2Fdqib/jobs/artifacts/master/download?job=convert_riscv64-virt -O artifacts.zip && \
unzip artifacts.zip && rm artifacts.zip

CMD qemu-system-riscv64 -smp 2 -m 2G -cpu rv64 -nographic -machine virt -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf -device virtio-blk-device,drive=hd -drive file=dqib_riscv64-virt/image.qcow2,if=none,id=hd -device virtio-net-device,netdev=net -netdev user,id=net,hostfwd=tcp::2222-:22 -object rng-random,filename=/dev/urandom,id=rng -device virtio-rng-device,rng=rng -append "root=LABEL=rootfs console=ttyS0"
CMD qemu-system-riscv64 -smp ${QM_CPU} -m ${QM_RAM} -cpu rv64 -nographic -machine virt -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf -device virtio-blk-device,drive=hd -drive file=dqib_riscv64-virt/image.qcow2,if=none,id=hd -device virtio-net-device,netdev=net -netdev user,id=net,hostfwd=tcp::2222-:22 -object rng-random,filename=/dev/urandom,id=rng -device virtio-rng-device,rng=rng -append "root=LABEL=rootfs console=ttyS0"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ ssh root@localhost -p 2222

```bash
# 2. Alternative: Allocate more CPU / RAM to QEMU guest
# Start the container, and manually start QEMU with the required specs.
# replace AAAA with desired cpus (e.g. 2 or 4)
# replace BBBB with desired RAM (e.g. 2G or 4G)
docker run -d --publish 127.0.0.1:2222:2222/tcp davidburela/riscv-emulator qemu-system-riscv64 -smp AAAA -m BBBB -cpu rv64 -nographic -machine virt -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf -device virtio-blk-device,drive=hd -drive file=dqib_riscv64-virt/image.qcow2,if=none,id=hd -device virtio-net-device,netdev=net -netdev user,id=net,hostfwd=tcp::2222-:22 -object rng-random,filename=/dev/urandom,id=rng -device virtio-rng-device,rng=rng -append "root=LABEL=rootfs console=ttyS0"
# Amount of memory and CPU count are available as docker variables.
# QM_CPU=X where X is the number of CPUs to be added.
# QM_RAM=Y where Y is the amount of memory, i.e. 4G means 4 gigabytes of RAM.
docker run -d --publish 127.0.0.1:2222:2222/tcp -e QM_CPU=4 -e QM_RAM=4G davidburela/riscv-emulator
```

### Podman
Expand Down