From 6a2016f56834ee21189a3a72343a621c8f98de6b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 15 Jan 2021 15:09:49 +0100 Subject: [PATCH 1/6] Remove redundant entrys --- platformio_override_sample.ini | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index d82b7f45d..e46754e7a 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -116,33 +116,21 @@ build_flags = ${esp82xx_defaults.build_flags} -DWAVEFORM_LOCKED_PWM -Wno-switch-unreachable - [common32] -platform = ${core32.platform} platform_packages = ${core32.platform_packages} build_unflags = ${core32.build_unflags} build_flags = ${core32.build_flags} -board = esp32dev -board_build.ldscript = esp32_out.ld -board_build.partitions = esp32_partition_app1984k_spiffs64k.csv -board_build.flash_mode = ${common.board_build.flash_mode} -board_build.f_flash = ${common.board_build.f_flash} -board_build.f_cpu = ${common.board_build.f_cpu} -monitor_speed = ${common.monitor_speed} -upload_port = ${common.upload_port} -upload_resetmethod = ${common.upload_resetmethod} -upload_speed = 921600 -extra_scripts = ${common.extra_scripts} +upload_port = COM4 lib_extra_dirs = ${library.lib_extra_dirs} ; *** ESP32 lib. ALWAYS needed for ESP32 !!! lib/libesp32 + [core32] ; Activate Stage Core32 by removing ";" in next 3 lines, if you want to override the standard core32 ;platform_packages = ${core32_stage.platform_packages} ;build_unflags = ${core32_stage.build_unflags} ;build_flags = ${core32_stage.build_flags} - [core32_stage] platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/arduino-esp32/releases/download/1.0.5-rc6/esp32-1.0.5-rc6.zip platformio/tool-mklittlefs @ ~1.203.200522 From 7fc0c42e0490ead2ec22bc4fc42c54d5dcaadb41 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 15 Jan 2021 15:15:04 +0100 Subject: [PATCH 2/6] change from string to list and hack for using littlefs for ESP32 instead of SPIFFS --- pio-tools/download_fs.py | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/pio-tools/download_fs.py b/pio-tools/download_fs.py index ed6426cc7..f43bec128 100644 --- a/pio-tools/download_fs.py +++ b/pio-tools/download_fs.py @@ -1,14 +1,14 @@ # Written by Maximilian Gerhardt # 29th December 2020 # License: Apache -# Expanded from functionality provided by PlatformIO's espressif32 and espressif8266 platforms, credited below. -# This script provides functions to download the filesystem (SPIFFS or LittleFS) from a running ESP32 / ESP8266 +# Expanded from functionality provided by PlatformIO's espressif32 and espressif8266 platforms, credited below. +# This script provides functions to download the filesystem (SPIFFS or LittleFS) from a running ESP32 / ESP8266 # over the serial bootloader using esptool.py, and mklittlefs / mkspiffs for extracting. -# run by either using the VSCode task "Custom" -> "Download Filesystem" -# or by doing 'pio run -t downloadfs' (with optional '-e ') from the commandline. +# run by either using the VSCode task "Custom" -> "Download Filesystem" +# or by doing 'pio run -t downloadfs' (with optional '-e ') from the commandline. # output will be saved, by default, in the "unpacked_fs" of the project. -# this folder can be changed by writing 'custom_unpack_dir = some_other_dir' in the corresponding platformio.ini -# environment. +# this folder can be changed by writing 'custom_unpack_dir = some_other_dir' in the corresponding platformio.ini +# environment. import re import sys from os.path import isfile, join @@ -23,25 +23,29 @@ Import("env") platform = env.PioPlatform() board = env.BoardConfig() mcu = board.get("build.mcu", "esp32") +# Hack for using mklittlefs instead of mkspiffs -> needed since littlefs is not supported with this for ESP32 +#print("Replace MKSPIFFSTOOL with mklittlefs") +env.Replace( MKSPIFFSTOOL=platform.get_package_dir("tool-mklittlefs") + '/mklittlefs' ) + # needed for later AutodetectUploadPort(env) -class FSType(Enum): +class FSType(Enum): SPIFFS="spiffs" LITTLEFS="littlefs" - FATFS="fatfs" + FATFS="fatfs" class FSInfo: - def __init__(self, fs_type, start, length, page_size, block_size): + def __init__(self, fs_type, start, length, page_size, block_size): self.fs_type = fs_type - self.start = start + self.start = start self.length = length self.page_size = page_size self.block_size = block_size def __repr__(self): return f"FS type {self.fs_type} Start {hex(self.start)} Len {self.length} Page size {self.page_size} Block size {self.block_size}" # extract command supposed to be implemented by subclasses - def get_extract_cmd(self): + def get_extract_cmd(self, input_file, output_dir): raise NotImplementedError() class LittleFSInfo(FSInfo): @@ -53,10 +57,10 @@ class LittleFSInfo(FSInfo): self.tool = env["MKFSTOOL"] # from mkspiffs package self.tool = join(platform.get_package_dir("tool-mklittlefs"), self.tool) super().__init__(FSType.LITTLEFS, start, length, page_size, block_size) - def __repr__(self): + def __repr__(self): return f"FS type {self.fs_type} Start {hex(self.start)} Len {self.length} Page size {self.page_size} Block size {self.block_size} Tool: {self.tool}" def get_extract_cmd(self, input_file, output_dir): - return f'"{self.tool}" -b {self.block_size} -p {self.page_size} --unpack "{output_dir}" "{input_file}"' + return [self.tool, "-b", str(self.block_size), "-p", str(self.page_size), "--unpack", output_dir, input_file] class SPIFFSInfo(FSInfo): @@ -68,7 +72,7 @@ class SPIFFSInfo(FSInfo): self.tool = env["MKFSTOOL"] # from mkspiffs package self.tool = join(platform.get_package_dir("tool-mkspiffs"), self.tool) super().__init__(FSType.SPIFFS, start, length, page_size, block_size) - def __repr__(self): + def __repr__(self): return f"FS type {self.fs_type} Start {hex(self.start)} Len {self.length} Page size {self.page_size} Block size {self.block_size} Tool: {self.tool}" def get_extract_cmd(self, input_file, output_dir): return f'"{self.tool}" -b {self.block_size} -p {self.page_size} --unpack "{output_dir}" "{input_file}"' @@ -258,16 +262,16 @@ def download_fs(fs_info: FSInfo): fs_file = join(env["PROJECT_DIR"], f"downloaded_fs_{hex(fs_info.start)}_{hex(fs_info.length)}.bin") esptoolpy_flags = [ "--chip", mcu, - "--port", '"' + env.subst("$UPLOAD_PORT") + '"', + "--port", env.subst("$UPLOAD_PORT"), "--baud", env.subst("$UPLOAD_SPEED"), "--before", "default_reset", "--after", "hard_reset", - "read_flash", + "read_flash", hex(fs_info.start), hex(fs_info.length), - '"' + fs_file + '"' + fs_file ] - esptoolpy_cmd = '"' + env["PYTHONEXE"]+ '"' + ' "' + esptoolpy + '" ' + " ".join(esptoolpy_flags) + esptoolpy_cmd = [env["PYTHONEXE"], esptoolpy] + esptoolpy_flags print("Executing flash download command.") print(esptoolpy_cmd) try: @@ -302,7 +306,7 @@ def unpack_fs(fs_info: FSInfo, downloaded_file: str): return (False, "") def display_fs(extracted_dir): - # extract command already nicely lists all extracted files. + # extract command already nicely lists all extracted files. # no need to display that ourselves. just display a summary file_count = sum([len(files) for r, d, files in os.walk(extracted_dir)]) print("Extracted " + str(file_count) + " file(s) from filesystem.") @@ -326,4 +330,4 @@ env.AddCustomTarget( ], title="Download Filesystem", description="Downloads and displays files stored in the target ESP32/ESP8266" -) \ No newline at end of file +) From a16306fbf6c7b61d7be8ac5b27040c22c1f0fd96 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 15 Jan 2021 15:16:41 +0100 Subject: [PATCH 3/6] add custom_unpack_dir --- platformio_tasmota32.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini index 79c56eb96..a41222bb4 100644 --- a/platformio_tasmota32.ini +++ b/platformio_tasmota32.ini @@ -48,6 +48,7 @@ build_unflags = ${core32.build_unflags} build_flags = ${core32.build_flags} board = esp32dev board_build.filesystem = ${common.board_build.filesystem} +custom_unpack_dir = ${common.custom_unpack_dir} board_build.ldscript = esp32_out.ld board_build.partitions = esp32_partition_app1984k_spiffs64k.csv board_build.flash_mode = ${common.board_build.flash_mode} From 129af59a9db58dc9b57506d62cd786262ed912df Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 15 Jan 2021 15:19:01 +0100 Subject: [PATCH 4/6] change unpack_dir --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index a95530335..12ccfcc90 100644 --- a/platformio.ini +++ b/platformio.ini @@ -67,7 +67,7 @@ default_envs = ${build_envs.default_envs} framework = arduino board = esp01_1m board_build.filesystem = littlefs -custom_unpack_dir = unpacked_esp8266_littlefs +custom_unpack_dir = unpacked_littlefs board_build.flash_mode = dout board_build.ldscript = eagle.flash.1m.ld From c74cce1c4e9d3c8b1866dfe7342e2fdb7392dfe9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 15 Jan 2021 15:20:39 +0100 Subject: [PATCH 5/6] add filesystems directorys --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 96c63651b..503ccf780 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ .clang_complete .gcc-flags.json .cache +data +unpacked_fs tasmota/user_config_override.h build build_output From af798b40e20cee018dfa857670d3d46adbc180b6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 15 Jan 2021 20:59:56 +0100 Subject: [PATCH 6/6] fix compile ESP8266 --- pio-tools/download_fs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pio-tools/download_fs.py b/pio-tools/download_fs.py index f43bec128..4343adee3 100644 --- a/pio-tools/download_fs.py +++ b/pio-tools/download_fs.py @@ -24,8 +24,9 @@ platform = env.PioPlatform() board = env.BoardConfig() mcu = board.get("build.mcu", "esp32") # Hack for using mklittlefs instead of mkspiffs -> needed since littlefs is not supported with this for ESP32 -#print("Replace MKSPIFFSTOOL with mklittlefs") -env.Replace( MKSPIFFSTOOL=platform.get_package_dir("tool-mklittlefs") + '/mklittlefs' ) +if env["PIOPLATFORM"] == "espressif32": + #print("Replace MKSPIFFSTOOL with mklittlefs") + env.Replace( MKSPIFFSTOOL=platform.get_package_dir("tool-mklittlefs") + '/mklittlefs' ) # needed for later AutodetectUploadPort(env)