howto automatically restart a Pybv11 after flashing

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
josverl
Posts: 12
Joined: Fri Nov 24, 2017 4:22 pm

howto automatically restart a Pybv11 after flashing

Post by josverl » Mon Jan 10, 2022 8:15 pm

for an automated CI/CD process I would like to be able to run the following sequence without the need for manual operation:
preferably on windows , but ubuntu is fine if required.

1. set board in bootloader mode
2. download a new firmware v1.xx with dfu-util
3. reset/restart the board
4. upload some scripts
5. run a set up tests
6. download the results

I can get all steps to work , apart from the reset of the board after dfu-util has loaded the new firmware.

setup :
- windows 10/11
- zadig WinUSB(libusb) driver installed ( also tried with libusbK driver to no avail)
- pyboard.py to set the board in pyb.bootloader() mode
- dfu-util version 0.9
- .\Tools\dfu-util\dfu-util.exe --device 0483:df11 --alt 0 --download $filename_dfu

the --reset option and -E eject options do not work as I had expected/hoped.
I assume that a similar config is used in other micropython projects, and hope that someone can share a solution to this,

User avatar
dhylands
Posts: 3753
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: howto automatically restart a Pybv11 after flashing

Post by dhylands » Wed Jan 12, 2022 6:45 pm

If you pass the arguments "-s :leave" to dfu-util, it will cause the DFU boot loader to be exited after flashing. I commonly do this by creating a GNUmakefile in my ports/stm32 directory which has the following contents:

Code: Select all

$(info Executing GNUmakefile)

DFU_UTIL = dfu-util -s :leave
USE_PYDFU = 0 

include Makefile
then when you do a "make deploy" it will flash your program, and then reboot after flashing.

User avatar
josverl
Posts: 12
Joined: Fri Nov 24, 2017 4:22 pm

Re: howto automatically restart a Pybv11 after flashing

Post by josverl » Tue Jan 18, 2022 9:20 am

Thanks Dave,
Works like a charm on Windows as well :D

For me the process is a bit different , but the same parameters work for my scenario.

Code: Select all

$filename = "./PYB_11/pybv11-network-20210902-v1.17.dfu"
$serialport = "COM7"
# Put device into bootloader mode 
python .\Tools\pyboard.py -d $serialPort --command "import time;time.sleep_ms(200);import pyb;pyb.bootloader()" --no-follow
# Flash 
dfu-util.exe --device 0483:df11 --alt 0 -s :leave  --download $filename --reset
# Erase and Flash 
# dfu-util.exe --device 0483:df11 --alt 0 -s :mass-erase:force:leave  --download $filename --reset
Knowing the answer :
I was able to refomulate my question to the search engines and find a source for these -s :MODIFIERS

Post Reply