nRF52840 SDK16 - nrf_fstorage: addr_is_within_bounds(p_fs, dest, len) check failed in nrf_fstorage_write() with value 0x10.

Hi guys,

I try to integrate the flash logger backend

When I run the code I get the following error:

<error> nrf_fstorage: addr_is_within_bounds(p_fs, dest, len) check failed in nrf_fstorage_write() with value 0x10.

This is the sdk_config section

//==========================================================
// <e> NRF_LOG_BACKEND_FLASH_ENABLED - nrf_log_backend_flash - Log flash backend
//==========================================================
#ifndef NRF_LOG_BACKEND_FLASH_ENABLED
#define NRF_LOG_BACKEND_FLASH_ENABLED 1
#endif
 
// <e> NRF_LOG_BACKEND_FLASHLOG_ENABLED - Enable flashlog backend.
//==========================================================
#ifndef NRF_LOG_BACKEND_FLASHLOG_ENABLED
#define NRF_LOG_BACKEND_FLASHLOG_ENABLED 1
#endif
// <o> NRF_LOG_BACKEND_FLASHLOG_QUEUE_SIZE - Logger messages queue size. 
// <i> Queue holds log messages pending to be written to flash.
// <i> Note that the queue holds logger messages and thus the queue size determines
// <i> increasing the pool of logger messages (see log message pool configuration).
 
#ifndef NRF_LOG_BACKEND_FLASHLOG_QUEUE_SIZE
#define NRF_LOG_BACKEND_FLASHLOG_QUEUE_SIZE 8
#endif
 
// </e>
 
// <e> NRF_LOG_BACKEND_CRASHLOG_ENABLED - Enable crashlog backend.
//==========================================================
#ifndef NRF_LOG_BACKEND_CRASHLOG_ENABLED
#define NRF_LOG_BACKEND_CRASHLOG_ENABLED 1
#endif
// <o> NRF_LOG_BACKEND_CRASHLOG_FIFO_SIZE - Number of log messages held to be flushed in panic. 
// <i> Crashlog FIFO always keeps a defined number of the most
// <i> recent logs (severity level is set on runtime).
// <i> Note that the FIFO holds logger messages and thus the FIFO size determines
// <i> increasing the pool of logger messages (see log message pool configuration).
 
#ifndef NRF_LOG_BACKEND_CRASHLOG_FIFO_SIZE
#define NRF_LOG_BACKEND_CRASHLOG_FIFO_SIZE 8
#endif
 
// </e>
 
// <o> NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE - Size of the buffer used for serialize log message. 
// <i> Message is trimmed if it is longer. It may happen in case of 
// <i> hexdump message. Buffer size must be multiple of 4.
 
#ifndef NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE
#define NRF_LOG_BACKEND_FLASH_SER_BUFFER_SIZE 64
#endif
 
// <h> Flash log location - Configuration of flash area used for storing the logs.
 
//==========================================================
// <o> NRF_LOG_BACKEND_FLASH_START_PAGE - Starting page.  
// <i> If 0, then pages directly after the application are used.
 
#ifndef NRF_LOG_BACKEND_FLASH_START_PAGE
#define NRF_LOG_BACKEND_FLASH_START_PAGE 0
#endif
 
// <o> NRF_LOG_BACKEND_PAGES - Number of pages. 
#ifndef NRF_LOG_BACKEND_PAGES
#define NRF_LOG_BACKEND_PAGES 1
#endif
 
// </h> 
//==========================================================
// </e>

This is my flashlog init function:

void flashlog_init(void) {
  ret_code_t ret;
  int32_t backend_id;

  ret = nrf_log_backend_flash_init(&nrf_fstorage_sd);
  APP_ERROR_CHECK(ret);

  backend_id = nrf_log_backend_add(&m_flash_log_backend, NRF_LOG_SEVERITY_WARNING);
  APP_ERROR_CHECK_BOOL(backend_id >= 0);

  backend_id = nrf_log_backend_add(&m_crash_log_backend, NRF_LOG_SEVERITY_INFO);
  APP_ERROR_CHECK_BOOL(backend_id >= 0);

  nrf_log_backend_enable(&m_flash_log_backend);
  nrf_log_backend_enable(&m_crash_log_backend);
}

The error returns from nrf_fstorage_write() when calling the NRF_FSTORAGE_PARAM_CHECK(addr_is_within_bounds(p_fs, dest, len), NRF_ERROR_INVALID_ADDR)

What am I missing?

Parents Reply
  • Thank you Vidar,

    But I only see the "addr_is_within_bounds(p_fs, dest, len)" error once on startup if reset the device

    I stopped receiving this error as soon as I enabled the dynamic log filtering. So let's assume that this issue has been resolved.

    Please note that the actual text strings are not stored in the logging flash page

    That's clear, so the flash page stores just pointers that reference the actual text strings that are stored in a different flash location.

    You were inputting the decimal address as an hex address.

    I didn't notice, thanks!!

    To read a log message you need to use the nrf_log_backend_flash_next_entry_get() function

    I run your example but I do not see how can I print the string text logs using the  nrf_log_backend_flash_next_entry_get() . Could you please provide an example?

Children
Related