Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Flash Autodetect and Bootloader patching #23

Merged
merged 9 commits into from
Jun 22, 2021

Conversation

conradopoole
Copy link
Collaborator

@conradopoole conradopoole commented Jun 22, 2021

  • Added commands to autodetect flash size mimicking what esptool.py does. It is called automatically after the stub is run.

  • Added bootloader patching on the fly of the flash parameters in the header bytes of the bootloader. In this iteration Flash Mode is always set to DIO and Flash Frequency to 40m. Flash Size is set to the autodetected value, if any, otherwise 4MB. The code checks for a magic bytes that indicate the image being flashed is a bootloader.

  • Replaced chip detection with reading form CHIP_DETECT_MAGIC_REG_ADDR register which is the way esptool.py does it currently.

To be added in the future:

  1. Being able to pass FlashMode and FlashFrequency to flashData so that defaults DIO and 40m can be overridden. ESP-Web-tools would have to be able to pass these in some sort advanced mode? Otherwise there might be boards that cannot be flashed because those settings must be in the bootloader.

  2. Esptool.py does one additional check to make sure the image being flashed is in fact a boot loader, just in case by chance a normal user image starts with the "magic header". This is pretty complex code and according to their comments it is a rare occurrence anyway, only more frequent when flashing encrypted images which eep-web-flasher does not support (yet, maybe ever).

- Added commands to autodetect flash size mimicking what esptool.py does. It is called automatically after the stub is run.

- Added bootloader patching on the fly of the flash parameters in the header bytes of the bootloader. In this iteration Flash Mode is always set to DIO and Flash Frequency to 40m. Flash Size is set to the autodetected value, if any, otherwise 4MB. The code checks for a magic bytes that indicate the image being flashed is a bootloader.
Replaced chip detection with reading form CHIP_DETECT_MAGIC_REG_ADDR register which is the way esptool.py does it currently.
src/const.ts Outdated Show resolved Hide resolved
src/esp_loader.ts Outdated Show resolved Hide resolved
src/esp_loader.ts Outdated Show resolved Hide resolved
src/esp_loader.ts Outdated Show resolved Hide resolved
src/esp_loader.ts Outdated Show resolved Hide resolved
src/esp_loader.ts Outdated Show resolved Hide resolved
conradopoole and others added 2 commits June 22, 2021 23:21
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
conradopoole and others added 2 commits June 22, 2021 23:23
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
@balloob balloob linked an issue Jun 22, 2021 that may be closed by this pull request
conradopoole and others added 2 commits June 22, 2021 23:25
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
@balloob balloob merged commit 0d55ce1 into NabuCasa:main Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect more chip families
2 participants