Commit b9192a4c authored by Carles Cufi's avatar Carles Cufi Committed by Fabio Utzig
Browse files

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: default avatarCarles Cufi <carles.cufi@nordicsemi.no>
parent e3822f81
......@@ -589,9 +589,8 @@ boot_serial_output(void)
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 @@ boot_serial_in_dec(char *in, int inlen, char *out, int *out_off, int maxout)
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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment