2022-05-04 06:18 AM
I am using an STM32L4 chip that sends an update to the nRF52832 on a ublox module over USART. I assume the nordic chip is in the bootloader during the update.
We get a UART error: 4 and when we observe the UART lines we see that on the TX line of the nRF the stop bit is not present. I assume the nRF does not pull the line high properly after transmitting a frame. (we do not use pull-up resistors on the USART lines on STM32L4 side)
When trying to update with an OTA the device updates but then falls back into the bootloader at startup making me assume the problem is with the bootloader.
I am wondering if there is such documented cases of bootloader errors or if the missing stop bit could point to another issue with my HW/SW?
Thank you for any hint!
Bad behavior with missing stop bit:
Good behavior with stop bit present:
Bad behavior with
2022-05-04 06:28 AM
Sorry, not familiar with the nRF device update process, perhaps review their documentation deeper, or log the working process from a PC based update.
The L4 should allow you to enable a pull-up on the pin itself.
2022-05-04 08:04 AM
If a device meant to drive a UART pin is reset (like during a code update) and that device has programmable pins, then the pin may go temporarily tri-state. For UART data lines I'd recommend you add a pullup if this can happen (or enable one in L4 as Tesla says) to avoid the pin drifting or picking up noise.
Paul
2022-05-11 02:54 AM
The problem was the clock setting (low accuracy clock was used probably)
solution is here: https://devzone.nordicsemi.com/f/nordic-q-a/87580/issue-with-updating-nrf52832-over-usart
err_code = sd_clock_hfclk_request();
APP_ERROR_CHECK(err_code);
uint32_t hfclk_is_running = 0;
while (!hfclk_is_running)
{
APP_ERROR_CHECK(sd_clock_hfclk_is_running(&hfclk_is_running) );
}
It must be called here:
ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer)
{
NRF_LOG_DEBUG("In nrf_bootloader_init");
.....
// SoftDevice is started
ret_val = nrf_dfu_init(dfu_observer);
if (ret_val != NRF_SUCCESS)
{
return NRF_ERROR_INTERNAL;
}
/*
* ATTENTION: sd_clock_hfclk_request required the SoftDevice to be running/available
* Therefore it must be called after nrf_dfu_init (which calls nrf_dfu_transports_init which inits the SD and UART)
* In a bootloader/app without OTA and therefore no SD we must use nrf_drv_clock_hfclk_request
*/
// Request the external high frequency crystal for best UART clock accuracy. For lowest current consumption, don't request the crystal.
sd_clock_hfclk_request();
uint32_t p_is_running = 0;
while(! p_is_running) { //wait for the hfclk to be available
sd_clock_hfclk_is_running((&p_is_running));
}