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

DFU project

I try to create coap server project and it should by  updateable by DFU. I merge project simple coap server and thread dfu client, and I keep  instructions in documentation to build it and run DFU. But Server doesnt response to coap requests and when I start multicast DFU process server is not updated. and when I try to start unicast DFU it waiting to promote a router. 

Parents
  • I am folowing this instructions:

    first version

    D:
    cd IS\nRF5_SDK_for_Thread_and_Zigbee_v3.1.0_c7c4730\examples\thread\dfu_client
    make -C dfu_client_coap_server\pca10056\blank\armgcc
    nrfutil settings generate --family NRF52840 --application dfu_client_coap_server\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex
    mergehex -m dfu_client_coap_server\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex settings.hex -o dfu_client.hex
    nrfjprog -f nrf52 --eraseall
    nrfjprog -f nrf52 -r --program ..\..\..\components\softdevice\mbr\nrf52840\hex\mbr_nrf52_2.4.1_mbr.hex --chiperase
    nrfjprog -f nrf52 -r --program bootloader\pca10056\blank\armgcc\_build\nrf52840_xxaa_mbr.hex
    nrfjprog -f nrf52 -r --program dfu_client.hex --sectorerase


    code change

    next version
    make -C dfu_client_coap_server\pca10056\blank\armgcc
    nrfutil pkg generate --hw-version 52 --sd-req 0x00 --application-version 2 --application dfu_client_coap_server\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex --key-file key.pem app_dfu_package.zip


    DFU multicast
    nrfutil dfu thread -f -pkg app_dfu_package.zip -p COM14 --channel 11 --panid 43981 -r 4 -rs 5000 -a FF03::1

    DFU unicast
    nrfutil dfu thread -f -pkg app_dfu_package.zip -p COM14 --channel 11 --panid 43981
    nrfutil dfu thread -f -pkg app_dfu_package.zip -p COM14 --channel 11 --panid 43981 -a fdde:ad00:beef:0:65ab:b4da:9355:117b

  • Hi,

    Can you post the log output? Have you tried to run the DFU client application without the coap server and see if everything works? Can you post your project folder so we can reproduce it?

    Best regards,

    Marjeris

  • We wanna use it for thousands devices an update firmware without DFU will not possible. 

  • If I understand it, I should use coap library which is used in DFU project? 

  • Hi Fran,

    That's the buildt-in OpenThread coap library, the external coap library (the one used by the thread DFU client) is this one: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.iotsdk.v0.9.0%2Flib_iot_coap.html

  • I use nRF5_SDK_for_Thread_and_Zigbee_v3.2.0_9fade31

    I try example to DFU thread client and I add turn on LED. DFU was sucessfull. Next I add CoAP resources to code and it not start.

    This is terminal output:

    D:\IS\nRF5_SDK_for_Thread_and_Zigbee_v3.2.0_9fade31\examples\thread\dfu>nrfutil dfu thread -f -pkg app_dfu_package.zip -p COM12 --channel 11 --panid 43981
    Address not specified. Using ff03::1 (all Thread nodes)
    Using connectivity board at serial port: COM12
    Flashing connectivity firmware...
    Connectivity firmware flashed.
    Waiting for NCP to promote to a router...
    Thread DFU server is running... Press <Ctrl + D> to stop.

    edited file: coap_dfu.c

    added code:

    #define MY_APP_RESOURCE_HELLO "hello"
    coap_resource_t coap_resource_hello;
    
    #define MY_APP_RESOURCE_READ "read"
    coap_resource_t coap_resource_read;
    
    #define MY_APP_RESOURCE_WRITE "write"
    coap_resource_t coap_resource_write;
    
    static void hello_request_callback(coap_resource_t * p_resource, coap_message_t * p_request)
    {
    NRF_LOG_INFO("Hello packet");
    
    coap_message_t * p_response = NULL;
    
    if (!is_addr_multicast(&p_request->local))
    {
    p_response = empty_reset_response_create(p_request);
    }
    
    // Send response, if created.
    if (p_response != NULL)
    {
    coap_dfu_message_send(p_response);
    }
    
    }
    
    static void read_request_callback(coap_resource_t * p_resource, coap_message_t * p_request)
    {
    NRF_LOG_INFO("Read packet");
    
    coap_message_t * p_response = NULL;
    
    if (!is_addr_multicast(&p_request->local))
    {
    p_response = empty_reset_response_create(p_request);
    }
    
    // Send response, if created.
    if (p_response != NULL)
    {
    coap_dfu_message_send(p_response);
    }
    
    }
    
    static void write_request_callback(coap_resource_t * p_resource, coap_message_t * p_request)
    {
    NRF_LOG_INFO("Write packet");
    
    coap_message_t * p_response = NULL;
    
    if (!is_addr_multicast(&p_request->local))
    {
    p_response = empty_reset_response_create(p_request);
    }
    
    // Send response, if created.
    if (p_response != NULL)
    {
    coap_dfu_message_send(p_response);
    }
    
    }
    
    
    static uint32_t MyAppCoapResource_init()
    {
        uint32_t err_code = NRF_SUCCESS;
        
        do
        {
            err_code = coap_resource_create(&coap_resource_hello, MY_APP_RESOURCE_HELLO);
            err_code = coap_resource_create(&coap_resource_read, MY_APP_RESOURCE_READ);
            err_code = coap_resource_create(&coap_resource_write, MY_APP_RESOURCE_WRITE);
            if (err_code != NRF_SUCCESS)
            {
                break;
            }
    
            coap_resource_hello.permission = (COAP_PERM_POST | COAP_PERM_GET);
            coap_resource_hello.callback = hello_request_callback;
    
            coap_resource_read.permission = (COAP_PERM_POST | COAP_PERM_GET);
            coap_resource_read.callback = read_request_callback;
    
            coap_resource_write.permission = (COAP_PERM_POST | COAP_PERM_GET);
            coap_resource_write.callback = write_request_callback;
    
            NRF_LOG_INFO("Endpoints initialized");
    
        } while (0);
    
        return err_code;
    }
    
    //upgrade this existing function
    
    uint32_t coap_dfu_init(const void * p_context)
    {
        uint32_t err_code;
    
        do
        {
            memset(&m_coap_dfu_ctx, 0 , sizeof(m_coap_dfu_ctx));
    
            err_code = coap_protocol_init(p_context);
            if (err_code != NRF_SUCCESS)
            {
                break;
            }
    
            err_code = MyAppCoapResource_init();
            if (err_code != NRF_SUCCESS)
            {
                break;
            }
    
            err_code = endpoints_init(&m_coap_dfu_ctx);
            if (err_code != NRF_SUCCESS)
            {
                break;
            }
    
            nrf_dfu_settings_init(false);
            nrf_dfu_req_handler_init(dfu_observer);
    
            background_dfu_state_init(&m_dfu_ctx);
    
            app_timer_create(&m_send_timer, APP_TIMER_MODE_SINGLE_SHOT, delayed_send_handler);
            app_timer_create(&m_reset_timer, APP_TIMER_MODE_SINGLE_SHOT, delayed_reset_handler);
            app_timer_create(&m_coap_delayed_error_handling_timer, APP_TIMER_MODE_SINGLE_SHOT, coap_delayed_error_handler);
    
            APP_SCHED_INIT(SCHED_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
        } while (0);
    
        return err_code;
    }
    

  • Hi Fran,

    I am so sorry but I am going out on vacation so I will not be able to review your code before the 7th of October. Sorry for the inconvenience and thanks for your patience.

    Best regards,

    Marjeris

Reply Children
  • now it write this output:

    Traceback (most recent call last):
    File "C:\Python27\lib\site-packages\nrfutil-4.0.0-py2.7.egg\nordicsemi\thread\tncp.py", line 130, in _wpan_receive
    receiver.receive(payload, src, dst)
    File "build\bdist.win-amd64\egg\piccata\core.py", line 541, in receive
    self._message_layer.receive(data, remote, local)
    File "build\bdist.win-amd64\egg\piccata\core.py", line 206, in receive
    self._transaction_layer.receive_message(message, remote, local)
    File "build\bdist.win-amd64\egg\piccata\core.py", line 428, in receive_message
    self._process_response(message)
    File "build\bdist.win-amd64\egg\piccata\core.py", line 359, in _process_response
    self._finish_transaction(response.token, remote, RESULT_SUCCESS, response)
    File "build\bdist.win-amd64\egg\piccata\core.py", line 305, in _finish_transaction
    self._handle_app_callback(callback, result, request, response)
    File "build\bdist.win-amd64\egg\piccata\core.py", line 274, in _handle_app_callback
    cb(result, request, response, *args, **kw)
    File "C:\Python27\lib\site-packages\nrfutil-4.0.0-py2.7.egg\nordicsemi\thread\dfu_server.py", line 217, in _handle_trigger_response
    assert (result == piccata.constants.RESULT_TIMEOUT)
    AssertionError

Related