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

working without DFU, not working with DFU

Hi there,

I had the DFU already working very well for quite some time, but my luck has ended. When I program the application via JLink it works perfectly fine, also the download of the application via secure DFU itself doesnt cause any issues.

My application starts advertising, I can connect but always at the same moment (when I start up an SPI interface and want to start talking to an external ADC) the application resets. I checked the ROM/RAM settings a thousand times, the bootloader address is correct, the RAM settings of the application according to the requirements of the softdevice and also tried many different combinations (mainly different irom sizes of application) but still the same reboot issue which does not appear when downloading the application directly.

I use SDK13, Softdevice S132 4.0.2, nRF52832 with 512KB flash (168KB available when using dual bank dfu) and 65KB RAM (57KB left with Softdevice enabled) and my application is not that big: Program Size: Code=76740 RO-data=6620 RW-data=1688 ZI-data=21800

Any idea what I could be missing?

Thanks a lot, Josef

  • I also tried different code optimizations, from -O0 to -O3, but same result... :/

  • Next best guess: I am using one of the pins reserved for the NFC antenna as SPI Clock pin, in the application i a UICR setting defined in a header file to enable that.

    const uint32_t UICR_ADDR_0x20C attribute((at(0x1000120C))) attribute((used)) = 0xFFFFFFFE;

    Does the Bootloader perform the same write to UICR as specified in the application header file or is that ignored? And if it is ignored, how could i have that write executed from the applidation during ota?

    Many thanks, Josef

  • Hi Josef,

    Could you try to simplify your application and check if it was using SPI causing the issue ? You can for example create a program that only do SPI and nothing else just for testing.

    Could you check where exactly the hardfault occurs ? You can debug the application code and step in the code as a normal application even if the bootloader is flashed.

    I suspect there could be an issue with the interrupt handle and forwarding.

  • Hi Hung, Thansk for the feedback! I managed to solve the issue! It was indeed related to the UICR configuration. I programmed my application to set the NFC pins as GPIO, which happened when programming the application via SWD. On the other hand, when updating the application via Bluetooth DFU, the bootloader didn't allow/perform this write, which meant that the pins were not configured as GPIO but still as NFC antenna pins. As soon as my application wanted to access the pins to perform SPI transfers, the microcontroller crashed. I solved the issue by setting the UICR already in the bootloader firmware instead of the application, now it works perfectly.

    Best regards, Josef

  • Great that you found the issue. One option you may consider is to write the application using programmer (e.g nrfjprog) and generate a bootloader setting to allow the bootloader to start your application so that you don't have to do OTA DFU on the first time. This way UICR will be written when you write your application. You then can merge the bootloader + application + bootloader setting and softdevice to be one hex and can use that in production. You can have a look at Appendix 1. Advanced features here.

Related