Page 1 of 1

First experiences (firmware upgrade & hardware design issue/mitigation)

Posted: Sun Apr 19, 2020 6:31 pm
by Jurjen
Hello,

First poster here, thanks for developing the hardware and this forum! I am new to (micro)python as well, so I use the Pyb-D and the ESP8266 as vehicles to learn an enjoy ... .

The two PYBD_SF6W devices I have had firmware revision 1.11 so I wanted to upgrade to 1.12. Since the upgrade process is not entirely trivial (as it emerged from some posts) I decided to write down all steps for the first device upgrade. In the end I was able to successfully upgrade it (indeed it took quite some time and some research / trial-and-error) and following these steps exactly the second device followed successfully without issues. Therefore I hope the following detailed description serves other users of the D-series as well:

Detailed procedure using Dfutils for upgrading PyB-D SF6W from 1.11 to 1.12

Hardware used:
Pyboard-D model SF6W, mounted on WBUS-DIP28 and accessed through the latter's USB-port
PC: Surface Pro 6 and/or the much older Surface 3 (both Windows 10)

Preparation:
1. Install PyUSB (I ran "pip install pyusb" from PowerShell in Admin mode)
2. Download Zadig ( https://zadig.akeo.ie/ )
3. Donwload DFUtils, unpack the zipped file ( http://dfu-util.sourceforge.net/ ) and then go to the directory with the unpacked files. This directory should contain several files/executables, including the "dfu-util-static" executable
4. Download a recent firmware DFU file (http://micropython.org/download/pybd/ ) into the same directory as the Dfutils executables from step 3. I used the PYBD-SF6-20191220-v1.12.dfu baseline file, but the latest dfu build works as well.

Execution:

1. Install PyUSB (I ran "pip install pyusb" from PowerShell in Admin mode)

2. Get the PyBoard-D in bootloader mode. There are several ways, but a very easy one was as suggested by Jimmo, direct from REPL (I use Thonny for that, but anything goes):
>>> import machine
>>> machine.bootloader()
As a consequence the Repl (or editor using it) gets disconnected and the red led starts flashing each second, indicating the board is in bootloader mode. Also around this time Windows *might* signal that it has found and will install a new driver, just let this happen, this will be overridden in the next step. Keep the PyB-D connected physically.

3. Now install the proper driver by running Zadig (Libusbk works for me as a device driver (as recommended by Jimmo somewhere else on this forum), but WinUSB does appear to work equally well, as tested on my second board to be upgraded) :
a. Start up Zadig (it is a standalone program that does not require installation)
b. From the main menu in Zadig, select Options -> List all devices
c. Select the PyBoard DFU as the device (be careful not to accidently select anything else. Furthermore, if you do not see the Pyboard DFU as an option then your device is not in bootloader mode)
d. Upgrade the driver to WinUSB or Libusbk

4. Start up Powershell (Administrator) and go to the dir with the unpacked Difutils files. Run Difutils in PowerShell with the following command (correct the dfu file name for the latest version you have downloaded, and mark the .\ at the start of the command):
.\dfu-util-static.exe -D PYBD-SF6-20191220-v1.12.dfu

5. Now you should see a stream of messages, ending with the message "Download Done. Done parsing DfuSe file"

That is it, you can now disconnect the PybD physically. Next time you start connecting to REPL or your favorite editor, the PyBoard will greet you with the updated firmware version!

Using pydfu (python script) instead of dfutils
Using pydfu (python script) instead of dfutils (replacing step 4) did not work for me, a timeout error was reported and I was not able to fix that in any way … .

Re: First experiences (firmware upgrade & hardware design issue/mitigation)

Posted: Sun Apr 19, 2020 7:03 pm
by Jurjen
I also noted that I ran into a hardware design issue due to the placement of the SD-card reader, when mounting it to the WBUS-DIP28 if the latter has strip connector pins soldered. In that case the VIN and 3V3 pins of the WBUS-DIP28 easily touch the SD-Card reader outer metal, causing the PybD not to work (and I got a report form my PC that a USB-port was drawing excess current, indicating some short-circuit issue ...). The two pictures below show the issue:
Image
Image

This however can be easily solved by wirecutting away the top part of those pins (and the GND pin near to it), as shown here:
Image

Regards,
Jurjen

Re: First experiences (firmware upgrade & hardware design issue/mitigation)

Posted: Sun Apr 19, 2020 11:42 pm
by jimmo
Jurjen wrote:
Sun Apr 19, 2020 6:31 pm
Detailed procedure using Dfutils for upgrading PyB-D SF6W from 1.11 to 1.12
Thank you for doing this, I look forward to being able to link to this post in the future! :)

I should note that this is entirely a Windows-specific issue. I don't really understand what the whole Zadig driver thing is doing and why it's necessary. One thing I've heard is that if you use the ST tools instead of dfu-util and avoid this problem.

There's also a less well known way that you can firmware update the PYBD by copying a gzipped dfu file to the filesystem -- no dfu-util or drivers required.
The steps are roughly:
- gzip the .dfu file to firmware.dfu.gz, copy to the device filesystem
- copy fwupdate.py from https://github.com/micropython/micropyt ... wupdate.py to the device filesystem

Then at the REPL:
>>> import fwupdate
>>> fwupdate.update_mpy('firmware.dfu.gz', 0x80000000, 0x200000)

(I haven't tested this in a long time, but I have definitely done it before) (Edit, I just tested this on an SF2, works great -- note the filesystem needs to be FAT though, which is still the default).
Jurjen wrote:
Sun Apr 19, 2020 7:03 pm
This however can be easily solved by wirecutting away the top part of those pins (and the GND pin near to it)
Yup, my DIP28 looks exactly the same :)

Re: First experiences (firmware upgrade & hardware design issue/mitigation)

Posted: Mon Jun 08, 2020 3:28 pm
by kbrenner
Jurjen wrote:
Sun Apr 19, 2020 6:31 pm
Jurjen, this post was extremely helpful. I would love to see this level of simplicity/detail for simple tasks like firmware updates for those of us who are not as familiar with the environment coming from the MicroPython team (if possible).

First poster here, thanks for developing the hardware and this forum! I am new to (micro)python as well, so I use the Pyb-D and the ESP8266 as vehicles to learn an enjoy ... .

The two PYBD_SF6W devices I have had firmware revision 1.11 so I wanted to upgrade to 1.12. Since the upgrade process is not entirely trivial (as it emerged from some posts) I decided to write down all steps for the first device upgrade. In the end I was able to successfully upgrade it (indeed it took quite some time and some research / trial-and-error) and following these steps exactly the second device followed successfully without issues. Therefore I hope the following detailed description serves other users of the D-series as well:

Detailed procedure using Dfutils for upgrading PyB-D SF6W from 1.11 to 1.12

Hardware used:
Pyboard-D model SF6W, mounted on WBUS-DIP28 and accessed through the latter's USB-port
PC: Surface Pro 6 and/or the much older Surface 3 (both Windows 10)

Preparation:
1. Install PyUSB (I ran "pip install pyusb" from PowerShell in Admin mode)
2. Download Zadig ( https://zadig.akeo.ie/ )
3. Donwload DFUtils, unpack the zipped file ( http://dfu-util.sourceforge.net/ ) and then go to the directory with the unpacked files. This directory should contain several files/executables, including the "dfu-util-static" executable
4. Download a recent firmware DFU file (http://micropython.org/download/pybd/ ) into the same directory as the Dfutils executables from step 3. I used the PYBD-SF6-20191220-v1.12.dfu baseline file, but the latest dfu build works as well.

Execution:

1. Install PyUSB (I ran "pip install pyusb" from PowerShell in Admin mode)

2. Get the PyBoard-D in bootloader mode. There are several ways, but a very easy one was as suggested by Jimmo, direct from REPL (I use Thonny for that, but anything goes):
>>> import machine
>>> machine.bootloader()
As a consequence the Repl (or editor using it) gets disconnected and the red led starts flashing each second, indicating the board is in bootloader mode. Also around this time Windows *might* signal that it has found and will install a new driver, just let this happen, this will be overridden in the next step. Keep the PyB-D connected physically.

3. Now install the proper driver by running Zadig (Libusbk works for me as a device driver (as recommended by Jimmo somewhere else on this forum), but WinUSB does appear to work equally well, as tested on my second board to be upgraded) :
a. Start up Zadig (it is a standalone program that does not require installation)
b. From the main menu in Zadig, select Options -> List all devices
c. Select the PyBoard DFU as the device (be careful not to accidently select anything else. Furthermore, if you do not see the Pyboard DFU as an option then your device is not in bootloader mode)
d. Upgrade the driver to WinUSB or Libusbk

4. Start up Powershell (Administrator) and go to the dir with the unpacked Difutils files. Run Difutils in PowerShell with the following command (correct the dfu file name for the latest version you have downloaded, and mark the .\ at the start of the command):
.\dfu-util-static.exe -D PYBD-SF6-20191220-v1.12.dfu

5. Now you should see a stream of messages, ending with the message "Download Done. Done parsing DfuSe file"

That is it, you can now disconnect the PybD physically. Next time you start connecting to REPL or your favorite editor, the PyBoard will greet you with the updated firmware version!

Using pydfu (python script) instead of dfutils
Using pydfu (python script) instead of dfutils (replacing step 4) did not work for me, a timeout error was reported and I was not able to fix that in any way … .

Re: First experiences (firmware upgrade & hardware design issue/mitigation)

Posted: Fri Jun 12, 2020 12:21 am
by rcolistete
There are shorter male headers so that they don't touch the Pyboard D.

Anyway, it would be better to have a note about this issue in :
https://pybd.io/hw/wbus_dip28.html