diff options
author | Arthur She <arthur.she@linaro.org> | 2022-12-31 05:33:05 +0000 |
---|---|---|
committer | Arthur She <arthur.she@linaro.org> | 2023-07-10 03:57:48 +0000 |
commit | cee82d3f179260910ffb8defe7643e161ff0c496 (patch) | |
tree | e21bc30878312daa037895764ccf836adb8416bc | |
parent | e571fa5b1506dc8590c27f1ea941c559275ea1bc (diff) |
Dockerfile:
install extra packages
copy post_servod.sh
docker-compose.yaml
start the containers with docker-compose
Signed-off-by: Arthur She <arthur.she@tf-nuc-worker01.tflab>
-rw-r--r-- | src/dockerfiles/servod/Dockerfile | 9 | ||||
-rw-r--r-- | src/dockerfiles/servod/docker-compose.yaml | 91 | ||||
-rwxr-xr-x | src/dockerfiles/servod/post_servod.sh | 25 | ||||
-rwxr-xr-x | src/dockerfiles/servod/start_servod.sh | 132 |
4 files changed, 255 insertions, 2 deletions
diff --git a/src/dockerfiles/servod/Dockerfile b/src/dockerfiles/servod/Dockerfile index 50082fd..16979f3 100644 --- a/src/dockerfiles/servod/Dockerfile +++ b/src/dockerfiles/servod/Dockerfile @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -ARG RELEASE_TYPE=beta +ARG RELEASE_TYPE=latest FROM us-docker.pkg.dev/chromeos-hw-tools/servod/servod:${RELEASE_TYPE} @@ -11,7 +11,10 @@ RUN apt-get update --no-install-recommends \ bzip2 \ curl \ fdisk \ - python-is-python3 + python-is-python3 \ + vim \ + file \ + bash-completion # Avoid watchtower updating servod, it gets pulled before every start of the # container, we should not stop/start it in the case a new version is pushed. @@ -22,3 +25,5 @@ RUN apt-get autoclean \ && rm -rf /var/lib/apt/lists/* RUN ln -s /usr/bin/futility /usr/bin/gbb_utility + +COPY post_servod.sh /post_servod.sh diff --git a/src/dockerfiles/servod/docker-compose.yaml b/src/dockerfiles/servod/docker-compose.yaml new file mode 100644 index 0000000..d3cf8e0 --- /dev/null +++ b/src/dockerfiles/servod/docker-compose.yaml @@ -0,0 +1,91 @@ +version: "3.9" + +x-common: &common_settings + +services: + lazor-01: + image: servod-image + build: + context: . + dockerfile: Dockerfile + container_name: "lazor-01-servod" + hostname: "lazor-01-servod" + restart: always + privileged: true + network_mode: "host" + cap_add: + - NET_ADMIN + environment: + - PORT=9999 + - MODEL=trogdor + - BOARD=trogdor + - SERIAL=0280E045-8C643893 + - LAVA_DEVICE=lazor-01 + volumes: + - /dev:/dev + - /run/pts:/run/pts + - /var/log/servod:/var/log/servod + command: ["/bin/bash", "/post_servod.sh"] + + lazor-02: + image: servod-image + container_name: "lazor-02-servod" + hostname: "lazor-02-servod" + restart: always + privileged: true + network_mode: "host" + cap_add: + - NET_ADMIN + environment: + - PORT=9993 + - MODEL=trogdor + - BOARD=trogdor + - SERIAL=2301E022-95AC5252 + - LAVA_DEVICE=lazor-02 + volumes: + - /dev:/dev + - /run/pts:/run/pts + - /var/log/servod:/var/log/servod + command: ["/bin/bash", "/post_servod.sh"] + + asurada-02: + image: servod-image + container_name: "asurada-02-servod" + hostname: "asurada-02-servod" + restart: always + privileged: true + network_mode: "host" + cap_add: + - NET_ADMIN + environment: + - PORT=9992 + - MODEL=asurada + - BOARD=asurada + - SERIAL=18012023-94AB4762 + - LAVA_DEVICE=asurada-02 + volumes: + - /dev:/dev + - /run/pts:/run/pts + - /var/log/servod:/var/log/servod + command: ["/bin/bash", "/post_servod.sh"] + + asurada-03: + image: servod-image + container_name: "asurada-03-servod" + hostname: "asurada-03-servod" + restart: always + privileged: true + network_mode: "host" + cap_add: + - NET_ADMIN + environment: + - PORT=9995 + - MODEL=asurada + - BOARD=asurada + - SERIAL=1080801C-94A3D022 + - LAVA_DEVICE=asurada-03 + volumes: + - /dev:/dev + - /run/pts:/run/pts + - /var/log/servod:/var/log/servod + command: ["/bin/bash", "/post_servod.sh"] diff --git a/src/dockerfiles/servod/post_servod.sh b/src/dockerfiles/servod/post_servod.sh new file mode 100755 index 0000000..e05abb1 --- /dev/null +++ b/src/dockerfiles/servod/post_servod.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -x + +DUT_CONTROL="/usr/local/bin/dut-control" +PTS_DIR="/run/pts" +PORT_FLAG="--port ${PORT}" + +/start_servod.sh & + +PID=$! +sleep 10 + +if [ -n "$LAVA_DEVICE" ]; then + CPU_UART="$(${DUT_CONTROL} ${PORT_FLAG} cpu_uart_pty | awk -F':' '{print $2}')" + [ -n "${CPU_UART}" ] && ln -fs "${CPU_UART}" "${PTS_DIR}/cpu_uart-${LAVA_DEVICE}" + CR50_UART="$(${DUT_CONTROL} ${PORT_FLAG} cr50_uart_pty | awk -F':' '{print $2}')" + [ -n "${CR50_UART}" ] && ln -fs "${CR50_UART}" "${PTS_DIR}/cr50_uart-${LAVA_DEVICE}" + EC_UART="$(${DUT_CONTROL} ${PORT_FLAG} ec_uart_pty | awk -F':' '{print $2}')" + [ -n "${EC_UART}" ] && ln -fs "${EC_UART}" "${PTS_DIR}/ec_uart-${LAVA_DEVICE}" +fi + + +wait $PID +echo "servod has been terminated!!" diff --git a/src/dockerfiles/servod/start_servod.sh b/src/dockerfiles/servod/start_servod.sh new file mode 100755 index 0000000..d1fd474 --- /dev/null +++ b/src/dockerfiles/servod/start_servod.sh @@ -0,0 +1,132 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +#!/bin/bash + +set -x + +CONFIG_FILE_DIR="/var/lib/servod" +CONFIG_FILE=$CONFIG_FILE_DIR/config_$PORT +LOG="/var/log/servod_$PORT.STARTUP.log" +LOG_BACKUP_COUNT=1024 +LOG_DIR="/var/log/servod" +DUT_CONTROL="/usr/local/bin/dut-control" +PTS_DIR="/run/pts" + +# Default port to be 9999. +PORT=${PORT:-9999} +mkdir -p /var/lib/servod +. /hdctools/chromeos/servod_utils.sh + +echo "Pre-start PORT=$PORT BOARD=$BOARD MODEL=$MODEL SERIAL=$SERIAL." + +for CMD in iptables-legacy ip6tables-legacy ; do + $CMD -A INPUT -p tcp --dport $PORT -j ACCEPT || echo "Failed to configure $CMD." +done + +echo "Update config. PORT=$PORT BOARD=$BOARD MODEL=$MODEL SERIAL=$SERIAL." + +# We'll want to update the config file with all the args passed in. +update_config $CONFIG_FILE BOARD $BOARD +update_config $CONFIG_FILE MODEL $MODEL +update_config $CONFIG_FILE SERIAL $SERIAL +update_config $CONFIG_FILE CONFIG $CONFIG +update_config $CONFIG_FILE DUAL_V4 $DUAL_V4 + +echo "Store servo hub location and servo micro serial if presents. "\ + "$CONFIG_FILE $SERIAL" +cache_servov4_hub_and_servo_micro $CONFIG_FILE $SERIAL +echo "Pre-start complete." + +SERVO_MICRO_VIDPID="18d1:501a" +SERVO_V4_VIDPID="18d1:501b" + +if [ ! -f $CONFIG_FILE ]; then + echo "No configuration file ($CONFIG_FILE); terminating" + stop + exit 0 +fi + +if [ -z "$BOARD" ]; then + echo "No board specified; terminating" + stop + exit 0 +fi + +MODEL_MSG="" +MODEL_FLAG="" +if [ -n "$MODEL" ]; then + MODEL_FLAG="--model ${MODEL}" + MODEL_MSG=" model ${MODEL}" +fi + +SERIAL_FLAG="" +SERIAL_MSG="" +if [ -z "$SERIAL" ]; then + log_output "No serial specified" +else + SERIAL_FLAG="--serialname ${SERIAL}" + SERIAL_MSG="using servo serial $SERIAL" +fi + +BOARD_FLAG="--board ${BOARD}" +PORT_FLAG="--port ${PORT}" + +if [ "$DEBUG" = "1" ]; then + DEBUG_FLAG="--debug" +else + DEBUG_FLAG="" +fi + +CONFIG_FLAG="" +if [ ! -z "$CONFIG" ]; then + CONFIG_FLAG="--config ${CONFIG}" +fi + +REC_MODE_FLAG="" +if [ ! -z "$REC_MODE" ]; then + REC_MODE_FLAG="--recovery_mode" +fi + +if [ "$DUAL_V4" = "1" ]; then + DUAL_V4_FLAG="--allow-dual-v4" +else + DUAL_V4_FLAG="" +fi + +if [ -n "$SERIAL" ]; then + servodtool device -s $SERIAL reboot && sleep 5 +fi + +echo "Launching servod for $BOARD $MODEL_MSG on port $PORT $SERIAL_MSG" + +servod \ + --host 0.0.0.0 \ + --log-dir-backup-count $LOG_BACKUP_COUNT \ + --log-dir $LOG_DIR \ + --recovery_mode \ + $BOARD_FLAG \ + $MODEL_FLAG \ + $SERIAL_FLAG \ + $PORT_FLAG \ + $DEBUG_FLAG \ + $REC_MODE_FLAG \ + $CONFIG_FLAG \ + $DUAL_V4_FLAG & + +PID=$! +sleep 10 + +if [ -n "$LAVA_DEVICE" ]; then + CPU_UART="$(${DUT_CONTROL} $PORT_FLAG cpu_uart_pty | awk -F':' '{print $2}')" + [ -n "${CPU_UART}" ] && ln -fs "${CPU_UART}" "${PTS_DIR}/cpu_uart-${LAVA_DEVICE}" + CR50_UART="$(${DUT_CONTROL} $PORT_FLAG cr50_uart_pty | awk -F':' '{print $2}')" + [ -n "${CR50_UART}" ] && ln -fs "${CR50_UART}" "${PTS_DIR}/cr50_uart-${LAVA_DEVICE}" + EC_UART="$(${DUT_CONTROL} $PORT_FLAG ec_uart_pty | awk -F':' '{print $2}')" + [ -n "${EC_UART}" ] && ln -fs "${EC_UART}" "${PTS_DIR}/ec_uart-${LAVA_DEVICE}" +fi + + +wait $PID +echo "servod has been terminated!!" |