![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
CCS bootloader that can change eeprom. |
Posted: Wed Jun 24, 2009 11:29 am |
|
|
CCS 3.249 18F452@18.432MhZ
Has anyone seen the CCS example bootloader corrupt or change the data eeprom?
After a Firmware update my Data EEPROM seems to now all be set to 255.
((or I should say at least the first 32 bytes)) that I use for config info.
Last edited by treitmey on Thu Jun 25, 2009 9:28 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 24, 2009 11:54 am |
|
|
1. Is the problem repeatable, or does it rarely happen ?
2. Are you calling write_eeprom() in your application program ?
Comment out all such lines, and see if you still get the problem.
3. Try setting the WRTD fuse, when you program the bootloader itself
into the PIC. This will protect the data eeprom from write operations.
Also, preload the data eeprom with some known values, by using the
#rom 0xF00000 = {} method. Do this in the bootloader program itself.
See if you still get the problem. I'm trying to establish if the problem
is caused by some fluke in the code, or is it a hardware issue.
4. Have you followed all standard hardware design practices, such as
putting a 100 nF (0.1 uF) ceramic capacitor between all Vdd pins and Gnd,
placed very close to the chip ? |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Jun 25, 2009 9:19 am |
|
|
Thanks for the speedy reply.
(I've been debugging and doing what you suggested since 5min after your post)
I think I've got it solved. It was my own incorrect code.
The below code seems to be working as intended.
soo...
Any suggestions on this bootloader code chunk that allows for eprom updating. Just took the CCS loader and changed a little. I'll only post a chuck in hopes to avoid the copyright issues.
1. I increased the upper limit of addr of PCH for region of eprom 0x0f0000
2. Then I check if the address is in that area and read/write the eprom
3. ??am I correct in thinking the h_addr should be reset back to zero after a record type 4?? if record type 4 it has 2 bytes of data that are the upper 16bit of a 32bit address.
Then the next loop it uses the h_addr for make32. But after it uses the h_addr in the make32 shouldn't that be reset back to 0 until it hits another type 4 record.??
Any suggesstions for updates/enhancments
Any suggesstions for updates for PIC16
loader.c
Code: | if (line_type == 1)
{
done = TRUE;
#if defined(__PCM__)
} else if ((addr < LOADER_ADDR || addr > LOADER_END) && addr < 0x2000){
#elif defined(__PCH__)
} else if ((addr < LOADER_ADDR || addr > LOADER_END) && addr < 0xF000FF){
#endif
checksum = 0; // Sum the bytes to find the check sum value
for (i=1; i<(buffidx-3); i+=2)
checksum += atoi_b16 (&buffer[i]);
checksum = 0xFF - checksum + 1;
if (checksum != atoi_b16 (&buffer[buffidx-3]))
do_ACKLOD = FALSE;
else
{
if (line_type == 0)
{
// Loops through all of the data and stores it in data
// The last 2 bytes are the check sum, hence buffidx-3
for (i = 9,dataidx=0; i < buffidx-3; i += 2)
{
data[dataidx++]=atoi_b16(&buffer[i]);
}
if ((addr >= 0x00F00000) && (addr <= 0x00F000FF))//data eprom
{
Eaddr=addr-0x00F00000;//write_eeprom is zero based, subtract the offset
for(i=0;i<count;i++,Eaddr++)
{
tmpData=read_eeprom(Eaddr);
if(tmpData!=data[i])
{
write_eeprom(Eaddr,data[i]);
//fputc(Eaddr,DEBUG);//06/24/2009 11:54AM tjr
//fputc(data[i],DEBUG);//06/24/2009 11:54AM tjr
}
}
}
#if getenv("FLASH_ERASE_SIZE") > getenv("FLASH_WRITE_SIZE")
#if defined(__PCM__)
if ((addr!=next_addr)&&(addr&(getenv("FLASH_ERASE_SIZE")-1)!=0))
#else
if ((addr!=next_addr)&&(addr&(getenv("FLASH_ERASE_SIZE")/2-1)!=0))
#endif
erase_program_eeprom(addr);
next_addr = addr + 1;
#endif
// if data is in the EEPROM area use write_eeprom()
//record type 04, Extended Linear Address Record,
//else
write_program_memory(addr, data, count);
//h_addr =0;
}
else if (line_type == 4)
{
h_addr = make16(atoi_b16(&buffer[9]), atoi_b16(&buffer[11]));
//fputc('%',DEBUG);
//fputc(hi(h_addr),DEBUG);//06/24/2009 11:54AM tjr
//fputc(lo(h_addr),DEBUG);//06/24/2009 11:54AM tjr
//fputc('%',DEBUG);
}
}
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|