Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU commit 7b28699 didn't fix the read/write issues with ESP32-S3 (ESPTOOL-634) #848

Closed
mrdude2478 opened this issue Feb 25, 2023 · 25 comments

Comments

@mrdude2478
Copy link

mrdude2478 commented Feb 25, 2023

Operating System

Windows 10 64Bit

Esptool Version

Commit: 7b28699

Python Version

3.11

Full Esptool Command Line that Was Run

esptool -b 921600 --port COM3 --chip esp32s3 read_flash 0xCA2000 0x148000 FAT9.bin

Esptool Output

No issues with the output.

What is the Expected Behaviour?

Please revert commit:
7b28699

After further investigation I was able to fix this issue, please see here at the bottom of the page:
#832

There was an issue with reading/writing esp32-s3 chip with newer builds of esptool. It was discussed in issue 832. After further investigation and installing the sdk to build the stub files, I modded the files and found what was making the read/write fails. Please see the bottom of issue 832 (which is closed), for the fix. CPU speed can be put back to 240Mhz.

Thanks

More Information

No response

Other Steps to Reproduce

No response

@github-actions github-actions bot changed the title CPU commit 7b28699 didn't fix the read/write issues with ESP32-S3 CPU commit 7b28699 didn't fix the read/write issues with ESP32-S3 (ESPTOOL-634) Feb 25, 2023
@radimkarnis
Copy link
Collaborator

radimkarnis commented Feb 27, 2023

Hi @mrdude2478,
I am going to answer here, not in the linked discussion.

Thanks for looking into this more. Let me clarify first - lowering the CPU frequency to 160 MHz didn't help in your case? First, you said this fix helped.

Now, let's discuss your solution:
You propose to change the SYSTEM_SYSCLK_CONF_REG from SYSTEM_BASE_REG + 0x060 to just SYSTEM_BASE_REG. This helps in your case, but you also say am unsure what adding these addresses on to those clock registers actually does.

Looking into the TRM, it says that all the registers starting with SYSTEM are relative to the base address of system registers (SYSTEM_BASE_REG). That's why the address of SYSTEM_SYSCLK_CONF_REG is defined as the base reg SYSTEM_BASE_REG plus an offset of 0x060:
image

This address is where the CPU frequency switch is. What happens in your case is that you change the address so you are essentially switching another random thing, not the CPU freq settings. In other words, this is like reverting the feature completely, but with the added danger of messing something else up.

Therefore, this can't be considered a real fix, it's more of a lucky coincidence.

On the other hand, this feature proves to be more and more unpredictable and unstable. Removing it completely now seems like a viable solution to me. Stability is more important than flashing speeds. We will think about this more.

@mrdude2478
Copy link
Author

mrdude2478 commented Feb 27, 2023

OK thanks, I do know that since changing this value, I have not experienced a failure yet when reading or writing, so that will mean yes you are probably correct, removing this value seems like a viable fix. I guess the first time when the cpu frequency was changed I might have been lucky, however I still got crashes randomly, yesterday I flashed my dongle about 50 times also dumped the entire flash maybe about 20 times to test and didn't get a failure once.

@mrdude2478
Copy link
Author

mrdude2478 commented Feb 27, 2023

@radimkarnis

What about doing something like this - in stubflasher.c add these two lines.

#if USE_MAX_CPU_FREQ
static bool can_use_max_cpu_freq()
{
  /* Check if any of available USB modes are being used. */
  #if ESP32S3 //added this
  return false; //added this
  #elif WITH_USB_OTG && !WITH_USB_JTAG_SERIAL
  return stub_uses_usb_otg();
  #elif !WITH_USB_OTG && WITH_USB_JTAG_SERIAL
  return stub_uses_usb_jtag_serial();
  #elif WITH_USB_OTG && WITH_USB_JTAG_SERIAL
  return stub_uses_usb_otg() || stub_uses_usb_jtag_serial();
  #else
  return false;
  #endif
}

Then if the chip was detected as esp32-s3, it would disable the max cpu frequency. Would that work?

@radimkarnis
Copy link
Collaborator

@mrdude2478 it would work, but if this feature is unstable on the S3, we don't want to risk these issues also on other chips. So it will be reverted for all the chips, until we figure out why it doesn't work for everyone and how to implement it in a safe way.

@mrdude2478
Copy link
Author

mrdude2478 commented Feb 27, 2023

OK, thanks - you could then just return false from that function then and it would do the same thing for all chips, and would save needing to re-write lots of code until it's figured out why there's an timing issue? Maybe it's down to the xtal in my board? I don't know much about electronics but surely if that deals with the timing it could be something related to that? I ordered another board to check this, I might try replacing that crystal with a different brand to see if it makes any differnce.

@JunOllyLi
Copy link

