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

Problem with fs_init after importing to Segger Embedded Studio

Hi, 

I followed the instructions for importing the Thing:52 firmware into SES and managed to get the firmware compiled and loading, and the code reaches the main function without any apparent problem. When it gets to the application though I get an error in m_ble_flash_init. The problem is in the structure returned by FS_SECTION_ITEM_GET(i) within fs_init (called within m_ble_init->m_ble_flash_init->fsd_init) - particularly in these lines (fstorage.c:363) : - 

p_config_i = FS_SECTION_ITEM_GET(max_index);

        p_config_i->p_end_addr   = p_current_end;
        p_config_i->p_start_addr = p_current_end - (p_config_i->num_pages * FS_PAGE_SIZE_WORDS);

The write of p_current_end to p_config_i>p_end_addr doesn't happen and the value remains 0. The same is true for p_config_i->p_start_addr.

p_current_end is 0x00080000, i.e. the end of the flash section - as expected. The p_config pointer is pointing to 0x5beac.

Of course what then happens is that p_current_end gets update to 0x0: -

p_current_end = p_config_i->p_start_addr;

This causes problems later on. 

There are earlier warnings which Iooked into. The first on happens because all the structure values are 0, so the drv_ext_light_off driver tries to setup a timer with timeout_ticks = 0, so this generated an NRF_ERROR_INVALID_PARAM error.

It seems these errors could all be down to the same root cause - the inability to write to these structures.

Any idea what I am doing wrong?

Thanks in advance for any help.

Phil.

p.s. If it is useful - here is the trace from the debug console.

main :INFO:===== Thingy started! =====
drv_ext_light :WARNING:Err code returned in file: /Users/derrick/work/third-party/Nordic-Thingy52-FW/source/drivers/drv_ext_light.c, line: 754, code 7 
drv_ext_light :WARNING:Err code returned in file: /Users/derrick/work/third-party/Nordic-Thingy52-FW/source/drivers/drv_ext_light.c, line: 858, code 7
drv_ext_light :WARNING:Err code returned in file: /Users/derrick/work/third-party/Nordic-Thingy52-FW/source/drivers/drv_ext_light.c, line: 754, code 7
drv_ext_light :WARNING:Err code returned in file: /Users/derrick/work/third-party/Nordic-Thingy52-FW/source/drivers/drv_ext_light.c, line: 858, code 7
m_env :INFO:Init:
m_motion :INFO:Init
m_sound :INFO:Sound_init
m_ble :WARNING:Too few random bytes available. Trying again
m_ble :WARNING:Too few random bytes available. Trying again
m_ble :WARNING:Too few random bytes available. Trying again
m_ble :INFO:Available random bytes: 16
m_ble :INFO:Random value (hex): 2x2x2x2x
m_ble_flash :INFO:Initialization
m_ble_flash :WARNING:Err code returned in file: /Users/derrick/work/third-party/Nordic-Thingy52-FW/source/modules/m_ble_flash.c, line: 197, code 11
m_ble :ERROR: m_ble_flash_init failed - 11
main :ERROR: id = 16385, pc = 0, file = /Users/derrick/work/third-party/Nordic-Thingy52-FW/project/pca20020_s132/main.c, line number: 304, error code = 11 = NRF_ERROR_INVALID_DATA
Parents Reply Children
  • So it fails because the call to app_timer_start is made with app timer ticks of 0. To workaround this I have to set the sequence_vals in drv_ext_light_off to be non-zero which then executes a different code branch (LED_DRV_ENABLED_BLINK_OR_BREATH) in m_ioext_cmd_process. Without this, the LED_DRV_ENABLED_SINGLE_SHOT branch is executed which sets active_time_ms based on the zero sum of the fade_in, on and fade_out times -> thus the error on app_timer_start. 

    I'm not sure how this is meant to work.

    Here is my modified version of drv_ext_light_off.

    ret_code_t drv_ext_light_off(uint32_t id)
    {
        ret_code_t err_code;
    
        VALID_LIGHT_ID_CHECK(id);
    
        NRF_LOG_DEBUG("Light off \r\n");
    
        drv_ext_light_rgb_sequence_t sequence;
        sequence.sequence_vals = SEQUENCE_DEFAULT_VAL;
        sequence.sequence_vals.on_intensity = DRV_EXT_LIGHT_INTENSITY_OFF;
        sequence.color = DRV_EXT_LIGHT_COLOR_WHITE;
        sequence.sequence_vals.fade_in_time_ms = 900;
        sequence.sequence_vals.on_time_ms = 100;
        sequence.sequence_vals.fade_out_time_ms = 900;
        sequence.sequence_vals.off_time_ms = 100;
        sequence.sequence_vals.on_intensity = 0xff;
        sequence.sequence_vals.off_intensity = 100;
    
        err_code = m_ioext_cmd_process(id, &sequence);
        RETURN_IF_ERROR(err_code);
    
        return DRV_EXT_LIGHT_STATUS_CODE_SUCCESS;
    }
  • Although it looks like this may be the LED for the colour sensor (the one next to the colour sensor) so this probably needs to be off...

Related