Skip to content

Commit 588cfdd

Browse files
klutzklutz
authored andcommitted
Pulled up common embedded recipes to public repo
0 parents  commit 588cfdd

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# For a detailed description and guide on how best to use this Docker
2+
# image, please look at the README. Note that this image is set up to
3+
# pull many of its requirements from an S3 bucket rather than the
4+
# public internet. Unless you want to build this Docker image
5+
# yourself, we'd recommend just using as-is with a docker pull.
6+
7+
# The image extends from the 13coders/cpp17-base image (always an
8+
# identified version, never latest...), which contains GCC6 and Clang
9+
# (both for amd64) and additional tooling that helps in CI builds. The
10+
# purpose of this image is to add dependencies and tools that are
11+
# common to developing for ARM Cortex-M platforms.
12+
13+
FROM 13coders/cpp17-base:1.1
14+
MAINTAINER Mike Ritchie <mike@13coders.com>
15+
LABEL description="Docker image for C++ dual-target ARM Cortex-M development"
16+
17+
# These environment variables for the AWS command line need to be
18+
# passed to the docker build command. This is preferable to persisting
19+
# credentials in the Docker image. Note that these credentials will be
20+
# visible in your (host) shell history, so clear them down. Also use
21+
# an IAM role in AWS with highly constrained privileges - potentially
22+
# read-only access to the single S3 bucket containing the
23+
# dependencies.
24+
25+
ARG AWS_ACCESS_KEY_ID
26+
ARG AWS_SECRET_ACCESS_KEY
27+
ARG AWS_DEFAULT_REGION
28+
ARG AWS_BUCKET
29+
30+
# Additional configuration has to take place using root user.
31+
32+
USER root
33+
34+
# USB utilities are essential for diagnosing issues connecting to
35+
# embedded hardware over USB from the Docker container.
36+
37+
RUN apt-get install -y usbutils
38+
39+
# We add Jenkins to the plugdev group to allow access to USB
40+
# devices. This will still require that (preferably) a device is
41+
# mapped in to the run command with --device, or (less ideal) that the
42+
# container is run as --privileged
43+
44+
RUN adduser jenkins plugdev
45+
46+
# Version of GCC ARM Embedded that we need to fetch from S3 bucket.
47+
48+
ARG v_gcc_arm=gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2
49+
50+
RUN aws s3 cp s3://${AWS_BUCKET}/${v_gcc_arm} .
51+
RUN mkdir -p /opt/tools/gcc-arm-none-eabi
52+
RUN tar xf ${v_gcc_arm} -C /opt/tools/gcc-arm-none-eabi --strip 1
53+
54+
# Bail back out to Jenkins user for setting persistent environment
55+
# variable changes
56+
57+
USER jenkins
58+
59+
# Set the path to pick up the GNU ARM embedded tools we've added.
60+
61+
ENV PATH "$PATH:/opt/tools/gcc-arm-none-eabi/bin"

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# A Docker image for Embedded C++17 CI builds
2+
3+
This Docker container extends `13coders/cpp17-base`, [located in
4+
DockerHub](https://hub.docker.com/r/13coders/cpp17-base/) with tooling
5+
for ARM Cortex-M development. Please check the base image for more
6+
detailed documentation.
7+
8+
## Features
9+
10+
The base image contains a complete set of C++ tooling for amd64
11+
development, as well as extending from the official Jenkins
12+
image. Added components in this image are:
13+
14+
| Component | Source | Version | Notes |
15+
| --- | ---| --- | --- |
16+
| [usbutils](https://packages.debian.org/stretch/usbutils) | apt-get | | Gives `lsusb` for debugging USB connection issues |
17+
| [GNU Arm Embedded](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm) | S3/binary | 7-2017-q4-major | Toolchain for Cortex-M/R development |
18+
19+
In addition, this image adds the `jenkins` user to the `plugdev` group
20+
for connection to USB hardware for deployment/flash of binaries for
21+
on-device testing or profiling - or just as a reproducible
22+
version-controlled deployment for other manual test with hardware
23+
diagnostic tools and debuggers.
24+
25+
It's expected that this image will in turn be extended for specific
26+
debug toolchains.
27+
28+
## Running the CI server
29+
30+
Please consult the `13coders/cpp17-base` documentation for a fuller
31+
description of the container launch.
32+
33+
We'll note here that it's also generally necessary to pass USB devices
34+
into the container launch for any embedded USB hardware that you need
35+
to interact with. It is strongly preferred to do this rather than run
36+
the container as `--privileged`.
37+
38+
On the host side, running the `lsusb` command would show the USB
39+
device we want to access in the container:
40+
41+
```
42+
$ lsusb
43+
...
44+
Bus 001 Device 009: ID 1366:0101 XYZ PLC JTAG/SWD Debug Probe
45+
...
46+
```
47+
48+
The bus and device are then identified to Docker when we launch the
49+
container with the `--device` argument shown below (see the base image
50+
documentation for an explanation of the other command-line arguments):
51+
52+
```
53+
$ docker run \
54+
-p 8080:8080 \
55+
-p 50000:50000 \
56+
-v /path/to/local/dir:/var/jenkins_home \
57+
--cap-add SYS_PTRACE \
58+
--device=/dev/bus/usb/001/009 \
59+
13coders/cpp17-base
60+
61+
```
62+
63+
It's worth noting also that Docker containers are immutable after
64+
launch, and although unplugging and re-inserting USB cables for
65+
embedded hardware on the host side might result in `udev` picking up
66+
the reinserted device, the container will not see it. Leave embedded
67+
test hardware plugged in throughout the container run.

0 commit comments

Comments
 (0)