Arduino IDE v2.0.3 missing SPIFFS upload tool

DOugL-
Posts: 21
Joined: Sun Dec 18, 2022 6:00 pm

Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby DOugL- » 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

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby bidrohini » Mon Dec 19, 2022 10:30 am

I have almost zero knowledge about makefiles. Could you please suggest from where I can start learning about generating makefiles? Thank you.

DOugL-
Posts: 21
Joined: Sun Dec 18, 2022 6:00 pm

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby DOugL- » Mon Dec 19, 2022 7:50 pm

bidrohini wrote:
Mon Dec 19, 2022 10:30 am
I have almost zero knowledge about makefiles. Could you please suggest from where I can start learning about generating makefiles? Thank you.
I found this: https://opensource.com/article/18/8/what-how-makefile

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby bidrohini » Sat Dec 24, 2022 5:19 pm

Thank you so much.

Acuario
Posts: 7
Joined: Mon Apr 04, 2016 11:21 am

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby Acuario » Sun Dec 25, 2022 5:26 am

..just one point, SPIFFS has been deprecated, you should use LittleFS instead.

DOugL-
Posts: 21
Joined: Sun Dec 18, 2022 6:00 pm

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby DOugL- » Mon Dec 26, 2022 9:57 pm

Acuario wrote:
Sun Dec 25, 2022 5:26 am
..just one point, SPIFFS has been deprecated, you should use LittleFS instead.
Thanks, I will have to look at this and see what changes need to be made to do the same with LittleFS instead of SPIFFS.

gottit
Posts: 4
Joined: Thu Jan 26, 2023 10:07 am

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby gottit » Thu Jan 26, 2023 10:12 am

Acuario wrote:
Sun Dec 25, 2022 5:26 am
..just one point, SPIFFS has been deprecated, you should use LittleFS instead.
Has it really been deprecated? On the esp-idf API reference there is no mention of LittleFS anymore, only SPIFFS

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby lbernstone » Thu Jan 26, 2023 7:32 pm

I don't think SPIFFS is deprecated, just discouraged. It has serious flaws which can result in data loss or failure to perform. These issues are inherent to the pseudo-indexed file system, so littlefs is a much better choice.

gottit
Posts: 4
Joined: Thu Jan 26, 2023 10:07 am

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby gottit » Fri Jan 27, 2023 9:55 am

lbernstone wrote:
Thu Jan 26, 2023 7:32 pm
I don't think SPIFFS is deprecated, just discouraged. It has serious flaws which can result in data loss or failure to perform. These issues are inherent to the pseudo-indexed file system, so littlefs is a much better choice.
I was talking about LittleFS, not SPIFFS. If i rembmer correctly there was a mention of LittleFS in the Storage API pages but now LittleFS has been moved to an external component (not shipped with the IDF).

ESP_Minatel
Posts: 364
Joined: Mon Jan 04, 2021 2:06 pm

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby ESP_Minatel » Fri Jan 27, 2023 5:21 pm


Who is online

Users browsing this forum: No registered users and 53 guests