cncbasher / mphidflash Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/mphidflash
License: GNU General Public License v3.0
Automatically exported from code.google.com/p/mphidflash
License: GNU General Public License v3.0
'mphidflash' is a simple command-line tool for communicating with Microchips USB HID-Bootloader and downloading new firmware. mphidflash supports Linux, Mac OS X (Leopard and later), and Windows. The 'mphidflash' project is hosted on http://code.google.com/p/mphidflash/ Building and Installing ======================= Linux ----- For Linux, you'll need the 'libhid' development library (and associated dependencies) installed, which can be handled by most package managers or from the command line: sudo apt-get install libhid-dev Assuming you're reading this as the README.txt alongside the source code, to compile mphidflash for a 32 or 64 bit system, in the Terminal window type: make mphidflash32 or make mphidflash64 Then install with the command: sudo make install32 or sudo make install64 This will copy the appropriate executable to /usr/local/bin/mphidflash so you don't need to specify a complete path to the program each time. Mac OS X -------- To build mphidflash for Mac, you'll need to have Xcode (Apple's developer tools) already installed. The IDE portion is not used here, just the command line interface. Assuming you're reading this as the README.txt alongside the source code, to compile mphidflash for a 32 or 64 bit system, in the Terminal window type: make mphidflash32 or make mphidflash64 Then install with the command: sudo make install32 or sudo make install64 This will copy the appropriate executable to /usr/local/bin/mphidflash so you don't need to specify a complete path to the program each time. Windows ------- To build mphidflash for Windows, you can use mingw32 (cross) compiler. For cross compiling on Linux, you'll need the 'mingw32' toolchain (and associated dependencies) installed, which can be handled by most package mangager or from the command line: sudo apt-get install mingw32 Assuming you're reading this as the README.txt alongside the source code, to compile mphidflash, in the Terminal window type: make -f Makefile.win This will create a .exe in the binaries sub-directory, which can be called from the Windows commmand line - e.g. 'mphidflash-1.6-win-32.exe'. You should copy this file somewhere on your executable path and rename it to 'mphidflash.exe'. Usage ===== To upload a new program to your PIC, it must be connected to your computer and set into bootloader mode. mphidflash can then be used with the following options: -help Display help screen (alternately: -?) -write <file> Upload given file to PIC -reset Reset PIC -noverify Skip verification step -erase Erase PIC memory -vendor <hex> Use given USB vendor id instead of default id -product <hex> Use given USB product id instead of default id Example: To upload the program test.hex to the PIC and to reset the PIC thereafter the following command line can be used: mphidflash -write test.hex -reset
What steps will reproduce the problem?
When my HEX file data exactly fills a page (eg 02xx) and jumps to a new
non-contiguous page (eg 05xx), there is no "Program Complete" USB code 06 to
make the bootloader flush it's buffer to storage
What is the expected output? What do you see instead?
This results in some sections of storage never being written to
What version of the product are you using? On what operating system?
Running V1.3 on Mac XCODE
Please provide any additional information below.
I've been using mphidflash as a basis for a version that needs no user data, so
there are more changes.
I also had problems with mphidflash trying to write to invalid data, so I added
ProgramStart / End bounds - you can delete that code from hex.c.
I added a "flushBuffer" routine, and called it from appropriate places.
Final note: using this on PIC24 family, I also needed to divide all write
addresses by 2, since the PIC24 uses word addresses but the HEX file uses byte
addresses! I deleted that code from attached hex.c
Original issue reported on code.google.com by [email protected]
on 8 Feb 2013 at 4:13
Attachments:
When I try to write a program :
./mphidflash -w file.hex
USB HID device found
Device family: PIC18
Program memory: 20480 bytes free. 8 bytes free.
Erasing...
Writing hex file 'USB Device - Libusb - Generic Driver - C18 - PICDEM
FSUSB.hex':.....................................................................
..........................................
Verifying:.
./mphidflash Error: Verify failed
And breaks the bootloader.
I'm using the last svn version under Linux.
Original issue reported on code.google.com by [email protected]
on 7 Aug 2010 at 5:51
What version of the product are you using? On what operating system?
v1.4
I offer you a commented version, the only code change is to remove unused
variable ret:
/* check memory address & length are in a programmable memory area, as reported
by device's Bootloader */
static int verifyBlock( unsigned int *addr, char *len )
{
int i, isA, isL, MA, ML;
for ( i = 0; i < devQuery.memBlocks; i++ )
{
/* only look at programmable memory blocks */
if ( !devQuery.mem[ i ].Type ) continue;
MA = devQuery.mem[ i ].Address;
ML = devQuery.mem[ i ].Length;
/* calc if first or last address is in this block */
isA = ( *addr >= MA ) && ( *addr < MA + ML );
isL = ( *addr + *len > MA ) && ( *addr + *len <= MA + ML );
/* loop if neither */
if ( !isA && !isL ) continue;
/* both addresses is fine */
if ( isA && isL ) return 0;
/* if only start address we adjust length to end of block */
if ( isA ) *len = ( MA + ML ) - *addr;
/* if only last address we adjust start to start of block */
if ( isL ) { *len = ( *addr + *len ) - MA; *addr = MA; }
return 0;
}
/* not programmable */
return 1;
}
Original issue reported on code.google.com by [email protected]
on 1 Jul 2014 at 4:14
I use PIC24FJ64GB002 and USB Framework v2.7 in Microchip Applications Library.
I wrote the hex of HID Bootloader and I confirmed to be able to wrote
application hex
with HIDBootloader.exe. The operation is no problem.
Now I think I want to mphidflash on Mac OS X 10.6.3. So I downloaded the latest
ver.
from SVN and installed.
The writing is maybe OK but the verification is failed. Additionaly an
application program
doesn't operate.
I attached debug log. Please give me any advice.
Thanks.
Original issue reported on code.google.com by [email protected]
on 10 Jun 2010 at 5:34
Attachments:
Hi,
Recently, I use PIC32MX675F512H.
I wrote USB HID bootloader and succeeded to erase, program and verify
with PIC32UBL.exe on Windows7. Of course, the application firmware is
no trouble.
However, the latest mphidflash(svn trunk ver.) cannot be used on this
bootloader.
I tried on Mac OS X 10.6.8 and the massage "USB HID device found" is shown
but the process is stopped.
Are there any solution?
*PIC32 bootloader's url
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appn
ote=en554836
Thank,
Original issue reported on code.google.com by [email protected]
on 1 Sep 2011 at 1:52
What steps will reproduce the problem?
1. connect board with PIC, forgetting to set Linux udev rules for file
permissions
2. run "mphidflash -w EBF_EBBv13_and_above.hex -r" and receive "Error: Device
not found (is device attached and in Bootloader mode?)"
3. run "mphidflash -d3 -w EBF_EBBv13_and_above.hex -r" and receive only the
same error.
What is the expected output? What do you see instead?
With "-d 3" expected to see a lot of debugging output. Saw none. When I hacked
in hid_set_usb_debug() into usb-linux.c (see patch below), I got the debug
output I needed.
You might also want to consider changing the error message hint from "is device
attached and in Bootloader mode?" to include something about access or
permissions.
What version of the product are you using? On what operating system?
1.4 on Ubuntu 10.04 x86_64
Please provide any additional information below.
v1.4 Code was downloaded from
https://code.google.com/p/eggbotcode/downloads/detail?name=mphidflash_1_4.zip&ca
n=2&q=
diff -u mphidflash-1.4.orig/usb-linux.c mphidflash/usb-linux.c
--- mphidflash-1.4.orig/usb-linux.c 2010-07-09 22:02:38.000000000 -0400
+++ mphidflash/usb-linux.c 2010-12-22 12:48:48.342691545 -0500
@@ -82,6 +82,11 @@
matcher.product_id = productID;
matcher.matcher_fn = NULL;
+ if (debugLevel >= DEBUG_USB) {
+ hid_set_debug(HID_DEBUG_ALL);
+ hid_set_usb_debug(HID_DEBUG_ALL);
+ }
+
if(HID_RET_SUCCESS == hid_init()) {
status = ERR_USB_INIT2;
if((hid = hid_new_HIDInterface())) {
Original issue reported on code.google.com by [email protected]
on 22 Dec 2010 at 6:10
My think is that the terminal window should not disappear at the end of
programming if the programming went wrong:
I use the -reset flag and I haven't time sufficient to read the message at the
end.
I think that it's ok to stick with the auto-closing of the window if everything
was fine, but one should confirm with at least a "PRESS A KEY..." to allow him
to fully read any error encountered in the programming.
Just my idea...
Sincerely
Stefano
Original issue reported on code.google.com by [email protected]
on 17 Dec 2014 at 12:18
What steps will reproduce the problem?
1. Loading a boot loader with USB access on it using MPLABX & Pickit2. I used
generic DEMO one from Microchip to compile with a 18f2455 chip set.
2. Placed it in a basic circuit with program & reset capabilities on a 20Mhz
crystal. Nothing special.
3. Make sure I am root and run the program as rot and load a basic test2.hex
Which only consist of a blinking LED.
./mphidflash -v 2233 -p 7001 -w ../piccode/test2.hex
What is the expected output? What do you see instead?
It does not even get started uploading the test hex file to the pic I get.
USB HID device found
./mphidflash Error: USB read error
What version of the product are you using? On what operating system?
mphidflash 1.3 : Debian 6.0 stable and Linux Kernel 3.0.8
Please provide any additional information below.
lsusb
Bus 001 Device 008: ID 2233:7001 RadioShack Corporation
dmesg
[21964.752426] usb 1-1.4: new full speed USB device number 10 using ehci_hcd
[21964.847784] usb 1-1.4: New USB device found, idVendor=2233, idProduct=7001
[21964.847793] usb 1-1.4: New USB device strings: Mfr=1, Product=2,
SerialNumber=0
[21964.847800] usb 1-1.4: Product: Generic HID
[21964.847805] usb 1-1.4: Manufacturer: Test
[21964.850760] generic-usb 0003:2233:7001.0005: hiddev0,hidraw3: USB HID v1.11
Device [Test Generic HID] on usb-0000:00:13.5-1.4/input0
Original issue reported on code.google.com by [email protected]
on 12 Nov 2011 at 10:30
ammend file name in header comment
Original issue reported on code.google.com by [email protected]
on 23 Feb 2013 at 6:45
Attachments:
What steps will reproduce the problem?
1. OSX build
2. analyzer
3. run command line
What is the expected output? What do you see instead?
I have a beagle USB analyzer and we tried both the 1.3 and 1.4 (not sure where
my programmer got that) and a weird thing happens.
The PIC32MX Ethernet Starter kit. Straight 1388 firmware.
The PIC32MX enumerates fine and we start up mphidflash and the code opens and
finds the PIC32MX HID and then it writes the 02 stream (8 bytes) and the
PIC32MX never responds.
The Beagle Analyzer file is attached and you can down load the viewer and see
all the OUTS from the mphidflash program are all in red indicating an error.
What version of the product are you using? On what operating system?
10.8.5
Please provide any additional information below.
Thanks,
Gordon
Original issue reported on code.google.com by [email protected]
on 4 Feb 2014 at 8:22
Attachments:
What steps will reproduce the problem?
1. program de pic18f4550 with HIDbootloader from Microchip USB framework using
a pickit2 programmer
2. transfer an hex file to te microcontroller
3. The task is done
What is the expected output? What do you see instead?
te aplication isn´t start, te microcontroller is still in bootloader mode
What version of the product are you using? On what operating system?
i'm using the last 1.6
Please provide any additional information below.
When i use the HIDbootloader that Microchip provides for window, it works!
Original issue reported on code.google.com by [email protected]
on 30 Nov 2014 at 11:56
As we've now addressed a bunch of issues that have been lying here for many
years, I felt it was time for a new release... Please review/comment on r8 -
r16.
Once we're happy, we need executables for distribution. I can take care of 64
bit Linux and Mac OS-X, but having trouble producing 32-bit Linux, and can't do
Windows - again, we need 32 and 64 bit versions...
Original issue reported on code.google.com by fnargwibble
on 2 Jul 2014 at 6:46
What steps will reproduce the problem?
1. Get any HEX file which contains a start address record (type 5). For
example:
...
:040000051D0040009A
:00000001FF
2. Try to program it into device.
What is the expected output? What do you see instead?
I get a fatal message: Unsupported record type in hex file
What version of the product are you using? On what operating system?
Version: svn checkout revision 7.
Mac OS 10.6.8.
Please provide any additional information below.
Bug fixed, patch attached
Original issue reported on code.google.com by [email protected]
on 1 Apr 2012 at 1:14
Attachments:
HID bootloader hang, when HEX file contains some lines with odd length of bytes
in line. Adding one byte 0xFF before write data to PIC solve this problem.
When HEX file contains some code in bootloader memory area or fuses, we must
skip this area, or unlock fuses. Otherwise verification failed, or attempt to
write to locked flash program memory hang PIC.
Proposal of version 1.4 is attached.
Petr
Original issue reported on code.google.com by [email protected]
on 28 Dec 2010 at 5:42
Attachments:
What steps will reproduce the problem?
1. save this fragment as mini.hex
:020000040000fa
:020000041fc01b
:042ffc00f7ffff7f5d
:020000040000fa
:020000041fc01b
:080000000010400b000000009d
:020000040000fa
:020000041d00dd
2. build trunk with "-DDEBUG"
3. attempt to program
USB HID device found
Device family: PIC32
Program memory: 512000 bytes free.
Erasing...
Writing hex file 'mini.hex':Address: 1fc02ffc Len 4
Writing
Completing
Address: 00000000 Len 8 <------------ ****
Writing
Completing
Address: 1d004000 Len 16
Writing
Completing
PASS 0 of 1 COMPLETE
What is the expected output? What do you see instead?
Inspection of the .hex file shows that it should write 4 bytes @ 1fc02ffc
then 8 bytes @ 1fc00000 then 16 bytes @ 1d004000
In fact, the second write is going to 0x00000000 instead of 0x1fc00000
What version of the product are you using? On what operating system?
trunk latest on Linux.
Please provide any additional information below.
The bug occurs in the handling of type 4 records:
} else if(4 == type) { /* Extended linear address record */
if(1 != sscanf(&hexFileData[offset+9],"%04x",&addrHi))
return ERR_HEX_SYNTAX;
addrHi <<= 16;
addr32 = addrHi + addrLo;
/* Assume this means a noncontiguous address jump; issue block
and start anew. The prior noncontiguous address code should
already have this covered, but in the freak case of an
extended address record with no subsequent data, make sure
the last of the data is issued. */
if(bufLen) {
if(ERR_NONE != (status = issueBlock(addrSave,bufLen,pass)))
return status;
bufLen = 0;
addrSave = addr32;
}
} else { /* Unsupported record type */
bug 1. addrSave is only updated on a "flush". In the example .hex, there are 2
adjacent type 4 records. The first one does a flush and sets addrSave to 0. The
second sets addr32 to 0x1fc00000 but leaves addrSave at 0!! The next data
record has an address field (low 16 bits of address) of 0 so is considered
sequential (otherwise addrSave would have been updated and everything would be
fine). Since it is considered sequential, it is saved ready for writing, but
using the wrong address: 0
The fix to this is to do "addrSave = addr32" unconditionally.
bug 2. by inspection, "addr32 = addrHi + addrLo;" should be "addr32 = addrHi;".
An addrLo value is only valid within the context/scope of a type 0 (data)
record. To consider it another way, that addrLo value belongs with the
*previous* addrHi. In a pathalogical situation this could cause an address to
be considered continuous when it is not.
With these two fixes:
Erasing...
Writing hex file 'mini.hex':Address: 1fc02ffc Len 4
Writing
Completing
Address: 1fc00000 Len 8
Writing
Completing
Address: 1d004000 Len 16
Writing
Completing
PASS 0 of 1 COMPLETE
The patch to fix these both is below:
--- hex.c.orig 2012-07-12 22:05:55.487515965 +0100
+++ hex.c 2012-07-12 22:27:47.048522549 +0100
@@ -308,7 +308,7 @@
if(1 != sscanf(&hexFileData[offset+9],"%04x",&addrHi))
return ERR_HEX_SYNTAX;
addrHi <<= 16;
- addr32 = addrHi + addrLo;
+ addr32 = addrHi;
/* Assume this means a noncontiguous address jump; issue block
and start anew. The prior noncontiguous address code should
already have this covered, but in the freak case of an
@@ -318,8 +318,8 @@
if(ERR_NONE != (status = issueBlock(addrSave,bufLen,pass)))
return status;
bufLen = 0;
- addrSave = addr32;
}
+ addrSave = addr32;
} else { /* Unsupported record type */
return ERR_HEX_RECORD;
Thanks for a very useful program. I am glad of the opportunity to make it "more
perfect".
regards,
Neal.
Original issue reported on code.google.com by [email protected]
on 12 Jul 2012 at 9:31
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.