CRC calculation using srec_cat
I am using STM32F207. The project that im working on will later on will be used by a bootloader. I am, therefore, trying to add crc information in the hex file so that bootloader will be able to validate its correctness.
I am using srec_cat to calculate the crc in postbuild using this example
with a modification that i use obj_copy to fill the memory gaps rather than srec_cat. (--gap-fill 0xFF)
I have added a section in linker file, with the same address as that the one used by srec_cat,
/* Sections */
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/*placing section for crc */
.crc32 0x08010000:
{
KEEP(*(.crc32)) /*keep my variable even if not referenced*/
} >FLASH
/* The program code and other data into "FLASH" Rom type memory */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
.....and
const uint32_t __attribute__ ((section(".crc32"))) crc_crc32;problems:
- Srec_cat generates error of contradictory bytes on memory address. If i set it to warning only, then it overwrites the crc. i am working around it using exclude, but then it rightly points out that there are holes in memory. What do you guys suggest i should do?
- as i am not appending the crc to the end of the file, and do not want the hex file to be bloated (hence using objcopy fill), i failed miserably to calculate the firmware size, so that bootloader would be able to use it. i know that _etext, and _edata from linker sections could be used, but im not able to calculate it.
- since i would have to jump over the memory location on which the crc is, i am using HAL_CRC_calculate along with accumulate, is this the right way of doing it?
Ples help
