Hello, gentleman!
We are developing our nRF52840-based application using nRF Connect SDK v1.4.2. I know there is a NCS v1.5.1 already available, we plan to switch to that version pretty soon.
We would like to have the ability to update nRF52840 firmware by connecting it to the PC over USB and transferring updated firmware over USB serial link (USB DFU profile).
I've been researching a little bit and came across this guide explaining how to perform DFU with MCUBoot bootloader using a serial USB connection to a host PC. Even though this example contains everything we need and helped us a lot to understand the DFU process, it contains two parts that we would like to be able to automate:
- Once we have our initial firmware version together with the MCUBoot bootloader flashed into nRF52840, we would like to be able to put the nRF52840 into MCUBoot's DFU mode from our firmware (e.g. at the moment we detect USB power). This process is performed manually in the guide by pressing a Reset button while holding a Button 1 on DK (see step 27).
- Similarly, once the DFU process is finished and new firmware binary file transferred over USB, we need to hit Reset button on nRF52840 DK board in order to restart CPU and boot updated firmware (step 35). Again, we would like to be able to automatically restart the nRF52840 once the DFU process is done because we will not have Reset button exposed to the end user in our final product design.
With that said, I would have a few questions related to the above limitations:
- Is it possible to somehow put the MCUBoot in DFU mode from inside the firmware? I know that, in the case of nRF SDK and baremetal C approach, we had the possibility to play with the GPREGRET register and put the nRF52 in DFU mode with the following piece of code, for example:
void reboot_into_bootloader(void) {
uint32_t gp_reg_ret;
APP_ERROR_CHECK(sd_power_gpregret_set(0, BOOTLOADER_DFU_START));
nrf_delay_ms(1500);
APP_ERROR_CHECK(sd_power_gpregret_get(0, &gp_reg_ret));
perform_system_reset();
}
Can we do something similar from the NCS/Zephyr environment?
- Would it be possible to catch from the NCS/Zephyr side when USB Power is detected/removed on nRF52840 (APP_USBD_EVT_POWER_DETECTED event from nRF SDK world)?
- Finally, is there a way to automatically restart the board once DCU process is finished without a need to manually press Reset button?
Thank you very much for your time and efforts, guys. It is really appreciated.
Cheers,
Bojan.