Arduino IDE v2.0.3 missing SPIFFS upload tool

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

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby DOugL- » Mon Feb 20, 2023 4:37 pm

I've updated the Makefile and I use it now for both building and flashing the Arduino sketch and when I need to update the SPIFFS storage area. If you want a LittleFS image then change the MKSPIFFS tool to the MKLITTLEFS tool by commenting out MKSPIFFS line and uncommenting the MKLITTLEFS line:

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


Rulioht
Posts: 2
Joined: Fri Dec 16, 2022 2:32 pm

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby Rulioht » Fri Mar 10, 2023 4:17 pm

Hello, I have problem to update flash OTA

Connecting to: XXX.s3.amazonaws.com
Fetching Bin: /XXX.littlefs.bin
Got application/octet-stream payload.
Got 1507328 bytes from server
contentLength : 1507328, isValidContentType : 1
Not enough space to begin OTA

Can someone help me?

void execOTA() {
Serial.println(“Connecting to: ” + String(host));
if (ota_h_client.connect(host.c_str(), port)) {
Serial.println(“Fetching Bin: ” + String(bin2));

ota_h_client.print(String(“GET “) + bin2 + ” HTTP/1.1\r\n” +
“Host: ” + host + “\r\n” +
“Cache-Control: no-cache\r\n” +
“Connection: close\r\n\r\n”);

unsigned long timeout = millis();
while (ota_h_client.available() == 0) {
if (millis() – timeout > 5000) {
Serial.println(“Client Timeout !”);
ota_h_client.stop();
return;
}
}
while (ota_h_client.available()) {
String line = ota_h_client.readStringUntil(‘\n’);
line.trim();
if (!line.length()) {
break;
}

if (line.startsWith(“HTTP/1.1”)) {
if (line.indexOf(“200”) < 0) {
Serial.println(“Got a non 200 status code from server. Exiting OTA Update.”);
break;
}
}

if (line.startsWith(“Content-Length: “)) {
contentLength = atol((getHeaderValue(line, “Content-Length: “)).c_str());
Serial.println(“Got ” + String(contentLength) + ” bytes from server”);
}

if (line.startsWith(“Content-Type: “)) {
String contentType = getHeaderValue(line, “Content-Type: “);
Serial.println(“Got ” + contentType + ” payload.”);
if (contentType == “application/octet-stream”) {
isValidContentType = true;
}
}
}
} else {
Serial.println(“Connection to ” + String(host) + ” failed. Please check your setup”);
}

Serial.println(“contentLength : ” + String(contentLength) + “, isValidContentType : ” + String(isValidContentType));

if (contentLength && isValidContentType) {
bool canBegin = Update.begin(contentLength);

if (canBegin) {
Serial.println(“Begin OTA. This may take 2 – 5 mins to complete. Things might be quite for a while.. Patience!”);
size_t written = Update.writeStream(ota_h_client);

if (written == contentLength) {
Serial.println(“Written : ” + String(written) + ” successfully”);
} else {
Serial.println(“Written only : ” + String(written) + “/” + String(contentLength) + “. Retry?” );
}

if (Update.end()) {
Serial.println(“OTA done!”);
if (Update.isFinished()) {
Serial.println(“Update successfully completed. Rebooting.”);
ESP.restart();
} else {
Serial.println(“Update not finished? Something went wrong!”);
}
} else {
Serial.println(“Error Occurred. Error #: ” + String(Update.getError()));
}
} else {
Serial.println(“Not enough space to begin OTA”);
ota_h_client.flush();
}
} else {
Serial.println(“There was no content in the response”);
ota_h_client.flush();
}
}
Attachments
erro.jpg
erro.jpg (47.54 KiB) Viewed 3628 times

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

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby DOugL- » Mon Mar 13, 2023 1:49 am

@Rulioht, that has nothing to do with SPIFFS support in the Arduino v2 IDE.
Please notice the subject title of this forum thread "Re: Arduino IDE v2.0.3 missing SPIFFS upload tool"

You should create your own thread with a subject related to your problem.

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

Re: Arduino IDE v2.0.3 missing SPIFFS upload tool

Postby DOugL- » Fri Apr 14, 2023 4:32 am

I've figured some things out and have a better working Makefile which now lets you select/set your filesystem partitioning type and it will also so the littleFS filesystem too. Have at it and let me know what you think. Just fix up the sketch name and a few paths.

Code: Select all

#
# Usage: make build | flash | filesystem.bin | flash-fs
#
CHIP        := esp32
sketch      := YOUR_SKETCH_HERE.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/
ESP32_PATH=~/.arduino15/packages/esp32/hardware/esp32/2.0.7/
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

# Partition table configuration options:
# default default_ffat ffat huge_app large_spiffs_16MB max_app_8MB 
# minimal min_spiffs noota_3g
# app3M_fat9M_16MB bare_minimum_2MB default_16MB default_8MB
# noota_3gffat no_ota noota_ffat
# rainmaker
PARTITIONTYPE := default
#PARTITIONTYPE := min_spiffs
PARTITIONSIZE := "${PARTITIONTYPE}.csv"
PARTITIONMAX := `cat $(ESP32_PATH)/tools/partitions/${PARTITIONSIZE}  | grep app0 | cut -f5 -d',' | xargs printf "%d" | cut -f1 -d'('`
PARTITION_TABLE=$(ESP32_PATH)/tools/partitions/${PARTITIONSIZE}

partitioncmd := --build-property build.partitions=${PARTITIONTYPE} --build-property upload.maximum_size=${PARTITIONMAX}


DEVICE :=/dev/ttyUSB0
#DEVICE :=/dev/ttyACM0

.PHONY: build
build:
	$(ARDUINO_CLI) compile --verbose --fqbn $(boardconfig) $(sketch) $(partitioncmd)

.PHONY: flash
flash:
	$(ARDUINO_CLI) upload --verbose -p ${DEVICE} --fqbn ${boardconfig} ${sketch} $(partitioncmd)

.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

Who is online

Users browsing this forum: No registered users and 143 guests