mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
Updated Compiling esp32 port with docker (markdown)
@@ -10,26 +10,31 @@ cat << "EOF" > ~/.local/bin/esp-compile
|
||||
SCRIPTPATH=$(readlink --canonicalize-existing "${BASH_SOURCE[0]}")
|
||||
|
||||
# Wrapper script to build / flash esp32 boards inside the official ESP IDF docker container
|
||||
# Usage: esp-compile <IDF_VER> <BOARD> <port to deploy>
|
||||
# Usage: esp-compile <IDF_VER> <BOARD> <port if want to deploy> <extra args if needed>
|
||||
# Examples
|
||||
# esp-compile v5.0.4 ESP32_GENERIC /dev/ttyACM0
|
||||
# esp-compile v5.2.2 ESP32_GENERIC
|
||||
# esp-compile v5.2.2 ESP32_GENERIC_C3 /dev/ttyACM0
|
||||
# esp-compile v5.2.2 ESP32_GENERIC_C3 clean
|
||||
# esp-compile v5.2.2 ESP32_GENERIC_S3 clean
|
||||
# esp-compile v5.2.2 ESP32_GENERIC_S3 /dev/ttyACM1 BOARD_VARIANT=FLASH_4M
|
||||
|
||||
|
||||
if [ ! -f /.dockerenv ]; then
|
||||
# If not running in docker container, parse arguments then re-run this same script inside a new esp idf container
|
||||
|
||||
if [ "$1" == "" ]; then echo "$0 IDF_VER BOARD <DEPLOY_PORT> <clean>"; exit; fi
|
||||
if [ "$1" == "" ]; then echo "$0 IDF_VER BOARD <DEPLOY_PORT> <extra args>"; exit; fi
|
||||
IDF_VER=$1
|
||||
BOARD=$2
|
||||
DEPLOY_PORT=$3
|
||||
CLEAN=$([ "${@: -1}" == "clean" ] && echo "1")
|
||||
if [[ $3 == /dev/* ]]; then
|
||||
DEPLOY_PORT=$3
|
||||
shift
|
||||
fi
|
||||
shift;shift
|
||||
ARGS="${@}"
|
||||
CD=$(pwd)
|
||||
|
||||
docker run -it --rm \
|
||||
-e BOARD=$BOARD -e CLEAN=$CLEAN -e DEPLOY_PORT=$DEPLOY_PORT -e UID=$(id -u) \
|
||||
-e BOARD=$BOARD -e ARGS="$ARGS" -e DEPLOY_PORT=$DEPLOY_PORT -e UID=$(id -u) \
|
||||
-v "$CD":"$CD" -v"$SCRIPTPATH":"$SCRIPTPATH" -v /sys/bus:/sys/bus -v /dev:/dev \
|
||||
--net=host --privileged -w "$CD" espressif/idf:$IDF_VER bash "$SCRIPTPATH"
|
||||
|
||||
@@ -51,28 +56,26 @@ export HOME=/tmp
|
||||
# inform git that we're in a trusted environemnt (container)
|
||||
git config --global --add safe.directory '*';
|
||||
|
||||
if [ ! -e mpy-cross/build/mpy-cross ]; then
|
||||
if [ ! -e mpy-cross/build/mpy-cross ]; then
|
||||
make -C mpy-cross
|
||||
fi
|
||||
|
||||
if [ "$CLEAN" == "1" ]; then
|
||||
make -C ports/esp32 BOARD=$BOARD clean
|
||||
|
||||
else
|
||||
# Build the firmware
|
||||
make -C ports/esp32 BOARD=$BOARD submodules
|
||||
|
||||
if [ "$DEPLOY_PORT" == "" ]; then
|
||||
# Just build the firmware
|
||||
make -C ports/esp32 BOARD=$BOARD
|
||||
echo "# make -C ports/esp32 BOARD=$BOARD $ARGS"
|
||||
make -C ports/esp32 BOARD=$BOARD $ARGS
|
||||
else
|
||||
# build and flash the firmware
|
||||
make -C ports/esp32 BOARD=$BOARD deploy PORT=$DEPLOY_PORT
|
||||
echo "# make -C ports/esp32 BOARD=$BOARD $ARGS deploy PORT=$DEPLOY_PORT"
|
||||
make -C ports/esp32 BOARD=$BOARD $ARGS deploy PORT=$DEPLOY_PORT
|
||||
fi
|
||||
|
||||
fi # end of build
|
||||
fi # end of user
|
||||
fi # end of container
|
||||
|
||||
EOF
|
||||
chmod +x ~/.local/bin/esp-compile
|
||||
```
|
||||
Reference in New Issue
Block a user