What I have observed is that the official 4.5 and the latest code (4.6-dev) in the repo behave the same, that sometimes it works most of the time, while sometimes it just does not work at all. And mrdude2478's exe works while the 4.6-dev refuses to work.

I still have not figured out exactly what is the difference between those two scenarios. I am using the same computer (Surface 8 Pro, with nothing else connected, except the charger. I have tried with both charger connected and not connected, did not see any difference), same USB cable, same boards (yes I have different boards, some powered by on-board 5V=>3.V, some powered by external buck converter, and all behave the same). All I can tell is that it normally works while I sit in front of my desk, and not work while I sit in the bed, but I don't see how that would affect the result :(

@JunOllyLi
Copy link

JunOllyLi commented Feb 27, 2023

Reading this thread more and here are my thoughts:
So mrdude2478 was writing something intended for SYSTEM_BASE_REG + 0x060 to just SYSTEM_BASE_REG and luckily it worked. Now:

  1. What is the value of that?
  2. What that value mean to the register at SYSTEM_BASE_REG?
  3. Would it still work if we totally just skip the write (neither writing to SYSTEM_BASE_REG + 0x060, nor SYSTEM_BASE_REG)
  4. What if both registers were written with the same values?

So there are three possibilities:
a. the value written to SYSTEM_BASE_REG luckily had some bits that affects the behavior and make it more stable
b. the value originally written to SYSTEM_BASE_REG + 0x060 made it fail to work, and we should just ignore it
c. combination of both a and b.

I think it would be a good idea to understand what situation we are in first.

@JunOllyLi
Copy link

@radimkarnis if you have a quick guide on how to change that part of code and compile the exe (or simple modify python code to do that), I would be happy to help to try out.

I just don't have time to read all the code to find where this particular change is.

@mrdude2478
Copy link
Author

mrdude2478 commented Feb 27, 2023

@JunOllyLi , @radimkarnis allready explained that it's down to the CPU frequency using the max speed of the chip (see the code above). This is in the stub that is uploaded to the chip before dumping/flashing routines kick in. It's being looked into by people far smarter than me, well at least with far more experience in chip programming and writing software. At least those people are aware of the issues and why there's an issue so I imagine that it will be fixed in the near future as has already been stated. We just need to wait now and be patient and thank the coders for the hard work they do and for looking into this issue.

@JunOllyLi
Copy link

@JunOllyLi , @radimkarnis allready explained that it's down to the CPU frequency using the max speed of the chip (see the code above). This is in the stub that is uploaded to the chip before dumping/flashing routines kick in. It's being looked into by people far smarter than me, well at least with far more experience in chip programming and writing software. At least those people are aware of the issues and why there's an issue so I imagine that it will be fixed in the near future as has already been stated. We just meed to wait now and be patient and thank the coders for the hard work they do and for looking into this issue.

But I thought the frequency change had already been in the lates of the repo? And it did not work? At least not working after doing the "pip install"

@radimkarnis
Copy link
Collaborator

Thank you both for your interest and for helping with this issue.
Good news! We have possibly identified the underlying reason why this keeps happening on the S3. A fix is in the works. If that works, we don't have to revert. Will keep you guys updated.

@mrdude2478
Copy link
Author

@radimkarnis

Thank you for the updated news, that's great that you guys managed to find the issue so quickly. Well done and thank you for looking into this, it's very much appreciated.

espressif-bot pushed a commit that referenced this issue Feb 28, 2023
@radimkarnis
Copy link
Collaborator

The plan is to temporarily disable this feature and make a stable v4.5.1 release. Then we can properly implement a fix, re-enable it, and test it thoroughly for v4.6.

@JunOllyLi
Copy link

JunOllyLi commented Feb 28, 2023

@radimkarnis Thanks for the hard work!

So when can we expect the change (to make it stable in v4.5.1) in the repo and try it out?

Oh, never mind, just saw the new commit. I am going to give it a try

@radimkarnis
Copy link
Collaborator

@JunOllyLi it is already in master, you can clone the repo and install esptool (instructions here) to try! It will be released on PyPI tomorrow.

@JunOllyLi
Copy link

it worked pretty well last night. Thanks!

@radimkarnis
Copy link
Collaborator

@JunOllyLi thanks for the confirmation! I am now working on the proper fix, I will ask you to kindly try it when it's ready.

@mrdude2478
Copy link
Author

@radimkarnis

I'll try it out as well once it's done. Thanks.

@radimkarnis
Copy link
Collaborator

@JunOllyLi @mrdude2478 I have created a development release with a possible fix. It can be installed with pip install esptool==4.6.dev0.

Could you please try if that solves the issue for you? Thank you!

@JunOllyLi
Copy link

I tried it several times, so far it works well

@mrdude2478
Copy link
Author

@radimkarnis

