esp-rs / espflash

Serial flasher utility for Espressif SoCs and modules based on esptool.py
Apache License 2.0
488 stars 118 forks source link

save-image is confusing #376

Closed bugadani closed 9 months ago

bugadani commented 1 year ago

I'm trying to convert an .elf file into .bin. espflash (2.0.0-rc3) correctly picks up the partition sizes (my target partition is 2.5MB) and prints partition usage, but the stored binary is padded to 4MB.

bugadani commented 1 year ago

Interesting, I think I just misunderstood what save-image is intended to do. I assumed it'll generate an image appropriate for my partition table, but instead it seems to generate the image as if I'm targeting a bare-metal chip.

Interestingly though, -P still gives me a binary larger than what the app size is (1_684_000 bytes vs 1_487_392) - my guess is, it still pads my binary to some alignment? I think I would expect -P to just leave my binary alone 🙃

Note to self: don't try to be clever and just skip passing anything to espflash. save-image --chip esp32 out.bin in.elf works just fine. Figuring this out took some trial and error all the while wondering why --merge is required and the app complains at me for removing it.

Edit #23642: to make this issue at least somewhat interesting: it would be nice if I could pass my partition table to espflash so that it knows what % of the partition my app takes up, but still generates the raw binary without any merging and padding.