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

[nRF52811]Implement the FDS example

Hi,

I got problem with Implementing the FDS example code as below, which I using is SDK nRF5_SDK_17.0.2, and always got error "FDS_ERR_UNALIGNED_ADDR", Already searched this issue and found that  "__ALIGN(4)" may be a solution for it, please help indicate how to use it for the example, thanks

static ret_code_t fds_write(void)
{       
    //ret_code_t err_code=NRF_SUCCESS;
        otLogDebgMac("write %d\n",__LINE__);
        
        static char       const m_hello[]  = "Hello, world!";
        fds_record_t        record;
        fds_record_desc_t   record_desc;
        
        // Set up data.
        record.data.p_data       = &m_hello;
        /* The following calculation takes into account any eventual remainder of the division. */
        record.data.length_words = (sizeof(m_hello) + 3) / 4;
        // Set up record.
        record.file_id              = FILE_ID;
        record.key                      = REC_KEY;
        
        otLogDebgMac("hello address: %p\r\n", (void*)&m_hello);
        otLogDebgMac("hello length: %d\r\n"record.data.length_words);
        
        ret_code_t ret = fds_record_write(&record_desc, &record);
        if (ret != NRF_SUCCESS)
        {
                otLogDebgMac("Webber: fds_record_write failllllllllll %d\n",__LINE__);
                return ret;
        }
         otLogDebgMac("Writing Record ID = %d \r\n",record_desc.record_id);
        return NRF_SUCCESS;
}
-----: hello address: 0x25df6
-----: hello length: 4
fds.c
if (!is_word_aligned(p_record->data.p_data))
    {
        
        otLogDebgMac("%p is unaligned\r\n"p_record->data.p_data);
        otLogDebgMac("FDS_ERR_UNALIGNED_ADDR");
        return FDS_ERR_UNALIGNED_ADDR;
    }
-----:0x25df6 is unaligned
-----: FDS_ERR_UNALIGNED_ADDR
thanks,
Webber
Related