]>
us-delaporte.pagekite.me Git - dotfiles.git/blob - invoke/esptool/tasks.py
1 from invoke
import task
3 from datetime
import datetime
as dt
6 HOME
= os
.path
.expanduser('~')
7 TODAY
= dt
.now().strftime('%Y.%m.%d')
9 # Examples for CardputerAdv
11 PORT
='/dev/ttyACM0' # Linux
13 # PORT='COM0' # Windows
18 On using this tasks file
20 - Set the Cardputer Adv power to 'off' state
21 - Plugging in to USB will cause it to boot
22 - Hold 'Go' while booting
23 - Hold 'Go' and press 'Reset' to try again.
24 - On success, the usual screen content still shows up
25 > Tip: Be sure to use a cable that can carry data, not just power.
28 https://github.com/echo-lalia/MicroHydra
35 '''Check that the current user is a member of dialout'''
36 result
= c
.run(f
'groups {os.getlogin()}')
37 assert 'dialout' in result
.stdout
42 '''Use lsusb to try to find the new device.'''
43 input('Un-plug in the device...')
44 c
.run('lsusb > /tmp/before.txt')
45 input('Plug in the device...')
46 c
.run('lsusb > /tmp/after.txt')
47 result
= c
.run('diff /tmp/before.txt /tmp/after.txt')
51 # Maybe https://thelastoutpostworkshop.github.io/ESPConnect/ in Chromium?
56 result
= c
.run(f
'lsusb | grep {DEVICE}')
57 assert DEVICE
in result
.stdout
62 # result = c.run('ls /dev/ttyACM*')
63 result
= c
.run(f
'ls {PORT}')
66 # c.run('ls /dev/ttyUSB*')
70 result
= c
.run(f
'esptool --port {PORT} chip-id')
71 assert CHIP
in result
.stdout
82 '''Erasing flash is recommended before flashing fresh.'''
83 c
.run(f
'esptool --port {PORT} erase-flash')
86 def write_flash(c
, filepath
):
88 c
.run(f
'esptool --chip {CHIP} --port {PORT} --baud 460800 write_flash -z 0x1000 {filepath}')