micropython-samples/fastbuild/pyb_boot

29 wiersze
591 B
Plaintext
Czysty Zwykły widok Historia

2020-10-21 07:52:18 +00:00
#! /usr/bin/env python
2016-11-27 13:56:27 +00:00
# Called from buildpyb
# Put pyboard into DFU mode.
2016-06-21 09:24:50 +00:00
import sys
2016-11-27 13:56:27 +00:00
import os
mp = os.getenv('MPDIR')
sys.path.append(''.join((mp, '/tools')))
2016-06-21 09:24:50 +00:00
import pyboard
2020-10-21 07:52:18 +00:00
errmsg = 'pyb_boot error: usage pyb_boot device.'
2016-06-21 09:24:50 +00:00
def main():
2020-10-21 07:52:18 +00:00
if len(sys.argv) < 2:
print(errmsg)
sys.exit(1)
device = sys.argv[1]
2016-11-27 13:56:27 +00:00
pyb=pyboard.Pyboard(device)
2016-06-21 09:24:50 +00:00
pyb.enter_raw_repl()
try:
2020-10-21 07:52:18 +00:00
pyb.exec_raw('import pyb;pyb.bootloader()')
2016-11-27 13:56:27 +00:00
print('Failed to enter DFU mode')
except Exception: # It will throw one!
2016-06-21 09:24:50 +00:00
pass
if __name__ == "__main__":
main()