Skip to content

Add esptool backend the ESP32-C3, switch to XIP flash layout - #149

Open
lschuermann wants to merge 2 commits into
masterfrom
dev/esp32-c3-esptool
Open

lschuermann wants to merge 2 commits into
masterfrom
dev/esp32-c3-esptool

Conversation

@lschuermann

Copy link
Copy Markdown
Member

As the title says, this:

  • switches the ESP32-C3's addresses to the ones used by the kernel after boards/esp32-c3: switch to fast XIP flash tock#5260 is merged,
  • adds esptool support which can read and write the chip's external SPI flash, adding native support for both chip discovery and modifying Tock's app list.

@bradjc bradjc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separation between connecting and entering the bootloader is a little messy, but, it doesn't matter that much.

Comment thread tockloader/esptool.py
Comment on lines +49 to +60
"""
Import esptool lazily, such that it is only required for users of this
channel.
"""
try:
import esptool.cmds
from esptool.logger import log
except ImportError:
raise TockLoaderException(
"Tockloader esptool support requires esptool >= 5.0. "
"Install it with `pip install esptool`."
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just install it with the package. There is nothing worse than using a tool and then having it tell you you need to install its dependencies for it when it could have just done it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense! I guess I was defaulting to the way the nRF tools work given they're proprietary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, esptool is GPL-2.0 and Tockloader is MIT, so we couldn't re-distribute a bundle if we add it as a required dependency. 😒

@lschuermann

Copy link
Copy Markdown
Member Author

The separation between connecting and entering the bootloader is a little messy, but, it doesn't matter that much.

Yeah, I don't know how to improve it given those are inherently the same thing with the ESP's bootloader.

This adds a Tockloader `BoardInterface` implementation that uses the
Python API of `esptool` to read and write the external SPI flash of
Espressif chips through their ROM serial bootloader. It keeps a single
connection to the chip open for each Tockloader command, which avoids a
chip reset and flasher stub upload for every flash read. `esptool` is
imported lazily, such that it is only required for users of this
backend. This requires `esptool` >= 5.0.

Tockloader uses this backend when passed `--esptool`. Otherwise, it
probes serial ports with Espressif's USB VID or a USB-UART bridge
commonly found on Espressif development kits, and only selects this
backend when `esptool` reports a supported chip on that port. This
probing runs before the serial bootloader probing, which would otherwise
claim the chip's serial port.

This also switches the ESP32-C3-DevKitM-1 board definition to the XIP
flash layout introduced in tock/tock#5260, with the kernel mapped at
0x42000000 and apps starting at 0x42040000. The previous layout, which
had the ROM bootloader copy the kernel into SRAM, is no longer
supported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants