Skip to content

Commit

Permalink
Fix ESP32 support
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstoer committed Feb 16, 2020
1 parent 13ec071 commit 62b51dd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
32 changes: 26 additions & 6 deletions ESP32/before-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,43 @@ echo "Running 'before_script' for ESP32"
# select modules
# ---------------------------------------------------------------------------
# disable all modules
sed -ri 's/(CONFIG_LUA_MODULE_.*=).{0,1}/\1n/' sdkconfig
sed -ri 's/(CONFIG_LUA_MODULE_.*=).{0,1}/\1/' sdkconfig
# enable the selected ones
echo "Enabling modules $X_MODULES"
mapfile -t modules < <(echo "$X_MODULES" | tr , '\n' | tr '[:lower:]' '[:upper:]')
for m in "${modules[@]}"; do
sed -ri "s/(CONFIG_LUA_MODULE_$m=)n/\1y/" sdkconfig
sed -ri "s/(CONFIG_LUA_MODULE_$m=)/\1y/" sdkconfig
done

# ---------------------------------------------------------------------------
# set SSL/TLS
# ---------------------------------------------------------------------------
if [ "${X_SSL_ENABLED}" == "true" ]; then
echo "Enabling SSL/TLS"
sed -ri 's/(CONFIG_MBEDTLS_TLS_ENABLED=).*/\1y/' sdkconfig
echo "Enabling SSL/TLS for mbed TLS and MQTT"
sed -ri 's/(CONFIG_MBEDTLS_TLS_ENABLED=).{0,1}/\1y/' sdkconfig
sed -ri 's/(CONFIG_MQTT_TRANSPORT_SSL=).{0,1}/\1y/' sdkconfig
else
echo "Disabling SSL/TLS"
sed -ri 's/(CONFIG_MBEDTLS_TLS_ENABLED=).*/\1n/' sdkconfig
echo "Disabling SSL/TLS for mbed TLS and MQTT"
sed -ri 's/(CONFIG_MBEDTLS_TLS_ENABLED=).{0,1}/\1/' sdkconfig
sed -ri 's/(CONFIG_MQTT_TRANSPORT_SSL=).{0,1}/\1/' sdkconfig
fi

# ---------------------------------------------------------------------------
# set FatFS i.e. enable the SDMMC module in case the user forgot
# ---------------------------------------------------------------------------
if [ "${X_FATFS_ENABLED}" == "true" ]; then
echo "Enabling FatFS/SDMMC"
sed -ri "s/(CONFIG_LUA_MODULE_SDMMC=).{0,1}/\1y/" sdkconfig
fi

# ---------------------------------------------------------------------------
# set debug mode/level
# ---------------------------------------------------------------------------
if [ "${X_DEBUG_ENABLED}" == "true" ]; then
echo "Enabling debug mode"
sed -ri "s/(CONFIG_LOG_DEFAULT_LEVEL_INFO=).{0,1}/\1/" sdkconfig
sed -ri "s/(CONFIG_LOG_DEFAULT_LEVEL_DEBUG=).{0,1}/\1y/" sdkconfig
sed -ri "s/(CONFIG_LOG_DEFAULT_LEVEL=).{0,1}/\14/" sdkconfig
fi

cat sdkconfig
Expand Down
1 change: 1 addition & 0 deletions ESP32/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set -e

echo "Running 'install' for ESP32"
(
/usr/bin/python -m pip install setuptools
/usr/bin/python -m pip install --user -r "$PWD"/sdk/esp32-esp-idf/requirements.txt
)
12 changes: 4 additions & 8 deletions ESP32/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,29 @@ set -e

echo "Running 'script' for ESP32"
(
export BUILD_DIR_BASE
timestamp=$(date "+%Y-%m-%d-%H-%M-%S")
image_name="$X_BRANCH-$X_NUMBER_OF_MODULES-modules-$timestamp"

toolchain_dir=$(find tools/toolchains -name "esp32-linux-x86_64*" -type d -exec basename {} \;)
export PATH=$PWD/tools/toolchains/$toolchain_dir/bin:$PATH

mkdir bin

# ---------------------------------------------------------------------------
# run float build in ./build/float
# ---------------------------------------------------------------------------
BUILD_DIR_BASE=$(pwd)/build/float
make MORE_CFLAGS="-DBUILD_DATE='\"'$timestamp'\"'" all
# package the 3 binaries into a single .bin for 0x0000
# 0x1000 bootloader.bin
# 0x8000 partitions.bin
# 0x10000 NodeMCU.bin
# current command is a simplification of the one proposed at https://github.com/marcelstoer/docker-nodemcu-build/issues/55#issuecomment-440830227
srec_cat -output bin/nodemcu-"${image_name}"-float.bin -binary "$BUILD_DIR_BASE"/bootloader/bootloader.bin -binary -offset 0x1000 -fill 0xff 0x0000 0x8000 "$BUILD_DIR_BASE"/partitions.bin -binary -offset 0x8000 -fill 0xff 0x8000 0x10000 "$BUILD_DIR_BASE"/NodeMCU.bin -binary -offset 0x10000
srec_cat -output bin/nodemcu-"${image_name}"-float.bin -binary build/bootloader/bootloader.bin -binary -offset 0x1000 -fill 0xff 0x0000 0x8000 build/partitions.bin -binary -offset 0x8000 -fill 0xff 0x8000 0x10000 build/NodeMCU.bin -binary -offset 0x10000

make clean

# ---------------------------------------------------------------------------
# run integer build in ./build/integer
# ---------------------------------------------------------------------------
BUILD_DIR_BASE=$(pwd)/build/integer
make MORE_CFLAGS="-DLUA_NUMBER_INTEGRAL -DBUILD_DATE='\"'$timestamp'\"'" all
srec_cat -output bin/nodemcu-"${image_name}"-integer.bin -binary "$BUILD_DIR_BASE"/bootloader/bootloader.bin -binary -offset 0x1000 -fill 0xff 0x0000 0x8000 "$BUILD_DIR_BASE"/partitions.bin -binary -offset 0x8000 -fill 0xff 0x8000 0x10000 "$BUILD_DIR_BASE"/NodeMCU.bin -binary -offset 0x10000
srec_cat -output bin/nodemcu-"${image_name}"-integer.bin -binary build/bootloader/bootloader.bin -binary -offset 0x1000 -fill 0xff 0x0000 0x8000 build/partitions.bin -binary -offset 0x8000 -fill 0xff 0x8000 0x10000 build/NodeMCU.bin -binary -offset 0x10000

ls -al bin
)
2 changes: 1 addition & 1 deletion build.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[email protected]
branch=dev-esp32
modules=node,file,gpio,wifi,net,tmr,uart,mqtt,spi,http
modules=file,gpio,http,mqtt,net,node,tmr,wifi,time
ssl-enabled=true
debug-enabled=true
fatfs-enabled=true
Expand Down

0 comments on commit 62b51dd

Please sign in to comment.