Arduino IDE v2.0.3 missing SPIFFS upload tool
Posted: Sun Dec 18, 2022 6:16 pm
I'm trying out in-circuit debugging and hoping to get it working with the Arduino IDE v2 since I've been able to get that working with the Arduino Zero(SAMD) and STM32/Bluepill(using ST-Link) and ran into the issue of the v2 IDE not having external tools plugin capabilities yet. As a work around, I started using commandline tools mkspiffs and arduino-cli when someone made a Makefile to help so I'm sharing my Makefile in hopes it's useful to others and maybe someone can help fix it so it works better. I could not get the makefile to runs some of the scripts and set variables so I had to pull that data from running them on bash and hard-coded them for the esp-wrover-32 board.
Code: Select all
#
# Usage: make filesystem.bin flash-fs
# ToDo:
# 1) figure out why build doesn't compile like the IDE does and instead causes reboot loop
# 2) fix makefile so hardcoded vars like BUILD_SPIFFS_START_HEX, BUILD_SPIFFS_SIZE_HEX and BUILD_SPIFFS_SIZE get computed
sketch := Websockets-esp32Dev.ino
CORE :=esp32:esp32
# Flashing on an "ESP32 Dev Module" board
boardconfig :="${CORE}:esp32"
TOOL_PATH=~/.arduino15/packages/esp32/tools/mkspiffs/0.2.3
ARDUINO_CLI ?= arduino-cli
MKSPIFFS ?= $(TOOL_PATH)/mkspiffs
BC ?= bc
PARTITION_TABLE=~/.arduino15/packages/esp32/hardware/esp32/2.0.5/tools/partitions/default.csv
DEVICE :=/dev/ttyUSB0
.PHONY: build
build:
$(ARDUINO_CLI) compile --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_SPIFFS_BLOCKSIZE=4096
BUILD_SPIFFS_PAGESIZE=256
BUILD_SPIFFS_START_HEX=$$(cat ${PARTITION_TABLE} | grep "^spiffs"|cut -d"," -f4 | xargs)
BUILD_SPIFFS_START_HEX=`cat $(PARTITION_TABLE)`
BUILD_SPIFFS_START_HEX="0x290000"
BUILD_SPIFFS_START=$$(echo "ibase=16;$${BUILD_SPIFFS_START_HEX:2}"|bc -q)
BUILD_SPIFFS_START=0
echo "BUILD_SPIFFS_START $$BUILD_SPIFFS_START_HEX ($$BUILD_SPIFFS_START)"
BUILD_SPIFFS_SIZE_HEX=$$(cat ${PARTITION_TABLE} | grep "^spiffs"|cut -d, -f5 | xargs)
BUILD_SPIFFS_SIZE_HEX="0x170000"
BUILD_SPIFFS_SIZE=$$(echo "ibase=16;$${BUILD_SPIFFS_SIZE_HEX:2}"|bc -q)
BUILD_SPIFFS_SIZE=1507328
echo "BUILD_SPIFFS_SIZE $$BUILD_SPIFFS_SIZE_HEX ($$BUILD_SPIFFS_SIZE)"
# echo 'DJL-$(MKSPIFFS) -c data --page ${BUILD_SPIFFS_PAGESIZE} --block ${BUILD_SPIFFS_BLOCKSIZE} --size ${BUILD_SPIFFS_SIZE} $@'
$(MKSPIFFS) -c data --page $$BUILD_SPIFFS_PAGESIZE --block $$BUILD_SPIFFS_BLOCKSIZE --size $$BUILD_SPIFFS_SIZE $@
.PHONY: flash-fs
.ONESHELL:
flash-fs: filesystem.bin
BUILD_SPIFFS_START_HEX=$$(cat ${PARTITION_TABLE} | grep "^spiffs"|cut -d, -f4 | xargs)
python ~/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool.py --chip esp32 \
--port ${DEVICE} \
--baud 460800 \
--before default_reset \
--after hard_reset \
write_flash $${BUILD_SPIFFS_START_HEX} filesystem.bin
.PHONY: clean
clean:
rm -rf build
rm -f filesystem.bin