Skip to content

Commit

Permalink
flasher_stub: drop --embed from wrap_stub.py
Browse files Browse the repository at this point in the history
Since commit 94f29a5 the flasher stub is not embedded in the Python
source, but rather included as simple json files.

As such, wrap_stub.py --embed was converted to basically just vary the
build dir. Rather than keep this indirection and for better clarity,
remove that piece of code and replace it by a simple "cp" in the
Makefile.

While at it, replace the target name from "embed" to "install", as this
more akin to a "make install" step.
  • Loading branch information
paravoid committed Mar 13, 2023
1 parent 0da4447 commit 47e2b25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
12 changes: 6 additions & 6 deletions flasher_stub/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile to compile the flasher stub program
#
# Note that YOU DO NOT NEED TO COMPILE THIS IN ORDER TO JUST USE
# esptool.py - a precompiled version is embedded in esptool.py,
# esptool.py - a precompiled version is included in esptool.py,
# so if you don't want to modify the stub code then you are good to go.
#
# See the comments in the top of the Makefile for parameters that
Expand Down Expand Up @@ -91,11 +91,11 @@ STUBS_ELF += \
$(STUB_ELF_32H2)
endif

.PHONY: all clean embed
.PHONY: all clean install

all: $(STUBS_ELF:.elf=.json)

embed: $(patsubst $(BUILD_DIR)/%.elf,$(ESPTOOL_STUBS_DIR)/%.json,$(STUBS_ELF))
install: $(patsubst $(BUILD_DIR)/%.elf,$(ESPTOOL_STUBS_DIR)/%.json,$(STUBS_ELF))

$(BUILD_DIR):
$(Q) mkdir $@
Expand All @@ -104,9 +104,9 @@ $(BUILD_DIR)/%.json: $(BUILD_DIR)/%.elf
@echo " WRAP $^ -> $(BUILD_DIR)"
$(Q) $(WRAP_STUB) $^

$(ESPTOOL_STUBS_DIR)/%.json: $(BUILD_DIR)/%.elf
@echo " WRAP $^ -> $(ESPTOOL_STUBS_DIR)"
$(Q) $(WRAP_STUB) --embed $^
$(ESPTOOL_STUBS_DIR)/%.json: $(BUILD_DIR)/%.json
@echo " INSTALL $^ -> $@"
$(Q) cp $^ $@

CFLAGS = -std=c99 -Wall -Werror -Os \
-mtext-section-literals -mlongcalls -nostdlib -fno-builtin -flto \
Expand Down
2 changes: 1 addition & 1 deletion flasher_stub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Activating an ESP-IDF environment takes care of most of these steps (only the ES

# To Test

To test the built stub, you can run `make embed` (or `make embed WITHOUT_ESP8266=1`), which will update the stubs in `esptool.py` to the newly compiled ones. Or there are some convenience wrappers to make testing quicker to iterate on:
To test the built stub, you can run `make install` (or `make install WITHOUT_ESP8266=1`), which will update the stubs in `esptool.py` to the newly compiled ones. Or there are some convenience wrappers to make testing quicker to iterate on:

* Running `esptool_test_stub.py` is the same as running `esptool.py`, only it uses the just-compiled stubs from the build directory.

Expand Down
7 changes: 1 addition & 6 deletions flasher_stub/wrap_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

THIS_DIR = os.path.dirname(__file__)
BUILD_DIR = os.path.join(THIS_DIR, "./build/")
STUBS_DIR = os.path.join(THIS_DIR, "../esptool/targets/stub_flasher/")


def wrap_stub(elf_file):
Expand Down Expand Up @@ -67,8 +66,7 @@ def default(self, obj):
return json.JSONEncoder.default(self, obj)

for filename, stub_data in stubs_dict.items():
DIR = STUBS_DIR if args.embed else BUILD_DIR
with open(DIR + filename, "w") as outfile:
with open(BUILD_DIR + filename, "w") as outfile:
json.dump(stub_data, outfile, cls=BytesEncoder, indent=4)


Expand All @@ -79,9 +77,6 @@ def stub_name(filename):

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--embed", help="Embed stub json files into esptool.py", action="store_true"
)
parser.add_argument("elf_files", nargs="+", help="Stub ELF files to convert")
args = parser.parse_args()

Expand Down

0 comments on commit 47e2b25

Please sign in to comment.