Skip to content

Commit 9b473e2

Browse files
Rework images (#1)
* Add new makefiles structure with common vars and targets. * Remove compose file only used to replace Makefile. * Change makefiles to: - make base os an arg - Change five-embeddev to fiveembeddev in image names - make source urls and tags args - Updates for upstream changes * Add some README's * Add spike + GDB and spike + openocd images. Add GTWWAve image. * Update image names. * Remove compose from examples * Update README files. * Misc fixes * Update examples * Update gdb and trace examples * Remove debug-sim (moved to common debug images) * Fixes for gnu build * Readme for examples
1 parent bb89944 commit 9b473e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+994
-736
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ _deps
1515

1616
**/build/*
1717
*.log
18-
18+
*#
19+
.#*

README.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ See <https://five-embeddev.com/> for more info.
44

55
## Dockerfiles
66

7-
Each directory in `docker/` folder includes at least `Dockerfile`,
8-
`compose.yaml` and `Makefile`. The docker `Dockerfile` will build an
7+
Each directory in `docker/` folder includes at least `Dockerfile` and `Makefile`. The docker `Dockerfile` will build an
98
image, either from source or using the OS package and tools
10-
manager. The Docker compose `compose.yaml` is used to define the image
9+
manager. The `Makefile` is used to define the image
1110
tags and run some commands or open a shell to check the build. The
1211
`Makefile` is generally for convinience, the build steps are in the
13-
`Dockerfile` and `compose.yaml` file. NOTE - `riscv-gnu-toolchain-2`
14-
relies on the `Makefile` to build the image, as the build files are stored
12+
`Dockerfile` and `targets.mak` file. NOTE - `riscv-gnu-toolchain-2`
13+
relies on the `compose.yaml` to build the image, as the build files are stored
1514
outside of docker.
1615

1716
The docker images are designed to run tools using a user account with
@@ -25,9 +24,9 @@ files can be mounted to this volume.
2524

2625
The directories in `example/` will compile or simulate some target code.
2726

28-
The `compose.yaml` files generally include the commands, the
29-
`Makefiles` are provided for convinience. These all assume the
30-
required images in `docker/` have been built.
27+
The `Makefile` files generally include the commands, the
28+
`compose.yaml` are provided for convinience if needed. These all
29+
assume the required images in `docker/` have been built.
3130

3231

3332

docker/Makefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
.PHONY: build push
3+
build push :
4+
${MAKE} -C riscv-tool-build/ $@
5+
${MAKE} -C riscv-spike/ $@
6+
${MAKE} -C riscv-spike/ -f Makefile.vcd_spike $@
7+
${MAKE} -C riscv-openocd/ $@
8+
${MAKE} -C riscv-xpack-gcc/ $@
9+
${MAKE} -C riscv-spike-debug-sim/ $@
10+
${MAKE} -C riscv-spike-debug-sim/ -f Makefile.vcd_spike $@
11+
${MAKE} -C riscv-spike-debug-gdb/ $@
12+
${MAKE} -C riscv-rust/ $@
13+
14+
.PHONY: login
15+
login :
16+
docker login \
17+
-u fiveembeddev
18+
19+

docker/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Docker for emebdded RISC-V development.
2+
3+
| Target | Description |
4+
|-----------------------|-------------|
5+
| riscv-tool-build | Base image for compiling tools|
6+
| riscv-spike | RISC-V ISA Simulator. |
7+
| riscv-openocd | OpenOCD JTAG debugger interface|
8+
| riscv-xpack-gcc | X-PACK packaged GCC |
9+
| riscv-spike-debug-sim | RISC-V Spike ISA configured to run with OpenOCD|
10+
| riscv-spike-debug-gdb | RISC-V Spike ISA configured to run with OpenOCD & GDB|
11+
| riscv-rust | Rust for RISC-V |
12+
| riscv-gnu-toolchain | Build GCC for RISC-V |
13+
| riscv-gnu-toolchain-2 | Build GCC for RISC-V (using docker compose to conserve resources) |
14+
15+
Each Docker environment is configured to run with a `docker_user` account and user `/project/` as the working directory.
16+
17+

docker/common.mak

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
DOCKER=docker
2+
DOCKER_COMPOSE=${DOCKER} compose
3+
DOCKER_USER_UID:=$(shell id -u)
4+
DOCKER_USER_GID:=$(shell id -g)
5+
6+
BASE_IMAGE=ubuntu:focal
7+
8+
DOCKER_REPO=
9+
DOCKER_USER=fiveembeddev
10+
11+
RELEASE_VERSION=0.1.0
12+
RELEASE_LABEL=env_${RELEASE_VERSION}
13+
BUILD_TAG=${DOCKER_USER}/${IMAGE_NAME}:latest
14+
RELEASE_TAG=${DOCKER_USER}/${IMAGE_NAME}:${RELEASE_LABEL}
15+
16+
DOCKER_BUILD_ARGS=\
17+
DOCKER_USER_UID=${DOCKER_USER_UID} \
18+
BASE_IMAGE=${BASE_IMAGE}
19+
20+
#NO_CACHE=--no-cache
21+
NO_CACHE=
22+
# Show cache
23+
#export DOCKER_BUILDKIT=0
24+
25+
# Versions
26+
SPIKE_TAG=v1.1.0
27+
SPIKE_URL=https://github.com/riscv-software-src/riscv-isa-sim.git
28+
GNU_TOOLCHAIN_TAG=2022.03.09
29+
GCC_TAG=riscv-gcc-10.2.0
30+
31+
# Default arch
32+
RISCV_MARCH=rv32imac
33+
RISCV_ABI=ilp32
34+
35+
OPENOCD_TAG=riscv
36+
37+
DOCKER_RUN_SHELL=/bin/bash

docker/riscv-gnu-toolchain-2/Makefile

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1+
include ../common.mak
2+
13
MOUNT_BUILD_PATH=/project/build_dir
24
MOUNT_INSTALL_PATH=/opt/riscv-gnu-toolchain
3-
TOOLCHAIN_TAG=master
4-
GCC_TAG=riscv-gcc-10.2.0
5-
RISCV_MARCH=rv32imac
6-
RISCV_ABI=ilp32
7-
DOCKER_USER_UID:=$(shell id -u)
8-
COMPOSE_RUN_BUILD_DIR=docker-compose run -w ${MOUNT_BUILD_PATH} build_env
9-
COMPOSE_RUN_SRC_DIR=docker-compose run -w ${MOUNT_BUILD_PATH}/riscv-gnu-toolchain build_env
5+
COMPOSE_RUN_BUILD_DIR=${DOCKER_COMPOSE} run -w ${MOUNT_BUILD_PATH} build_env
6+
COMPOSE_RUN_SRC_DIR=${DOCKER_COMPOSE} run -w ${MOUNT_BUILD_PATH}/riscv-gnu-toolchain build_env
107

118
all : dev_env
129

@@ -15,12 +12,13 @@ tools : docker_build/install_dir/bin/riscv32-unknown-elf-gcc
1512
docker_build/install_dir/bin/riscv32-unknown-elf-gcc :
1613
if [ ! -d docker_build/install_dir ] ; then mkdir docker_build/install_dir; fi
1714
if [ ! -d build_dir ] ; then mkdir build_dir; fi
18-
docker-compose build \
15+
${DOCKER_COMPOSE} build \
1916
--build-arg DOCKER_USER_UID=${DOCKER_USER_UID} \
2017
build_env
18+
${COMPOSE_RUN_BUILD_DIR} rm -rf riscv-gnu-toolchain
2119
${COMPOSE_RUN_BUILD_DIR} git clone \
2220
--depth 1 \
23-
--branch ${TOOLCHAIN_TAG} \
21+
--branch ${GNU_TOOLCHAIN_TAG} \
2422
https://github.com/riscv-collab/riscv-gnu-toolchain.git
2523
${COMPOSE_RUN_SRC_DIR} git submodule set-branch --branch ${GCC_TAG} riscv-gcc
2624
${COMPOSE_RUN_SRC_DIR} git submodule update \
@@ -36,7 +34,7 @@ docker_build/install_dir/bin/riscv32-unknown-elf-gcc :
3634
${COMPOSE_RUN_SRC_DIR} make
3735

3836
dev_env : docker_build/install_dir/bin/riscv32-unknown-elf-gcc
39-
docker-compose build \
37+
${DOCKER_COMPOSE} build \
4038
--build-arg DOCKER_USER_UID=${DOCKER_USER_UID} \
4139
dev_env
4240

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
# GNU Toolchain compiled from source
2+
3+
| | |
4+
|-------|-----------------------------------------|
5+
|*Image*| `fiveembeddev/riscv_gnu_toolchain_dev_env2:latest`|
6+
|*User* | `docker_user`|
7+
|*Home Dir*| `/home/docker_user`|
8+
|*Workdir*| `/project`|
9+
|*Tool Path*| `/opt/riscv-toolchain/`|
10+
11+
112
Clone the https://github.com/riscv-collab/riscv-gnu-toolchain repo and
213
build the toolchain in this folder. The build files will be copied
314
into a docker container.
415

516
NOTE - The Makefile in this directory is not for convinence, it must
617
be used to build the image.
718

8-
The final five_embeddev/riscv_gnu_toolchain_dev_env image will have
9-
the riscv32-unknown-elf- toolchain on the path.
19+
The final `fiveembeddev/riscv_gnu_toolchain_dev_env2` image will have
20+
the `riscv32-unknown-elf-` toolchain on the path.
1021

1122
NOTE - The tool build requires 5GB+ of disk space.
1223

docker/riscv-gnu-toolchain-2/compose.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
context: ../riscv-tool-build/
77
dockerfile: Dockerfile
88
target: riscv_tools_build_env
9-
image: five_embeddev/build_env
9+
image: fiveembeddev/build_env
1010
volumes:
1111
- ./build_dir:/project/build_dir
1212
- ./docker_build/install_dir:/opt/riscv-gnu-toolchain
@@ -15,14 +15,14 @@ services:
1515
build:
1616
context: docker_build/
1717
dockerfile: Dockerfile
18-
target: riscv_gnu_toolchain_dev_env
18+
target: riscv_gnu_toolchain_dev_env2
1919
args:
2020
DOCKER_USER_UID: 1000
21-
image: five_embeddev/riscv_gnu_toolchain_dev_env
21+
image: fiveembeddev/riscv_gnu_toolchain_dev_env2
2222
command: ["riscv32-unknown-elf-gcc", "--version"]
2323

2424
shell:
25-
image: five_embeddev/riscv_gnu_toolchain_dev_env
25+
image: fiveembeddev/riscv_gnu_toolchain_dev_env2
2626
stdin_open: true # docker run -i
2727
tty: true # docker run -t
2828
command: ["bash"]

docker/riscv-gnu-toolchain-2/docker_build/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ ARG DOCKER_USER_UID=1000
22

33
# ------------------------------------------------------------------------
44
# Lightwieght container with only tools, no source
5-
FROM ubuntu:focal AS riscv_gnu_toolchain_dev_env
5+
ARG BASE_IMAGE=ubuntu:focal
6+
FROM ${BASE_IMAGE} AS riscv_gnu_toolchain_dev_env2
67

78
ARG DOCKER_USER_UID
89
ARG TZ

docker/riscv-gnu-toolchain/Dockerfile

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
ARG TOOLCHAIN_TAG=master
1+
ARG GNU_TOOLCHAIN_TAG=2022.03.09
22
ARG GCC_TAG=riscv-gcc-10.2.0
33
ARG RISCV_MARCH=rv32imac
44
ARG RISCV_ABI=ilp32
55
ARG DOCKER_USER_UID=1000
6+
ARG BASE_IMAGE=ubuntu:focal
67

78
# ------------------------------------------------------------------------
8-
FROM five_embeddev/build_env:latest AS riscv_gnu_toolchain_build_config
9+
FROM fiveembeddev/build_env:latest AS riscv_gnu_toolchain_build_config
910

10-
ARG TOOLCHAIN_TAG
11+
ARG GNU_TOOLCHAIN_TAG
1112
ARG GCC_TAG
1213
ARG RISCV_MARCH
1314
ARG RISCV_ABI
@@ -16,7 +17,7 @@ RUN sudo mkdir -p /work/git && sudo chown -R docker_user /work/
1617
WORKDIR /work/git/
1718
RUN git clone \
1819
--depth 1\
19-
--branch ${TOOLCHAIN_TAG} \
20+
--branch ${GNU_TOOLCHAIN_TAG} \
2021
https://github.com/riscv-collab/riscv-gnu-toolchain.git
2122
WORKDIR /work/git/riscv-gnu-toolchain/
2223

@@ -45,7 +46,8 @@ RUN make
4546
# ------------------------------------------------------------------------
4647
# Lightwieght container with only tools, no source
4748

48-
FROM ubuntu:focal AS riscv_gnu_toolchain_dev_env
49+
ARG BASE_IMAGE
50+
FROM ${BASE_IMAGE} AS riscv_gnu_toolchain_dev_env
4951

5052
ARG DOCKER_USER_UID
5153
ARG TZ
@@ -69,7 +71,7 @@ USER docker_user
6971

7072
COPY --from=riscv_gnu_toolchain_build_config ${INSTALL_PATH} ${INSTALL_PATH}
7173

72-
ENV PATH=${INSTALL_PATH}:/bin:/usr/bin:/usr/local/bin
74+
ENV PATH=${INSTALL_PATH}/bin:/bin:/usr/bin:/usr/local/bin
7375

7476
RUN sudo mkdir /project && sudo chown docker_user /project
7577
WORKDIR /project

docker/riscv-gnu-toolchain/Makefile

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
DOCKER_USER_UID:=$(shell id -u)
1+
include ../common.mak
22

3-
riscv_gnu_toolchain : riscv_tools_build_env
4-
docker-compose build \
5-
--build-arg DOCKER_USER_UID=${DOCKER_USER_UID} \
6-
build_env
3+
IMAGE_NAME=riscv_gnu_toolchain_dev_env
74

8-
riscv_tools_build_env :
9-
${MAKE} -C ../riscv-tool-build
5+
# Override to choose spike fork
6+
RELEASE_TAG:=${RELEASE_TAG}_gcc_${GCC_TAG}
7+
8+
DOCKER_BUILD_ARGS += \
9+
GNU_TOOLCHAIN_TAG=${GNU_TOOLCHAIN_TAG} \
10+
GCC_TAG=${GCC_TAG} \
11+
RISCV_MARCH=${RISCV_MARCH} \
12+
RISCV_ABI=${RISCV_ABI}
13+
14+
all : docker-build-${IMAGE_NAME}
15+
16+
docker-build-${IMAGE_NAME} : riscv-tool-build
17+
18+
include ../targets.mak

docker/riscv-gnu-toolchain/README.md

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1+
# GNU Toolchain compiled from source
2+
3+
| | |
4+
|-------|-----------------------------------------|
5+
|*Image*| `fiveembeddev/riscv_gnu_toolchain_dev_env:latest`|
6+
|*User* | `docker_user`|
7+
|*Home Dir*| `/home/docker_user`|
8+
|*Workdir*| `/project`|
9+
|*Tool Path*| `/opt/riscv-toolchain/`|
10+
11+
112
Clone the https://github.com/riscv-collab/riscv-gnu-toolchain repo and
213
build the toolchain within Docker. A multistage docker file is used to
314
reduce the size of the final image.
415

5-
The final five_embeddev/riscv_gnu_toolchain_dev_env image will have
6-
the riscv32-unknown-elf- toolchain on the path.
16+
The final `fiveembeddev/riscv_gnu_toolchain_dev_env` image will have
17+
the `riscv32-unknown-elf-` toolchain on the path.
718

819

9-
NOTE - The tool build requires 5GB+ of disk space, and building within
20+
*NOTE*: The tool build requires 5GB+ of disk space, and building within
1021
docker requires a lot of system resources. An alternate build is in
11-
../riscv-gnu-toolchain-2/.
22+
`../riscv-gnu-toolchain-2/`.
23+
24+
```bash
25+
docker run \
26+
--tty \
27+
--interactive \
28+
--rm \
29+
-v .:/project \
30+
fiveembeddev/riscv_gnu_toolchain_dev_env:latest \
31+
riscv32-unknown-elf-gcc --version
32+
```
1233

docker/riscv-gnu-toolchain/compose.yaml

-21
This file was deleted.

0 commit comments

Comments
 (0)