SMP command using ZCBOR command line and CDDL file

Hello !

We would like to implement a SMP client code as described in https://docs.zephyrproject.org/latest/services/device_mgmt/smp_protocol.html.
In Zephyr we can use the zcbor lib that you implemented: https://github.com/NordicSemiconductor/zcbor/blob/main/ARCHITECTURE.md  

zcbor -c cbor.cddl --no-prelude  --default-max-qty 2 code -t MultiList --encode --output-cmake imageslot

Image = (
  "slot" => uint,
  "version" => bstr,
  ? "bootable" => bool,
  ? "pending" => bool,
  ? "confirmed" => bool,
  ? "active" => bool,
  ? "permanent" => bool,
)

MultiList = {
  "images" => [+{
    "image" => uint,
    Image
  }]
}

I am struggling writing the proper cddl message so that the decoding code is generated by the zcbor command line.
The one above adds the "image" tstr. which is not expected.

bf 66 69 6d 61 67 65 73  9f bf 64 73 6c 6f 74 00 |.fimages ..dslot.
67 76 65 72 73 69 6f 6e  65 30 2e 30 2e 33 64 68 |gversion e0.0.3dh
61 73 68 58 20 90 70 cc  23 30 17 54 06 a8 ce 15 |ashX .p. #0.T....
28 63 3e 9c f4 19 a7 4a  ec 7e ca ce 10 24 c4 af |(c>....J .~...$..
48 68 e1 2c c7 68 62 6f  6f 74 61 62 6c 65 f5 67 |Hh.,.hbo otable.g
70 65 6e 64 69 6e 67 f4  69 63 6f 6e 66 69 72 6d |pending. iconfirm
65 64 f5 66 61 63 74 69  76 65 f5 69 70 65 72 6d |ed.facti ve.iperm
61 6e 65 6e 74 f4 ff ff  6b 73 70 6c 69 74 53 74 |anent... ksplitSt
61 74 75 73 00 ff                                |atus..

Do you have an example on a CDDL code for doing an SMP upload request or a get state request?

?

Thanks a lot!

  • Hello!

    I re-implemented the logic on a device (not nrf52 based) to do the upload image using SMP. The target was an nrf52 device.
    With the cddl file shared above, I get the "encode" and "decode" functions from the zcbor command line.

    Here is the cddl to do the upload of the payload (encode, decode).

    SmpImageUploadReq = {
      ? "len" => uint,
      ? "sha"  => bstr,
      "off" => uint,
      "data" => bstr,
      ? "image" => uint,
      ? "upgrade" => bool,
    }

    We faced such issue when trying to decode from python cbor library but it was because we did not use the proper data structure

Related