45 Commits

Author SHA1 Message Date
Peter Dragun
66a137738e fix(elf2image): Fix --pad-to-size argument parsing 2025-08-22 12:36:50 +02:00
copilot-swe-agent[bot]
206970acf8 refactor: set up and apply pyupgrade ruff rules
Closes https://github.com/espressif/esptool/issues/1115

Closes https://github.com/espressif/esptool/pull/1116
2025-08-14 16:01:17 +02:00
Jaroslav Burian
97a1546166 fix(elf2image): validate ELF section types and addresses before processing 2025-07-15 00:33:31 +02:00
Peter Dragun
e9f03aeb44 docs: Remove .py suffix from tool names 2025-06-24 14:22:28 +02:00
Peter Dragun
3cecd6dcc1 feat(cli): Commands and options use dashes instead of underscores for uniformity
BREAKING CHANGE
2025-03-07 10:02:16 +01:00
Radim Karniš
46a9e31cfe feat(cmds): Expand input of all functions to file paths, bytes, or file-like objects 2025-03-06 15:14:01 +01:00
Peter Dragun
2e4e77cde2 change: fix issues reported by ruff linter 2025-02-24 10:10:22 +01:00
Jaroslav Burian
8be617c2ba fix(elf2image): support --flash-mmu-page-config for all chips
This commit fixes the issue where the `--flash-mmu-page-config` option
did not work for chips that do not have configurable MMU page sizes.
2025-02-14 22:50:20 +08:00
Jaroslav Burian
f4fabc5de4 fix(elf2image): Try to correct MMU page size if not specified
This commit fixes issue with using elf2image command without --flash-mmu-page-size.
In that case, app info segment might be incorrectly placed in the image.
This is fixed by checking if app info segment is present and if so,
use page size from it or from its alignment.
Closes https://github.com/espressif/esptool/issues/1062
2025-02-14 22:50:20 +08:00
Radim Karniš
0864e17530 feat(errors): Print errors to STDERR, catch KeyboardInterrupt
BREAKING CHANGE

Closes https://github.com/espressif/esptool/issues/981

Closes https://github.com/espressif/esptool/issues/888

Closes https://github.com/espressif/esptool/issues/934
2025-01-29 10:56:53 +01:00
Radim Karniš
3f625c39ad feat(image_info): Deprecate the --version 1 output format
BREAKING CHANGE
2025-01-29 10:45:47 +01:00
Marek Matej
4bc8d5bf88 revert(elf2image): revert the use of ELF flags as merge condition
Remove the flags condition from merging function because it prevents
merging segments in certain conditions.

This reverts commit e87cc3ec62.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2024-11-28 17:11:10 +08:00
Marek Matej
e87cc3ec62 fix(elf2image): add ELF flags to merge condition
Improve the condition upon the segments being merged in the
elf2image command. Covering the cases when comparing adjacent
segment addresses and types is not enough.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2024-05-23 17:44:25 +02:00
Peter Dragun
3301d0ff46 change: fix typos and spelling errors by codespell 2024-02-20 20:31:08 +08:00
Almir Okato
da28460aaf feat(elf2image): add ram-only-header argument
The ram-only-header configuration makes only
the RAM segments visible to the ROM bootloader placing
them at the beginning of the file and altering the
segment count from the image header with the quantity
of these segments, and also writing only their
checksum. This segment placement also may not result
as optimal as the standard way regarding the padding
gap use among the flash segments that could result
in a less fragmented binary.

The image built must then handle the basic hardware
initialization and the flash mapping for code execution
after ROM bootloader boot it.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-10-31 02:17:03 +00:00
radim.karnis
9c8c1f1a52 tests: Create custom host_test marker for tests without real chip connected
Closes https://github.com/espressif/esptool/issues/838
2023-02-20 13:48:35 +01:00
radim.karnis
471172d535 ci: Run tests against installed packages, not scripts 2022-11-29 14:59:04 +01:00
radim.karnis
1d18196eab ci(test_esptool): Migrate tests from unittest to pytest 2022-10-25 11:05:41 +02:00
radim.karnis
40e6afd97b ci(host_tests): Migrate from unittest to pytest
Closes https://github.com/espressif/esptool/issues/747/
2022-10-25 11:05:41 +02:00
radim.karnis
220c63063a refactor: Remove future imports 2022-06-15 15:45:10 +02:00
Roland Dobai
4e56df5196 elf2image: Add argument to disable appending SHA256 digests 2022-05-25 08:13:20 +00:00
radim.karnis
30821a3f93 Make esptool callable as esptool.py even on Unix systems 2022-05-05 22:22:17 +02:00
radim.karnis
45f1da954e refactoring: Employ Black code formatting 2022-03-28 23:06:34 +02:00
radim.karnis
07678b5810 refactoring: Separate binary image functions 2022-03-28 23:05:04 +02:00
radim.karnis
aee798dbe4 refactoring: Separate executable logic 2022-03-28 23:05:04 +02:00
radim.karnis
4875e8906f refactoring: Initial structure 2022-03-28 23:05:02 +02:00
Angus Gratton
5619ecd723 elf2image: merge adjacent sections
Mostly for the use case of linker scripts which have a large number of sections.
This is also required when having both .eh_frame and .eh_frame_hdr sections in
an ELF file. Having this feature will let us merge both sections within the
flash's rodata section (as long as they are all adjacent).

