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

NRF_LOG not working on Segger Embedded Studio

Greetings,

I'm having some trouble displaying logs to the SES Debug Terminal... Basically, I can see the logs with RTTviewer but not in SES Debug Terminal. However printf works just fine on the SES Debug Terminal

My setup:

OS: Windows 10

Board: NRF52-DK

SDK: 15.3.0

Example: peripheral\bsp

IDE: Segger Embedded Studio 4.16

After reading lots of posts and documentation that's what I've done so far:

1) tried many other examples and got the same problem

2) NO, I'm not using RTTviewer and SES Debug Terminal at the same time

3) On SDK_Config.h made sure that settings are:

NRF_LOG_BACKEND_RTT_ENABLE 1
NRF_LOG_BACKEND_RTT_ENABLE 0
NRF_LOG_ENABLE 1
NRF_LOG_DEFFERED 1
NRF_LOG_DEFAULT_LEVEL 3 //AKA Info

4) Tried to build clean, build Debug, build Release

5)  On main:

Initializing NRF_LOG:

APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();

On main loop:

NRF_LOG_INFO("BSP example started.");
NRF_LOG_FLUSH();

6) If instead of NRF_LOG_INFO I use printf the SES Debug Terminal prints my message just fine

7) If I open the SES J-Link Control Panel Window while debugging, I can see the message on the RTT tab, but still not in Debug Terminal:

8) Verified Project Debug Settings:

9) Tried changing NRF_LOG_FLUSH() to NRF_LOG_PROCESS() . No difference...

10) I also notice that something is been send to the Debug Terminal because the cursor moves to a new line every time a new NRF_LOG should be displayed.

Any ideas of what I am doing wrong?

Parents
  • Hi !

    Usually my Debugger works but when I execute a function which returns a error message, i cannot see messages from NRF_LOG anymore. 

    uint32_t ble_cos_char_add(uint16_t                        service_handle,
                               ble_uuid_t                      uuid,
                               ble_cos_init_params             char_params,
                               ble_gatts_char_handles_t      * p_handles)
    {
        // uuid type starts at 0x02, this is the index of the first base UUID we add. 0x03 will be the index of the second base UUID we add and etc
        // About exponent : actual value = Characteristic Value * 10^Exponent
        // About CPF description : WIKA number
        // About Namespace : SIG number or not
        if((uuid.type <= BLE_UUID_TYPE_UNKNOWN) || (uuid.type > (1 + NRF_SDH_BLE_VS_UUID_COUNT))
        || (char_params.read_access > SEC_SIGNED_MITM) || (char_params.read_access < SEC_NO_ACCESS) 
        || (char_params.write_access > SEC_SIGNED_MITM) || (char_params.write_access < SEC_NO_ACCESS) 
        || (char_params.cpf.format > BLE_GATT_CPF_FORMAT_STRUCT) || (char_params.cpf.format < BLE_GATT_CPF_FORMAT_BOOLEAN)
        || (char_params.cpf.name_space < BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN) || (char_params.cpf.name_space > BLE_GATT_CPF_NAMESPACE_BTSIG) 
        /*|| (char_params.cpf.desc != WIKA_NUMBER)*/
        /*|| (char_params.cpf.unit < BLE_GATT_UNIT_UNITLESS)|| (char_params.cpf.unit > BLE_GATT_UNIT_CONCENTRATION_PARTS_PER_BILLION)*/)
        {
            NRF_LOG_INFO("Info: Unable to add characteristic to COS Service, invalid parameter");
            NRF_LOG_ERROR("Error: Unable to add characteristic to COS Service, invalid parameter");
            NRF_LOG_DEBUG("Debug: Unable to add characteristic to COS Service, invalid parameter");
    
            return NRF_ERROR_INVALID_PARAM;
        }
    
        if((char_params.len == 0) || (p_handles == NULL))
        {
            NRF_LOG_INFO("Info: Unable to add characteristic to COS Service, NULL parameter");
            NRF_LOG_ERROR("Error: Unable to add characteristic to COS Service, NULL parameter");
            NRF_LOG_DEBUG("Debug: Unable to add characteristic to COS Service, NULL parameter");
            return NRF_ERROR_NULL;
        }
    
        ble_add_char_params_t add_char_params;
    
        //APP_ERROR_CHECK_BOOL(char_params.p_value != NULL);
        //APP_ERROR_CHECK_BOOL(char_params.len > 0);
    
        memset(&add_char_params, 0, sizeof(add_char_params));
    
        add_char_params.uuid_type       = uuid.type;
        add_char_params.uuid            = uuid.uuid;
        add_char_params.max_len         = char_params.len;
        add_char_params.init_len        = char_params.len;
    
        if(char_params.p_value != NULL) add_char_params.p_init_value = char_params.p_value;
        else add_char_params.p_init_value = NULL;
    
        add_char_params.char_props.read = (char_params.read_access == 0) ? 0 : 1;
        add_char_params.read_access     = char_params.read_access;
        add_char_params.char_props.write = (char_params.write_access == 0) ? 0 : 1;
        add_char_params.write_access     = char_params.write_access;
        //add_char_params.p_presentation_format = &char_params.cpf;
    
        return characteristic_add(service_handle, &add_char_params, p_handles);
    }

    For example I have this function, and for now due to my parameters it returns NRF_ERROR_INVALID_PARAM. Thuis error code is given to the APP_ERROR_CHECK() MACRO. So when I have a function like that, I would like to see fastly where is the mistake, that's why I have put some nrf_log. 

    Do you have any ideas why it doesn't work ?

