-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjlinkRemoteServerEmu.dockerfile
More file actions
57 lines (48 loc) · 2.18 KB
/
jlinkRemoteServerEmu.dockerfile
File metadata and controls
57 lines (48 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
##
# Usage example:
# Build:
# docker build -t my-jlink-image -f jlinkRemoteServerEmu.dockerfile .
# Run (with USB access and custom network):
# docker network create --subnet=192.168.100.0/24 jlink-net
# docker run -d --rm --name jlink1 --network jlink-net --ip 192.168.100.10 \
# --device=/dev/bus/usb:/dev/bus/usb \
# my-jlink-image \
# -select usb=SERIAL1 -device STM32F103RE -endian little -speed 4000 -if swd
# Replace SERIAL1 with your J-Link serial number.
#
FROM ubuntu:22.04
## Install required packages and JLink dependencies
RUN apt-get update && \
apt-get install -y wget libusb-1.0-0 udev && \
rm -rf /var/lib/apt/lists/*
# Copy both JLink packages into the container (they must be present in build context)
# COPY .github/workflows/JLink_Linux_${JLINK_VERSION}_x86_64.deb /tmp/JLink_Linux_${JLINK_VERSION}_x86_64.deb
# COPY .github/workflows/JLink_Linux_${JLINK_VERSION}_arm64.deb /tmp/JLink_Linux_${JLINK_VERSION}_arm64.deb
# Workaround: replace udevadm with a stub to avoid postinst errors in Docker
RUN if [ -f /bin/udevadm ]; then mv /bin/udevadm /bin/udevadm.real; fi && \
echo '#!/bin/bash' > /bin/udevadm && \
echo 'exit 0' >> /bin/udevadm && \
chmod +x /bin/udevadm
# Install the appropriate JLink package depending on architecture (force install, then fix deps)
WORKDIR /tmp
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
wget --post-data "accept_license_agreement=accepted" \
https://www.segger.com/downloads/jlink/JLink_Linux_V794e_x86_64.deb \
-O JLink.deb && \
dpkg --force-depends -i JLink.deb && \
rm JLink.deb; \
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then \
wget --post-data "accept_license_agreement=accepted" \
https://www.segger.com/downloads/jlink/JLink_Linux_V794e_arm64.deb \
-O JLink.deb && \
dpkg --force-depends -i JLink.deb && \
rm JLink.deb; \
fi
# Restore real udevadm after J-Link installation
RUN if [ -f /bin/udevadm.real ]; then rm /bin/udevadm && mv /bin/udevadm.real /bin/udevadm; fi
# Add user (optional)
RUN useradd -ms /bin/bash jlink
USER jlink
WORKDIR /home/jlink
ENTRYPOINT ["/opt/SEGGER/JLink/JLinkRemoteServer"]