Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

flash_manager works properly only after a reset

Hello, I have a issue about flash_manager module.

When I load a program on processor (that has been previously erased) there is a problem with initialization (flash_manager_add return NRF_ERROR_NO_MEM ) and then with writing data. But when I restart progam everithing works fine (even writing and reading data)

I use: 

  • nRF52840
  • SDK version: 17.0.0
  • SDK for Mesh version: 4.2.0

I just want the flash_manager to work properly from the beginning.

Thanks in advance for any help or tip!

Parents
  • Hi, 

    Do you use a custom board or nRF52840DK? How do you erase the board and restart progam

    Could you step into flash_manager_add to see which function or code returns NRF_ERROR_NO_MEM?

    Regards,

    Amanda 

  • Yes, I use custom board. I erase / restart program using Segger Embedded Studio debugger. The code look like this:

    void flashStorage_init(){ 
        flash_manager_t flashManager;
        
        flash_manager_page_t * p_area;
        p_area = (flash_manager_page_t *)(((const uint8_t *) flash_manager_recovery_page_get()) 
                                               - (15 * PAGE_SIZE));
    
        const flash_manager_config_t config =
        {
            .write_complete_cb =      writeCb,
            .invalidate_complete_cb = invalidateCb,
            .remove_complete_cb =     removeCb,
            .min_available_space =    WORD_SIZE,
            .p_area =                 p_area,
            .page_count =             1
        };
    
        uint32_t ret = flash_manager_add(&flashManager, &config);
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Return code from flash manager %d \n", ret);  
    }

    The problem appear in flash_manager_add -> flash_area_build -> reserve_action_buffer and that return NULL pointer which leads to an error NRF_ERROR_NO_MEM. After a restart program this method works as it should - there is no problem with initialization and then with writing or reading process.

Reply
  • Yes, I use custom board. I erase / restart program using Segger Embedded Studio debugger. The code look like this:

    void flashStorage_init(){ 
        flash_manager_t flashManager;
        
        flash_manager_page_t * p_area;
        p_area = (flash_manager_page_t *)(((const uint8_t *) flash_manager_recovery_page_get()) 
                                               - (15 * PAGE_SIZE));
    
        const flash_manager_config_t config =
        {
            .write_complete_cb =      writeCb,
            .invalidate_complete_cb = invalidateCb,
            .remove_complete_cb =     removeCb,
            .min_available_space =    WORD_SIZE,
            .p_area =                 p_area,
            .page_count =             1
        };
    
        uint32_t ret = flash_manager_add(&flashManager, &config);
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Return code from flash manager %d \n", ret);  
    }

    The problem appear in flash_manager_add -> flash_area_build -> reserve_action_buffer and that return NULL pointer which leads to an error NRF_ERROR_NO_MEM. After a restart program this method works as it should - there is no problem with initialization and then with writing or reading process.

Children
Related