Adding crc32 in the last 4 bytes of flash

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I'm trying to understand if is possible to add crc32 in the last 4 bytes of my program.

Now I have modified my project options adding the "srec_cat" in the post build command line and this work fine but in this way I can add the CRC32 only in bin, intel etc, but when start a debug session the debugger load my program without the last 4 bytes.
Can someone help me to understand where I'm wrong ?

Thanks in advance

Last Edited: Tue. Feb 21, 2017 - 08:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Earlier today, on AVR Freaks:

 

https://www.avrfreaks.net/forum/a...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, 

but there is something I don't understant. I have already user srec_cat in the post-build command, but in this way I can only modify the HEX BIN etc. What I want to do is to add a CRC32 also to the ELF program loaded from the debugger. 

Is it possible ? Sorry maybe this is a basic question but I really can not solve this problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I cannot think of an "easy" way do what you want here. All I can suggest is that you get srec_cat to do the process and find out what the CRC is then when you debug the ELF use the debugger to modify the last 4 bytes in the flash memory image once it has loaded. But presumably srec_cat is also 0xFF padding the "unused" space beyond the end of the app code right up to whether the 4 bytes are located? I'm not sure of an easy way to achieve that automatically.

 

EDIT: having said tha. If you are debugging the operation of a CRC checking bootloader then don't you actually use the debugger to run the bootloader to the point just after when it has received and SPM'd the data. At this stage the "empty" area should now be 0xFF and the last 4 bytes should be the CRC so now you can step through the code that does the runtime CRC calculation as the integrity check. So why would you need the CRC in the ELF anyway?

 

(don't tell me you have combined app and bootloader into one source project?)
 

Last Edited: Tue. Feb 21, 2017 - 04:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not Studio related, moving to general programming.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are modifying hex file uding srec tool and adding elf to debug then at debug session you will not see CRC as CRC is appended to hex bit you are flashing elf.

To do so
1. Modify hex using stec tool
https://embdsysbasics.blogspot.com/2018/12/hex-file-checksum-calculator-using.html?m=1

2. After appending CRC at end, load elf.
3. If it is possible for the compiler to change flash containts by loading hex file, then load modified hex file to change flash memory containts.
e.g as in ghs compiler you will use FLOAD cmd.
4. Or try write CRC at particular address of target using memory window. ( not recommended option)

Last Edited: Thu. Jan 17, 2019 - 05:53 PM