0

I am developing a Project over a Arduino Due Board(ATSAM3X), I am using Atmel Studio7, and ASF. I would like to know how to read a flash memory block/region, to calculate CRC32 or a simple check sum memory, the datasheet is very confusing, EEFC module describe how to write in the flash or how read "Unique Identifier", but not how read an address flash range.

If someone has a example code or documentation that i can read, I would be grateful.

Best Regards to everybody. Marco

artless noise
  • 21,212
  • 6
  • 68
  • 105
mabroglia
  • 1
  • 2
  • you mean the flash memory you are executing out of that has a fixed address space? you just point at it and read it yes? – old_timer Dec 11 '17 at 21:15
  • I dont know if I asked the question correctly, my apologies, but ATSAM3X has flash memory range from 0x80000h up to end of flash code. I would like just to 'read' the data of these address range in execution time to calculate a checksum. – mabroglia Dec 11 '17 at 21:31
  • then just do that, read it. unsigned char *x; x = (unsigned char *)0x80000; and just use it (then mix in volatiles if/as needed) – old_timer Dec 11 '17 at 22:02
  • are you running on an operating system an RTOS? – old_timer Dec 11 '17 at 22:14
  • 2 Code lines, problem solved. "You are the man!", I am grateful for your response. – mabroglia Dec 11 '17 at 22:31
  • About RTOS. At moment I am not intend to use RTOS, just pulling and wait by request, now it is enough to me, but in future I will analize this alternative. – mabroglia Dec 11 '17 at 22:38
  • if you had an RTOS the solution might not work but that depends... – old_timer Dec 11 '17 at 23:47

1 Answers1

0

You can use
char *ptr = <start address of the required memory block>;
and then start reading from ptr.

You happen to mention that you are going to calculate checksum. Calculating checksums of running programs has a disadvantage that the programs data section (section which contains variable assignments among other things) changes as program executes. Calculate checksum only of the text section, which remains constant throughout the program. Read about code sections for more details.