Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6940759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:47:39+00:00 2026-05-27T12:47:39+00:00

I have a configuration structure I would like to save on the internal flash

  • 0

I have a configuration structure I would like to save on the internal flash of ARM cortex M3.
According to the specifications, the data save in the internal flash, must be aligned to 32bit.
Because I have lot’s of boolean, and chars in my structure,I don’t want to use 32bits to store 8 bits… I decided to pack the structure using the __packed preprocessor pragma, Then When I save it as a whole structure, I just have to make sure that the structure size is divisible by 4 (4 bytes = 32bits), I do it by adding padding bytes if needed.
Currently, during development I alter the structure a lot, and to make it aligned with the 32 bits, I need to change the padding bytes all the time.
Currently, the structure look slike this

typedef __packed struct
{
uint8_t status;
uint16_t delay;
uint32_t blabla;
uint8_t foo[5];
uint8_t padding[...] // this has to be changed every time I alter the structure.
} CONFIG;

Is there a better way to achieve what I’m doing ?
I’m quite new in Embedded programming, and I want to make sure that I’m not doing mistakes.

Edit: Please note. The data is persisted in the end of the internal-flash, so omitting the padding will not work…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:47:40+00:00Added an answer on May 27, 2026 at 12:47 pm

    Perhaps this is an idea:

    typedef __packed struct {
        uint8_t status;
        uint16_t delay;
        uint32_t blabla;
        uint8_t foo[5];
    } CONFIG;
    
    typedef __packed struct {
        CONFIG cfg;
        uint8_t padding[4 - (sizeof(CONFIG) % 4)]
    } CONFIGWRAPPER;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some configuration data that I'd like to model in code as so:
I have some configuration data in a config file that I read off disk
I have some application settings that I'd like to add to my configuration file,
I need to have some configuration options on my website. I thought it would
I have an external configuration file, for a third party tool, which I would
I have a menu structure that outputs a list of favourite configuration items. In
I have an existing ASP .NET MVC application and I would like to ignore
I have a data structure representing a CSV file containing thousands of config settings.
I have a structure that only one function must access. The function converts tokens
I have the following array structure: Array ( [0] => Array ( [configuration_id] =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.