Normally would use segments (PHDRs) instead, but there are some things about our
ELF files that are not easily comaptible with this (especially ESP32-S2 where
DRAM & IRAM have different VMAs but use the same LMA space, however our linker
scripts so far haven't reflected this.)

Alternative approach to https://github.com/espressif/esptool/pull/546

More discussion at https://www.esp32.com/viewtopic.php?p=62918&sid=564af52d09a51a307f9e9ef9eba6eff6#p62918

Please refer to https://gitlab.espressif.cn:6688/espressif/esp-idf/-/merge_requests/12070 for more info about the use of this functionality.

Relates to IDF-2064
2021-02-05 14:47:44 +08:00
Angus Gratton
b96df73ba7 elf2image: Add a test case for --use_segments option 2020-12-15 18:29:44 +11:00
Roland Dobai
365a0ba963 Check the right part of the segment where SHA-256 will be written
Closes https://github.com/espressif/esptool/issues/560
2020-10-26 13:49:37 +01:00
Angus Gratton
07c1c8370e flake8: Update files to pass all flake8 conditions, including plugins and some previously excluded warnings 2020-10-05 11:55:15 +11:00
Angus Gratton
4f1e825d2d esp32c: Add chip_id field for ESP32-S2 2019-08-30 16:41:30 +08:00
suda-morris
60f56e6869 add minimum chip revision to image header 2019-08-27 18:08:56 +08:00
Angus Gratton
40258ed6de elf2image --sha256-offset: Only insert SHA256 if overwriting zero data
Updated tests to verify the same.
2019-03-18 11:45:14 +11:00
Ivan Grokhotkov
1504978d50 test/test_imagegen.py: clean up generated files 2018-11-29 17:58:22 +11:00
Ivan Grokhotkov
d8aa1e65f4 elf2image: support patching SHA256 digest of ELF file into the binary
Allows generating a properly checksummed and hashed binary file which
contains the hash of the original ELF file inside. Useful for being
able to identify the ELF file used to produce the binary.
2018-11-29 17:58:22 +11:00
Angus Gratton
8a288e27c7 elf2image: Fail with a proper error if the ELF file contains more than 16 loadable sections
(More than 16 sections in the output .bin will not boot, and there is a hard limit of 255 sections
in the .bin file format.)

Related to https://github.com/espressif/esp-idf/issues/2727
2018-11-23 10:39:10 +11:00
Angus Gratton
a2f678c001 elf2image: Don't add empty ELF sections to the binary 2018-11-23 10:36:49 +11:00
Angus Gratton
192b88aae3 elf2image --version=2: Make compatible with ESP8266 SDK gen_appbin.py
* Pad IROM section to 16 byte boundary
* Append a CRC32 of the rest of the file

Backwards compatible with previous approach (CRC32 is ignored, padding IROM
section changes length so rboot/etc will be able to accommodate.)
2018-06-13 12:02:52 +10:00
Ryan Jarvis
fa7e37aa4c PEP8 imports (https://www.python.org/dev/peps/pep-0008/#imports). Remove unused import statements. 2017-09-17 12:22:03 -07:00
Angus Gratton
10099e8595 esp32 elf2image: Use RAM-loaded data as padding content, instead of zeroes
Can reduces binary image size by almost 128KB in some cases.
2017-07-18 10:04:23 +10:00
Angus Gratton
2cb00b77bb elf2image: Fix error when section header is not at end of ELF file
Closes #197

Includes test case (first ELF file posted in linked issue.)
2017-05-03 11:16:56 +10:00
Angus Gratton
8904583a33 Merge tag 'v1.3' into feature/esp32_v20_refactor 2017-01-09 17:59:53 +11:00
Angus Gratton
0f33564973 Add test cases for image header bytes
Fix ESP32 flash size header generation
2016-10-19 08:16:11 +11:00
Angus Gratton
6e3e8469e6 elf2image: Add esp32 test cases to test_imagegen.py 2016-10-17 16:48:10 +11:00
Angus Gratton
1fe8865828 elf2image: Fix esp8266 image generation bugs, update esp8266 image generation tests 2016-10-17 15:45:59 +11:00