Sorry for the late replay as I just noticed you'd replied. I updated and tried but still get issues.

C:\Users\MrDude\Desktop>esptool -b 921600 --port COM1 --chip esp32s3 read_flash 0x0 0x1000000 FAT.bin
esptool.py v4.6.dev0
Serial port COM1
Connecting...
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: f4:12:fa:44:a5:04
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
532480 (3 %)
A fatal error occurred: Corrupt data, expected 0x1000 bytes but received 0xfb2 bytes

C:\Users\MrDude\Desktop>esptool -b 921600 --port COM1 --chip esp32s3 read_flash 0x0 0x1000000 FAT.bin
esptool.py v4.6.dev0
Serial port COM1
Connecting...
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: f4:12:fa:44:a5:04
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
3186688 (18 %)
A fatal error occurred: Corrupt data, expected 0x1000 bytes but received 0xf80 bytes

Out of two attempts it failed on both.

@JunOllyLi
Copy link

JunOllyLi commented Mar 24, 2023

emm...after seeing @mrdude2478's reply, I went back to check my log. Looks like I did not really update to the test release. The pip install said everything was already satisfied.

C:\Espressif\frameworks\esp-idf-v5.0.1>pip install esptool==4.6.dev0
Requirement already satisfied: esptool==4.6.dev0 in c:\edgetx\xesp (4.6.dev0)
Requirement already satisfied: bitstring>=3.1.6 in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from esptool==4.6.dev0) (4.0.1)
Requirement already satisfied: cryptography>=2.1.4 in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from esptool==4.6.dev0) (36.0.2)
Requirement already satisfied: ecdsa>=0.16.0 in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from esptool==4.6.dev0) (0.18.0)
Requirement already satisfied: pyserial>=3.0 in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from esptool==4.6.dev0) (3.5)
Requirement already satisfied: reedsolo<=1.6.0,>=1.5.3 in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from esptool==4.6.dev0) (1.5.4)
Requirement already satisfied: cffi>=1.12 in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from cryptography>=2.1.4->esptool==4.6.dev0) (1.15.1)
Requirement already satisfied: pycparser in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from cffi>=1.12->cryptography>=2.1.4->esptool==4.6.dev0) (2.21)
Requirement already satisfied: six>=1.9.0 in c:\espressif\python_env\idf5.0_py3.8_env\lib\site-packages (from ecdsa>=0.16.0->esptool==4.6.dev0) (1.16.0)

@radimkarnis
Copy link
Collaborator

@JunOllyLi @mrdude2478 thank you both for trying.
It now seems like the fix would require a large amount of code to be added to the stub. I am therefore thinking about putting this on hold. Faster flashing/reading speeds for ESP32-S3 currently do not justify the time spent debugging and implementing a fix for this and the increased stub flasher size (the stub has to be as small as possible).

The feature works for other chips and we have a stable version (v4.5.1). I will keep this open for future reference until a real need for faster transfer speeds appears.

Thanks again for the time you've spent helping us with this!

@mrdude2478
Copy link
Author

mrdude2478 commented Mar 28, 2023

@radimkarnis

To be honest, I didn't notice any speed difference with the increase in cpu frequency when dumping or flashing. It was pretty much the same speed with the CPU frequency disabled. I am just happy that it's now able to dump and flash properly with 4.5.1 as stability is more important than saving a few seconds. A full 16MB dump takes about 1/2 hour, flashing is much faster though and just takes a couple of minutes.

@radimkarnis
Copy link
Collaborator

Closing this as increasing CPU frequency won't be implemented for the ESP32-S3. If anyone feels like this should be reconsidered, feel free to reopen.

Jason2866 added a commit to Jason2866/esptool that referenced this issue Nov 4, 2023
* docs: espsecure remote signing using a HSM broken link fix

* fix(rfc2217_server): Use new reset sequences

* fix(ESP32-S3): Lower CPU freq to improve flasher stub stability

Closes espressif#832

* fix: Unknown chip (ID or magic number) error

* pyinstaller: fix glibc dependency on gnu/linux

pyinstaller package for linux is built within the ubuntu-latest image in
github workflow. This may cause prbolem with glibc symbol versions on
older distributions, where the new symbol versions are not available.
Fix this by building on the older ubuntu version.

Closes espressif#843

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>

* tests: Create custom `host_test` marker for tests without real chip connected

Closes espressif#838

* fix(ESP32-S3): Temporarily disable increasing CPU freq

Related to espressif#848

Related to espressif#842

* build: add esp_rfc2217_server to published scripts

Closes espressif#846

* Update version to v4.5.1

* Update version to v4.6-dev

* espefuse: Hide sensitive info by default during burning burn_key and burn_key_digest

Adds --show-sensitive-info flag for two commands:
burn_key and burn_key_digest.

