|
| 1 | +# ESP32 driver |
| 2 | + |
| 3 | +`jumpstarter-driver-esp32` provides functionality for flashing, monitoring, and controlling ESP32 devices using esptool and serial communication. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```{code-block} console |
| 8 | +:substitutions: |
| 9 | +$ pip3 install --extra-index-url {{index_url}} jumpstarter-driver-esp32 |
| 10 | +``` |
| 11 | + |
| 12 | +## Configuration |
| 13 | + |
| 14 | +Example configuration: |
| 15 | + |
| 16 | +```yaml |
| 17 | +export: |
| 18 | + esp32: |
| 19 | + type: jumpstarter_driver_esp32.driver.ESP32 |
| 20 | + config: |
| 21 | + port: "/dev/ttyUSB0" |
| 22 | + baudrate: 115200 |
| 23 | + chip: "esp32" |
| 24 | + # Optional GPIO pins for hardware control |
| 25 | + # reset_pin: 2 |
| 26 | + # boot_pin: 0 |
| 27 | +``` |
| 28 | + |
| 29 | +### Config parameters |
| 30 | + |
| 31 | +| Parameter | Description | Type | Required | Default | |
| 32 | +| ------------- | --------------------------------------------------------------------- | ---- | -------- | ------- | |
| 33 | +| port | The serial port to connect to the ESP32 | str | yes | | |
| 34 | +| baudrate | The baudrate for serial communication | int | no | 115200 | |
| 35 | +| chip | The ESP32 chip type (esp32, esp32s2, esp32s3, esp32c3, etc.) | str | no | esp32 | |
| 36 | +| reset_pin | GPIO pin number for hardware reset (if connected) | int | no | null | |
| 37 | +| boot_pin | GPIO pin number for boot mode control (if connected) | int | no | null | |
| 38 | +| check_present | Check if the serial port exists during exporter initialization | bool | no | True | |
| 39 | + |
| 40 | +## API Reference |
| 41 | + |
| 42 | +```{eval-rst} |
| 43 | +.. autoclass:: jumpstarter_driver_esp32.client.ESP32Client() |
| 44 | + :members: chip_info, reset, erase_flash, flash_firmware, flash_firmware_file, read_flash, enter_bootloader |
| 45 | +``` |
| 46 | + |
| 47 | +### CLI |
| 48 | + |
| 49 | +The ESP32 driver client comes with a CLI tool that can be used to interact with ESP32 devices: |
| 50 | + |
| 51 | +``` |
| 52 | +jumpstarter ⚡ local ➤ j esp32 |
| 53 | +Usage: j esp32 [OPTIONS] COMMAND [ARGS]... |
| 54 | +
|
| 55 | + ESP32 client |
| 56 | +
|
| 57 | +Options: |
| 58 | + --help Show this message and exit. |
| 59 | +
|
| 60 | +Commands: |
| 61 | + bootloader Enter bootloader mode |
| 62 | + chip-id Get chip ID information |
| 63 | + erase Erase the entire flash |
| 64 | + flash Flash firmware to the device |
| 65 | + info Get device information |
| 66 | + read-flash Read flash contents |
| 67 | + reset Reset the device |
| 68 | +``` |
| 69 | + |
| 70 | +## Examples |
| 71 | + |
| 72 | +### Getting device information |
| 73 | + |
| 74 | +```{testcode} |
| 75 | +:skipif: True |
| 76 | +info = esp32.chip_info() |
| 77 | +print(f"Connected to {info['chip_revision']}") |
| 78 | +print(f"MAC Address: {info['mac_address']}") |
| 79 | +print(f"Chip ID: {info['chip_id']}") |
| 80 | +``` |
| 81 | + |
| 82 | +### Flashing firmware |
| 83 | + |
| 84 | +```{testcode} |
| 85 | +:skipif: True |
| 86 | +# Flash firmware from a local file |
| 87 | +result = esp32.flash_firmware_file("firmware.bin", address=0x10000) |
| 88 | +print(result) |
| 89 | +``` |
| 90 | + |
| 91 | +### Reading flash contents |
| 92 | + |
| 93 | +```{testcode} |
| 94 | +:skipif: True |
| 95 | +# Read 1024 bytes from address 0x0 |
| 96 | +data = esp32.read_flash(address=0x0, size=1024) |
| 97 | +print(f"Read {len(data)} bytes from flash") |
| 98 | +``` |
| 99 | + |
| 100 | +### Device control |
| 101 | + |
| 102 | +```{testcode} |
| 103 | +:skipif: True |
| 104 | +# Reset the device |
| 105 | +result = esp32.reset() |
| 106 | +
|
| 107 | +# Enter bootloader mode |
| 108 | +result = esp32.enter_bootloader() |
| 109 | +
|
| 110 | +# Erase entire flash |
| 111 | +result = esp32.erase_flash() |
| 112 | +``` |
| 113 | + |
| 114 | +### CLI Examples |
| 115 | + |
| 116 | +```{code-block} console |
| 117 | +# Get device information |
| 118 | +$ j esp32 info |
| 119 | +
|
| 120 | +# Flash firmware to default app partition (0x10000) |
| 121 | +$ j esp32 flash firmware.bin |
| 122 | +
|
| 123 | +# Flash firmware to specific address |
| 124 | +$ j esp32 flash firmware.bin --address 0x1000 |
| 125 | +
|
| 126 | +# Read flash contents |
| 127 | +$ j esp32 read-flash 0x0 1024 |
| 128 | +
|
| 129 | +# Save flash contents to file |
| 130 | +$ j esp32 read-flash 0x0 1024 --output flash_dump.bin |
| 131 | +
|
| 132 | +# Reset the device |
| 133 | +$ j esp32 reset |
| 134 | +
|
| 135 | +# Erase the entire flash |
| 136 | +$ j esp32 erase |
| 137 | +``` |
0 commit comments