This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

The same code getting FDS_ERR_UNALIGNED_ADDR in Release mode but not in Debug mode

Hello,

I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flashing the image. I am using ‘ble_app_blinky’.

I am using FDS module to write into Flash. I am observing strange behavior. I have gone through fds example.

Below is my structure. Initially either in Release or Debug mode I did not face any problem. Suddenly I started getting FDS_ERR_UNALIGNED_ADDR for same code base (I added few code for other functionality).

/* A record containing Datalog state data. */
static fds_record_t const DtStateRecord =
{
    .file_id           = FILE_ID,
    .key               = RECORD_KEY_2,
    .data.p_data       = &eDataLogRecordingState,
    /* The length of a record is always expressed in 4-byte units (words). */
    .data.length_words = (sizeof(eDataLogRecordingState) + 3) / sizeof(uint32_t),
};

My queries are

1) Whether "eDataLogRecordingState" in above structure should be word aligned.

2) In fds example only 'length_words' variable is make sure multiple of 4. But no where data.p_data is word aligned.

3) In "Debug" mode eDataLogRecordingState is word aligned (0x0000000020002e28). Where as in "Release" mode eDataLogRecordingState is not word aligned (0x0000000020002dc9). Will this cause FDS_ERR_UNALIGNED_ADDR error.

4) To make sure always word aligned then whether below way is fine. If yes, better modify FDS example so that it will be easy for new developers. In that case, irrespective of aligned or not aligned, __ALIGN(4) to be kept for all FDS variables so that FDS variables will always be word aligned.

__ALIGN(4) DataLogRecordingStates_t eDataLogRecordingState = 0;

Thanks & Regards

Vishnu Beema

Related