NanoVNA-H* – my method for firmware updates

Over the last few years I have evaluated many of the competing firmwares for the NanoVNA, and needed a method to quickly and reliably write new firmware to the device.

The notes here apply to NanoVNA-H and NanoVNA-H4, the method suits some other variants, but some are quite different, eg NanoVNA-F.

I have other projects that use the same chip family, and a solution had to be compatible, I did not want to be changing bootloader drivers for different upload clients for different projects.

So, I settled on dfu-util and the main upload client, and it works with the WinUSB driver, as does STM32CubeProgrammer (but the popular and obsoleted DfuseDemo uses STub30 driver).

The programming instructions are encapsulated in a bat file for the firmware type, it finds the lastes download in its directory, and installs it.

Here is the bat file for the H4, dodu-H4.bat:

@echo off
echo %0
rem set the NanoVNA into bootloader mode (jog button down and power on)
rem looks for newest "NanoVNA.H.v*.dfu"

rem use WinUSB driver

set DFUUTILPATH=..\dfu-util\

for /f "tokens=*" %%a in ('dir "NanoVNA.H4.v*.dfu" /b /od') do set newestdfu=%%a
echo newestdfu is %newestdfu%

echo on
%DFUUTILPATH%dfu-util-static -D "%newestdfu%"
@echo off

pause

The process is to download the dfu file from github to the DiSlord directory, start the NanoVNA in bootloader mode, and double click on dodu-H4.bat. It finds the most recent file matching the pattern, and installs it.

Here is the console log of an update:

"S:\NanoVna\Dislord\dodu-H4.bat"
newestdfu is NanoVNA.H4.v1.2.00.dfu

S:\NanoVna\Dislord>..\dfu-util\dfu-util-static -D "NanoVNA.H4.v1.2.00.dfu"
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Match vendor ID from file: 0483
Match product ID from file: 0000
Multiple alternate interfaces for DfuSe file
Opening DFU capable USB device...
Device ID 0483:df11
Device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Interface #1 ...
Determining device status...
DFU state(10) = dfuERROR, status(10) = Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations
Clearing status
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Option Bytes  "
Non-valid multiplier ' ', assuming bytes
DfuSe interface name: "Internal Flash  "
File contains 1 DFU images
Parsing DFU image 1
Target name: ST...
Image for alternate setting 0, (1 elements, total size = 93088)
Setting Alternate Interface #0 ...
Parsing element 1, address = 0x08000000, size = 93080
Erase           [=========================] 100%        93080 bytes
Erase    done.
Download        [=========================] 100%        93080 bytes
Download done.
Done parsing DfuSe file
Press any key to continue . . .

Other distributions

Similar scripts can be written for different distributions, eg bin files, hex files, files wrapped in a zip etc.

For example, this is a script I used with the original ttrftech distribution:

@echo off

for /f "tokens=*" %%a in ('dir nanovna-firmware-*.zip /b /od') do set newest=%%a

echo newest is %newest%

7za -aoa  e %newest%

dfu-util-static -a 0 -s0x8000000 -D ch.bin

pause

Summary

The ‘canned’ processes make updates reliable and fairly painless.

As a side note, noting that there are a squillion forks of the original NanoVNA firmware, I did not find any that were better than the current release of ttrftech’s (original) firmware… until DiSlord’s v1.1 release which had a bunch of marked improvements that actually worked, and worked very well.