We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I have a structure initialized in a flash
struct DEFSTRUCT const str_default;
I also have an assembly module which loads a binary file:
AREA defprog_00111, CODE, READONLY, PREINIT_ARRAY EXPORT EXT_Default_profile EXT_Default_profile INCBIN E:\Aprojects\default_30.bin ; includes file END
How can I initialize the structure str_fefault to the loaded binary file ? I am trying to avoid an absolute placement of a structure.
I tried to search for possible solution, but no luck, or maybe I missed something.
Thank you, Gennady
I have a structure initialized in a flash
Sorry, I meant 'a structure instantiated in a flash'
If I understand the question correctly, then I think what you want is:
extern struct DEFSTRUCT const str_default;
and
AREA defprog_00111, CODE, READONLY, PREINIT_ARRAY ; EXPORT EXT_Default_profile ;EXT_Default_profile EXPORT str_default str_default INCBIN E:\Aprojects\default_30.bin ; includes file END
Then the contents of 'str_default' are defined by the file 'default_30.bin'.
Be careful: having the structure data external to the program (that is, in a file) is a fragile thing. Any change to the structure type could invalidate your data file.
You might well be better off expressing the structure value as a C initialization:
struct DEFSTRUCT const str_default = { /* ... member values here ... */ };