Code: Select all
#
# Usage: make build flash filesystem.bin flash-fs
#
CHIP := esp32
sketch := OpenWeatherMap-Display.ino
CORE :=esp32:esp32
# Flashing on an "ESP32 Dev Module" board
boardconfig :="${CORE}:${CHIP}"
ARDUINO_PATH=~/Projects/Arduino/arduino-ide_nightly-20230206_Linux_64bit/resources/app/node_modules/arduino-ide-extension/build/
ARDUINO_CLI ?= $(ARDUINO_PATH)/arduino-cli
TOOL_PATH=~/.arduino15/packages/esp32/tools/
MKSPIFFS ?= ~/.arduino15/packages/esp32/tools/mkspiffs/0.2.3/mkspiffs
MKLITTLEFS ?= ~/.arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933/mklittlefs
BC ?= bc
PARTITION_TABLE=~/.arduino15/packages/esp32/hardware/esp32/2.0.6/tools/partitions/default.csv
DEVICE :=/dev/ttyUSB1
.PHONY: build
build:
$(ARDUINO_CLI) compile --verbose --fqbn $(boardconfig) $(sketch)
.PHONY: flash
flash:
$(ARDUINO_CLI) upload --verbose -p ${DEVICE} --fqbn ${boardconfig} ${sketch}
.PHONY: filesystem.bin
.ONESHELL:
filesystem.bin:
PROPS=$$($(ARDUINO_CLI) compile --fqbn $(boardconfig) --show-properties)
BUILD_FS_BLOCKSIZE=4096
BUILD_FS_PAGESIZE=256
BUILD_FS_START_HEX=$$(cat ${PARTITION_TABLE} | grep "^spiffs"|cut -d"," -f4 | xargs)
#echo "BUILD_FS_START_HEX = $${BUILD_FS_START_HEX}"
BUILD_FS_START=`printf "%d" $${BUILD_FS_START_HEX}`
BUILD_FS_SIZE_HEX=$$(cat ${PARTITION_TABLE} | grep "^spiffs"|cut -d, -f5 | xargs)
BUILD_FS_SIZE=`printf "%d" $${BUILD_FS_SIZE_HEX}`
$(MKSPIFFS) -c data --page $$BUILD_FS_PAGESIZE --block $$BUILD_FS_BLOCKSIZE --size $$BUILD_FS_SIZE $@
#$(MKLITTLEFS) -c data --page $$BUILD_FS_PAGESIZE --block $$BUILD_FS_BLOCKSIZE --size $$BUILD_FS_SIZE $@
.PHONY: flash-fs
.ONESHELL:
flash-fs: filesystem.bin
BUILD_FS_START_HEX=$$(cat ${PARTITION_TABLE} | grep "^spiffs"|cut -d, -f4 | xargs)
python ~/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool.py --chip ${CHIP} \
--port ${DEVICE} \
--baud 460800 \
--before default_reset \
--after hard_reset \
write_flash $${BUILD_FS_START_HEX} filesystem.bin
.PHONY: clean
clean:
rm -rf build
rm -f filesystem.bin