Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions contrib/loaders/flash/esp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ESP32 Stubs

These are small bits of code that run on the ESP32 to facilitate OpenOCD operation on the chip. The generated `.inc` files ind these directories are included in the final `openocd` binary, but these `.inc` files need to be generated separately.

## Building Stubs

The stubs use a specific build of ESP-IDF. Look at at the `stub_flasher_image.h` file for the `ESP32*_STUB_BUILD_IDF_REV` comment to find the ESP-IDF SHA that you need to use to build the stub. The process for each chip (e.g. esp32, esp32s3, etc) is roughly the same, though the stubs may use different versions of IDF. The process is:

1. Download the git repo for the ESP-IDF version.
```bash
git clone https://github.com/espressif/esp-idf.git
```

2. Checkout the right version of ESP-IDF based on the comment in `stub_flasher_image.h` for your target chip (e.g. `036bd3eb26` from `esp32s3/stub_flasher_image.h`)
```bash
cd esp-idf
git checkout 036bd3eb26 # or whatever the SHA is
git submodule update --init --recursive
```

3. Set up the ESP-IDF environment
```bash
./install.sh
source export.sh
```

4. Go back to your `openocd-esp32` directory and build the stub for your target chip
```bash
cd ../openocd-esp32/contrib/loaders/flash/esp/esp32s3
```

5. Build the stub
```bash
make
```

6. Now you can go through the normal OpenOCD build process, and the stub will be included in the final binary.
4 changes: 2 additions & 2 deletions contrib/loaders/flash/esp/esp32/stub_flasher_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
6 changes: 3 additions & 3 deletions contrib/loaders/flash/esp/esp32c2/stub_flasher_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
0x72, 0x13, 0x38, 0x40, 0x7a, 0x13, 0x38, 0x40, 0x48, 0x13, 0x38, 0x40,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
4 changes: 2 additions & 2 deletions contrib/loaders/flash/esp/esp32c3/stub_flasher_code.inc
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@
0xfd, 0x54, 0xe9, 0xb7, 0x93, 0x77, 0x34, 0x00, 0xfd, 0xd7, 0x71, 0x98,
0x6d, 0xf4, 0x8d, 0x47, 0xe3, 0xe8, 0x37, 0xff, 0xa1, 0x67, 0x61, 0x74,
0xc1, 0x07, 0x71, 0x14, 0x8a, 0x97, 0x3e, 0x94, 0x11, 0x46, 0xa2, 0x85,
0x33, 0x05, 0x59, 0x01, 0x15, 0x3e, 0x79, 0xf9, 0x4e, 0x85, 0xef, 0xf0,
0x33, 0x85, 0x2a, 0x01, 0x15, 0x3e, 0x79, 0xf9, 0x4e, 0x85, 0xef, 0xf0,
0x0f, 0xcc, 0xaa, 0x84, 0x71, 0xd5, 0x4e, 0x86, 0xa2, 0x85, 0x97, 0xf0,
0xc7, 0xff, 0xe7, 0x80, 0x20, 0x77, 0x26, 0x85, 0xef, 0xf0, 0x8f, 0xc5,
0x45, 0xfd, 0xef, 0xf0, 0xaf, 0xc0, 0xaa, 0x84, 0x35, 0xdd, 0x7d, 0xb7,
0xaa, 0x85, 0x22, 0x86, 0x33, 0x05, 0x59, 0x01, 0x01, 0x36, 0xaa, 0x89,
0xaa, 0x85, 0x22, 0x86, 0x33, 0x85, 0x2a, 0x01, 0x01, 0x36, 0xaa, 0x89,
0x5a, 0x85, 0xef, 0xf0, 0xaf, 0xc3, 0x33, 0xe5, 0xa9, 0x00, 0x59, 0xf9,
0x22, 0x99, 0xef, 0xf0, 0x6f, 0xbe, 0x39, 0xd9, 0x71, 0xb7, 0xb7, 0x47,
0xc8, 0x3f, 0x83, 0xc6, 0x07, 0x30, 0x3e, 0x87, 0xb9, 0xca, 0xb7, 0x97,
Expand Down
6 changes: 3 additions & 3 deletions contrib/loaders/flash/esp/esp32c3/stub_flasher_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
0x68, 0x12, 0x38, 0x40, 0x6e, 0x12, 0x38, 0x40, 0x9a, 0x13, 0x38, 0x40,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
6 changes: 3 additions & 3 deletions contrib/loaders/flash/esp/esp32s2/stub_flasher_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
0x48, 0x16, 0x03, 0x40, 0x99, 0x17, 0x03, 0x40, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
6 changes: 3 additions & 3 deletions contrib/loaders/flash/esp/esp32s3/stub_flasher_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
0x90, 0x17, 0x3b, 0x40, 0x9b, 0x17, 0x3b, 0x40, 0xf1, 0x18, 0x3b, 0x40,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
4 changes: 4 additions & 0 deletions contrib/loaders/flash/esp/stub_flasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,10 @@ static uint32_t stub_flash_get_size(void)
case 0x16: size = 4 * 1024 * 1024; break;
case 0x17: size = 8 * 1024 * 1024; break;
case 0x18: size = 16 * 1024 * 1024; break;
case 0x19: size = 32 * 1024 * 1024; break;
case 0x20: size = 64 * 1024 * 1024; break;
case 0x21: size = 128 * 1024 * 1024; break;
case 0x22: size = 256 * 1024 * 1024; break;
case 0x39: size = 32 * 1024 * 1024; break;
default:
size = 0;
Expand Down