Skip to content

Commit dd8243d

Browse files
authored
Merge pull request #5 from Ar-Ray-code/add_docker
add dev-tool
2 parents f0f9ccc + e3675e8 commit dd8243d

File tree

6 files changed

+122
-0
lines changed

6 files changed

+122
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ build/
22
sdkconfig
33
*.old
44
*.lock
5+
.env

dev_tool/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# mros2-esp32 dev-tool
2+
3+
Building mros2-esp32 tool using docker.
4+
5+
6+
7+
8+
## Requirements
9+
10+
- USB accessable docker-compose environment
11+
12+
13+
14+
## Usage
15+
16+
M5Stack CoreS3
17+
18+
```bash
19+
bash build_example.bash /dev/ttyACM0 ../../mros2-esp32 ../workspace/echoback_string esp32s3
20+
```
21+
22+
23+
### Arguments
24+
25+
- 1: Serial port (default: `/dev/ttyUSB0`)
26+
- 2: Path to mros2-esp32 (default: `../../mros2-esp32`)
27+
- 3: Path to workspace (default: `../workspace/echoback_string`)
28+
- 4: Target board (esp32, esp32s2, esp32s3...) (default: `esp32`)

dev_tool/build_example.bash

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
SCRIPT_DIR=$(cd $(dirname $0); pwd)
3+
PORT=${1:-/dev/ttyUSB0}
4+
MROS2_DIR=${2:-${SCRIPT_DIR}/../../mros2-esp32}
5+
WORKSPACE=${3:-${SCRIPT_DIR}/../workspace/echoback_string}
6+
TARGET=${4:-esp32}
7+
8+
echo "====================="
9+
echo "PORT: ${PORT}"
10+
echo "MROS2_DIR: ${MROS2_DIR}"
11+
echo "WORKSPACE: ${WORKSPACE}"
12+
echo "TARGET: ${TARGET}"
13+
echo "====================="
14+
15+
rm -rf ${SCRIPT_DIR}/.env
16+
echo "PORT=${PORT}" > ${SCRIPT_DIR}/.env
17+
echo "MROS2_DIR=${MROS2_DIR}" >> ${SCRIPT_DIR}/.env
18+
echo "WORKSPACE=${WORKSPACE}" >> ${SCRIPT_DIR}/.env
19+
echo "TARGET=${TARGET}" >> ${SCRIPT_DIR}/.env
20+
21+
cd ${SCRIPT_DIR}
22+
23+
if [ ! -d ${MROS2_DIR} ]; then
24+
echo "mros2-esp32 directory not found."
25+
fi
26+
27+
docker-compose up --build mros2_esp32

dev_tool/docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "3"
2+
services:
3+
mros2_esp32:
4+
build:
5+
context: ./docker
6+
dockerfile: esp_idf.dockerfile
7+
container_name: esp_idf
8+
volumes:
9+
- ${MROS2_DIR}:/mros2-esp32
10+
- ${WORKSPACE}:/mros2-esp32/workspace/target
11+
devices:
12+
- ${PORT}:${PORT}
13+
environment:
14+
- PORT=${PORT}
15+
- TARGET=${TARGET}
16+
command: ["/tmp/build_mros2.bash"]
17+
env_file:
18+
- .env

dev_tool/docker/build_mros2.bash

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
SCRIPT_DIR=/mros2-esp32/workspace/target/
3+
4+
. /esp/esp-idf/export.sh
5+
6+
cd ${SCRIPT_DIR}
7+
rm -rf ${SCRIPT_DIR}/build/
8+
9+
idf.py set-target ${TARGET}
10+
if [ $? -ne 0 ]; then
11+
echo "Failed to set target"
12+
exit 1
13+
fi
14+
15+
sed -i 's/CONFIG_LWIP_IPV6=y/CONFIG_LWIP_IPV6=n/g' ${SCRIPT_DIR}/sdkconfig
16+
17+
idf.py build
18+
idf.py -p ${PORT} flash
19+
if [ $? -ne 0 ]; then
20+
echo "Failed to flash"
21+
exit 1
22+
fi

dev_tool/docker/esp_idf.dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ubuntu:22.04
2+
3+
ENV TZ=Asia/Tokyo
4+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
RUN apt update && apt install locales && \
8+
locale-gen en_US en_US.UTF-8 && \
9+
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
10+
apt -y clean && \
11+
rm -rf /var/lib/apt/lists/*
12+
ENV LANG=en_US.UTF-8
13+
14+
RUN apt-get update && \
15+
apt-get install -y \
16+
git wget flex bison gperf python3 python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
17+
18+
RUN mkdir -p /esp
19+
RUN cd /esp && git clone --recursive https://github.com/espressif/esp-idf.git -b v5.2-dev && \
20+
cd /esp/esp-idf && \
21+
./install.sh all
22+
23+
RUN /bin/bash -c "source /esp/esp-idf/export.sh && \
24+
pip3 install jinja2"
25+
26+
COPY ./build_mros2.bash /tmp/build_mros2.bash

0 commit comments

Comments
 (0)