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

Unable to align data to get rid of FDS_ERR_UNALIGNED_ADDR error

Hi! I am using SDK15.0 and SD 132 v6.0.0. My IDE is Segger Embedded Studio.

Everything was working fine and then suddenly after few weeks of developing a problem appeared.

I try to use FDS to write some data to flash memory but instead I get FDS_ERR_UNALIGNED_ADDR error.

Here is the code:

ret_code_t write_to_flash(uint32_t file_id, uint32_t key, void * data, uint8_t words_length, fds_record_desc_t * record_desc)
{   
    static fds_record_t record;
    
    record.file_id = file_id;
    record.key = key;
    record.data.p_data = data;
    record.data.length_words = words_length; 
    ret_code_t rc = fds_record_write(record_desc, &record);
    
    if(rc != FDS_SUCCESS)
    {
      NRF_LOG_INFO("FDS write error, code: %d", rc);
      return rc;
    }
    return NRF_SUCCESS;
}

And the call:

  rc = write_to_flash(0x0001, 0x0001, temp_adv_name_buffer, 4, &temp_adv_name_buffer_record_desc); 

Nothing really special, just the basics I believe.

I have read many posts on this topic but nothing helps me, I have tried various combinations of 

__ALIGN(4)

as well as 

__attribute__ ((aligned (4)))

applied to the fds_record_t definition in fds.h as well as fds_record_t record structure variable but no result.

When I print out record.data.p_data it turns out the address is 0x20006AB2, which is not 4-byte aligned afaik. The address doesn't change at all.

What do you suggest to do?

Thanks

Related