kopia lustrzana https://github.com/peterhinch/micropython-samples
29 wiersze
591 B
Python
Executable File
29 wiersze
591 B
Python
Executable File
#! /usr/bin/env python
|
|
|
|
# Called from buildpyb
|
|
# Put pyboard into DFU mode.
|
|
|
|
import sys
|
|
import os
|
|
mp = os.getenv('MPDIR')
|
|
sys.path.append(''.join((mp, '/tools')))
|
|
import pyboard
|
|
|
|
errmsg = 'pyb_boot error: usage pyb_boot device.'
|
|
def main():
|
|
if len(sys.argv) < 2:
|
|
print(errmsg)
|
|
sys.exit(1)
|
|
device = sys.argv[1]
|
|
pyb=pyboard.Pyboard(device)
|
|
pyb.enter_raw_repl()
|
|
try:
|
|
pyb.exec_raw('import pyb;pyb.bootloader()')
|
|
print('Failed to enter DFU mode')
|
|
except Exception: # It will throw one!
|
|
pass
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|