Reply
  • Hi !

    Usually my Debugger works but when I execute a function which returns a error message, i cannot see messages from NRF_LOG anymore. 

    uint32_t ble_cos_char_add(uint16_t                        service_handle,
                               ble_uuid_t                      uuid,
                               ble_cos_init_params             char_params,
                               ble_gatts_char_handles_t      * p_handles)
    {
        // uuid type starts at 0x02, this is the index of the first base UUID we add. 0x03 will be the index of the second base UUID we add and etc
        // About exponent : actual value = Characteristic Value * 10^Exponent
        // About CPF description : WIKA number
        // About Namespace : SIG number or not
        if((uuid.type <= BLE_UUID_TYPE_UNKNOWN) || (uuid.type > (1 + NRF_SDH_BLE_VS_UUID_COUNT))
        || (char_params.read_access > SEC_SIGNED_MITM) || (char_params.read_access < SEC_NO_ACCESS) 
        || (char_params.write_access > SEC_SIGNED_MITM) || (char_params.write_access < SEC_NO_ACCESS) 
        || (char_params.cpf.format > BLE_GATT_CPF_FORMAT_STRUCT) || (char_params.cpf.format < BLE_GATT_CPF_FORMAT_BOOLEAN)
        || (char_params.cpf.name_space < BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN) || (char_params.cpf.name_space > BLE_GATT_CPF_NAMESPACE_BTSIG) 
        /*|| (char_params.cpf.desc != WIKA_NUMBER)*/
        /*|| (char_params.cpf.unit < BLE_GATT_UNIT_UNITLESS)|| (char_params.cpf.unit > BLE_GATT_UNIT_CONCENTRATION_PARTS_PER_BILLION)*/)
        {
            NRF_LOG_INFO("Info: Unable to add characteristic to COS Service, invalid parameter");
            NRF_LOG_ERROR("Error: Unable to add characteristic to COS Service, invalid parameter");
            NRF_LOG_DEBUG("Debug: Unable to add characteristic to COS Service, invalid parameter");
    
            return NRF_ERROR_INVALID_PARAM;
        }
    
        if((char_params.len == 0) || (p_handles == NULL))
        {
            NRF_LOG_INFO("Info: Unable to add characteristic to COS Service, NULL parameter");
            NRF_LOG_ERROR("Error: Unable to add characteristic to COS Service, NULL parameter");
            NRF_LOG_DEBUG("Debug: Unable to add characteristic to COS Service, NULL parameter");
            return NRF_ERROR_NULL;
        }
    
        ble_add_char_params_t add_char_params;
    
        //APP_ERROR_CHECK_BOOL(char_params.p_value != NULL);
        //APP_ERROR_CHECK_BOOL(char_params.len > 0);
    
        memset(&add_char_params, 0, sizeof(add_char_params));
    
        add_char_params.uuid_type       = uuid.type;
        add_char_params.uuid            = uuid.uuid;
        add_char_params.max_len         = char_params.len;
        add_char_params.init_len        = char_params.len;
    
        if(char_params.p_value != NULL) add_char_params.p_init_value = char_params.p_value;
        else add_char_params.p_init_value = NULL;
    
        add_char_params.char_props.read = (char_params.read_access == 0) ? 0 : 1;
        add_char_params.read_access     = char_params.read_access;
        add_char_params.char_props.write = (char_params.write_access == 0) ? 0 : 1;
        add_char_params.write_access     = char_params.write_access;
        //add_char_params.p_presentation_format = &char_params.cpf;
    
        return characteristic_add(service_handle, &add_char_params, p_handles);
    }

    For example I have this function, and for now due to my parameters it returns NRF_ERROR_INVALID_PARAM. Thuis error code is given to the APP_ERROR_CHECK() MACRO. So when I have a function like that, I would like to see fastly where is the mistake, that's why I have put some nrf_log. 

    Do you have any ideas why it doesn't work ?

Children
No Data
Related