miniesptool_simpletest.py
1 import time 2 import board 3 import busio 4 from digitalio import DigitalInOut, Direction # pylint: disable=unused-import 5 import adafruit_miniesptool 6 7 print("ESP32 Nina-FW") 8 9 # Override these if you are manually wiring. Otherwise, this will use ESP pins from board. 10 tx = getattr(board, "ESP_TX", board.TX) 11 rx = getattr(board, "ESP_RX", board.RX) 12 resetpin = getattr(board, "ESP_RESET", board.D12) 13 gpio0pin = getattr(board, "ESP_GPIO0", board.D10) 14 15 uart = busio.UART(tx, rx, baudrate=115200, timeout=1) 16 17 esptool = adafruit_miniesptool.miniesptool( 18 uart, DigitalInOut(gpio0pin), DigitalInOut(resetpin), flashsize=4 * 1024 * 1024 19 ) 20 esptool.sync() 21 22 print("Synced") 23 print("Found:", esptool.chip_name) 24 if esptool.chip_name != "ESP32": 25 raise RuntimeError("This example is for ESP32 only") 26 esptool.baudrate = 912600 27 print("MAC ADDR: ", [hex(i) for i in esptool.mac_addr]) 28 29 # Note: Make sure to use the LATEST nina-fw binary release! 30 esptool.flash_file("NINA_W102-1.6.1.bin", 0x0, "0326db53e579f8a4293feac70d00f6bb") 31 32 esptool.reset() 33 time.sleep(0.5)