Pysense: hardware setup in a virtual machine


I had to help someone starting a project which includes, among others, a Pysense board.

The development environment was Linux Mint 18.3, running in a VirtualBox virtual machine (VirtualBox version 5.2.26). The host system was a MacBook Pro running macOS Mojave.

One difficulty that the user may face with this environment relates to the USB device redirection. When the Pysense is switched to bootloader mode, for firmware upgrade, it stays in this mode less than 7 seconds, which is not long enough to configure VirtualBox.

The following procedure allows to get round this problem, and to perform the firmware upgrade:

  • download Pysense DFU (Device Firmware Upgrade), with the download link presented here
  • install DFU-util tools package
  • connect the board to the USB port
  • check that the device is seen by VirtualBox (Devices > USB) and select it so that the virtual machine can access it. It appears as Pycom Pysense [0008]
  • run the dmesg command. More information is displayed:
[28075.466942] usb 1-2: new full-speed USB device number 6 using xhci_hcd
[28075.617716] usb 1-2: New USB device found, idVendor=04d8, idProduct=f012
[28075.617718] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[28075.617720] usb 1-2: Product: Pysense
[28075.617721] usb 1-2: Manufacturer: Pycom
[28075.617722] usb 1-2: SerialNumber: Py75463a
[28075.711112] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
[28075.712011] usbcore: registered new interface driver cdc_acm
[28075.712012] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Perfect, this is consistent with Pycom documentation.

  • assign the USB device to the virtual machine in a permanent way, using Devices > USB > USB Settings… to add a filter
  • unplug the USB cable
  • with Devices > USB > USB Settings…, add a filter for the board in bootloader mode. Provide following values:
    • Name: Microchip Technology, Inc. [0003]
    • Vendor ID: 04d8
    • Product ID: f011
    • Revision: 0003
    • Remote: No
    • no value for other fields. Note: vendor ID, product ID and revision are enough to let VirtualBox assign the board to the virtual machine. Name will be set automatically, using the vendor ID string provided by the board
  • in a terminal window, go to the directory where the DFU file has been downloaded
  • start typing the following command:
sudo dfu-util -D pysense_0.0.8.dfu
  • click on Enter key and type your password, but do not validate with Enter key
  • press the board button and keep it held
  • plug in the USB cable to the host computer and wait 1 second before releasing the button
  • you now have less than 7 seconds to click Enter key
  • an output similar to the one below should be displayed:
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Match vendor ID from file: 04d8
Match product ID from file: f011
Opening DFU capable USB device...
ID 04d8:f011
Run-time device DFU version 0100
Claiming USB DFU Runtime Interface...
Determining device status: state = dfuIDLE, status = 0
dfu-util: WARNING: Runtime device already in DFU state ?!?
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0100
Device returned transfer size 64
Copying data from PC to DFU device
Download [=========================] 100% 16384 bytes
Download done.
state(2) = dfuIDLE, status(0) = No error condition is present
Done!

That’s it!