* flasher_stub: pass -mabi=ilp32 to the RISC-V compiler

This is a no-op change for the upstream toolchain (compiled stubs are
binary identical), but is required when building with Debian's
riscv64-unknown-elf-gcc compiler.

* flasher_stub: allow passing extra CFLAGS

The flasher_stub Makefile allows for some system-local configuration,
either through local.mk, or through environment variables.

For example, the compiler prefix can be overridden, by defining e.g.
CROSS_ESPRISCV32. However, passing additional flags to the compiler
isn't possible right now. Add EXTRA_CFLAGS and EXTRA_CFLAGS_ESPRISCV32
to allow for that option.

* flasher_stub: collect all targets at the top, DRY

* flasher_stub: make target selection more modular

Rather than a special "make esp32", create WITHOUT_* variables to
selectively disable chip families. Currently, WITHOUT_ESP8266,
WITHOUT_ESP32_XTENSA and WITHOUT_ESP32_RISCV32 are defined, but the code
can be easily adjusted to allow for all kinds of other
sets/combinations.

* flasher_stub: create %.json targets, make all a proper PHONY

* flasher_stub: drop --embed from wrap_stub.py

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.

* espefuse: Support burning ECDSA_KEY from pem file

- fix some assert check in test_espefuse.py
- add tests to cover the new functionality

* espefuse(c2): Fix BLOCK_KEY0 view for summary cmd when SB + FE keys are burnt

For C2 secure boot + flash enc block, we saw that in summary cmd
"0's" from secure boot digest part (upper 128 bit) were translated
into "?'s" when the block was read protected.
For C2, we should apply this translation for lower 128 bits only.

* fix(ESP32-C6): Fix get_pkg_version and get_{major,minor}_chip_version

* image_info: removed check that reserved bytes in image header are zero

IDF may start using parts of the reserved bytes in the extended header at any time,
which will break chip auto-detect in image_info.

* build: limit max cryptography version to 40

* fix: Set flash parameters even with --flash_size keep

Related to espressif/esp-idf#10788

Related to espressif/esp-idf#10959

* build: add arm and arm64 as build target

Closes espressif#845

* Fix typo in serial protocol docs

Fixes misspelling of `triggered` in serial protocol docs.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>

* Support more recent reedsolo packages

- https://github.com/tomerfiliba-org/reedsolomon/releases/tag/v1.6.1 - this seems to be related to licenses only.
- https://github.com/tomerfiliba-org/reedsolomon/releases/tag/v1.7.0 - this is related to installation.

Closes espressif#872

* build(arm): add pip extra url for github action build

* ci: Fix libffi symlinks for cryptography>=40

* espefuse: Prevent burning XTS_AES and ECDSA keys into BLOCK9 (BLOCK_KEY5)

eFuse module has a hardware bug.
It is related to ESP32-C3, C6, S3, H2 chips:
    - BLOCK9 (BLOCK_KEY5) can not be used by XTS_AES keys.
For H2 chips, the BLOCK9 (BLOCK_KEY5) can not be used by ECDSA keys.
S2 does not have such a hardware bug.

* image_info: Display disabled WP pin as disabled

The image formats know about the special value 0xee used to disable WP.
Display this with image_info.

E.g.:

ESP32-C3 extended image header
==============================
WP pin: 0xee (disabled)

* image_info: Print chip ID's name if known

Example:

Flash pins drive settings: clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0
Chip ID: 5 (ESP32-C3)
Minimal chip revision: v0.0, (legacy min_rev = 0)
Maximal chip revision: v655.35

An unknown ID will be printed as:

Chip ID: 42 (Unknown ID)

* tests: Make the testsuite Windows compatible

* espefuse: Adds external esp instance

Closes espressif#873

* espefuse: Improve efuse error viewing

* espefuse: Explicit setting of efuse time settings

EFUSE_PWR_ON_NUM in C3 has default value = 0x2880, now = 0x3000

* docs(Boot log): Add all esp targets to cover boot troubleshooting

Closes espressif#732

* fix: USB-JTAG-Serial PID detection error

* esptool: Move bootdesc on the top of the ram segment

* espefuse: Move some vars under init method to speedup tool after adding yaml support

* espefuse: Adds yaml efuse description files for all chip

- esptool: Updates eFuses wafer major&minor versions
- esptool(esp32c6): Adds package versions
- espefuse(esp32c6): Replace PKG_VERSION BLK_VERSION_MINOR BLK_VERSION_MAJOR
- espefuse(esp32c6): Adds adc calib efuses
- espefuse: Adds yaml files for Build with PyInstaller

* efuse(H2): Adds RF Calibration Information

* espsecure: Improve error message for incorrect PEM format

Closes espressif#881

