]> apps.delaporte.us Git - dotfiles.git/blobdiff - invoke/esptool/tasks.py
Do not leave firefox-esr lying around.
[dotfiles.git] / invoke / esptool / tasks.py
index 54793ee4313dad878804a0ce9de4a2784557b671..546e261607629037533c0fe0fea13d3b18b7f55d 100644 (file)
@@ -9,7 +9,12 @@ TODAY = dt.now().strftime('%Y.%m.%d')
 # Examples for CardputerAdv
 DEVICE = 'Espressif'
 PORT='/dev/ttyACM0' # Linux
+CHIP='ESP32-S3'
 # PORT='COM0' # Windows
+MICROPYTHON=f'$HOME/Downloads/ESP32_GENERIC_S3-20260406-v1.28.0.bin'
+# MicroPython version 
+# from 
+# https://micropython.org/download/ESP32_GENERIC_S3/
 
 @task
 def help(c):
@@ -66,7 +71,8 @@ def listusb(c):
 
 @task
 def chip_id(c):
-    c.run(f'esptool --port {PORT} chip-id')
+    result = c.run(f'esptool --port {PORT} chip-id')
+    assert CHIP in result.stdout
     print('[ok]')
 
 @task
@@ -75,3 +81,18 @@ def check_all(c):
     check_conn(c)
     chip_id(c)
 
+@task
+def erase_flash(c):
+    '''Erasing flash is recommended before flashing fresh.'''
+    c.run(f'esptool --port {PORT} erase-flash')
+
+@task
+def write_flash(c, filepath=MICROPYTHON):
+    '''Write flash - defaults to MicroPython
+
+    Requires .bin file from micropython.org
+    '''
+    c.run(f'esptool --chip {CHIP} --port {PORT} --baud 460800 write-flash -z 0x1000 {filepath}')
+
+
+