Author Topic: AVR 0 Series- CRC Issue and question  (Read 651 times)

0 Members and 1 Guest are viewing this topic.

Offline sanka1pTopic starter

  • Contributor
  • Posts: 23
  • Country: us
AVR 0 Series- CRC Issue and question
« on: December 05, 2023, 04:05:29 pm »
Hi All,
I am using Atmega1608 and IAR IDE.
I have a boot.hex file and a App.hex file. I always update my App.hex file using the boot-loader. I want to make sure that the App.hex file has been updated correctly and has not been corrupted. To do this I want to use CRC checksum. My boot.hex file wont be changing, How can I check from the boot section that the App.hex file I just updated is correct? I can make CRC of App.hex and then just run a CRC check in the boot-loader before giving control to the App.hex. Is that a good idea? Am I missing something here? I did refer to AN2521 Application note from Microchip.
Using Analog in a Digital world.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: AVR 0 Series- CRC Issue and question
« Reply #1 on: December 05, 2023, 05:33:59 pm »
Typically you would embed the length and CRC of your application binary at fixed addresses so your bootloader can run a CRC check.  It may be possible for the length to be calculated and inserted by the linker when you build your application, you will need to investigate the linker symbols available. 

I have never used IAR so I don't know if it includes any facility for calculating and including a CRC at the link stage, most tools do not.  If not you can run a post build application (e.g. written in Python or similar) to calculate the length and/or CRC and insert it at the appropriate locations, which will will need to have been reserved to prevent any code or data being placed there.
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 828
Re: AVR 0 Series- CRC Issue and question
« Reply #2 on: December 05, 2023, 07:34:26 pm »
Quote
How can I check from the boot section that the App.hex file I just updated is correct?
That can be addressed via the bootloader and its controlling app on the pc- such as reading the flash after its programmed and compare it to what it should be. So if you want to only verify programming and do not need verification on each power up/reset, you could skip the boot crc checking (whether using hardware crcscan, or on your own).

According to your posts elsewhere-
https://www.avrfreaks.net/s/topic/a5CV400000000HlMAI/t393167?comment=P-2934502
IAR can generate the crc for you, but you would have to come up with an initial value due to the bootloader code being included in the hardware crcscan. You could also do your own crc checking code in the bootloader where you only check the app code and could then use the iar generated value with a default initial value.

Unless there is a real need for crc checking on each power up/reset, or even while running (pretty hard to otherwise detect corruption if your app remains powered on for long periods), I would stick to only verification at time of programming which is easily done by any bootloader/pc app combination (and most likely already done).
 

Offline sanka1pTopic starter

  • Contributor
  • Posts: 23
  • Country: us
Re: AVR 0 Series- CRC Issue and question
« Reply #3 on: December 05, 2023, 08:55:43 pm »
Quote
I would stick to only verification at time of programming which is easily done by any bootloader/pc app combination (and most likely already done).
I think thats a good idea. But my question is even if i find that the file I just uploaded was corrupt, how can I erase it just using an pc application?
Using Analog in a Digital world.
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 828
Re: AVR 0 Series- CRC Issue and question
« Reply #4 on: December 05, 2023, 10:37:50 pm »
Quote
But my question is even if i find that the file I just uploaded was corrupt, how can I erase it just using an pc application?
You just try programming again.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf