View previous topic :: View next topic |
Author |
Message |
MarcosAmbrose
Joined: 25 Sep 2006 Posts: 38 Location: Adelaide, Australia
|
Programming PIC without erasing EEPROM |
Posted: Mon Apr 23, 2007 8:06 pm |
|
|
Everytime re-compile and upload new code to my target board, the ICD-U40 erases the EEPROM.
"PCM programmer" posted a link in previous post which had the same problem, but the link doesn't work anymore. "PCM programmer", can you or anyone else recall what the solution was? -Cheers |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 24, 2007 6:43 pm |
|
|
Here is the information from that link:
Quote: |
If anyone else wants to know how to preserve the Data EEPROM on the
target chip, you have to click on "Advanced" in the ICD Control program
(invoked by clicking the little hammer and wrench icon in the Debug
Configure tab), then select "Erase when needed" under the Erase Modes
section. As long as the program file being downloaded doesn't contain
any Data EEPROM data, the Data EEPROM section of flash memory will
be preserved. |
|
|
|
Dimmu
Joined: 01 Jul 2007 Posts: 37
|
|
Posted: Tue Jul 17, 2007 1:46 pm |
|
|
Is it normal that I do not see the "Erase when needed" option but only the "bulk erase" and the "no erase" options in the Erase modes section ?
I found that the Erase and Burn section allows to prevent the EEPROM from being programmed, but the tools often resets my settings. Is it a special way to force this setting -but still the best option would be to used the famous erase when needed...- ?
Dimmu |
|
|
nilsener
Joined: 06 Dec 2005 Posts: 59
|
|
Posted: Mon Dec 07, 2009 11:40 am |
|
|
Hello Dimmu,
Sorry for reactivating this old thread. I have the same problem but with Microchips MPLAB ICD2. It seems to be impossible to reprogram the PIC with new software without erasing the EEPROM that is Code Protected in this case. My data in EEPROM must not be erased as it contains calibration data.
Have you solved your problem with the ICD-U40 to program (not to debug) the PIC while don't erasing the EEPROM? Then I will buy an ICD-U40.
Best Regards
nilsener |
|
|
Dimmu___ Guest
|
|
Posted: Mon Dec 07, 2009 1:09 pm |
|
|
Nope,
Never found a good way to do this.
On the other hand, I didn't touch a PIC for about 1 year now, so maybe the softwares have been updated since.
Best regards
Dimmu |
|
|
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
|
Posted: Fri Jan 08, 2010 11:06 am |
|
|
It's very easy to program a PIC chip without touching the EEPROM if you use a pickit 2 or 3 with their software. So that's a possibility if you have no other way to do it. Pickit2 is pretty cheap. |
|
|
JH1987
Joined: 22 Jan 2011 Posts: 11
|
Can't Preserve Data EEPROM with PickIt 2 |
Posted: Sat Jan 22, 2011 12:58 pm |
|
|
collink wrote: | It's very easy to program a PIC chip without touching the EEPROM if you use a pickit 2 or 3 with their software. So that's a possibility if you have no other way to do it. Pickit2 is pretty cheap. |
I'm having trouble programming a PIC while preserving Data EEPROM with the Pickit 2. What I'm trying to do is recover EEPROM data from a unit that had a failure in the field. I don't have the option of just reading back the Data EEPROM without programming because I have the CPD fuse set, which read-protects the Data EEPROM. So I have to download a program that prints the contents of EEPROM out on an rs232 pin.
I'm using the Pickit 2 Programmer app:
App Version 2.61.00
Device File Version 1.62.03
OS FW Version 2.32.00
and a PIC18F4685 which has 256 bytes of Data EEPROM.
I unchecked the Data EEPROM box in the app, which says 'preserving device EEPROM data on write'. However, I have to erase before I can write. When I erase, the Data EEPROM is not preserved. So there seems to be no way to preserve it. I also tried unchecking the mysterious 'Clear Memory Buffers on Erase', which seems to be the only setting which may affect the EEPROM. This setting is not discussed in the Pickit documents. Any idea what it means?
Anyway, I seem to be at a dead end and I really need that data. I'd really appreciate any help you guys could offer. |
|
|
JH1987
Joined: 22 Jan 2011 Posts: 11
|
Doesn't Seem Possible with CPD |
Posted: Sat Jan 22, 2011 1:41 pm |
|
|
collink wrote: | It's very easy to program a PIC chip without touching the EEPROM if you use a pickit 2 or 3 with their software. So that's a possibility if you have no other way to do it. Pickit2 is pretty cheap. |
Based on what I read on Microchip forums, I think what you're talking about involves the Pickit reading the data EEPROM, erasing the whole chip, programming the chip, then writing the data EEPROM with the old values.
If you have the CPD (Data EEPROM code-protected) fuse set, then it can't read the EEPROM. That's why I can't just read the EEPROM in the GUI and get the data.
Is there any way to make this thing only erase/write program memory without touching data EEPROM? Some way to give it an address range? The GUI is really limited. I guess I could check out the cmd line option. I'll keep searching. |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sat Jan 22, 2011 9:35 pm |
|
|
What you want to do is theoretically possible, but not with your current hardware (programmer) and software.
Microchip have a relevant programming specification document:
http://ww1.microchip.com/downloads/en/DeviceDoc/39622L.pdf
See section 3 on page 14. There are specific commands to selectively erase portions of code memory, allowing it to be reprogrammed. However, I don't know of any package to let you do this, so you'll either have to develop one yourself (and corresponding hardware), or find some open source PIC programmer software that you could modify. _________________ Andrew |
|
|
JH1987
Joined: 22 Jan 2011 Posts: 11
|
Thanks for getting back to me |
Posted: Sun Jan 23, 2011 11:36 am |
|
|
andrewg wrote: | What you want to do is theoretically possible, but not with your current hardware (programmer) and software.
Microchip have a relevant programming specification document:
http://ww1.microchip.com/downloads/en/DeviceDoc/39622L.pdf
See section 3 on page 14. There are specific commands to selectively erase portions of code memory, allowing it to be reprogrammed. However, I don't know of any package to let you do this, so you'll either have to develop one yourself (and corresponding hardware), or find some open source PIC programmer software that you could modify. |
You're right, it's not possible with the Pickit 2.
The programming doc was helpful. An "Erase Configuration Bits" command would solve the problem. It would set the CPD back to 1, which leaves the Data EEPROM unprotected. Then I could just read out the data EEPROM with the Pickit GUI.
At this point its simpler just to program out-going units with the CPD set to 1, and wait for the failure to occur again. It's a rare problem that affects a very small % of units, but it would be nice to have the data now instead of in a month.
If somebody is in the same situation but they absolutely need the info in Data EEPROM, they could build a Pickit board themselves. Microchip provides the schematics and the code (for the Microchip compiler), so you could spin your own board and modify the Pickit firmware.
Thanks for your help. |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
Re: Thanks for getting back to me |
Posted: Sun Jan 23, 2011 10:01 pm |
|
|
JH1987 wrote: | An "Erase Configuration Bits" command would solve the problem. | FYI, you've missing the note on the page that says a bulk erase is the only way to do that.
There's also a sentence that says if the data EEPROM is protected, you must ask for it to be erased.
On thinking about it, Microchip takes it's data protection facilities fairly seriously, and I'd be surprised if you could get access to protected data even indirectly.
Maybe you could change the firmware to support a debug dump of the data? For example, I use a 6-pin ICSP header and for one project I have it set up so that if I short the middle two pins (GND and B7) with a screwdriver the board goes into a "factory setup" mode. Adding a debug dump, even if it's a bit-bang serial port on B5/6/7 would be quite possible, unless you're already using those pins, of course. _________________ Andrew |
|
|
JH1987
Joined: 22 Jan 2011 Posts: 11
|
Bulk Erase |
Posted: Mon Jan 24, 2011 10:15 am |
|
|
Hey Andrew,
I actually did see the sentence "A Bulk Erase is the only way to reprogram
code-protect bits from an ON state to an
OFF state."
But since the bulk erase operation is configurable, I thought you could set the Bulk Erase Control registers to something like Erase Configuration Bits (0082h) and then execute the bulk erase. I wonder if that would turn off code protection. Like you say, Microchip takes code protect seriously, so maybe the IC has another safeguard. And you're right, they do say you have to erase data EEPROM when protected. But you'd think if you could do that bulk erase and clear the config bit, then you could get to the EEPROM. It might make an interesting experiment...
As for the factory debug feature, I could definitely do that. I was trying to replace the code in the PIC with code that did almost exactly that. For me its easier just to turn of CPD, since that EEPROM data really doesn't need to be protected. For somebody that needs protection, your option is better.
Thanks for your reply. |
|
|
|