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

How to test examples\dfu\secure_bootloader\pca10040_uart_debug

I build the example and download to PCA10040,but there no log print in RTT, and I debug in keil mdk, I found the program does not step into main function.

How to run this example?Does there have any document to describle about usart DFU?

  • Hi, 

    Have you follow the documentation here
    I also made a blog that might be useful for you, here
    Note that you need to flash the softdevice before you test the bootloader. 

  • I use proprietary RF, the softdevice is not needn't, right?

    I have a question, I'm not find the VTOR offset config in bootloader, where does it set?

    I want modify the bootloader dfu transport from usart to proprietary RF,Can you give me some brief description for to achieve it?

    Thank you 

  • Hi, 
    You are right, if you don't plan to use BLE in both your application and the bootloader (UART DFU) then you don't need the softdevice. 

    But the bootloader requires a MBR (master boot record) to be flashed at address 0x0000 to be able to work. The MBR will handle the forwarding of the vector table. 

    You can find the MBR at \components\softdevice\mbr\hex

    We don't have an example of using proprietary RF to do DFU. But due to the way the bootloader designed, it should be rather straight forward to do. I would suggest to study the nrf_dfu_serial_uart.c code. 
    In the code you can find how you can call DFU_TRANSPORT_REGISTER() to register your own dfu transport. And how you can define  the init function to handle event from the upper level of the DFU library. It shouldn't be too hard to change it to your own transport protocol. 

    But I would suggest to test with the stock UART bootloader first , before modifying it. 

  • thanks for reply, Does the MBR have source code?I want to know exactly what does it do.

    Your suggestion is very good But I have encounter some problem for runing the uasrt dfu example.

    Here's how I do it:

    1.I'm not flash MBR;

    2.I modify the secure bootloader project IROM1 start addr to 0x00

    3. I have generate key and package as the  <nRF Util v6.1.0 User Guide.pdf>

    4.I Flash the generated package on command 

    nrfutil dfu usb-serial -pkg app_dfu_signed_package.zip -p COM4 -b 115200

    The result:

    <error> nrf_dfu_serial_uart: on_rx_complete, receive error:17

    <info> app: add byte to buffer

    <error> nrf_dfu_serial_uart: on_rx_complete, receive error:17

    <info> app: finished reading packet

    <error> nrf_dfu_serial_uart: on_rx_complete, receive error:17

    <info> app: finished reading packet

    <info> nrf_dfu_serial_uart: Allocated buffer 2000065C

    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)

    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1

    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)

    the error code is print at 

    static __INLINE void on_rx_complete(nrf_dfu_serial_t * p_transport, uint8_t * p_data, uint8_t len)
    {
        ret_code_t ret_code = NRF_ERROR_TIMEOUT;
    
        // Check if there is byte to process. Zero length transfer means that RXTO occured.
        if (len)
        {
            ret_code = slip_decode_add_byte(&m_slip, p_data[0]);
        }
    
        (void) nrf_drv_uart_rx(&m_uart, &m_rx_byte, 1);
    
        if (ret_code == NRF_SUCCESS)
        {
            nrf_dfu_serial_on_packet_received(p_transport,
                                             (uint8_t const *)m_slip.p_buffer,
                                             m_slip.current_index);
    
            uint8_t * p_rx_buf = nrf_balloc_alloc(&m_payload_pool);
            if (p_rx_buf == NULL)
            {
                NRF_LOG_ERROR("Failed to allocate buffer");
                return;
            }
            NRF_LOG_INFO("Allocated buffer %x", p_rx_buf);
            // reset the slip decoding
            m_slip.p_buffer      = &p_rx_buf[OPCODE_OFFSET];
            m_slip.current_index = 0;
            m_slip.state         = SLIP_STATE_DECODING;
        }
        else
        {
            NRF_LOG_ERROR("%s, receive error:%d", __func__, ret_code);  // 17 is NRF_ERROR_BUSY
        }
    
    }

    So why there have a NRF_ERROR_BUSY(17) error?

  • Please do use the MBR. The MBR does vector table forwarding and handle the bootloader swap. 

    We unfortunately don't provide the source code for the MBR. But you can find some of the features of the MBR in the nrf_dfu_mbr.h file. 
    Changing the bootloader to address 0 would requires quite a few modification in the bootloader to make it work. 

Related