View previous topic :: View next topic |
Author |
Message |
RogerM
Joined: 07 Jun 2004 Posts: 10
|
Looking for source code for PC side of USB Bootloader |
Posted: Tue Sep 12, 2017 8:29 pm |
|
|
I have used the USB Bootloader in a number of cases with the CCS utilities but want to include the process in my own PC side program to make it a little easier for my users. If the code is available I would prefer to use it rather than having to reverse engineer it from the PIC side.
I'm probably going to do the PC side in python but C source would be good.
Roger |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Wed Sep 13, 2017 11:21 am |
|
|
You just send the hex file out the serial. Only important thing is you must enable flow control, since the bootloader has to stop you sending while it writes. You can even do it from the command line by just copying the file to the serial port, provided you have already enabled the flow control.
In c#, you can just use:
File.Copy(@"c:\boot.hex", "com1");
In MS C, you can do a similar thing using the shell, but you then need to have used a mode statement to have setup the port first. |
|
|
RogerM
Joined: 07 Jun 2004 Posts: 10
|
|
Posted: Wed Sep 13, 2017 11:54 am |
|
|
Thanks. I was over complicating it.
I can wrap that to make it friendly
Roger |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed Sep 13, 2017 12:09 pm |
|
|
Hi,
CCS also supplies an executable 'CCSBootlader.exe' that is a command line utility used to invoke bootloading. I wrote a Windows GUI 'front-end' program in VB6 (gasp!) for my customers. The front-end allows them to select the appropriate .hex file, and COM port. Makes firmware updating a breeze! _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
|
RogerM
Joined: 07 Jun 2004 Posts: 10
|
|
Posted: Fri Sep 15, 2017 5:08 pm |
|
|
My object was to do something like ezflyr but I wanted to "help" in finding the right USB port (on my Win 10 Dev machine that allocation of the COM port IDs is not consistent and for example a particular USB port might be COM 10 one time and COM7 another) and file so I did it all in Python and it works. I need to tidy up some items but it is looking good.
What I did notice was the CCS Bootloader does not read the "information" lines in the .HEX file that come after the EOF record so I got an error message from the Python serial USB I/O because the Boot loader on the PIC had 'gone away' so I test for the EOF record and don't transmit anything after that. A little more troubling was the CCS routines do a check sum verification on each line and do an error return if they find a failure. A straight file copy does not find this so some additional code is required. I'm a little curious to know how often this might occur? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Sat Sep 16, 2017 1:32 am |
|
|
In my own code that connects to the serial, I open the registry for the CCS device:
SYSTEM\CurrentControlSet\Enum\USB\VID_2405&PID_000C
Then for each Sub Key Name in this branch I open the 'Device Parameters' entry, and read the Portname. If there is only one, I open it, if more, I offer the user these ports only. |
|
|
|