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 ?

  • 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. 


  • Hello,

    We are running soft device 132 and SDK 17.0.2

    I've managed to isolate the problem to the SPI clock to our ADC. It was set to 8 MHZ which seemed to work during debug config or in release config when we have NRF_LOG_ENABLED = 1 and NRF_LOG_BACKEND_UART = 1. When i disabled the log and uart it does not work in release config until I switch SPI back to 1 MHZ. 

    Any ideas why this would happen? The ADC runs at up to 10 MHZ. We would like to run the bus as fast as possible to maximise down time.

    Thanks

  • Hi Jonathan, 
    Could you try the suggestion from Susheel in this ticket to see if it has something to so with the HFCLK ?
    RE: SPI with BLE Stack 

    You can also try testing with BLE turn off (don't start advertising) to see if it's the issue with BLE stack disable HFCLK or not. If it still doesn't work with BLE turn off, then you may want to try testing with simple SPI example in the SDK if you can reproduce the issue with these examples. 

Reply Children
Related