I'm developing an application for the nRF52832 using the nRF5 SDK version 15.0.0. We're using the s132 softdevice, the sample secure bootloader (modified to use our company's keys), and an application.
We plan to deploy our application on a printed circuit board (PCB). For development, we also run the application on the nRF52 series Software Development Kit.
The PCB is powered by a battery and/or a micro USB charging port.
If the USB charging port is plugged-in then everything works fine. We only have a problem when the USB charging port isn't plugged-in and the PCB is running off of battery power.
If the PCB is running off of battery power (the PCB is not plugged-in) and the nRF52 microcontroller restarts then the nRF52 will enter bootloader mode instead of application mode. If the PCB is plugged-in then restarting the application will stay in application mode and will not cause the nRF52 to drop into bootloader mode. It doesn't matter how the application restarts. It doesn't matter whether we perform an over-the-air device firmware update, call NVIC_SystemReset() or call nrf_bootloader_app_start(). All that matters is whether the PCB is plugged-in (and therefore not running off of battery power). When this happens, the app doesn't drop temporarily into bootloader for a few minutes and then revert to application mode like on a failed over-the-air Device Firmware Update. The PCB just just stuck in bootloader mode until we plug in the USB port and install a new applicatoin (such as sending a new .zip packet over Bluetooth Low Energy).
Our goal is a product that never gets stuck in bootloader mode while in the hands of an end user.
According to our supplier, "Charging is managed entirely by a dedicated CC/CV charge controller chip, requiring no direct action from the main system controller". I don't know how the nRF52 bootloader can tell whether the USB charging port is plugged-in, much less why it would care. (You'll see why in the block diagram at the end of this post. [The battery monitor in the block diagram can only tell whether the battery is charging, but this bug happens whenever the USB charging power is plugged-in, regardless of whether the battery is charging.])
Do you know what might be causing this or where I should look to try to figure it out? Under what circumstances does the bootloader choose not to load an application? Is there a way we can get the bootloader to always run the application when the nRF52 is restarted?
