Skip to content

add dev-tool #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build/
sdkconfig
*.old
*.lock
.env
28 changes: 28 additions & 0 deletions dev_tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# mros2-esp32 dev-tool

Building mros2-esp32 tool using docker.




## Requirements

- USB accessable docker-compose environment



## Usage

M5Stack CoreS3

```bash
bash build_example.bash /dev/ttyACM0 ../../mros2-esp32 ../workspace/echoback_string esp32s3
```


### Arguments

- 1: Serial port (default: `/dev/ttyUSB0`)
- 2: Path to mros2-esp32 (default: `../../mros2-esp32`)
- 3: Path to workspace (default: `../workspace/echoback_string`)
- 4: Target board (esp32, esp32s2, esp32s3...) (default: `esp32`)
27 changes: 27 additions & 0 deletions dev_tool/build_example.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
SCRIPT_DIR=$(cd $(dirname $0); pwd)
PORT=${1:-/dev/ttyUSB0}
MROS2_DIR=${2:-${SCRIPT_DIR}/../../mros2-esp32}
WORKSPACE=${3:-${SCRIPT_DIR}/../workspace/echoback_string}
TARGET=${4:-esp32}

echo "====================="
echo "PORT: ${PORT}"
echo "MROS2_DIR: ${MROS2_DIR}"
echo "WORKSPACE: ${WORKSPACE}"
echo "TARGET: ${TARGET}"
echo "====================="

rm -rf ${SCRIPT_DIR}/.env
echo "PORT=${PORT}" > ${SCRIPT_DIR}/.env
echo "MROS2_DIR=${MROS2_DIR}" >> ${SCRIPT_DIR}/.env
echo "WORKSPACE=${WORKSPACE}" >> ${SCRIPT_DIR}/.env
echo "TARGET=${TARGET}" >> ${SCRIPT_DIR}/.env

cd ${SCRIPT_DIR}

if [ ! -d ${MROS2_DIR} ]; then
echo "mros2-esp32 directory not found."
fi

docker-compose up --build mros2_esp32
18 changes: 18 additions & 0 deletions dev_tool/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3"
services:
mros2_esp32:
build:
context: ./docker
dockerfile: esp_idf.dockerfile
container_name: esp_idf
volumes:
- ${MROS2_DIR}:/mros2-esp32
- ${WORKSPACE}:/mros2-esp32/workspace/target
devices:
- ${PORT}:${PORT}
environment:
- PORT=${PORT}
- TARGET=${TARGET}
command: ["/tmp/build_mros2.bash"]
env_file:
- .env
22 changes: 22 additions & 0 deletions dev_tool/docker/build_mros2.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
SCRIPT_DIR=/mros2-esp32/workspace/target/

. /esp/esp-idf/export.sh

cd ${SCRIPT_DIR}
rm -rf ${SCRIPT_DIR}/build/

idf.py set-target ${TARGET}
if [ $? -ne 0 ]; then
echo "Failed to set target"
exit 1
fi

sed -i 's/CONFIG_LWIP_IPV6=y/CONFIG_LWIP_IPV6=n/g' ${SCRIPT_DIR}/sdkconfig

idf.py build
idf.py -p ${PORT} flash
if [ $? -ne 0 ]; then
echo "Failed to flash"
exit 1
fi
26 changes: 26 additions & 0 deletions dev_tool/docker/esp_idf.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:22.04

ENV TZ=Asia/Tokyo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install locales && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
apt -y clean && \
rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8

RUN apt-get update && \
apt-get install -y \
git wget flex bison gperf python3 python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0

RUN mkdir -p /esp
RUN cd /esp && git clone --recursive https://github.com/espressif/esp-idf.git -b v5.2-dev && \
cd /esp/esp-idf && \
./install.sh all

RUN /bin/bash -c "source /esp/esp-idf/export.sh && \
pip3 install jinja2"

COPY ./build_mros2.bash /tmp/build_mros2.bash