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

[Solved] CRC calculation over ROM/Flash range?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

[Solved] CRC calculation over ROM/Flash range?
PostPosted: Sat Dec 07, 2019 4:47 am     Reply with quote

Is there a way to get the CRC routines to work over a ROM/Flash range?
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?


Last edited by allenhuffman on Sat Dec 07, 2019 2:43 pm; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 07, 2019 6:06 am     Reply with quote

Not too sure what you mean, but data is data. Every bit of every byte of memory is accessible in any PIC...you can do what you want with it.

Maybe explain better or make me anoth rpot of coffee..still dark and cold here..
Jay
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Sat Dec 07, 2019 12:09 pm     Reply with quote

I thought the hardware architecture might prevent me from accessing it directly? I tried using the CCS CRC routines and giving it a flash address with no success. But it was around 5am after an all night coding session, so maybe I’ll have better luck when I revisit today.

After I program flash, I’d like to run a CRC check of what I programmed and validate it. I can read flash into RAM and check that, which works, but when I try to do the same check to the address it just read, I don’t get the same results.

Maybe I am not understanding the width parameter, and it has to be different when using the flash?
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Sat Dec 07, 2019 1:08 pm     Reply with quote

Maybe this is what I need:

#ROM address = crc16(start, end) - This will put a value at address that is a crc16 of all the program memory from start to end.

But, I am hoping to find a way to make a routine that will return the CRC of a specified range of Flash, so if we use our boot loader code to put a data table in program memory, dynamically, we can then verify the table after we write it .
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 07, 2019 1:20 pm     Reply with quote

You have the CRC source from this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=58331
Experiment with that routine and rom pointers.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Sat Dec 07, 2019 1:25 pm     Reply with quote

PCM programmer wrote:
You have the CRC source from this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=58331
Experiment with that routine and rom pointers.


Yes, I have a C implementation from here. I was wanting to use the hardware CRC unit in the PIC.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Sat Dec 07, 2019 2:34 pm     Reply with quote

The supplied CRC code is for a buffer in RAM.

However you can 'train' the CRC together.

What you do, is read a block from your ROM. Put this into RAM, and call the
CRC function to get a result. Then read the next block, and put the result from
the first block as the seed for this. Repeat for all the blocks. Result is the
total CRC.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Sat Dec 07, 2019 2:43 pm     Reply with quote

Thanks. That's how I was having to do it, but I was hoping the HW CRC had a way to just point it at a Flash address and it could do it directly.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Sat Dec 07, 2019 6:09 pm     Reply with quote

How does one make the crc routine continue so you can do it over several blocks of memory? I tried passing in the previous crc into the crc_init() like I do in my C version, but that did not produce expected results.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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