Forum : ARM
Original Post
Post Information | Post |
---|---|
January 18, 2016 - 12:33pm
|
How do I store a constant at a fixed location in the flash from within the GNU GCC compiler. The __attribute__ 'at' generates a warning to say its being ignored. This is required to do a simple sum check of the .text segment during program initialisation. e.g. csum = 0; while ( csum <> expected) - error |
Dear John,
In order to store a constant at a fixed location you need to create a section in your linker script and add your constant in the main.
Please, have a look of the count.rprj example you can find at C:\Raisonance\Ride\Example\ARM\Count:
We added the "count" variable (__attribute__) to the flash section "ram_start1"
For more information you can read GCC linker manual provided at C:\Raisonance\Ride\Doc\ARM\gcc\ld.pdf
I hope it helps.
Regards,
thanks
I had already got the declaration as
const WORD expected_chksum __attribute__((section (".myChecksumSection"))) = 0xEE9B959C ;
the problem I had was fixing location in the linker, given that the LD files get re-written each build. the 401 startup is in assembler, but adding the following to the end of startup_stm32f401xc.s appears to work
.section .text.myChecksumSection
this puts the section at the end of the vectors and before the code.
what I have found is that changing the expected checksum value also changes the actual checksum, which it shouldnt because it is stored outside of the area being checked. doing checksum in sections to try and identify,
regards
Dr Johhn
found the problem - the checksum was being stored where I wanted it and again whaere I didn't due to issue in startup file
Note that all LD files get re-written if you choose the default linker script. A part of the LD file will be re-written but not your specific script when selecting "No" to the default linker script.
You need to add this specific file in your project and specify the path.
Best regards,