I have a configuration structure that I would like to keep on the ARM cortex M3 internal flash. According to the specifications, the data storage in the internal flash should be aligned to 32 bits. Since I have a lot of logical and symbols in my structure, I don’t want to use 32 bits to store 8 bits ... I decided to pack the structure using the preprocessor pragma.Then __packed, when I save it in the whole structure, I just have to make sure that the size structure is divided by 4 (4 bytes = 32 bits), I do this by adding padding bytes, if necessary. Currently, during development, I change the structure a lot, and so that it aligns with 32 bits, I need to constantly change padding bytes. Currently the structure looks like slike this
typedef __packed struct
{
uint8_t status;
uint16_t delay;
uint32_t blabla;
uint8_t foo[5];
uint8_t padding[...]
} CONFIG;
Is there a better way to achieve what I am doing? I am new to embedded programming and I want to make sure that I am not mistaken.
Edit: Please note. Data is saved at the end of the internal flash, so lowering the pad will not work ...
source
share