The STM32L432 bootloader supports USB DFU protocol.
You can use dfu-utils or Web DFU to flash firmware onto your self-made CanoKey or Nucleo-L432KC board.
Currently, only Chromium / Google Chrome supports WebUSB, so you should use Chromium or Google Chrome to access Web Console and Web DFU.
123456
if you haven’t changed it before. If you’ve typed the right key, a green promot “PIN verification success” will show up in the bottom left and more configurable areas shows up in the page.Do not unplug your CanoKey after entering DFU, otherwise you will need to repeat the steps again!
This is not suggested as you need to know how to find your reader name of the CanoKey.
scriptor
and pcsc_scan
is available in your system. If not, install them from your package manager.pcsc_scan
command to identify the reader name. In my case it is Kingtrust Multi-Reader [OpenPGP PIV OATH] (00000000) 00 00
enter-dfu.sh "Kingtrust Multi-Reader [OpenPGP PIV OATH] (00000000) 00 00"
. If you see output like the following, then the CanoKey went into DFU successfully. The Can't get info: Transaction failed
can be safely ignored in this scenario.$ ./enter-dfu.sh "Kingtrust Multi-Reader [OpenPGP PIV OATH] (00000000) 00 00"
Reader name: Kingtrust Multi-Reader [OpenPGP PIV OATH] (00000000) 00 00
Using given card reader: Kingtrust Multi-Reader [OpenPGP PIV OATH] (00000000) 00 00
Using T=1 protocol
Reading commands from STDIN
> 00 A4 04 00 05 F0 00 00 00 00
< 90 00 : Normal processing.
> 00 20 00 00 06 31 32 33 34 35 36
< 90 00 : Normal processing.
> 00 FF 22 22
Can't get info: Transaction failed.
Do not unplug your CanoKey after entering DFU, otherwise you will need to repeat the steps again!
You need to manually change the driver to make DFU work under Windows. Follow the following steps.
Options
menu, then click List All Devices
.STM32 BOOTLOADER
from the main windowDriver
line, change the right side to WinUSB.Reinstall WICD Driver
After that, you should be able to use DFU to flash your firmware.
Make sure the DFU is recognised by your system. You should see a USB device with VID:PID 0483:df11
in your system. In my scenario, it is
$ lsusb | grep 0483:df11
Bus 003 Device 013: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
STM32 BOOTLOADER
from the promptDFU: cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/0128*0002Kg"
) and click “Select interface”The official dfu-util have some issue downloading firmware to STM32L432 sometimes, so we suggest you to use this patched version.
/path/to/your/dfu-util -i 0 -a 0 -D /path/to/your/canokey.bin -s 0x08000000
Replace /path/to/your/dfu-util with the path to your dfu-util, and /path/to/your/canokey.bin with the path to the firmware you want to flash.
sudo chromium-browser --no-sandbox
.Failed to get Canokey version: Device busy
error when connecting to the CanoKey using the web console