Part 1
요약·해설
비독점 file handle과 access hook, half-stateless upload context, CRC32/SHA256 선택과 response format을 설명합니다.
8
Offset + chunk
CRC32 · SHA256
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
083D02F54F8876843D0B3C2DDADFE69E718DED05BEBD062E4E3A5BAEB7B93529
.. _mcumgr_smp_group_8:
File management
###############
The file management group provides commands that allow to upload and download files
to/from a device.
File management group defines following commands:
.. table::
:align: center
+-------------------+-----------------------------------------------+
| ``Command ID`` | Command description |
+===================+===============================================+
| ``0`` | File download/upload |
+-------------------+-----------------------------------------------+
| ``1`` | File status |
+-------------------+-----------------------------------------------+
| ``2`` | File hash/checksum |
+-------------------+-----------------------------------------------+
| ``3`` | Supported file hash/checksum types |
+-------------------+-----------------------------------------------+
| ``4`` | File close |
+-------------------+-----------------------------------------------+
File download
*************
Command allows to download contents of an existing file from specified path
of a target device. Client applications must keep track of data they have
already downloaded and where their position in the file is (MCUmgr will cache
these also), and issue subsequent requests, with modified offset, to gather
the entire file.
Request does not carry size of requested chunk, the size is specified
by application itself.
Note that file handles will remain open for consecutive requests (as long as
an idle timeout has not been reached and another transport does not make use
of uploading/downloading files using fs_mgmt), but files are not exclusively
owned by MCUmgr, for the time of download session, and may change between
requests or even be removed.
.. note::
By default, all file upload/download requests are unconditionally allowed.
However, if the Kconfig option
:kconfig:option:`CONFIG_MCUMGR_GRP_FS_FILE_ACCESS_HOOK` is enabled, then an
application can register a callback handler for
:c:enumerator:`MGMT_EVT_OP_FS_MGMT_FILE_ACCESS` (see
:ref:`MCUmgr callbacks <mcumgr_callbacks>`), which allows for allowing or
declining access to reading/writing a particular file, or for rewriting the
path supplied by the client.
File download request
=====================
File download request header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``0`` | ``8`` | ``0`` |
+--------+--------------+----------------+
CBOR data of request:
.. code-block:: none
{
(str)"off" : (uint)
(str)"name" : (str)
}
where:
.. table::
:align: center
+-----------------------+---------------------------------------------------+
| "off" | offset to start download at |
+-----------------------+---------------------------------------------------+
| "name" | absolute path to a file |
+-----------------------+---------------------------------------------------+
File download response
======================
File download response header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``1`` | ``8`` | ``0`` |
+--------+--------------+----------------+
CBOR data of successful response:
.. code-block:: none
{
(str)"off" : (uint)
(str)"data" : (byte str)
(str,opt)"len" : (uint)
}
In case of error the CBOR data takes the form:
.. tabs::
.. group-tab:: SMP version 2
.. code-block:: none
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}
.. group-tab:: SMP version 1 (and non-group SMP version 2)
.. code-block:: none
{
(str)"rc" : (int)
}
where:
.. table::
:align: center
+------------------+-------------------------------------------------------------------------+
| "off" | offset the response is for. |
+------------------+-------------------------------------------------------------------------+
| "data" | chunk of data read from file; it is CBOR encoded stream of bytes with |
| | embedded size; "data" appears only in responses where "rc" is 0. |
+------------------+-------------------------------------------------------------------------+
| "len" | length of file, this field is only mandatory when "off" is 0. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "group" | :c:enum:`mcumgr_group_t` group of the group-based error code. Only |
| | appears if an error is returned when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "rc" | contains the index of the group-based error code. Only appears if |
| | non-zero (error condition) when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "rc" | :c:enum:`mcumgr_err_t` only appears if non-zero (error condition) when |
| | using SMP version 1 or for SMP errors when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
File upload
***********
Allows to upload a file to a specified location. Command will automatically overwrite
existing file or create a new one if it does not exist at specified path.
The protocol supports stateless upload where each requests carries different chunk
of a file and it is client side responsibility to track progress of upload.
Note that file handles will remain open for consecutive requests (as long as
an idle timeout has not been reached, but files are not exclusively owned by
MCUmgr, for the time of download session, and may change between requests or
even be removed. Note that file handles will remain open for consecutive
requests (as long as an idle timeout has not been reached and another transport
does not make use of uploading/downloading files using fs_mgmt), but files are
not exclusively owned by MCUmgr, for the time of download session, and may
change between requests or even be removed.
.. note::
Weirdly, the current Zephyr implementation is half-stateless as is able to hold
single upload context, holding information on ongoing upload, that consists
of bool flag indicating in-progress upload, last successfully uploaded offset
and total length only.
.. note::
By default, all file upload/download requests are unconditionally allowed.
However, if the Kconfig option
:kconfig:option:`CONFIG_MCUMGR_GRP_FS_FILE_ACCESS_HOOK` is enabled, then an
application can register a callback handler for
:c:enumerator:`MGMT_EVT_OP_FS_MGMT_FILE_ACCESS` (see
:ref:`MCUmgr callbacks <mcumgr_callbacks>`), which allows for allowing or
declining access to reading/writing a particular file, or for rewriting the
path supplied by the client.
File upload request
===================
File upload request header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``2`` | ``8`` | ``0`` |
+--------+--------------+----------------+
CBOR data of request:
.. code-block:: none
{
(str)"off" : (uint)
(str)"data" : (str)
(str)"name" : (str)
(str,opt)"len" : (uint)
}
where:
.. table::
:align: center
+-----------------------+---------------------------------------------------+
| "off" | offset to start/continue upload at. |
+-----------------------+---------------------------------------------------+
| "data" | chunk of data to write to the file; |
| | it is CBOR encoded with length embedded. |
+-----------------------+---------------------------------------------------+
| "name" | absolute path to a file. |
+-----------------------+---------------------------------------------------+
| "len" | length of file, this field is only mandatory |
| | when "off" is 0. |
+-----------------------+---------------------------------------------------+
File upload response
====================
File upload response header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``3`` | ``8`` | ``0`` |
+--------+--------------+----------------+
CBOR data of successful response:
.. code-block:: none
{
(str)"off" : (uint)
}
In case of error the CBOR data takes the form:
.. .. tabs::
.. group-tab:: SMP version 2
.. code-block:: none
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}
.. group-tab:: SMP version 1 (and non-group SMP version 2)
.. code-block:: none
{
(str)"rc" : (int)
}
where:
.. table::
:align: center
+------------------+-------------------------------------------------------------------------+
| "off" | offset of last successfully written data. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "group" | :c:enum:`mcumgr_group_t` group of the group-based error code. Only |
| | appears if an error is returned when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "rc" | contains the index of the group-based error code. Only appears if |
| | non-zero (error condition) when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "rc" | :c:enum:`mcumgr_err_t` only appears if non-zero (error condition) when |
| | using SMP version 1 or for SMP errors when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
File status
***********
Command allows to retrieve status of an existing file from specified path
of a target device.
File status request
===================
File status request header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``0`` | ``8`` | ``1`` |
+--------+--------------+----------------+
CBOR data of request:
.. code-block:: none
{
(str)"name" : (str)
}
where:
.. table::
:align: center
+-----------------------+---------------------------------------------------+
| "name" | absolute path to a file. |
+-----------------------+---------------------------------------------------+
File status response
====================
File status response header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``1`` | ``8`` | ``1`` |
+--------+--------------+----------------+
CBOR data of successful response:
.. code-block:: none
{
(str)"len" : (uint)
}
In case of error the CBOR data takes form:
.. tabs::
.. group-tab:: SMP version 2
.. code-block:: none
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}
.. group-tab:: SMP version 1 (and non-group SMP version 2)
.. code-block:: none
{
(str)"rc" : (int)
}
where:
.. table::
:align: center
+------------------+-------------------------------------------------------------------------+
| "len" | length of file (in bytes). |
+------------------+-------------------------------------------------------------------------+
| "err" -> "group" | :c:enum:`mcumgr_group_t` group of the group-based error code. Only |
| | appears if an error is returned when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "rc" | contains the index of the group-based error code. Only appears if |
| | non-zero (error condition) when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "rc" | :c:enum:`mcumgr_err_t` only appears if non-zero (error condition) when |
| | using SMP version 1 or for SMP errors when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
File hash/checksum
******************
Command allows to generate a hash/checksum of an existing file at a specified
path on a target device. Note that kernel heap memory is required for buffers to
be allocated for this to function, and large stack memory buffers are required
for generation of the output hash/checksum.
Requires :kconfig:option:`CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH` to be enabled for
the base functionality, supported hash/checksum are opt-in with
:kconfig:option:`CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32` or
:kconfig:option:`CONFIG_MCUMGR_GRP_FS_HASH_SHA256`.
File hash/checksum request
==========================
File hash/checksum request header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``0`` | ``8`` | ``2`` |
+--------+--------------+----------------+
CBOR data of request:
.. code-block:: none
{
(str)"name" : (str)
(str,opt)"type" : (str)
(str,opt)"off" : (uint)
(str,opt)"len" : (uint)
}
where:
.. table::
:align: center
+-----------------------+---------------------------------------------------+
| "name" | absolute path to a file. |
+-----------------------+---------------------------------------------------+
| "type" | type of hash/checksum to perform |
| | :ref:`mcumgr_group_8_hash_checksum_types` or omit |
| | to use default. |
+-----------------------+---------------------------------------------------+
| "off" | offset to start hash/checksum calculation at |
| | (optional, 0 if not provided). |
+-----------------------+---------------------------------------------------+
| "len" | maximum length of data to read from file to |
| | generate hash/checksum with (optional, full file |
| | size if not provided). |
+-----------------------+---------------------------------------------------+
.. _mcumgr_group_8_hash_checksum_types:
Hash/checksum types
===================
.. table::
:align: center
+-------------+--------------------------------------+-------------+--------------+
| String name | Hash/checksum | Byte string | Size (bytes) |
+=============+======================================+=============+==============+
| ``crc32`` | IEEE CRC32 checksum | No | 4 |
+-------------+--------------------------------------+-------------+--------------+
| ``sha256`` | SHA256 (Secure Hash Algorithm) | Yes | 32 |
+-------------+--------------------------------------+-------------+--------------+
Note that the default type will be crc32 if it is enabled, or sha256 if crc32 is
not enabled.
File hash/checksum response
===========================
File hash/checksum response header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``1`` | ``8`` | ``2`` |
+--------+--------------+----------------+
CBOR data of successful response:
.. code-block:: none
{
(str)"type" : (str)
(str,opt)"off" : (uint)
(str)"len" : (uint)
(str)"output" : (uint or bstr)
}
In case of error the CBOR data takes the form:
.. tabs::
.. group-tab:: SMP version 2
.. code-block:: none
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}
.. group-tab:: SMP version 1 (and non-group SMP version 2)
.. code-block:: none
{
(str)"rc" : (int)
}
where:
.. table::
:align: center
+------------------+-------------------------------------------------------------------------+
| "type" | type of hash/checksum that was performed |
| | :ref:`mcumgr_group_8_hash_checksum_types`. |
+------------------+-------------------------------------------------------------------------+
| "off" | offset that hash/checksum calculation started at (only present if not |
| | 0). |
+------------------+-------------------------------------------------------------------------+
| "len" | length of input data used for hash/checksum generation (in bytes). |
+------------------+-------------------------------------------------------------------------+
| "output" | output hash/checksum. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "group" | :c:enum:`mcumgr_group_t` group of the group-based error code. Only |
| | appears if an error is returned when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "rc" | contains the index of the group-based error code. Only appears if |
| | non-zero (error condition) when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "rc" | :c:enum:`mcumgr_err_t` only appears if non-zero (error condition) when |
| | using SMP version 1 or for SMP errors when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
Supported file hash/checksum types
**********************************
Command allows listing which hash and checksum types are available on a device.
Requires Kconfig :kconfig:option:`CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_CMD`
to be enabled.
Supported file hash/checksum types request
==========================================
Supported file hash/checksum types request header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``0`` | ``8`` | ``3`` |
+--------+--------------+----------------+
The command sends empty CBOR map as data.
Supported file hash/checksum types response
===========================================
Supported file hash/checksum types response header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``1`` | ``8`` | ``3`` |
+--------+--------------+----------------+
CBOR data of successful response:
.. code-block:: none
{
(str)"types" : {
(str)<hash_checksum_name> : {
(str)"format" : (uint)
(str)"size" : (uint)
}
...
}
}
In case of error the CBOR data takes form:
.. tabs::
.. group-tab:: SMP version 2
.. code-block:: none
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}
.. group-tab:: SMP version 1 (and non-group SMP version 2)
.. code-block:: none
{
(str)"rc" : (int)
}
where:
.. table::
:align: center
+----------------------+-------------------------------------------------------------------------+
| <hash_checksum_name> | name of the hash/checksum type |
| | :ref:`mcumgr_group_8_hash_checksum_types`. |
+----------------------+-------------------------------------------------------------------------+
| "format" | format that the hash/checksum returns where 0 is for numerical and 1 is |
| | for byte array. |
+----------------------+-------------------------------------------------------------------------+
| "size" | size (in bytes) of output hash/checksum response. |
+----------------------+-------------------------------------------------------------------------+
| "err" -> "group" | :c:enum:`mcumgr_group_t` group of the group-based error code. Only |
| | appears if an error is returned when using SMP version 2. |
+----------------------+-------------------------------------------------------------------------+
| "err" -> "rc" | contains the index of the group-based error code. Only appears if |
| | non-zero (error condition) when using SMP version 2. |
+----------------------+-------------------------------------------------------------------------+
| "rc" | :c:enum:`mcumgr_err_t` only appears if non-zero (error condition) when |
| | using SMP version 1 or for SMP errors when using SMP version 2. |
+----------------------+-------------------------------------------------------------------------+
File close
**********
Command allows closing any open file handles held by fs_mgmt upload/download
requests that might have stalled or be incomplete.
File close request
==================
File close request header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``2`` | ``8`` | ``4`` |
+--------+--------------+----------------+
The command sends empty CBOR map as data.
File close response
===================
File close response header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``3`` | ``8`` | ``4`` |
+--------+--------------+----------------+
The command sends an empty CBOR map as data if successful.
In case of error the CBOR data takes the form:
.. tabs::
.. group-tab:: SMP version 2
.. code-block:: none
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}
.. group-tab:: SMP version 1 (and non-group SMP version 2)
.. code-block:: none
{
(str)"rc" : (int)
}
where:
.. table::
:align: center
+------------------+-------------------------------------------------------------------------+
| "err" -> "group" | :c:enum:`mcumgr_group_t` group of the group-based error code. Only |
| | appears if an error is returned when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "rc" | contains the index of the group-based error code. Only appears if |
| | non-zero (error condition) when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "rc" | :c:enum:`mcumgr_err_t` only appears if non-zero (error condition) when |
| | using SMP version 1 or for SMP errors when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
Part 3
한국어 전문 번역
File management group은 device로 file을 upload하거나 device에서 file을 download할 수 있는 command를 제공합니다.
File management group은 다음 command를 정의합니다.
| Command ID | Command description |
|---|---|
| 0 | File download/upload |
| 1 | File status |
| 2 | File hash/checksum |
| 3 | 지원되는 file hash/checksum type |
| 4 | File close |
File download
이 command는 target device의 지정 path에 있는 기존 file 내용을 download합니다. Client application은 이미 받은 data와 현재 file position을 추적해야 하며, MCUmgr도 이를 cache합니다. 전체 file을 모을 때까지 offset을 바꿔 후속 request를 보냅니다.
Request에는 원하는 chunk size가 들어 있지 않습니다. Size는 application 자체가 정합니다.
Idle timeout에 도달하지 않고 다른 transport가 fs_mgmt upload/download를 사용하지 않는 동안에는 연속 request 사이에도 file handle이 열린 채로 유지됩니다. 그러나 download session 동안 file은 MCUmgr가 독점하지 않으므로 request 사이에 바뀌거나 삭제될 수도 있습니다.
File download request
File download request header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 0 | 8 | 0 |
Request의 CBOR data는 다음과 같습니다.
{
(str)"off" : (uint)
(str)"name" : (str)
}
Request field의 의미는 다음과 같습니다.
off | Download를 시작할 offset입니다. |
name | File의 absolute path입니다. |
File download response
File download response header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 1 | 8 | 0 |
성공한 response의 CBOR data는 다음과 같습니다.
{
(str)"off" : (uint)
(str)"data" : (byte str)
(str,opt)"len" : (uint)
}
Error가 발생하면 CBOR data는 다음 형식입니다.
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}{
(str)"rc" : (int)
}Response field의 의미는 다음과 같습니다.
off | 이 response가 대응하는 offset입니다. |
data | File에서 읽은 data chunk입니다. Size가 내장된 CBOR byte stream이며 rc가 0인 response에만 나타납니다. |
len | File length입니다. off가 0일 때만 필수입니다. |
err → group | Group 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다. |
err → rc | Group 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다. |
rc | mcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다. |
File upload
지정한 위치로 file을 upload합니다. 해당 path에 file이 있으면 자동으로 덮어쓰고, 없으면 새로 만듭니다. Protocol은 각 request가 서로 다른 file chunk를 운반하는 stateless upload를 지원하며 upload 진행 상황은 client가 추적해야 합니다.
연속 request 사이의 file handle 유지와 비독점 access에는 download와 같은 주의가 적용됩니다. Idle timeout이나 다른 transport의 fs_mgmt 사용 전까지 handle이 유지되지만, file은 request 사이에 바뀌거나 삭제될 수 있습니다. 원문은 이 경고를 일부 중복해서 서술합니다.
File upload request
File upload request header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 2 | 8 | 0 |
Request의 CBOR data는 다음과 같습니다.
{
(str)"off" : (uint)
(str)"data" : (str)
(str)"name" : (str)
(str,opt)"len" : (uint)
}
Request field의 의미는 다음과 같습니다.
off | Upload를 시작하거나 계속할 offset입니다. |
data | File에 쓸 data chunk입니다. Length가 내장된 CBOR data입니다. |
name | File의 absolute path입니다. |
len | File length입니다. off가 0일 때만 필수입니다. |
File upload response
File upload response header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 3 | 8 | 0 |
성공한 response의 CBOR data는 다음과 같습니다.
{
(str)"off" : (uint)
}
Error가 발생하면 SMP version 2는 err map 안의 group과 rc를 사용하고, SMP version 1 및 group 기반이 아닌 SMP version 2는 top-level rc를 사용합니다. 원문의 upload error tab directive는 .. .. tabs:: 오타 때문에 공식 HTML에서는 두 code block이 렌더링되지 않습니다.
Response field의 의미는 다음과 같습니다.
off | 마지막으로 성공적으로 쓴 data의 offset입니다. |
err → group | Group 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다. |
err → rc | Group 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다. |
rc | mcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다. |
File status
이 command는 target device의 지정 path에 있는 기존 file 상태를 가져옵니다.
File status request
File status request header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 0 | 8 | 1 |
Request의 CBOR data는 다음과 같습니다.
{
(str)"name" : (str)
}
Request field의 의미는 다음과 같습니다.
name | File의 absolute path입니다. |
File status response
File status response header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 1 | 8 | 1 |
성공한 response의 CBOR data는 다음과 같습니다.
{
(str)"len" : (uint)
}
Error가 발생하면 CBOR data는 다음 형식입니다.
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}{
(str)"rc" : (int)
}Response field의 의미는 다음과 같습니다.
len | Byte 단위 file length입니다. |
err → group | Group 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다. |
err → rc | Group 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다. |
rc | mcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다. |
File hash/checksum
이 command는 target device의 지정 path에 있는 기존 file의 hash/checksum을 생성합니다. 동작에 필요한 buffer를 할당하려면 kernel heap memory가 필요하고, output hash/checksum을 만들려면 큰 stack memory buffer가 필요합니다.
기본 기능에는 CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH가 필요합니다. 지원할 hash/checksum은 CONFIG_MCUMGR_GRP_FS_CHECKSUM_IEEE_CRC32 또는 CONFIG_MCUMGR_GRP_FS_HASH_SHA256로 개별 선택합니다.
File hash/checksum request
File hash/checksum request header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 0 | 8 | 2 |
Request의 CBOR data는 다음과 같습니다.
{
(str)"name" : (str)
(str,opt)"type" : (str)
(str,opt)"off" : (uint)
(str,opt)"len" : (uint)
}
Request field의 의미는 다음과 같습니다.
name | File의 absolute path입니다. |
type | 수행할 hash/checksum type입니다. 아래 type 중 하나를 지정하거나 생략해 default를 사용합니다. |
off | Hash/checksum 계산을 시작할 offset입니다. 선택 사항이며 생략하면 0입니다. |
len | Hash/checksum 생성에 읽을 file data의 maximum length입니다. 선택 사항이며 생략하면 전체 file size입니다. |
Hash/checksum type
| String name | Hash/checksum | Byte string | Size (bytes) |
|---|---|---|---|
crc32 | IEEE CRC32 checksum | No | 4 |
sha256 | SHA256 (Secure Hash Algorithm) | Yes | 32 |
Default type은 CRC32가 활성화돼 있으면 crc32이고, CRC32가 비활성화돼 있으면 sha256입니다.
File hash/checksum response
File hash/checksum response header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 1 | 8 | 2 |
성공한 response의 CBOR data는 다음과 같습니다.
{
(str)"type" : (str)
(str,opt)"off" : (uint)
(str)"len" : (uint)
(str)"output" : (uint or bstr)
}
Error가 발생하면 CBOR data는 다음 형식입니다.
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}{
(str)"rc" : (int)
}Response field의 의미는 다음과 같습니다.
type | 실제로 수행한 hash/checksum type입니다. |
off | Hash/checksum 계산을 시작한 offset입니다. 0이 아닐 때만 나타납니다. |
len | Hash/checksum 생성에 사용한 input data length입니다. |
output | 출력 hash/checksum입니다. |
err → group | Group 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다. |
err → rc | Group 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다. |
rc | mcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다. |
지원되는 file hash/checksum type
이 command는 device에서 사용할 수 있는 hash와 checksum type을 나열합니다. CONFIG_MCUMGR_GRP_FS_CHECKSUM_HASH_SUPPORTED_CMD를 활성화해야 합니다.
지원 type request
Supported file hash/checksum types request header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 0 | 8 | 3 |
이 command는 data로 빈 CBOR map을 보냅니다.
지원 type response
Supported file hash/checksum types response header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 1 | 8 | 3 |
성공한 response의 CBOR data는 다음과 같습니다.
{
(str)"types" : {
(str)<hash_checksum_name> : {
(str)"format" : (uint)
(str)"size" : (uint)
}
...
}
}
Error가 발생하면 CBOR data는 다음 형식입니다.
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}{
(str)"rc" : (int)
}Response field의 의미는 다음과 같습니다.
<hash_checksum_name> | Hash/checksum type의 name입니다. |
format | Hash/checksum 반환 format입니다. 0은 numerical value, 1은 byte array입니다. |
size | 출력 hash/checksum response의 byte size입니다. |
err → group | Group 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다. |
err → rc | Group 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다. |
rc | mcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다. |
File close
이 command는 멈췄거나 완료되지 않은 fs_mgmt upload/download request가 보유한 열린 file handle을 모두 닫습니다.
File close request
File close request header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 2 | 8 | 4 |
이 command는 data로 빈 CBOR map을 보냅니다.
File close response
File close response header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 3 | 8 | 4 |
성공하면 command는 data로 빈 CBOR map을 보냅니다.
Error가 발생하면 CBOR data는 다음 형식입니다.
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}{
(str)"rc" : (int)
}Error field의 의미는 다음과 같습니다.
err → group | Group 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다. |
err → rc | Group 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다. |
rc | mcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다. |
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.