# uavcan.protocol.file.BeginFirmwareUpdate

**URL:** <https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541>\
**Category:** Libcanard\
**Created:** [June 24, 2019, 1:05pm UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541 "2019-06-24T13:05:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![YGQ](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/y/97f17d/32.png) [@YGQ](https://forum.opencyphal.org/u/YGQ)\
**Post date:** [June 24, 2019, 1:05pm UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/1 "2019-06-24T13:05:04Z")

</div>

Hello, now my UAVCAN node received this message and implemented a jump to the bootloader. Now how should I handle the firmware upgrade? Is it possible to call uavcan.protocol.file.Read directly, but I think it is There should be no response information, I am not sure how the whole process is, ask for help. Thank you！！

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [June 24, 2019, 7:46pm UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/2 "2019-06-24T19:46:55Z")

</div>

Please read this: [https://uavcan.org/Specification/6.\_Application\_level\_functions/#firmware-update](https://uavcan.org/Specification/6._Application_level_functions/#firmware-update)

Also this: [https://uavcan.org/Implementations/Libuavcan/Tutorials/11.\_Firmware\_update/](https://uavcan.org/Implementations/Libuavcan/Tutorials/11._Firmware_update/) The tutorial is for libuavcan, not libcanard, but the general principles are the same so you can use it as a high-level reference.

The Kocherga protocol module implements the UAVCAN bootloader protocol: [https://github.com/Zubax/kocherga/blob/master/kocherga\_uavcan.hpp](https://github.com/Zubax/kocherga/blob/master/kocherga_uavcan.hpp) (and it is built on Libcanard!)

---

<div class="post-metadata">

**Author:** ![YGQ](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/y/97f17d/32.png) [@YGQ](https://forum.opencyphal.org/u/YGQ)\
**Post date:** [June 29, 2019, 6:24am UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/3 "2019-06-29T06:24:44Z")

</div>

thank you

---

<div class="post-metadata">

**Author:** ![YGQ](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/y/97f17d/32.png) [@YGQ](https://forum.opencyphal.org/u/YGQ)\
**Post date:** [June 29, 2019, 6:28am UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/4 "2019-06-29T06:28:42Z")

</div>

Continuing the discussion from [uavcan.protocol.file.BeginFirmwareUpdate](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/2):

I have another problem now. When I receive a lot of data, I can’t enter onTransferReceived. For example, when I receive the information of the file, I can’t confirm what the problem is.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [June 29, 2019, 1:10pm UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/5 "2019-06-29T13:10:11Z")

</div>

You might be losing frames to RX queue overrun. If you’re using STM32, this might be relevant:

> <https://github.com/Zubax/kocherga/issues/5>
>
> I'm not sure whether this issue belongs to this repository but at least I will s…hare the problem I encountered.
> 
> I'm using this bootloader on a STM32F103 @ 72 MHz and the main bootloader loop is too slow to poll libcanard stm32 driver receive function hence losing packets during file transfer. The internal receive buffer is only 2 frames and it seems that it cannot keep up with 1mbps CAN bitrate. The way I solved this is by making libcanard driver interrupt driven and feeding frames to an intermediate RX queue (ChibiOS FIFO).
> 
> This is highly platform specific, but I think someone will definitely encounter this issue. I'm not sure if this should be fixed by making libcanard driver buffered or by other means.

---

<div class="post-metadata">

**Author:** ![YGQ](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/y/97f17d/32.png) [@YGQ](https://forum.opencyphal.org/u/YGQ)\
**Post date:** [July 1, 2019, 3:59am UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/6 "2019-07-01T03:59:41Z")

</div>

Yes, it is this problem that has been resolved. I need to send a message to the file service after I get and update, or I can directly convert the state of the UAVCAN node from SOFTWARE\_UPDATE to OPERATIONAL.

---

<div class="post-metadata">

**Author:** ![YGQ](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/y/97f17d/32.png) [@YGQ](https://forum.opencyphal.org/u/YGQ)\
**Post date:** [July 4, 2019, 3:01am UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/7 "2019-07-04T03:01:20Z")

</div>

How to verify the uavcan protocol file transfer part, I have not found relevant information at present, I feel that the transmission process is prone to errors.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [July 30, 2019, 9:09am UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/8 "2019-07-30T09:09:26Z")

</div>

> [@YGQ](#):
>
> I need to send a message to the file service after I get and update, or I can directly convert the state of the UAVCAN node from SOFTWARE\_UPDATE to OPERATIONAL.

The updatee can just switch its published mode to OPERATIONAL, no additional steps are required.

_Unrelated: you can’t send a “message” to a service, these are opposite concepts. You can send either a service request or a service response, there is no such thing as “service message”._

> [@YGQ](#):
>
> How to verify the uavcan protocol file transfer part, I have not found relevant information at present, I feel that the transmission process is prone to errors.

Either:

1. Embed a CRC into your file and check it. This works if the file is a firmware image (you probably need a CRC there anyway regardless of UAVCAN).
2. Use a separate hash file as described here (the linked definition is for UAVCAN v1 but it is istill applicable to v0):

> <https://github.com/OpenCyphal/public_regulated_data_types/blob/a532bfa7d09409f1d160bdf5240ebd7430a662ba/uavcan/file/408.Read.1.0.uavcan#L14-L29>

---

<div class="post-metadata">

**Author:** ![YGQ](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/y/97f17d/32.png) [@YGQ](https://forum.opencyphal.org/u/YGQ)\
**Post date:** [August 6, 2019, 5:08am UTC](https://forum.opencyphal.org/t/uavcan-protocol-file-beginfirmwareupdate/541/9 "2019-08-06T05:08:11Z")

</div>

Thank you for your help, I have implemented the above functions.
