CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

write_program_memory function and bootloader questions
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jeremiah



Joined: 20 Jul 2010
Posts: 1426

View user's profile Send private message

PostPosted: Mon Sep 10, 2012 5:54 pm     Reply with quote

Some fuses do prevent writing. You might check your fuse settings yes. Also, did you try it with the erase_program_memory() line uncommented? I initially left it commented since it shouldn't be needed, but you might give it a try with it not commented out as well.

Still your fuses are probably your next route to check.
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Mon Sep 10, 2012 6:10 pm     Reply with quote

jeremiah wrote:
Some fuses do prevent writing. You might check your fuse settings yes. Also, did you try it with the erase_program_memory() line uncommented? I initially left it commented since it shouldn't be needed, but you might give it a try with it not commented out as well.

Still your fuses are probably your next route to check.

sorry, man, I just updated my last poster and tried uncomment the erase program line, the same result.

and my fuse is
Code:

#if defined(__PCD__)
#include <33EP256MU814.h>
#fuses HS,PR,NOWDT,ICSP2
#device ADC=12
#use delay(clock=20000000) // Actual crystal is 20M
#pin_select U1TX = PIN_D0
#pin_select U1RX = PIN_D1
#pin_select U2TX = PIN_D2
#pin_select U2RX = PIN_D3
#use RS232(UART1, STREAM = GSM, BAUD=2400, XMIT = PIN_D0 , RCV = PIN_D1 ,  BITS = 8, STOP = 1, PARITY = N, ERRORS)
#use RS232(UART2, STREAM = MODBUS, BAUD=9600, XMIT = PIN_D2 , RCV = PIN_D3 ,  BITS = 8, STOP = 1, PARITY = N, ERRORS)
#use i2c(MASTER, I2C1,SCL = PIN_D10, SDA = PIN_D9 , FORCE_SW)
#pin_select IC1=PIN_F0
#pin_select C1TX = PIN_D6
#pin_select C1RX = PIN_D5
#endif

Just have some other port declaration than your example code, I think that won't effect the result. The fuse part are the same. Sad
jeremiah



Joined: 20 Jul 2010
Posts: 1426

View user's profile Send private message

PostPosted: Mon Sep 10, 2012 6:20 pm     Reply with quote

You aren't specifying many fuses, so there are a lot of them being defaulted. You might check and see if any of those prevent writing to flash memory. That's all I can think of.
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Mon Sep 10, 2012 6:37 pm     Reply with quote

jeremiah wrote:
You aren't specifying many fuses, so there are a lot of them being defaulted. You might check and see if any of those prevent writing to flash memory. That's all I can think of.

Thanks for your time, mate. I will check it out. Meanwhile I am trying another board although it has dsPIC30 on it, I just wanna make sure that is not hardware problem... Sad
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Mon Sep 10, 2012 7:35 pm     Reply with quote

jeremiah wrote:
You aren't specifying many fuses, so there are a lot of them being defaulted. You might check and see if any of those prevent writing to flash memory. That's all I can think of.

Hey, mate.
a very funny thing I just found.
I tried to program the code into micro and the MPLAB told me program failed, and then the code ran on my screen CORRECTLY! Then I reprogram, this time it said program/verify complete, then the code ran and back to the bad result again! Only one time I got the program/verify complete notice after I using MPLAB programmer and got correct result, others are all bad ones..
I was really mad by this compiler and programmer and the micro...
asmallri



Joined: 12 Aug 2004
Posts: 1680
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Sep 10, 2012 7:50 pm     Reply with quote

naughty_mark wrote:
jeremiah wrote:
You aren't specifying many fuses, so there are a lot of them being defaulted. You might check and see if any of those prevent writing to flash memory. That's all I can think of.

Hey, mate.
a very funny thing I just found.
I tried to program the code into micro and the MPLAB told me program failed, and then the code ran on my screen CORRECTLY! Then I reprogram, this time it said program/verify complete, then the code ran and back to the bad result again! Only one time I got the program/verify complete notice after I using MPLAB programmer and got correct result, others are all bad ones..
I was really mad by this compiler and programmer and the micro...


You cannot verify a PIC with code protection set - obviously. If you could do this then it would be a simple process of elimination to crack the contents of any code protect PIC.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Mon Sep 10, 2012 7:55 pm     Reply with quote

asmallri wrote:
naughty_mark wrote:
jeremiah wrote:
You aren't specifying many fuses, so there are a lot of them being defaulted. You might check and see if any of those prevent writing to flash memory. That's all I can think of.

Hey, mate.
a very funny thing I just found.
I tried to program the code into micro and the MPLAB told me program failed, and then the code ran on my screen CORRECTLY! Then I reprogram, this time it said program/verify complete, then the code ran and back to the bad result again! Only one time I got the program/verify complete notice after I using MPLAB programmer and got correct result, others are all bad ones..
I was really mad by this compiler and programmer and the micro...


You cannot verify a PIC with code protection set - obviously. If you could do this then it would be a simple process of elimination to crack the contents of any code protect PIC.


sorry, mate. I can not quite understand what you mean. Do you mean I shouldn't have PR in #fuse?

Actually yesterday, I tried to read out the hex from micro by using MPLAB and export it, then compare with my hex file. They are not different! only part of them are the same and the second half of my hex file is not equal with the content read out in same address.
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Mon Sep 10, 2012 8:48 pm     Reply with quote

Hi, guys.

I noticed that in configuration bit, there is a register named "FGS" and has "GSSK" and "GSS" and "GWRP", which showed in datasheet page 474, and as it required, I set it in #fuse

so now is
Code:
#fuses HS,PR,NOWDT,ICSP2,NOPROTECT,NOGSSK


but still doesn't work Sad
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Tue Sep 11, 2012 1:05 am     Reply with quote

Hi, Guys.

Finally I fixed it.

Although I don't know why. the fuse statement is
Code:

#fuses HS,PR,NOWDT,ICSP2,NOGSSK,NOPROTECT,NOAPROTECT,NOAPLK

I found it by accident, because I found the NOGSSK fuse first and tried, but failed, and then I think maybe I can not write to main flash memory while I run code on it. So I tried to write to Auxiliary flash, and change the write address, failed again. Then I change to main flash memory write back but without delete, NOAPLK and NOAPROTECT fuse. Then it works!!!!!!

Now I can let my bootloader code work~ just need CCS to support auxiliary flash to put bootloader code. Or maybe it is my fault. Maybe try download bootloader code to auxiliary flash tomorrow.

Anyway, thank you all guys! thanks a lot! Very Happy
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Sep 11, 2012 5:35 am     Reply with quote

Usual steps to prevent problems like this are:
- review valid fuses in CCS IDE
- if you have any doubts about correct fuse settings, check the actual fuses in MPLAB, compare with datasheet specifications
- if necessary, correct CCS fuse definitions in device editor or bypass the compiler fuse output by writing the configuration words with a #rom statement
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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