Skip to content

Commit 9f8bfee

Browse files
committed
Changes for ESP-IDF v4.0
- Before source'ing $IDF_PATH/export.sh, check if IDF_TOOLS_EXPORT_CMD is unset. This means it hasn't been source'd yet. - image-project assumes a particular target, config, and binary name. If image.sh exists, assume that is a more appropriate replacement and run it instead. - quick-build allows for quicker build iteration with less "safety" - --release is no longer required, forward command-line flags like in PR #12 since it works just as well for --features as --release
1 parent 64557e8 commit 9f8bfee

File tree

6 files changed

+29
-7
lines changed

6 files changed

+29
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ ENV CARGO_HOME="${PROJECT}target/cargo"
144144
VOLUME "${PROJECT}"
145145
WORKDIR "${PROJECT}"
146146

147-
COPY bindgen-project build-project create-project image-project xbuild-project flash-project /usr/local/bin/
147+
COPY bindgen-project build-project create-project image-project quick-build xbuild-project flash-project /usr/local/bin/
148148
COPY templates/ "${TEMPLATES}"
149149

150150
CMD ["/usr/local/bin/build-project"]

build-project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
[ -z "$IDF_TOOLS_EXPORT_CMD" ] && source "$IDF_PATH/export.sh"
6+
57
die() { echo "$*" 1>&2 ; exit 1 ; }
68

79
test -f Cargo.toml || die "unable to find 'Cargo.toml'. You will need to map the container path /home/project to the path of your Rust project. You can do this using: docker run -ti -v $PWD:/home/project:z rust-esp"

flash-project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
[ -z "$IDF_TOOLS_EXPORT_CMD" ] && source "$IDF_PATH/export.sh"
6+
57
"$IDF_PATH/components/esptool_py/esptool/esptool.py" \
68
--chip esp32 \
79
--port /dev/ttyUSB0 \

image-project

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
set -e
44

5-
"${IDF_PATH}/components/esptool_py/esptool/esptool.py" \
6-
--chip esp32 \
7-
elf2image \
8-
-o build/esp-app.bin \
9-
target/xtensa-esp32-none-elf/release/esp-app
5+
[ -z "$IDF_TOOLS_EXPORT_CMD" ] && source "$IDF_PATH/export.sh"
6+
7+
if [ -x ./image.sh ]
8+
then
9+
# If available, use script generated by esp_idf_build::esptool_write_script()
10+
. ./image.sh
11+
else
12+
"${IDF_PATH}/components/esptool_py/esptool/esptool.py" \
13+
--chip esp32 \
14+
elf2image \
15+
-o build/esp-app.bin \
16+
target/xtensa-esp32-none-elf/release/esp-app
17+
fi
1018

1119
echo "You can now flash 'build/esp-app.bin'"

quick-build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
[ -z "$IDF_TOOLS_EXPORT_CMD" ] && source "$IDF_PATH/export.sh"
6+
7+
xbuild-project "$@"
8+
image-project
9+
10+
echo Build complete

xbuild-project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -e
44

5-
cargo +xtensa xbuild --target "${XARGO_TARGET:-xtensa-esp32-none-elf}" --release
5+
cargo +xtensa xbuild --target "${XARGO_TARGET:-xtensa-esp32-none-elf}" "$@"

0 commit comments

Comments
 (0)