I have found the pyb.bootloader() function to be quite useful for the code-test-debug cycle, but I think that it could be improved. I do my development on a Mac; if I have a terminal program open and connected to the pyboard (I am using 'screen') and I type 'pyb.bootloader()' at the REPL, screen basically crashes and I need to clear and reset my Bash prompt. Do this enough times, and the USB system gets hung up to the point where I need to restart my machine. (And that is assuming that I also remember to unmount 'PYBFLASH' before jumping to DFU.)
The simple solution is to type something like 'pyb.delay(10000); pyb.bootloader()' to allow 10 seconds to exit screen gracefully before the DFU takes over. I finally got tired of this - sometimes I would mis-spell 'bootloader' and have to restart screen when the pyboard didn't restart.
I added this code to main.py - pyb.bootloader() is commented out here for testing:
Code: Select all
def bootload(count):
print("Restarting in DFU boot mode in {0} seconds".format(count))
while (count > 0):
pyb.delay(1000)
count -= 1
print("{0} ".format(count), end="")
print("\npyb.bootloader()")
# pyb.bootloader()
# Code executing:
>>> bootload(10)
Restarting in DFU boot mode in 10 seconds
9 8 7 6 5 4 3 2 1 0
pyb.bootloader()
I would like to implement this myself, but my priority right now is I2S, and if Damien likes the idea he might get it done in less time than it takes me to fire up my text editor