Merge pull request #10574 from Jason2866/patch-2

add ESP32 filesystem download with PIO
This commit is contained in:
Theo Arends 2021-01-16 10:06:34 +01:00 committed by GitHub
commit f928a1c75a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 35 deletions

2
.gitignore vendored
View File

@ -9,6 +9,8 @@
.clang_complete
.gcc-flags.json
.cache
data
unpacked_fs
tasmota/user_config_override.h
build
build_output

View File

@ -23,6 +23,11 @@ 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
if env["PIOPLATFORM"] == "espressif32":
#print("Replace MKSPIFFSTOOL with mklittlefs")
env.Replace( MKSPIFFSTOOL=platform.get_package_dir("tool-mklittlefs") + '/mklittlefs' )
# needed for later
AutodetectUploadPort(env)
@ -41,7 +46,7 @@ class FSInfo:
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):
@ -56,7 +61,7 @@ class LittleFSInfo(FSInfo):
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):
@ -258,16 +263,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",
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:

View File

@ -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

View File

@ -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

View File

@ -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}