* bugfix(usb_jtag_serial): Autofeed super watchdog (SWD) to avoid resets during flashing

* esptool: Read 64-bit MAC address on C6 and H2

* bugfix: Adjust wrapper scripts to not import themselves

* bugfix(espsecure): Print a clear error message if incompatible OpenSSL backend is used

Closes espressif#878

* fix: inconsistent usage of dirs separator

* feat(esptool): add option to dump whole flash based on detected size

Closes espressif#461

* Update version to v4.6

* Update version to v4.7-dev

* fix(ESP32-S3): Correct RTC WDT registers to fix resets during flashing

* Update version to v4.6.1

* Update version to v4.7-dev

* docs: add explanation for flash_id example to avoid confusion

* docs(boot-log): fix list formatting

* docs: add c2, c6 and h2 as build targets

* fix(compressed upload): Accept short data blocks with only Adler-32 bytes

* fix(CH9102F): Suggest to install new serial drivers if writing to RAM fails

* esptool & espefuse: Fix byte order in MAC (for C6 and H2)

MAC: 60:55:f9:ff:fe:f7:2c:a2 (EUI64, used for IEEE802154)
BASE MAC: 60:55:f9:f7:2c:a2 (used for BT)
MAC_EXT: ff:fe

* Update version to v4.6.2

* Update version to v4.7

* change: Add conventional precommit linter

* ci(pre-commit): Update version of `conventional-precommit-linter`

* feat(get_security_info): Improved the output format and added more
details

* fix(esp32-c2): Enable flashing in secure download mode

Closes espressif#895

* ci: Add DangerJS checks to GL and GH

* feat(esptool): Add PICO package for ESP32S3 and flash/psram efuses

* feat(esptool): Add tests for get_chip_features

* feat(esptool): Add new packages for ESP32C3 and flash efuses

* fix(expand file args): Correctly print the expanded command

* feat(espsecure): Allow prompting for HSM PIN in read_hsm_config

If hsm_config does not contain "credentials" the user will be
prompted for the HSM PIN.

This avoids the need to have HSM PINs typed in config files
which is not a good security practice.

ADJUNCT: Updated documentation to reflect new usage

Closes espressif#900

* fix(dangerGH): Update token permissions - allow Danger to add comments to PR

* fix(elf2image): fix text/rodata mapping overlap issue on uni-idrom bus chips

* fix: assert in esp32 exclusive workaround

* docs: Add other resources page

* fix(autodetection): Remove the ESP32-S2 ROM class from get_security_info autodetection

* change(pre-commit): Bump version conventional-precommit-linter to 1.2.1

* feat(esptool): added target to esp32p4

* feat(espefuse): Add support for esp32p4 chip

* fix: Fix redirection of STDOUT

Closes espressif#904

* fix(danger-github): Fir Danger GitHub token permission

* ci(danger-github): Fix github-action-bot permissions for posting Danger output

* ci: Shared danger to local stage (remove possible double CI pipelines)

* ci: add 'flake8-import-order' as a dependecy to flake8

* fix(bin_image): Check only ELF sections when searching for .flash.appdesc

Closes espressif#917

* feat(efuse): ESP32P4 adds ecdsa_key support

* feat(efuse): Update key purpose table and tests

* feat(esp32-s3): Support >16MB quad flash chips

Adds support for the W25Q256 and GD25Q256 flash chips.

Closes espressif#883

* ci(dev_release): Upload dev releases to PyPI with GH Actions

* ci: fix pipeline for building docs

* feat(merge_bin): add support for uf2 format

* feat(esp32c3): Support ECO6 and ECO7 magic numbers

* ci(gitlab_ci): Change only/except syntax to rules

* fix(flasher_stub): fix usb-serial-jtag enabled non-related intr source

* fix(loader): Could not open serial port message adjusted

* ci(gitlab): Fix deploying docs to production

* ci(github): Fix pyinstaller builds on ubuntu

* docs(basic-commands): added note for PowerShell users for merge_bin command

Closes espressif#923

* feat: Add support for Python 3.12

* feat(loader): Added hints for some serial port issues when rising port error

Closes espressif/esp-idf#12366

* feat: add support for get_security_info on esp32c3 ECO7

* docs(troubleshooting): Explain issues when flashing with USB-Serial/JTAG or USB-OTG

Closes espressif#924

* feat(espefuse): Update the way to complete the operation

* docs(boot_mode_selection): Correct secondary strapping pin boot mode levels

Closes espressif#928

* feat(espefuse): Adds efuse ADC calibration data for ESP32H2

* feat(rfc2217_server): Add hard reset sequence

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

* feat(esp32p4): Stub flasher support

* refactor(stub_flasher): Cleanup, make adding new targets easier

* feat: add support for intel hex format

