|
| 1 | +import time |
| 2 | +import board |
| 3 | +import busio |
| 4 | + |
| 5 | +from digitalio import DigitalInOut, Direction # pylint: disable=unused-import |
| 6 | +import adafruit_miniesptool |
| 7 | + |
| 8 | +print("ESP32 mini prog") |
| 9 | + |
| 10 | + |
| 11 | +# With a Metro or Feather M4 |
| 12 | +#uart = busio.UART(TX, RX, baudrate=115200, timeout=1) |
| 13 | +#resetpin = DigitalInOut(board.D5) |
| 14 | +#gpio0pin = DigitalInOut(board.D6) |
| 15 | + |
| 16 | +# With a Particle Argon, we need to also turn off flow control |
| 17 | +uart = busio.UART(board.ESP_RX, board.ESP_TX, baudrate=115200, timeout=1) |
| 18 | +resetpin = DigitalInOut(board.ESP_WIFI_EN) |
| 19 | +gpio0pin = DigitalInOut(board.ESP_BOOT_MODE) |
| 20 | +esp_cts = DigitalInOut(board.ESP_CTS) |
| 21 | +esp_cts.direction = Direction.OUTPUT |
| 22 | +esp_cts.value = False |
| 23 | + |
| 24 | +esptool = adafruit_miniesptool.miniesptool(uart, gpio0pin, resetpin, |
| 25 | + flashsize=4*1024*1024) |
| 26 | +esptool.debug = False |
| 27 | + |
| 28 | +esptool.sync() |
| 29 | +print("Synced") |
| 30 | +print("Found:", esptool.chip_name) |
| 31 | +if esptool.chip_name != "ESP32": |
| 32 | + raise RuntimeError("This example is for ESP32 only") |
| 33 | +esptool.baudrate = 912600 |
| 34 | +print("MAC ADDR: ", [hex(i) for i in esptool.mac_addr]) |
| 35 | + |
| 36 | +# 0x10000 ota_data_initial.bin |
| 37 | +esptool.flash_file("esp32/ota_data_initial.bin", 0x10000, |
| 38 | + '84d04c9d6cc8ef35bf825d51a5277699') |
| 39 | + |
| 40 | +# 0x1000 bootloader/bootloader.bin |
| 41 | +esptool.flash_file("esp32/bootloader/bootloader.bin", 0x1000, |
| 42 | + '195dae16eda6ab703a45928182baa863') |
| 43 | +# 0x20000 at_customize.bin |
| 44 | +esptool.flash_file("esp32/at_customize.bin", 0x20000, |
| 45 | + '9853055e077ba0c90cd70691b9d8c3d5') |
| 46 | + |
| 47 | +# 0x24000 customized_partitions/server_cert.bin |
| 48 | +esptool.flash_file("esp32/customized_partitions/server_cert.bin", 0x24000, |
| 49 | + '766fa1e87aabb9ab78ff4023f6feb4d3') |
| 50 | + |
| 51 | +# 0x26000 customized_partitions/server_key.bin |
| 52 | +esptool.flash_file("esp32/customized_partitions/server_key.bin", 0x26000, |
| 53 | + '05da7907776c3d5160f26bf870592459') |
| 54 | + |
| 55 | +# 0x28000 customized_partitions/server_ca.bin |
| 56 | +esptool.flash_file("esp32/customized_partitions/server_ca.bin", 0x28000, |
| 57 | + 'e0169f36f9cb09c6705343792d353c0a') |
| 58 | + |
| 59 | +# 0x2a000 customized_partitions/client_cert.bin |
| 60 | +esptool.flash_file("esp32/customized_partitions/client_cert.bin", 0x2a000, |
| 61 | + '428ed3bae5d58b721b8254cbeb8004ff') |
| 62 | + |
| 63 | +# 0x2c000 customized_partitions/client_key.bin |
| 64 | +esptool.flash_file("esp32/customized_partitions/client_key.bin", 0x2c000, |
| 65 | + '136f563811930a5d3bf04c946f430ced') |
| 66 | + |
| 67 | +# 0x2e000 customized_partitions/client_ca.bin |
| 68 | +esptool.flash_file("esp32/customized_partitions/client_ca.bin", 0x2e000, |
| 69 | + '25ab638695819daae67bcd8a4bfc5626') |
| 70 | + |
| 71 | +# 0xf000 phy_init_data.bin |
| 72 | +esptool.flash_file("esp32/phy_init_data.bin", 0xf000, |
| 73 | + 'bc9854aa3687ca73e25d213d20113b23') |
| 74 | + |
| 75 | +# 0x100000 esp-at.bin |
| 76 | +esptool.flash_file("esp32/esp-at.bin", 0x100000, |
| 77 | + 'ae256e4ab546354cd8dfa241e1056996') |
| 78 | + |
| 79 | +# 0x8000 partitions_at.bin |
| 80 | +esptool.flash_file("esp32/partitions_at.bin", 0x8000, |
| 81 | + 'd3d1508993d61aedf17280140fc22a6b') |
| 82 | + |
| 83 | +esptool.reset() |
| 84 | +time.sleep(0.5) |
0 commit comments