I would lije to perform a CRC or Checksum for the FLASH memory of my device, an AVR32UC3, this will be performed by blocks, so I'm thinking that the prototype can be:

uint32_t calculateCRC( uint32_t startAddr, uint32_t endAddr); 
  1. Do the contents of the Flash memory of the AVR32 have 32bit values?
  2. If i try to do a FULL flash CRC the startAddr value would be 0x0 or 0x80000000?? (due to the program start of the AVR32 is in 0x80000000).
  3. what could be the value for endAddr if checking the whole memory?
  • 3
    \$\begingroup\$ If you can't answer (1) and (2) on your own, you probably should not even be attempting this (or embedded C programming generally.) This is bog standard stuff you get straight from the datasheet, if you can read it. (3) is a good question, though. The map file can be read for this number, though that doesn't automate things for you and you'd have to compile twice. You should be able to arrange code in assembly, linked to your C code, to achieve this. Study the segment layout. It's also possible that your compiler provides an automated way. Can't say. \$\endgroup\$ – jonk May 30 '17 at 0:08
  • \$\begingroup\$ agree with jonk. easiest way to do the check/result value is to have an additional program after the toolchain that fills both it and the length of the program into a binary you can load. since the rest of the memory may not be initialized you would want to have a tool initialize it. so either checksum the length of the produced code, or have the tool pad and then provide the answer. \$\endgroup\$ – old_timer May 30 '17 at 2:09
  • \$\begingroup\$ @jonk: (1) and (2) have nothing to do with the datasheet. A1: If you read them in 32-bit groups, they will be 32-bit values. The actual Flash parameters (word size, block size) only matter for writing. Although reading 32-bit chunks could get awkward if the word size isn't 8, 16, or 32 bits, it would still be completely possible. A2: It depends on how you write the calculateCRC function, does it treat startAddr as an absolute or relative address. It's possible to write the code either way. \$\endgroup\$ – Ben Voigt May 30 '17 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.