MCUMGR firmware update via CAN bus (or any other bytestream source/sink) by software API instead of UART driver?

Hi, in one of our projects, we need to update the application firmware on our nRF5340 via CAN bus (using an MCP2515 interface which I will commision within the coming weeks, Zephyr driver seems to be available).

It is possible to update the firmware via UART or USB (CDC_ACM), but from an abstract point of view, there is only a bytestream which is forwarded to and received from MCUmgr.

As far as I know, MCUmgr cannot be used natively with CAN, which would also be tricky as only a fraction of the CAN messages would have to be handled by the MCUmgr. One straightforward way for using a CAN connection would be to create a fake uart device driver which does not access hardware, but provides a software interface which is used to receive and provide UART data (or a bytestream, like mentioned above). But probably this approach is overkill. Isn't there a simple generic software interface for MCUmgr available that can receive and send data without using drivers? E.g.

void mcumgr_data_in(uint8_t* buffer, uint32_t size);    // Send uart data from buffer to mcumgr
uint32_t mcumgr_data_in(uint8_t* buffer, uint32_t size);    // Receive uart data from mcumgr into buffer, returns amount of bytes transferred

This way, I could just filter my CAN packets and forward the uart payload to mcumgr. And if mcumgr provides some data, I can poll it and wrap it into CAN messages and send it out.

Is it possible to use MCUmgr in this way? If yes, which configuration values do I have to set?

Best regards,
Michael

Parents Reply
  • Hi Amanda,

    thank you very much for the reply. dfu-target definitely looks interesting.

    Unfortunately, the documentation is a bit lacking - there is some documentation about the code, but no flow diagrams and no description how dfu-target complements mcumgr... does dfu-target completely replace mcumgr, so that I have to remove mcumgr from my configuration and use df-target to write into the secondary slot from within my application, using my own comunication protocol?

    Or is dfu-target being used by mcumgr? Your first link looks like there are multiple already implemented communication channels for dfu-target available that work with the mcumgr's smp protocol, whereas the second link suggests that dfu-target is a completely separate module that works without the smp protocol...

    Further, is there any straightforward documentation on the mcumgr protocol available (packet definitions etc.)? This information would also be useful in creating our own little flashing application, as there seems to be no reliably working flashing application / command line tool for mcumgr available at this time. (Somewhere, it was written that a new version for the mcumgr command line tool is in development, and the old version should not be used for production as it is not reliable...)

    Best regards,
    Michael

Children
Related