Update 2017: Microchip now has a Qt 5 example in their MLA folder "apps\usb\device\bootloaders\utilities". It uses the popular HIDAPI by Alan Ott / Signal 11. It makes the below approach obsolete , and I really recommend to download and check out the Microchip MLA package instead.
==============================================
While working on a Microchip PIC32 based USB HID Composite Device for our Kickdrive environment, we realized the need for updating the PIC application firmware from our own UI, instead of using an external tool.
==============================================
While working on a Microchip PIC32 based USB HID Composite Device for our Kickdrive environment, we realized the need for updating the PIC application firmware from our own UI, instead of using an external tool.
Firmware updates for any Embedded device or accessory are an essential part of product support and should be done in the least disrupting way. So even launching an external Windows command line tool did not look like a good solution to us.
What I found was Microchip's own sample code from Application Note AN1388, but the PIC32UBL.exe code was MFC / Visual Studio 2003 and not designed to be anything else than a GUI application. There seems to be a Qt/Mac port of this project, but the original PIC32UBL.exe worked very reliable on Windows, so I didn't feel like back-porting from a Mac source.
I decided to build a DLL wrapper around the original PIC32UBL instead, and make it work without the main form and UI interaction. I uploaded the result to Github, with kind permission from Microchip Technology Inc. as the copyright holder of the original PIC32UBL project. Here is the link:
The kickd_pic32_ubl.dll is statically linked, code-signed and does not have any additional dependencies. With the PIC32 device already in bootloader mode, starting a the firmware update can look something like this in your C++ code:
pPic32UblRtLink *pUpdater;
pUpdater = new Pic32UblRtLink();
bool success = (pUpdater->getDLLStatus() == 0);
if (success) {
success = pUpdater->ConnectAndProgram("myfile.hex", 0x4d8, 0x3c);
(Putting the PIC in bootloader mode is very easy for our device - we implemented a HID protocol command for this purpose, and use Docklight Scripting to send HID reports for testing.)
For full documentation and a complete example, see the source code folder /pic32_firmware_upload_demo.
I hope you find the DLL useful, any feedback is highly appreciated!
Oliver
Hello Oliver,
ReplyDeleteI've already tried your Microchip PIC32 Firmware Update and it works great. It's better to use this one than the Microchip's one. I want to ask if you ever made any adaptations of this for macOS. I would really like to have something similar for macOS because the one adapted for JAVA actually requires the Max Runtime which has a 60 days trial. I want something simpler like yours.
Best regards.
Did anyone or the coder himself try to wrap the dll in managed-code c# or vb.net solutions? Is Oliver still getting notifications about posts here?
ReplyDeletejust for the record, see update, not recommended to use this approach for new SW. Never tried the DLL inside c#/ .net .
Delete