---------

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Signed-off-by: Marek Matej <marek.matej@espressif.com>
Signed-off-by: Almir Okato <almir.okato@espressif.com>
Co-authored-by: harshal.patil <harshal.patil@espressif.com>
Co-authored-by: radim.karnis <radim.karnis@espressif.com>
Co-authored-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Co-authored-by: Peter Dragun <peter.dragun@espressif.com>
Co-authored-by: KonstantinKondrashov <konstantin@espressif.com>
Co-authored-by: Faidon Liambotis <paravoid@debian.org>
Co-authored-by: XiNGRZ <hi@xingrz.me>
Co-authored-by: Marius Vikhammer <marius.vikhammer@espressif.com>
Co-authored-by: hasheddan <georgedanielmangum@gmail.com>
Co-authored-by: Roland Dobai <roland@espressif.com>
Co-authored-by: Trent Piepho <tpiepho@gmail.com>
Co-authored-by: Dean Gardiner <me@dgardiner.net>
Co-authored-by: Massimiliano Montagni <massimiliano@solutiontech.tech>
Co-authored-by: Tomas Sebestik <tomas.sebestik@espressif.com>
Co-authored-by: Aditya Patwardhan <aditya.patwardhan@espressif.com>
Co-authored-by: Richard Retanubun <richard.retanubun@mmbnetworks.com>
Co-authored-by: wuzhenghui <wuzhenghui@espressif.com>
Co-authored-by: Armando <douyiwen@espressif.com>
Co-authored-by: Jakub Kocka <jakub.kocka@espressif.com>
Co-authored-by: 20162026 <36726858+20162026@users.noreply.github.com>
Co-authored-by: Almir Okato <almir.okato@espressif.com>
Jason2866 added a commit to Jason2866/esptool that referenced this issue Nov 7, 2023
* docs: espsecure remote signing using a HSM broken link fix

* fix(rfc2217_server): Use new reset sequences

* fix(ESP32-S3): Lower CPU freq to improve flasher stub stability

Closes espressif#832

* fix: Unknown chip (ID or magic number) error

* pyinstaller: fix glibc dependency on gnu/linux

pyinstaller package for linux is built within the ubuntu-latest image in
github workflow. This may cause prbolem with glibc symbol versions on
older distributions, where the new symbol versions are not available.
Fix this by building on the older ubuntu version.

Closes espressif#843

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>

* tests: Create custom `host_test` marker for tests without real chip connected

Closes espressif#838

* fix(ESP32-S3): Temporarily disable increasing CPU freq

Related to espressif#848

Related to espressif#842

* build: add esp_rfc2217_server to published scripts

Closes espressif#846

* Update version to v4.5.1

* Update version to v4.6-dev

* espefuse: Hide sensitive info by default during burning burn_key and burn_key_digest

Adds --show-sensitive-info flag for two commands:
burn_key and burn_key_digest.

* flasher_stub: pass -mabi=ilp32 to the RISC-V compiler

This is a no-op change for the upstream toolchain (compiled stubs are
binary identical), but is required when building with Debian's
riscv64-unknown-elf-gcc compiler.

* flasher_stub: allow passing extra CFLAGS

The flasher_stub Makefile allows for some system-local configuration,
either through local.mk, or through environment variables.

For example, the compiler prefix can be overridden, by defining e.g.
CROSS_ESPRISCV32. However, passing additional flags to the compiler
isn't possible right now. Add EXTRA_CFLAGS and EXTRA_CFLAGS_ESPRISCV32
to allow for that option.

* flasher_stub: collect all targets at the top, DRY

* flasher_stub: make target selection more modular

Rather than a special "make esp32", create WITHOUT_* variables to
selectively disable chip families. Currently, WITHOUT_ESP8266,
WITHOUT_ESP32_XTENSA and WITHOUT_ESP32_RISCV32 are defined, but the code
can be easily adjusted to allow for all kinds of other
sets/combinations.

* flasher_stub: create %.json targets, make all a proper PHONY

* flasher_stub: drop --embed from wrap_stub.py

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.

* espefuse: Support burning ECDSA_KEY from pem file

- fix some assert check in test_espefuse.py
- add tests to cover the new functionality

* espefuse(c2): Fix BLOCK_KEY0 view for summary cmd when SB + FE keys are burnt

For C2 secure boot + flash enc block, we saw that in summary cmd
"0's" from secure boot digest part (upper 128 bit) were translated
into "?'s" when the block was read protected.
For C2, we should apply this translation for lower 128 bits only.

* fix(ESP32-C6): Fix get_pkg_version and get_{major,minor}_chip_version

* image_info: removed check that reserved bytes in image header are zero

IDF may start using parts of the reserved bytes in the extended header at any time,
which will break chip auto-detect in image_info.

* build: limit max cryptography version to 40

* fix: Set flash parameters even with --flash_size keep

