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

enabaling uart on nrf52840 causes soft device failure

We are using an NRF52840. After initializing a UART that uses P0.06-TX and P0.07-RX the following function calls fail: sd_ble_gap_device_name_set() and nrf_sdh_enable_rquest(). The debugger is unable to trace the calls. The calls are not returning and end up in memory locations that SES cannot resolve.

The UART device functions properly before these calls.

The parameters to these function calls are okay. Again, the failure only occurs after initializing the above UART device prior to these calls.

Any suggestions on tracking this down?

Parents
  • Do you have the RTT logs enabled? Do they show any messages?

  • The debugger and logging showed literally *nothing*.  One execution run showed the following:

    The system is halted.

    The debugger displays 'Unknown function at 0x0000978

    If I hit GO (F5) the system then displays

    <error> app: SOFTDEVICE: ASSERTION FAILED

    UPDATE

    I've isolated the problem.  For main.c, Options, Code Generation, 'Instrument Functions is enabled. I am trying to output data to the UART in the instrumentation calls.

    GCC Instrumentation adds a call to __cyg_profile_func_enter and __cyg_profile_func_exit at the entrance to and exit from every function, respectively.

    This is the code that was added to test instrumentation:

    void main_constructor(void) __attribute__ ((no_instrument_function, constructor));

    void main_destructor(void) __attribute__ ((no_instrument_function, destructor));

    void __cyg_profile_func_enter(void *, void *) __attribute__ ((no_instrument_function));

    void __cyg_profile_func_exit(void *, void *) __attribute__ ((no_instrument_function));

    void __cyg_profile_func_enter(void *this, void *callsite)
    {
    UART_Char_Out('X');
    }

    void __cyg_profile_func_exit(void *this, void *callsite)
    {
    UART_Char_Out('X');

    I haven't check the assembler output yet but  it would appear that hardware context is not sufficiently saved and restored. This would account for the different and seemingly random errors.

Reply
  • The debugger and logging showed literally *nothing*.  One execution run showed the following:

    The system is halted.

    The debugger displays 'Unknown function at 0x0000978

    If I hit GO (F5) the system then displays

    <error> app: SOFTDEVICE: ASSERTION FAILED

    UPDATE

    I've isolated the problem.  For main.c, Options, Code Generation, 'Instrument Functions is enabled. I am trying to output data to the UART in the instrumentation calls.

    GCC Instrumentation adds a call to __cyg_profile_func_enter and __cyg_profile_func_exit at the entrance to and exit from every function, respectively.

    This is the code that was added to test instrumentation:

    void main_constructor(void) __attribute__ ((no_instrument_function, constructor));

    void main_destructor(void) __attribute__ ((no_instrument_function, destructor));

    void __cyg_profile_func_enter(void *, void *) __attribute__ ((no_instrument_function));

    void __cyg_profile_func_exit(void *, void *) __attribute__ ((no_instrument_function));

    void __cyg_profile_func_enter(void *this, void *callsite)
    {
    UART_Char_Out('X');
    }

    void __cyg_profile_func_exit(void *this, void *callsite)
    {
    UART_Char_Out('X');

    I haven't check the assembler output yet but  it would appear that hardware context is not sufficiently saved and restored. This would account for the different and seemingly random errors.

Children
No Data
Related