[chbot] C question: variables in GCC
Bevin Brett
bevin_brett at hotmail.com
Fri Jun 2 06:46:39 BST 2023
Mark wants some value to be written in one 'boot' of his program, and available in the next 'boot'
Robin suggests using the eeprom
Charles suggests creating a linker section which is not initialized by the loader - (.bss and .data ARE initialized), at a known address [strictly speaking, just place an extern symbol in it, so you don't need to hardcode the number anywhere, and use its address), and aim a c pointer at it.
Robin's approach is very kosher
For the linker approach to work, you are going to need cooperation with the loader - it will all depend on whether the loader on your system does support such sections, and does it guarantee that they end up on same physical memory and that memory has not been trashed between the shutdown of the previous app and the end of the boot of the next app.
Obviously in a virtual-memory system they will not. Nor will it work on a system which tries to protect one execution from the next. But on a low level bare metal machine it may - unless the shutdown mechanisms of the first run, the decision to run the loader, and the loader itself (these all have run somewhere, right) - trash the location you have chosen.
/Bevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20230602/4f2e3a36/attachment.html>
More information about the Chchrobotics
mailing list