Related to espressif/esp-idf#10788

Related to espressif/esp-idf#10959

* build: add arm and arm64 as build target

Closes espressif#845

* Fix typo in serial protocol docs

Fixes misspelling of `triggered` in serial protocol docs.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>

* Support more recent reedsolo packages

- https://github.com/tomerfiliba-org/reedsolomon/releases/tag/v1.6.1 - this seems to be related to licenses only.
- https://github.com/tomerfiliba-org/reedsolomon/releases/tag/v1.7.0 - this is related to installation.

Closes espressif#872

* build(arm): add pip extra url for github action build

* ci: Fix libffi symlinks for cryptography>=40

* espefuse: Prevent burning XTS_AES and ECDSA keys into BLOCK9 (BLOCK_KEY5)

eFuse module has a hardware bug.
It is related to ESP32-C3, C6, S3, H2 chips:
    - BLOCK9 (BLOCK_KEY5) can not be used by XTS_AES keys.
For H2 chips, the BLOCK9 (BLOCK_KEY5) can not be used by ECDSA keys.
S2 does not have such a hardware bug.

* image_info: Display disabled WP pin as disabled

The image formats know about the special value 0xee used to disable WP.
Display this with image_info.

E.g.:

ESP32-C3 extended image header
==============================
WP pin: 0xee (disabled)

* image_info: Print chip ID's name if known

Example:

Flash pins drive settings: clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0
Chip ID: 5 (ESP32-C3)
Minimal chip revision: v0.0, (legacy min_rev = 0)
Maximal chip revision: v655.35

An unknown ID will be printed as:

Chip ID: 42 (Unknown ID)

* tests: Make the testsuite Windows compatible

* espefuse: Adds external esp instance

Closes espressif#873

* espefuse: Improve efuse error viewing

* espefuse: Explicit setting of efuse time settings

EFUSE_PWR_ON_NUM in C3 has default value = 0x2880, now = 0x3000

* docs(Boot log): Add all esp targets to cover boot troubleshooting

Closes espressif#732

* fix: USB-JTAG-Serial PID detection error

* esptool: Move bootdesc on the top of the ram segment

* espefuse: Move some vars under init method to speedup tool after adding yaml support

* espefuse: Adds yaml efuse description files for all chip

- esptool: Updates eFuses wafer major&minor versions
- esptool(esp32c6): Adds package versions
- espefuse(esp32c6): Replace PKG_VERSION BLK_VERSION_MINOR BLK_VERSION_MAJOR
- espefuse(esp32c6): Adds adc calib efuses
- espefuse: Adds yaml files for Build with PyInstaller

* efuse(H2): Adds RF Calibration Information

* espsecure: Improve error message for incorrect PEM format

Closes espressif#881

* bugfix(usb_jtag_serial): Autofeed super watchdog (SWD) to avoid resets during flashing

* esptool: Read 64-bit MAC address on C6 and H2

* bugfix: Adjust wrapper scripts to not import themselves

* bugfix(espsecure): Print a clear error message if incompatible OpenSSL backend is used

Closes espressif#878

* fix: inconsistent usage of dirs separator

* feat(esptool): add option to dump whole flash based on detected size

Closes espressif#461

* Update version to v4.6

* Update version to v4.7-dev

* fix(ESP32-S3): Correct RTC WDT registers to fix resets during flashing

* Update version to v4.6.1

* Update version to v4.7-dev

* docs: add explanation for flash_id example to avoid confusion

* docs(boot-log): fix list formatting

* docs: add c2, c6 and h2 as build targets

* fix(compressed upload): Accept short data blocks with only Adler-32 bytes

* fix(CH9102F): Suggest to install new serial drivers if writing to RAM fails

* esptool & espefuse: Fix byte order in MAC (for C6 and H2)

MAC: 60:55:f9:ff:fe:f7:2c:a2 (EUI64, used for IEEE802154)
BASE MAC: 60:55:f9:f7:2c:a2 (used for BT)
MAC_EXT: ff:fe

* Update version to v4.6.2

* Update version to v4.7

* change: Add conventional precommit linter

* ci(pre-commit): Update version of `conventional-precommit-linter`

* feat(get_security_info): Improved the output format and added more
details

* fix(esp32-c2): Enable flashing in secure download mode

Closes espressif#895

* ci: Add DangerJS checks to GL and GH

* feat(esptool): Add PICO package for ESP32S3 and flash/psram efuses

* feat(esptool): Add tests for get_chip_features

* feat(esptool): Add new packages for ESP32C3 and flash efuses

* fix(expand file args): Correctly print the expanded command

* feat(espsecure): Allow prompting for HSM PIN in read_hsm_config

If hsm_config does not contain "credentials" the user will be
prompted for the HSM PIN.

