Firmware update
The firmware can be updated by performing a CoAP PUT operation of the image file to '/fw/image'.
1. Firmware Update over Serial Port
The firmware update operation can be done using a CoAP client running over MUP1. In the example below, the image file in /tmp/rel.fip is transferred using the MUP1 client tool.
mup1ct -d /dev/ttyACM0 coap put fw/image < /tmp/rel.fip
2. Firmware Update over Network
The firmware update operation can be done using a CoAP client running over IP. In the example below, the image file in /tmp/rel.fip is transferred using the libcoap client tool. The IP address 1.2.3.4 has been assigned to the switch prior to the operation.
coap-client -m put coap://1.2.3.4/fw/image -f /tmp/rel.fip
3. Chunked Firmware Update
The image can also be transferred as a sequence of separate CoAP PUT operations instead of a single one. The device serves other requests in between, so management of the switch stays responsive for the duration of the update.
Each request states the byte offset of its part within the image in an offset
query parameter. The example below transfers a 192 KiB image in three parts of
64 KiB. Note the quoting, which keeps the shell from interpreting the '?'.
dd if=/tmp/rel.fip of=/tmp/part0 bs=65536 count=1 skip=0 dd if=/tmp/rel.fip of=/tmp/part1 bs=65536 count=1 skip=1 dd if=/tmp/rel.fip of=/tmp/part2 bs=65536 count=1 skip=2 coap-client -m put "coap://1.2.3.4/fw/image?offset=0" -f /tmp/part0 coap-client -m put "coap://1.2.3.4/fw/image?offset=65536" -f /tmp/part1 coap-client -m put "coap://1.2.3.4/fw/image?offset=131072" -f /tmp/part2
The following rules apply:
-
The offset must be a multiple of 4096, the flash erase block size. Every part except the last must therefore also be a multiple of 4096 bytes.
-
An offset of 0 starts a new upload. Every following offset must be exactly the end of the part sent before it, so that no part of the image is skipped or sent twice.
-
Only one upload can be in progress. An upload of '/fw/image' and an upload of '/fw/bootloader' cannot be interleaved.
-
Omitting the parameter transfers a complete image, as described in the previous sections.
A request that breaks one of these rules is answered with 4.02 (Bad Option) and
nothing is written to flash. Restart the upload from offset=0 to recover.
The image is activated by restarting the system once the last part has been transferred, as described below.