2020-11-08 10:38 AM
Hi all. I am working on a project that consist of 3 separate codes. One is bootloader, another is static code and the last one is updatable code. They all share one flash. Static code only fulfills basic tasks and updatable code is more sophisticated but it is more open to bugs.
Normally updatable code runs on MCU and I update it according to feedbacks. But sometimes bugs are occurring in updatable code, than I command MCU to branch static code until I solve bugs in updatable code.
This 3 separate codes are using same protocol to communicate and the communication functions occupies a lot of flash space. What I want to ask is, is there a way to place communication functions in flash not for every code and just for one time? Is there any example, application note or a source about that subject?
2020-11-08 11:18 AM
Typically you could build a jump table of function/API entry points, or provide the downstream linker with a definition file.
The code being call needs to use pointers or registers, be self contained, you can't use global variables or allocate memory, as these would be different.
So things like AES, SHA256, SECPxxx which are hogs would be good candidates.
2020-11-08 11:21 AM
Thanks for answer. If I use global variables in that functions with same names in sperate codes, does it work?
2020-11-08 01:46 PM
No
The linker puts things in different places. if you're using a lot of global variables you likely don't have the rigor to cleanly separate and reuse things.
You could define some common area and have those be the same, but that's a lot more work than just being more object oriented and use structures and pointers.
For floating point libraries you'd want to reference all functions so the linker would pull a complete set rather than do dead code elimination.