intercreate / smpclient

Simple Management Protocol (SMP) Client for remotely managing MCU firmware
Apache License 2.0
9 stars 6 forks source link

File management #35

Closed Maartenwn closed 4 months ago

Maartenwn commented 4 months ago

Added file management.

As this uses changes in smp that are currently not released this will be draft.

Might be nice to check the checksum after uploading a file to check if the file is correctly uploaded.

JPHutchins commented 4 months ago

Thanks for the detailed tests and examples! Is there a standard Zephyr example that I can test with?

Seeing the download method as a regular call instead of a generator makes me realize that this should be an option for all uploads and downloads.

Maybe something like

download is a regular async function

download_iter is the async iterator (not sure I like that name)

download would wrap download_iter

And this approach would be for all download/upload methods, including firmware updates.

What do you think?

JPHutchins commented 4 months ago

Might be nice to check the checksum after uploading a file to check if the file is correctly uploaded.

That would be nice! Like a default arg that will do the SMP calls asking for the checksum from the device, then compares with a checksum calculated from smpclient?

sgfeniex commented 4 months ago

In the Zephyr tree, it looks like samples/subsys/mgmt/mcumgr/smp_svr with overlay-fs.conf would be the closest match.

Maartenwn commented 4 months ago

In the Zephyr tree, it looks like samples/subsys/mgmt/mcumgr/smp_svr with overlay-fs.conf would be the closest match.

Looks the best however that example doesn't enable hashing by default. This can be enabled by enabling the MCUMGR_GRP_FS_CHECKSUM_HASH. You also have to enable an hashing algoritm by setting MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32 and/or MCUMGR_GRP_FS_HASH_SHA256 (this requires also setting an backend), see https://docs.zephyrproject.org/latest/services/device_mgmt/smp_groups/smp_group_8.html#file-hash-checksum

JPHutchins commented 4 months ago

Hello! The breaking changes from SMP 3.0.1 have been merged to main as of e5727fb8caa5a9c4bdb3e1487bd7f8258526b82d. This branch can be rebased to integrate the changes. Primarily it's renaming ErrorV0 -> ErrorV1 and ErrorV1 -> ErrorV2.

Maartenwn commented 4 months ago

Might be nice to check the checksum after uploading a file to check if the file is correctly uploaded.

That would be nice! Like a default arg that will do the SMP calls asking for the checksum from the device, then compares with a checksum calculated from smpclient?

I am not sure if this belongs in this pr, as this could be in a separate pr.

JPHutchins commented 4 months ago

I am not sure if this belongs in this pr, as this could be in a separate pr.

Agreed, we'll move along.