Skip to content

Commit 3ac05df

Browse files
committed
found esp32 programming bug causing OSError.
See adafruit/Adafruit_CircuitPython_miniesptool#9 for details.
1 parent b8fd112 commit 3ac05df

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

firmware/esp32_firmware/adafruit_miniesptool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class miniesptool: # pylint: disable=invalid-name
101101
boards, so you can burn ESP firmware direct from the CPy disk drive. Handy
102102
when you have an ESP module wired to a board and need to upload new AT
103103
firmware. Its slow! Expect a few minutes when programming 1 MB flash."""
104-
FLASH_WRITE_SIZE = 0x400
104+
FLASH_WRITE_SIZE = 0x200
105105
FLASH_SECTOR_SIZE = 0x1000 # Flash sector size, minimum unit of erase.
106106
ESP_ROM_BAUD = 115200
107107

firmware/esp32_firmware/esp_prog.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
print("ESP32 mini prog")
99

10-
11-
12-
uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=5)
1310
resetpin = DigitalInOut(board.RTS)
1411
gpio0pin = DigitalInOut(board.DTR)
1512
resetpin.direction = Direction.OUTPUT
@@ -19,17 +16,12 @@
1916
gpio0pin.value = 1
2017

2118
import adafruit_sdcard, storage
22-
try:
23-
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
24-
cs = DigitalInOut(board.xSDCS)
25-
sdcard = adafruit_sdcard.SDCard(spi, cs)
26-
vfs = storage.VfsFat(sdcard)
27-
storage.mount(vfs, "/sd")
28-
SD_IN = True
29-
except OSError:
30-
SD_IN = False
31-
print('\n---- No SD card found, proceeding without it ----\n')
32-
pass
19+
20+
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
21+
cs = DigitalInOut(board.xSDCS)
22+
sdcard = adafruit_sdcard.SDCard(spi, cs)
23+
vfs = storage.VfsFat(sdcard)
24+
storage.mount(vfs, "/sd")
3325

3426
def print_directory(path, tabs=0):
3527
for file in os.listdir(path):
@@ -53,10 +45,8 @@ def print_directory(path, tabs=0):
5345
if isdir:
5446
print_directory(path + "/" + file, tabs + 1)
5547

56-
print_directory("/sd")
57-
5848
time.sleep(0.5)
59-
49+
uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
6050
esptool = adafruit_miniesptool.miniesptool(uart, gpio0pin, resetpin, flashsize=4*1024*1024)
6151
esptool.debug = True
6252
time.sleep(0.5)
@@ -67,13 +57,13 @@ def print_directory(path, tabs=0):
6757
print("Found:", esptool.chip_name)
6858
if esptool.chip_name != "ESP32":
6959
raise RuntimeError("for ESP32 only")
70-
# esptool.baudrate = 912600
60+
esptool.baudrate = 912600
7161
print("MAC ADDR: ", [hex(i) for i in esptool.mac_addr])
72-
esptool.flash_file('/sd/MicroPython.bin', 0x10000)
7362

7463
esptool.flash_file('/sd/bootloader.bin', 0x1000)
7564
esptool.flash_file('/sd/phy_init_data.bin', 0xf000)
7665
esptool.flash_file('/sd/partitions_mpy.bin', 0x8000)
66+
esptool.flash_file('/sd/MicroPython.bin', 0x10000)
7767

7868
esptool.reset()
79-
time.sleep(0.5)
69+
time.sleep(0.5)

0 commit comments

Comments
 (0)