Problem running code in release mode when NRF_LOG_BACKEND_UART_ENABLED and NRF_LOG are disabled

Hello,

I am having an issue with running my application in release mode. It will only run when NRF_LOG_ENABLED = 1 and NRF_LOG_BACKEND_UART_ENABLED = 1. I can run my debug configuration with both of these disabled. I would like to disable them as it reduces power consumption of my device. I can run the debugger in the release config and the device will advertise and i can connect to it but it doesn't work when i flash the hex file.

I've tried setting optimization level to 'none' for release build and I've tried disabling and enabling the logs and uart.

Any help with this is appreciated.

Thanks

Parents
  • Hello,

    Thanks for your response.

    When i disable the UART and NRF Log I can build the project in release mode but when i flash the hex file the device will not advertise. As soon as i enable the log and UART the device will advertise and behave like normal but draw more power than we would like.

    I can run the debugger with the UART and NRF logs disabled and the device advertises as per normal.

    I will investigate the HFCLK.

    Thanks

  • Hi again, 
    Yes that's why I suggested to use GPIO or otherway of debugging to check where the code stop. Have you tried to do RTT log instead of UART ?

  • Hello,

    If i enable RTT and NRF Log and disable UART the device will not advertise when I run the code. As soon as i connect to J Link RTT viewer the device starts to advertise. Similarly, if i disable RTT the device won't advertise but it will appear as soon as the RTT viewer is connected.

    I can try the GPIO debug method.

    Thanks

  • Please let us know more about your application. Do you see the same problem when testing with our examples ? 

  • P/S: Please also do a nrfjprog --readregs . So we have a snapshot of the registers that may help. 

  • Hello,

    The application takes an adc and accelerometer value and transmits over ble every 50 ms then goes to sleep.

    I can run the blinky example and see it advertise when in release mode.

    When i build and run in release mode the register values are:

    R0: 0x000073C0
    R1: 0x00000000
    R2: 0x00000040
    R3: 0x00000001
    R4: 0x0000011A
    R5: 0x0002B9D1
    R6: 0x2000351D
    R7: 0x20003508
    R8: 0x00000000
    R9: 0x00000000
    R10: 0x00000000
    R11: 0x00000000
    R12: 0x200034E0
    SP: 0x2000FFB0
    LR: 0x0002861D
    PC: 0x0002B9D2
    xPSR: 0x21000000
    MSP: 0x2000FFB0
    PSP: 0x00000000
    RAZ: 0x00000000
    CFBP: 0x00000000
    APSR: 0x20000000
    EPSR: 0x01000000
    IPSR: 0x00000000

    Thanks

  • Hi Jonathan, 
    I couldn't see anything suspicious in the regs. 
    But you can check what the PC:0x002B9D2 point to with the addr2line.exe tool, it should be able to point you to where the program counter stuck at. I would suggest to try nrfjprog --readregs some more times to see the PC is still in the same area. 

    Which SDK and softdevice version are you using ? 

    Could you try not to put the CPU to sleep in the main loop to see if you still have the same problem ? 

    Have you looked at anything else that can cause your application different from the blinky ?

    You can try to disable the functionality one by one until your application getting similar to the blinky. For example the code that you interface with the external peripheral. 


Reply
  • Hi Jonathan, 
    I couldn't see anything suspicious in the regs. 
    But you can check what the PC:0x002B9D2 point to with the addr2line.exe tool, it should be able to point you to where the program counter stuck at. I would suggest to try nrfjprog --readregs some more times to see the PC is still in the same area. 

    Which SDK and softdevice version are you using ? 

    Could you try not to put the CPU to sleep in the main loop to see if you still have the same problem ? 

    Have you looked at anything else that can cause your application different from the blinky ?

    You can try to disable the functionality one by one until your application getting similar to the blinky. For example the code that you interface with the external peripheral. 


Children
Related