FEZ bootloader utility

I made a utility that will update a FEZ to the latest firmware. Tested with exactly one FEZ Domino on exactly one machine.

Code is available at GitHub - bcr/FezBootloaderUtil: FEZ bootloader utility. Good for updating firmware.

In general, you can just put your FEZ board in bootloader mode and run it, and the magic happens.

Two potential limitations right now:

  1. It looks for the USBizi firmware in a fixed location, namely “C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\USBizi\Firmware\USBizi_CLR.GHI”. This may not work on every machine.
  2. It looks for a USB device with a description of “GHI Boot Loader Interface”. If it doesn’t find that, it stops.

Happy to hear any guidance about how to address these potential limitations.

Principles of Operation

  1. Find the COM port for the FEZ in bootloader mode
  2. Transmit the new firmware using XMODEM-1K to the board over the COM port

One clever bit (well, I think it’s clever) that I found was the serial port identification code:

private SerialPort OpenFezBootloaderSerialPort()
    var searcher = new ManagementObjectSearcher("select DeviceID,MaxBaudRate from Win32_SerialPort where Description = \"GHI Boot Loader Interface\"");
    foreach (var obj in searcher.Get())
        return new SerialPort((string) obj["DeviceID"], (int) (uint) obj["MaxBaudRate"]);
    throw new Exception("Unable to find FEZ device. Is it in bootloader mode?");

This uses Windows Management Instrumentation (WMI) to find the associated COM port with the FEZ, and then creates a SerialPort object preconfigured for the MaxBaudRate advertised by the device.

Comments welcome. I may poke at it some more and do some other bootloader-related activities. Now that XMODEM-1K works, it should be fairly simple to add in loading / reading managed application code.

Good stuff Blake. Worked perfectly on my Win7 Intel Quad 64 bit with a panda II. It crashes if the panda is not plugged in or not in BL mode which is understandable. Might cause some people concern so a handler for that might be a good idea.

I have another win7 rig and several Vista and XP rigs and if I get a minute tomorrow I will check those out. All I have from fez is a Panda 11 zoo.

I need to clean things up a little bit – right now I throw an exception (which essentially looks like a crash) if you’re not in bootloader mode, and yeah, I should probably just catch and print that (as well as making it a more specific Exception derived class).

Also, it hangs after uploading the firmware (it goes into an infinite loop reading strings and printing them out, and eventually runs out of strings).

Glad to know it works with the Panda II.

I’ll fix it up some more tomorrow – thanks for the feedback.

Thank you Blake for the great contributions as usual. 8)

OK, it’s more polite now. Just prints out a message. Doesn’t hang after upload.

Thanks, Joe for the encouraging words.