boot: serial: Adapt to Zephyr's new CRC APIs
As part of https://github.com/zephyrproject-rtos/zephyr/pull/42457,
Zephyr recently changed its CRC APIs. The commit below
adapted the use of mcumgr in-tree, but MCUboot was missing the change:
https://github.com/zephyrproject-rtos/zephyr/commit/07c78e515c827c8346a758a5ce04cd56a46ae124
Note that although on other platforms the function called is
crc_ccitt(), the CRC16 actually used by MCUboot/mcumgr is:
https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-xmodem
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
diff --git a/boot/boot_serial/src/boot_serial.c b/boot/boot_serial/src/boot_serial.c
index 680cdf0..4b30d17 100644
--- a/boot/boot_serial/src/boot_serial.c
+++ b/boot/boot_serial/src/boot_serial.c
@@ -589,9 +589,8 @@
bs_hdr->nh_group = htons(bs_hdr->nh_group);
#ifdef __ZEPHYR__
- crc = crc16((uint8_t *)bs_hdr, sizeof(*bs_hdr), CRC_CITT_POLYMINAL,
- CRC16_INITIAL_CRC, false);
- crc = crc16(data, len, CRC_CITT_POLYMINAL, crc, true);
+ crc = crc16_itu_t(CRC16_INITIAL_CRC, (uint8_t *)bs_hdr, sizeof(*bs_hdr));
+ crc = crc16_itu_t(crc, data, len);
#else
crc = crc16_ccitt(CRC16_INITIAL_CRC, bs_hdr, sizeof(*bs_hdr));
crc = crc16_ccitt(crc, data, len);
@@ -665,7 +664,7 @@
out += sizeof(uint16_t);
#ifdef __ZEPHYR__
- crc = crc16(out, len, CRC_CITT_POLYMINAL, CRC16_INITIAL_CRC, true);
+ crc = crc16_itu_t(CRC16_INITIAL_CRC, out, len);
#else
crc = crc16_ccitt(CRC16_INITIAL_CRC, out, len);
#endif