Custom board got HardFault

Hi,

I have been programming my custom board using SWD on a DK. It worked fine when I tried blinky example, however, when I tried nrf_ble_uart example, it stopped at the log_init():

and when I break it, it showed in HardFault_handle() :

I tried several solution in the devzone but none of them solved this problem. The circuit only had  MDBT42Q chip with GND and VDD SWDCLK and SWDIO pins connected.

Could you help me out? 

Thanks a lot,

Chris

  • Hello,

    It's strange that you seem to be getting a fault exception from the log_init() call. When the ble_app_uart example does not run on a custom board it's usually one of two things: Either the wrong 32 KHz clock source is selected, or a floating UART RX input that causes the APP_UART_COMMUNICATION_ERROR event to be raised. But neither of these should trigger a fault exception.

    Does the exact same code run fine on your DK? And can you post a screenshot that includes the CPU registers and call stack  as well?

    Best regards,

    Vidar

  • Hi,

    I used the example and tested on DK. It worked fine. 

    Here is the screenshot

    Let me know if you need any other information

    Thanks,

    Chris

  • Hi Chris,

    The stack pointer (SP) value is suspiciously low in your case - it should never go below 0x2000e000 with the default 'pca10040' project configuration. But I'm not sure why this only happens on the custom board. Did you make any changes to the ble_app_uart example?

    You can see from the screenshot below what the default RAM layout is for the ble_app_uart_pca10040_s132 project in sdk 17.1.0. The valid address range for the stack pointer is defined by the .stack region.

    Do you get the same exception if you set the NRF_LOG_ENABLED symbol in sdk_config.h to '0'? Also, what is the SP value when you reach main() on startup before log_init()?

    Here is what the call stack and register view may look like after a hardfault expception has been raised in log_init():

    Best regards,

    Vidar

  • Hi Vidar,

    Thanks for you information.

    I only changed the RXD, TX pin numbers in the example files, and the code runs ok on DK. Do you think it is possible that I got a bad batch of chips? 

    I will test the SP later today.

    Thanks,

    Chris 

  • Hi Chris,

    I think it's rather unlikely that this issue is caused by a bad batch of chips. For that to happen, it would have had to slip through all of our production tests, in addition to the tests performed by the module vendor at their production line. I have not seen this failure mode before either. Hardfault exceptions are almost always caused by SW.

    Maybe you can try with one of the other BLE examples as well?

    Best regards,

    Vidar 

Related