This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unexpected serial UART bootloader exit mechanism

I'm testing an implementation of the serial UART bootloader for DFU. Firmware update using nrfutil works fine, using a serial-USB dongle, The only issue I'm seeing is that if the dongle is not plugged into USB port on my PC, the device will not stay in bootloader. It seems to be because the UART Rx line is low. Similarly, if it's in bootloader and I pull the dongle, the Rx line goes low and the device exits bootloader. Is this to be expected? It seems odd. I think I have a workaround by enabling the pull-up on the Rx line but it's not ideal.

Regards

Pete

Parents
  • Hello Pete,

    The UART transport is configured to invoke the app_error_handler_bare() function in main.c if an UART  Error condition is detected as you can see from the nrf_dfu_serial_uart.c source here:

    And the error handler will trigger system reset making the device exit dfu mode.

    A solution, as you suggested, is to enable the internal pull-up on the RX pin. This will prevent it from becoming floating when the USB port is not plugged in.

    static uint32_t uart_dfu_transport_init(nrf_dfu_observer_t observer)
    {
        ...
    
        err_code =  nrf_drv_uart_init(&m_uart, &uart_config, uart_event_handler);
        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR("Failed initializing uart");
            return err_code;
        }
    
        /* The UART driver configures the input pin without pullup enabled. We can override it 
           here after the driver initalization is complete. */
        NRF_P0->PIN_CNF[RX_PIN_NUMBER] |= (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos);
        
        ...

    Best regards,

    Vidar

Reply
  • Hello Pete,

    The UART transport is configured to invoke the app_error_handler_bare() function in main.c if an UART  Error condition is detected as you can see from the nrf_dfu_serial_uart.c source here:

    And the error handler will trigger system reset making the device exit dfu mode.

    A solution, as you suggested, is to enable the internal pull-up on the RX pin. This will prevent it from becoming floating when the USB port is not plugged in.

    static uint32_t uart_dfu_transport_init(nrf_dfu_observer_t observer)
    {
        ...
    
        err_code =  nrf_drv_uart_init(&m_uart, &uart_config, uart_event_handler);
        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR("Failed initializing uart");
            return err_code;
        }
    
        /* The UART driver configures the input pin without pullup enabled. We can override it 
           here after the driver initalization is complete. */
        NRF_P0->PIN_CNF[RX_PIN_NUMBER] |= (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos);
        
        ...

    Best regards,

    Vidar

Children
Related