Python DFU util
-
- Posts: 14
- Joined: Fri Mar 28, 2014 11:35 pm
Re: Python DFU util
Yes it doesn't matter where it lives, as long as it's somewhere in the same repo.
Re: Python DFU util
Hey guys - nice work, and I'm excited to use this, but I can't get it to work on my Mac.
Running python3.4, I installed pyusb using "sudo pip3 install --pre pyusb"
This worked, eliminated the first error message I got:
However now I get the following:
Any thoughts? I haven't tried to dig into the error message yet, just wondering if there is something obvious, maybe another library package, that I might be missing.
-Bryan
Running python3.4, I installed pyusb using "sudo pip3 install --pre pyusb"
This worked, eliminated the first error message I got:
Code: Select all
Traceback (most recent call last):
File "pydfu.py", line 20, in <module>
import usb.core
ImportError: No module named 'usb'
Code: Select all
stmhal bryan$ python3 pydfu.py -u build-PYBV10/firmware.dfu
File: build-PYBV10/firmware.dfu
b'DfuSe' v1, image size: 247553, targets: 1
Traceback (most recent call last):
File "pydfu.py", line 527, in <module>
main()
File "pydfu.py", line 514, in main
elements = read_dfu_file(args.path)
File "pydfu.py", line 295, in read_dfu_file
img_prefix['name'] = cstring(img_prefix['name'])
File "pydfu.py", line 242, in cstring
return string.split('\0', 1)[0]
TypeError: Type str doesn't support the buffer API
-Bryan
-
- Posts: 14
- Joined: Fri Mar 28, 2014 11:35 pm
Re: Python DFU util
Line 242:
Also fixed it in my repo and confirmed working with Py3
Code: Select all
return string.decode('utf-8').split('\0', 1)[0]
Re: Python DFU util
@iabdalkader - That did it, and just as intended it jumped to application mode without me needing to remove the DFU jumper and press reset. Thanks, and nice work!
-Bryan
-Bryan
Re: Python DFU util
@blmorris: There is a pyb.bootloader() command so that you don't even need the DFU jumper any more (except in rare cases).
-
- Posts: 14
- Joined: Fri Mar 28, 2014 11:35 pm
Re: Python DFU util
I saw the tear-down approach and jump to DFU, we set a magic byte instead in SRAM and reset and branch on to dfu, much easier.dhylands wrote:@blmorris: There is a pyb.bootloader() command so that you don't even need the DFU jumper any more (except in rare cases).
Re: Python DFU util
True, but if you issue that command from a REPL over USB then it has the downside of clobbering the terminal program by eliminating the tty device it is connected to. Not a catastrophe usually, and it is certainly possible to type 'pyb.delay(10000); pyb.bootloader()' to give myself time to exit gracefully, but I have still found the jumper method to be convenient enough for my purposesdhylands wrote:@blmorris: There is a pyb.bootloader() command so that you don't even need the DFU jumper any more (except in rare cases).
Not to dismiss the utility, of course. I am sure that I will make heavy use of these features to jump back and forth between DFU and application mode once we start putting micropython into our products. For now I was just commenting that the automatic jump to application mode was a nice feature.
-Bryan
-
- Posts: 14
- Joined: Fri Mar 28, 2014 11:35 pm
Re: Python DFU util
It's possible to add a vendor request to jump into DFU, which can be sent from the script, so the whole process (dfu->program->reset) can be done with a single command without ever touching the board.blmorris wrote: True, but if you issue that command from a REPL over USB then it has the downside of clobbering the terminal program by eliminating the tty device it is connected to. Not a catastrophe usually, and it is certainly possible to type 'pyb.delay(10000); pyb.bootloader()' to give myself time to exit gracefully, but I have still found the jumper method to be convenient enough for my purposes
Not to dismiss the utility, of course. I am sure that I will make heavy use of these features to jump back and forth between DFU and application mode once we start putting micropython into our products. For now I was just commenting that the automatic jump to application mode was a nice feature.
-Bryan