diff --git a/Makefile_patched.patch b/Makefile_patched.patch deleted file mode 100644 index 072463d..0000000 --- a/Makefile_patched.patch +++ /dev/null @@ -1,65 +0,0 @@ -diff --git a/flasher_stub/Makefile b/flasher_stub/Makefile -index 4e4f4d9..c794e29 100644 ---- a/flasher_stub/Makefile -+++ b/flasher_stub/Makefile -@@ -72,7 +72,7 @@ STUB_ELF_32H2 = $(BUILD_DIR)/$(STUB)_32h2.elf - - .PHONY: all clean embed - --all: $(STUB_ELF_8266) $(STUB_ELF_32) $(STUB_ELF_32S2) $(STUB_ELF_32S3_BETA_2) $(STUB_ELF_32S3) $(STUB_ELF_32C3) $(STUB_ELF_32C6BETA) $(STUB_ELF_32H2_BETA_1) $(STUB_ELF_32H2_BETA_2) $(STUB_ELF_32C2) $(STUB_ELF_32C6) $(STUB_ELF_32H2) -+all: $(STUB_ELF_32) $(STUB_ELF_32S2) $(STUB_ELF_32S3_BETA_2) $(STUB_ELF_32S3) $(STUB_ELF_32C3) $(STUB_ELF_32C6BETA) $(STUB_ELF_32H2_BETA_1) $(STUB_ELF_32H2_BETA_2) $(STUB_ELF_32C2) $(STUB_ELF_32C6) $(STUB_ELF_32H2) - @echo " WRAP $^ -> $(BUILD_DIR)" - $(Q) $(WRAP_STUB) $^ - -@@ -88,17 +88,14 @@ CFLAGS_ESPRISCV32 = -std=c99 -Wall -Werror -Os \ - -Wl,-static -g -ffunction-sections -Wl,--gc-sections -Iinclude -Lld - LDLIBS = -lgcc - --$(STUB_ELF_8266): $(SRCS) $(SRCS_8266) $(BUILD_DIR) ld/stub_8266.ld | Makefile -- @echo " CC(8266) $^ -> $@" -- $(Q) $(CROSS_8266)gcc $(CFLAGS) -DESP8266=1 -Tstub_8266.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) - - $(STUB_ELF_32): $(SRCS) $(BUILD_DIR) ld/stub_32.ld | Makefile - @echo " CC(32) $^ -> $@" -- $(Q) $(CROSS_32)gcc $(CFLAGS) -DESP32=1 -Tstub_32.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) -+ cp ../../target/xtensa-esp32-none-elf/release/flasher-stub build/stub_flasher_32.elf - - $(STUB_ELF_32S2): $(SRCS) $(BUILD_DIR) ld/stub_32s2.ld - @echo " CC(32S2) $^ -> $@" -- $(Q) $(CROSS_32S2)gcc $(CFLAGS) -DESP32S2=1 -Tstub_32s2.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) -+ cp ../../target/xtensa-esp32s2-none-elf/release/flasher-stub build/stub_flasher_32s2.elf - - $(STUB_ELF_32S3_BETA_2): $(SRCS) $(BUILD_DIR) ld/stub_32s3_beta_2.ld - @echo " CC(32S3) $^ -> $@" -@@ -106,11 +103,11 @@ $(STUB_ELF_32S3_BETA_2): $(SRCS) $(BUILD_DIR) ld/stub_32s3_beta_2.ld - - $(STUB_ELF_32S3): $(SRCS) $(BUILD_DIR) ld/stub_32s3.ld - @echo " CC(32S3) $^ -> $@" -- $(Q) $(CROSS_32S3)gcc $(CFLAGS) -DESP32S3=1 -Tstub_32s3.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) -+ cp ../../target/xtensa-esp32s3-none-elf/release/flasher-stub build/stub_flasher_32s3.elf - - $(STUB_ELF_32C3): $(SRCS) $(BUILD_DIR) ld/stub_32c3.ld - @echo " CC(32C3) $^ -> $@" -- $(Q) $(CROSS_32C3)gcc $(CFLAGS_ESPRISCV32) -DESP32C3=1 -Tstub_32c3.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) -+ cp ../../target/riscv32imc-unknown-none-elf/release/flasher-stub build/stub_flasher_32c3.elf - - $(STUB_ELF_32C6BETA): $(SRCS) $(BUILD_DIR) ld/stub_32c6_beta.ld - @echo " CC(32C6BETA) $^ -> $@" -@@ -126,7 +123,7 @@ $(STUB_ELF_32H2_BETA_2): $(SRCS) $(BUILD_DIR) ld/stub_32h2_beta_2.ld - - $(STUB_ELF_32C2): $(SRCS) $(BUILD_DIR) ld/stub_32c2.ld - @echo " CC(32C2) $^ -> $@" -- $(Q) $(CROSS_32C2)gcc $(CFLAGS_ESPRISCV32) -DESP32C2=1 -Tstub_32c2.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) -+ cp ../../target/riscv32imc-unknown-none-elf/release/flasher-stub build/stub_flasher_32c2.elf - - $(STUB_ELF_32C6): $(SRCS) $(BUILD_DIR) ld/stub_32c6.ld - @echo " CC(32C6) $^ -> $@" -@@ -136,7 +133,7 @@ $(STUB_ELF_32H2): $(SRCS) $(BUILD_DIR) ld/stub_32h2.ld - @echo " CC(32H2) $^ -> $@" - $(Q) $(CROSS_32H2)gcc $(CFLAGS_ESPRISCV32) -DESP32H2=1 -Tstub_32h2.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) - --embed: $(STUB_ELF_8266) $(STUB_ELF_32) $(STUB_ELF_32S2) $(STUB_ELF_32S3_BETA_2) $(STUB_ELF_32S3) $(STUB_ELF_32C3) $(STUB_ELF_32C6BETA) $(STUB_ELF_32H2_BETA_1) $(STUB_ELF_32H2_BETA_2) $(STUB_ELF_32C2) $(STUB_ELF_32C6) $(STUB_ELF_32H2) -+embed: $(STUB_ELF_32) $(STUB_ELF_32S2) $(STUB_ELF_32S3_BETA_2) $(STUB_ELF_32S3) $(STUB_ELF_32C3) $(STUB_ELF_32C6BETA) $(STUB_ELF_32H2_BETA_1) $(STUB_ELF_32H2_BETA_2) $(STUB_ELF_32C2) $(STUB_ELF_32C6) $(STUB_ELF_32H2) - @echo " WRAP $^ -> $(ESPTOOL_STUBS_DIR)" - $(Q) $(WRAP_STUB) --embed $^ - diff --git a/README.md b/README.md index 79f0670..af1c67b 100644 --- a/README.md +++ b/README.md @@ -49,23 +49,27 @@ cargo xtask wrap esp32c3 cargo xtask wrap esp32 esp32s2 esp32s3 ``` +JSON stub files will be generated in the project root directory. + ## Testing In order to run `test_esptool.py` follow steps below: - Build `esp-flasher-stub` as described in the section above. -- Clone `esptool` to the same directory where `esp-flasher-stub` resides. -- Run patched Makefile +- Clone `esptool`, if you don't have it yet: + ``` + git clone https://github.com/espressif/esptool + ``` +- Copy the stub JSON files into esptool installation. You can use the following one-liner: + ```bash + for n in esp*.json; do cp $n $ESPTOOL_PATH/esptool/targets/stub_flasher/stub_flasher_${n#esp}; done + ``` + where `ESPTOOL_PATH` is set to the location where you have cloned `esptool`. - Run tests - -```bash -git clone https://github.com/espressif/esptool -cd esptool/flasher_stub/ -git apply Makefile_patched.patch -make -C . -cd ../test -pytest test_esptool.py --port /dev/ttyUSB0 --chip esp32 --baud 115200 -``` + ```bash + cd $ESPTOOL_PATH/test + pytest test_esptool.py --port /dev/ttyUSB0 --chip esp32 --baud 115200 + ``` ## Debug logs diff --git a/esptool.patch b/esptool.patch deleted file mode 100644 index 4adda98..0000000 --- a/esptool.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 5ff6e377e8ddd123b6d6112d1547908bd2a47e01 Mon Sep 17 00:00:00 2001 -From: Martin Valik -Date: Thu, 23 Jun 2022 10:18:54 +0200 -Subject: [PATCH] new stub - ---- - flasher_stub/Makefile | 3 ++- - test/test_esptool.py | 4 ++-- - 2 files changed, 4 insertions(+), 3 deletions(-) - -diff --git a/flasher_stub/Makefile b/flasher_stub/Makefile -index af51a39..1ce39b5 100644 ---- a/flasher_stub/Makefile -+++ b/flasher_stub/Makefile -@@ -105,7 +105,7 @@ $(STUB_ELF_32S3): $(SRCS) $(BUILD_DIR) ld/stub_32s3.ld - - $(STUB_ELF_32C3): $(SRCS) $(BUILD_DIR) ld/stub_32c3.ld - @echo " CC(32C3) $^ -> $@" -- $(Q) $(CROSS_32C3)gcc $(CFLAGS_ESPRISCV32) -DESP32C3=1 -Tstub_32c3.ld -Wl,-Map=$(@:.elf=.map) -o $@ $(filter %.c, $^) $(LDLIBS) -+ cp ../../esp-flasher-stub/target/riscv32imc-unknown-none-elf/release/stub build/stub_flasher_32c3.elf - - $(STUB_ELF_32C6BETA): $(SRCS) $(BUILD_DIR) ld/stub_32c6_beta.ld - @echo " CC(32C6) $^ -> $@" -@@ -126,6 +126,7 @@ $(STUB_ELF_32C2): $(SRCS) $(BUILD_DIR) ld/stub_32c2.ld - $(STUB_PY): $(STUB_ELF_8266) $(STUB_ELF_32) $(STUB_ELF_32S2) $(STUB_ELF_32S3_BETA_2) $(STUB_ELF_32S3) $(STUB_ELF_32C3) $(STUB_ELF_32C6BETA) $(STUB_ELF_32H2_BETA_1) $(STUB_ELF_32H2_BETA_2) $(STUB_ELF_32C2) wrap_stub.py - @echo " WRAP $^ -> $@" - $(Q) $(WRAP_STUB) --out-file $@ $(filter %.elf,$^) -+ cp build/stub_flasher_snippet.py ../esptool/stub_flasher.py - - embed: $(STUB_ELF_8266) $(STUB_ELF_32) $(STUB_ELF_32S2) $(STUB_ELF_32S3_BETA_2) $(STUB_ELF_32S3) $(STUB_ELF_32C3) $(STUB_ELF_32C6BETA) $(STUB_ELF_32H2_BETA_1) $(STUB_ELF_32H2_BETA_2) $(STUB_ELF_32C2) wrap_stub.py - @echo " WRAP $^ -> esptool.py" -diff --git a/test/test_esptool.py b/test/test_esptool.py -index 79d22a6..e8e019e 100755 ---- a/test/test_esptool.py -+++ b/test/test_esptool.py -@@ -38,7 +38,7 @@ NODEMCU_FILE = "nodemcu-master-7-modules-2017-01-19-11-10-03-integer.bin" - TEST_DIR = os.path.abspath(os.path.dirname(__file__)) - os.chdir(os.path.dirname(__file__)) - try: -- ESPTOOL_PY = os.environ["ESPTOOL_PY"] -+ ESPTOOL_PY = os.path.join(TEST_DIR, "..", "esptool.py") - except KeyError: - ESPTOOL_PY = os.path.join(TEST_DIR, "..", "esptool/__init__.py") - ESPSECURE_PY = os.path.join(TEST_DIR, "..", "espsecure/__init__.py") -@@ -1015,4 +1015,4 @@ if __name__ == "__main__": - with io.open("report.xml", "wb") as output: - unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output)) - except ImportError: -- unittest.main(buffer=True) -+ unittest.main() -\ No newline at end of file --- -2.34.1 -