This avoids the need to have HSM PINs typed in config files
which is not a good security practice.

ADJUNCT: Updated documentation to reflect new usage

Closes espressif#900

* fix(dangerGH): Update token permissions - allow Danger to add comments to PR

* fix(elf2image): fix text/rodata mapping overlap issue on uni-idrom bus chips

* fix: assert in esp32 exclusive workaround

* docs: Add other resources page

* fix(autodetection): Remove the ESP32-S2 ROM class from get_security_info autodetection

* change(pre-commit): Bump version conventional-precommit-linter to 1.2.1

* feat(esptool): added target to esp32p4

* feat(espefuse): Add support for esp32p4 chip

* fix: Fix redirection of STDOUT

Closes espressif#904

* fix(danger-github): Fir Danger GitHub token permission

* ci(danger-github): Fix github-action-bot permissions for posting Danger output

* ci: Shared danger to local stage (remove possible double CI pipelines)

* ci: add 'flake8-import-order' as a dependecy to flake8

* fix(bin_image): Check only ELF sections when searching for .flash.appdesc

Closes espressif#917

* feat(efuse): ESP32P4 adds ecdsa_key support

* feat(efuse): Update key purpose table and tests

* feat(esp32-s3): Support >16MB quad flash chips

Adds support for the W25Q256 and GD25Q256 flash chips.

Closes espressif#883

* ci(dev_release): Upload dev releases to PyPI with GH Actions

* ci: fix pipeline for building docs

* feat(merge_bin): add support for uf2 format

* feat(esp32c3): Support ECO6 and ECO7 magic numbers

* ci(gitlab_ci): Change only/except syntax to rules

* fix(flasher_stub): fix usb-serial-jtag enabled non-related intr source

* fix(loader): Could not open serial port message adjusted

* ci(gitlab): Fix deploying docs to production

* ci(github): Fix pyinstaller builds on ubuntu

* docs(basic-commands): added note for PowerShell users for merge_bin command

Closes espressif#923

* feat: Add support for Python 3.12

* feat(loader): Added hints for some serial port issues when rising port error

Closes espressif/esp-idf#12366

* feat: add support for get_security_info on esp32c3 ECO7

* docs(troubleshooting): Explain issues when flashing with USB-Serial/JTAG or USB-OTG

Closes espressif#924

* feat(espefuse): Update the way to complete the operation

* docs(boot_mode_selection): Correct secondary strapping pin boot mode levels

Closes espressif#928

* feat(espefuse): Adds efuse ADC calibration data for ESP32H2

* feat(rfc2217_server): Add hard reset sequence

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

* feat(esp32p4): Stub flasher support

* refactor(stub_flasher): Cleanup, make adding new targets easier

* feat: add support for intel hex format

* feat(xip_psram): support xip psram feature on esp32p4

Expanded IROM / DROM range to include psram space as well

* Delete docs directory

* Delete .gitlab-ci.yml

* Delete .pre-commit-config.yaml

* Delete MANIFEST.in

* Update build_esptool.yml

* Delete .github/workflows/test_esptool.yml

---------

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Signed-off-by: Marek Matej <marek.matej@espressif.com>
Signed-off-by: Almir Okato <almir.okato@espressif.com>
Co-authored-by: harshal.patil <harshal.patil@espressif.com>
Co-authored-by: radim.karnis <radim.karnis@espressif.com>
Co-authored-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Co-authored-by: Peter Dragun <peter.dragun@espressif.com>
Co-authored-by: KonstantinKondrashov <konstantin@espressif.com>
Co-authored-by: Faidon Liambotis <paravoid@debian.org>
Co-authored-by: XiNGRZ <hi@xingrz.me>
Co-authored-by: Marius Vikhammer <marius.vikhammer@espressif.com>
Co-authored-by: hasheddan <georgedanielmangum@gmail.com>
Co-authored-by: Roland Dobai <roland@espressif.com>
Co-authored-by: Trent Piepho <tpiepho@gmail.com>
Co-authored-by: Dean Gardiner <me@dgardiner.net>
Co-authored-by: Massimiliano Montagni <massimiliano@solutiontech.tech>
Co-authored-by: Tomas Sebestik <tomas.sebestik@espressif.com>
Co-authored-by: Aditya Patwardhan <aditya.patwardhan@espressif.com>
Co-authored-by: Richard Retanubun <richard.retanubun@mmbnetworks.com>
Co-authored-by: wuzhenghui <wuzhenghui@espressif.com>
Co-authored-by: Armando <douyiwen@espressif.com>
Co-authored-by: Jakub Kocka <jakub.kocka@espressif.com>
Co-authored-by: 20162026 <36726858+20162026@users.noreply.github.com>
Co-authored-by: Almir Okato <almir.okato@espressif.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants