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

Need to change Tx & Rx pins on Custom board for Secure Serial bootloader DFU code

Hello,

 

I am using nRF52840, SDK_16.0.0, S140 SoftDevice and Segger 4.16 for flashing the image.

 

1)  For Secure Serial bootloader in below path, I want to change Tx & Rx for my custom board.

\examples\dfu\secure_bootloader\pca10056_uart\

Do I need to change below macros in pca10056.h file

#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6

2) Are there any other changes to be done.

Thanks & Regards

Vishnu Beema

Parents
  • Hi Vishnu, 

    1)  For Secure Serial bootloader in below path, I want to change Tx & Rx for my custom board.

    \examples\dfu\secure_bootloader\pca10056_uart\

    Do I need to change below macros in pca10056.h file

    #define RX_PIN_NUMBER 8
    #define TX_PIN_NUMBER 6

    Yes, these are the pins definitions used by the function that initializes the UART transport layer

     

    static uint32_t uart_dfu_transport_init(nrf_dfu_observer_t observer)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        if (m_active)
        {
            return err_code;
        }
    
        NRF_LOG_DEBUG("serial_dfu_transport_init()");
    
        m_observer = observer;
    
        err_code = nrf_balloc_init(&m_payload_pool);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    
        uint8_t * p_rx_buf = nrf_balloc_alloc(&m_payload_pool);
    
        m_slip.p_buffer      =  &p_rx_buf[OPCODE_OFFSET];
        m_slip.current_index = 0;
        m_slip.buffer_len    = UART_SLIP_MTU;
        m_slip.state         = SLIP_STATE_DECODING;
    
        m_serial.rsp_func           = rsp_send;
        m_serial.payload_free_func  = payload_free;
        m_serial.mtu                = UART_SLIP_MTU;
        m_serial.p_rsp_buf          = &m_rsp_buf[NRF_UART_MAX_RESPONSE_SIZE_SLIP -
                                                NRF_SERIAL_MAX_RESPONSE_SIZE];
        m_serial.p_low_level_transport = &uart_dfu_transport;
    
        nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
    
        uart_config.pseltxd   = TX_PIN_NUMBER;
        uart_config.pselrxd   = RX_PIN_NUMBER;
        uart_config.pselcts   = CTS_PIN_NUMBER;
        uart_config.pselrts   = RTS_PIN_NUMBER;
        uart_config.hwfc      = NRF_DFU_SERIAL_UART_USES_HWFC ?
                                    NRF_UART_HWFC_ENABLED : NRF_UART_HWFC_DISABLED;
        uart_config.p_context = &m_serial;
    
        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;
        }
    
        err_code = nrf_drv_uart_rx(&m_uart, &m_rx_byte, 1);
        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR("Failed initializing rx");
        }
    
        NRF_LOG_DEBUG("serial_dfu_transport_init() completed");
    
        m_active = true;
    
        if (m_observer)
        {
            m_observer(NRF_DFU_EVT_TRANSPORT_ACTIVATED);
        }
    
        return err_code;
    }

     

    2) Are there any other changes to be done.

     No, if you just want to change the pins then the definitions in pca10056.h is all you need to modify. Note, that hardware flow control is enabled, i.e. NRF_DFU_SERIAL_UART_USES_HWFC = 1, so if you only use the tx and RX pins and not any CTS or RTS pins, then you should disable the HWFC. 

    Best regards

    Bjørn

Reply
  • Hi Vishnu, 

    1)  For Secure Serial bootloader in below path, I want to change Tx & Rx for my custom board.

    \examples\dfu\secure_bootloader\pca10056_uart\

    Do I need to change below macros in pca10056.h file

    #define RX_PIN_NUMBER 8
    #define TX_PIN_NUMBER 6

    Yes, these are the pins definitions used by the function that initializes the UART transport layer

     

    static uint32_t uart_dfu_transport_init(nrf_dfu_observer_t observer)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        if (m_active)
        {
            return err_code;
        }
    
        NRF_LOG_DEBUG("serial_dfu_transport_init()");
    
        m_observer = observer;
    
        err_code = nrf_balloc_init(&m_payload_pool);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    
        uint8_t * p_rx_buf = nrf_balloc_alloc(&m_payload_pool);
    
        m_slip.p_buffer      =  &p_rx_buf[OPCODE_OFFSET];
        m_slip.current_index = 0;
        m_slip.buffer_len    = UART_SLIP_MTU;
        m_slip.state         = SLIP_STATE_DECODING;
    
        m_serial.rsp_func           = rsp_send;
        m_serial.payload_free_func  = payload_free;
        m_serial.mtu                = UART_SLIP_MTU;
        m_serial.p_rsp_buf          = &m_rsp_buf[NRF_UART_MAX_RESPONSE_SIZE_SLIP -
                                                NRF_SERIAL_MAX_RESPONSE_SIZE];
        m_serial.p_low_level_transport = &uart_dfu_transport;
    
        nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
    
        uart_config.pseltxd   = TX_PIN_NUMBER;
        uart_config.pselrxd   = RX_PIN_NUMBER;
        uart_config.pselcts   = CTS_PIN_NUMBER;
        uart_config.pselrts   = RTS_PIN_NUMBER;
        uart_config.hwfc      = NRF_DFU_SERIAL_UART_USES_HWFC ?
                                    NRF_UART_HWFC_ENABLED : NRF_UART_HWFC_DISABLED;
        uart_config.p_context = &m_serial;
    
        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;
        }
    
        err_code = nrf_drv_uart_rx(&m_uart, &m_rx_byte, 1);
        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR("Failed initializing rx");
        }
    
        NRF_LOG_DEBUG("serial_dfu_transport_init() completed");
    
        m_active = true;
    
        if (m_observer)
        {
            m_observer(NRF_DFU_EVT_TRANSPORT_ACTIVATED);
        }
    
        return err_code;
    }

     

    2) Are there any other changes to be done.

     No, if you just want to change the pins then the definitions in pca10056.h is all you need to modify. Note, that hardware flow control is enabled, i.e. NRF_DFU_SERIAL_UART_USES_HWFC = 1, so if you only use the tx and RX pins and not any CTS or RTS pins, then you should disable the HWFC. 

    Best regards

    Bjørn

Children
No Data
Related