This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

OP_CODE error

Hi All,

I have generated the application pkg using below commands

nrfutil.exe pkg generate --hw-version 52 --application-version 2 --application bt_app_42994+.hex --sd-req 0xAF --key-file private.pem app.zip

and i tried to load it using nrfUtil dfu serial -b 115200 -p COM5 -pkg app.zip command.

I have successfully loaded once. I tried once more time and i'm getting Unexpected OP_CODE error.

 

is My device missing bytes?

What is meaning by this error? Any data packet miss match?

Need to provide delay to transmit Huge packet?

Please Help me understand it. It became road block for my work.

C:\Projects\MHB3.0\CodeDoc\Sourcecode\Python_BTapp>nrfutil.exe pkg generate --hw-version 52 --application-version 2 --application bt_app_42994+.hex --sd-req 0xAF --key-file private.pem app.zip
Zip created at app.zip

C:\Projects\MHB3.0\CodeDoc\Sourcecode\Python_BTapp>nrfUtil dfu serial -b 115200 -p COM5 -pkg app.zip
[####################################] 100%
Device programmed.

C:\Projects\MHB3.0\CodeDoc\Sourcecode\Python_BTapp>nrfUtil dfu serial -b 115200 -p COM5 -pkg app.zip
[#############################-------] 82% 0d 00:00:04
Traceback (most recent call last):
File "nordicsemi\__main__.py", line 1133, in <module>
File "site-packages\click\core.py", line 722, in __call__
File "site-packages\click\core.py", line 697, in main
File "site-packages\click\core.py", line 1066, in invoke
File "site-packages\click\core.py", line 1066, in invoke
File "site-packages\click\core.py", line 895, in invoke
File "site-packages\click\core.py", line 535, in invoke
File "nordicsemi\__main__.py", line 858, in serial
File "nordicsemi\__main__.py", line 793, in do_serial
File "nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
File "nordicsemi\dfu\dfu.py", line 102, in _dfu_send_image
File "nordicsemi\dfu\dfu_transport_serial.py", line 298, in send_firmware
File "nordicsemi\dfu\dfu_transport_serial.py", line 423, in __stream_data
File "nordicsemi\dfu\dfu_transport_serial.py", line 358, in __calculate_checksum
File "nordicsemi\dfu\dfu_transport_serial.py", line 441, in __get_response
pc_ble_driver_py.exceptions.NordicSemiException: Unexpected Executed OP_CODE.
Expected: 0x03 Received: 0x47
Failed to execute script __main__

C:\Projects\MHB3.0\CodeDoc\Sourcecode\Python_BTapp>

Thanks,

Basava.

  • Hi.

    Could you try to enable flow-control?

    Have you tried to increment the application-version number from 2 to when you try the second time to do the DFU?

    Best regards,

    Andreas

  • Hi,

    Actually Our end plan is to implement nrfutils in microconroller code. we need to updata nrf52 using ST controller with UART.  So, ST doesnt have hardware flow control pins. we need to achieve this without using it.

    No I didnt incremented the number. But I'm updating FW packet 4 or 5 times without getting error. some time its give this error.

    Thanks 

    Basava

  • Hi Basava.

    Goudra said:
    No I didnt incremented the number. But I'm updating FW packet 4 or 5 times without getting error. some time its give this error.

     Could you try to perhaps lower the baudrate, and see if you still sometimes get this error?

    Best regards,

    Andreas

  • Hi,

    I tried to upload my Fw file from the command prompt using 9600 baud and without flow control. Its uploading properly. Below attachment shows LOG file. As in the log file, after every 3 FW packet it is taking 200msec delay. 

     2022.Baudrate_9600.htm

    Same Flow I have implemented with C code to send my FW file. But after updating 12k or 16k bytes . I'm not getting reply from the Bootloader. I traced it and it is in hardware fault.

    1. So to avoid this hardware fault i have increases the delay to 1sec between each 64bytes packet. Still it went to hardware fault.

    2. Then I reduced the each packet size to 32bytes and kept 1sec delay in between Tx packet. For this configuration also i'm not getting CRC. I traced it. but it is a different issue now.  I found issue in the below code. 

    As in the LOG, before sending initialization packet, Object will be selected as 1ie NRF_DFU_OBJ_TYPE_COMMAND  and current_object  will update with 1 and  init  data should send after this.

    Same way, to send FW packet, we need to select and create object   with 2 ie NRF_DFU_OBJ_TYPE_DATA. Now current_object become 2 and start sending FW packet using opcode 0x08.

    After sending some packet current_object becomes . But i didn't change the obj number still the current_object value is modified.  I really dont know how it is changed. 

    To check this i have created global variable to store this value. After some time variable value becoming zero. So some values are overlapped it and changed the value. 

    To make sure this overlapped issue, I have created the global arry with 500byte and the created the global variable. Then followed the updating procedure. After sending some FW packet array value and global variable value become Zero current_object value changed to 2 to 1. 

    Because of this,  code will consider FW packet as init packet  and  later it will give invalid parameter error.

    Please help me to understand what is going wrong.

    static bool nrf_dfu_obj_op(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res)
    {
    /* Keep track of the current object type since write and execute requests don't contain it. */
    static nrf_dfu_obj_type_t current_object = NRF_DFU_OBJ_TYPE_COMMAND;

    if ( (p_req->request == NRF_DFU_OP_OBJECT_SELECT)
    || (p_req->request == NRF_DFU_OP_OBJECT_CREATE))
    {
    STATIC_ASSERT(offsetof(nrf_dfu_request_select_t, object_type) ==
    offsetof(nrf_dfu_request_create_t, object_type),
    "Wrong object_type offset!");

    current_object = (nrf_dfu_obj_type_t)(p_req->select.object_type);
    }

    bool response_ready = true;

    switch (current_object)
    {
    case NRF_DFU_OBJ_TYPE_COMMAND:
    nrf_dfu_command_req(p_req, p_res);
    break;

    case NRF_DFU_OBJ_TYPE_DATA:
    response_ready = nrf_dfu_data_req(p_req, p_res);
    break;

    default:
    /* The select request had an invalid object type. */
    NRF_LOG_ERROR("Invalid object type in request.");
    current_object = NRF_DFU_OBJ_TYPE_INVALID;
    p_res->result = NRF_DFU_RES_CODE_INVALID_OBJECT;
    break;
    }

    return response_ready;
    }

    Regards,

    Basavanagouda

  • Hi.

    I see that you have posted the same question in this ticket, I will therefore close this ticket.

    Best regards,

    Andreas

Related