This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e1f84f447142a7bdbbe96f067f4084f8db42cc7a Author: mazhuang <[email protected]> AuthorDate: Tue Apr 7 10:12:53 2026 +0800 drivers/rpmsg: check the port frames with xorsum16() Replace the CRC-16/IBM table lookup with xorsum16() in rpmsg_port_spi, rpmsg_port_spi_slave and rpmsg_port_uart. The frame check runs on every frame in both directions, and xorsum16() reads the frame as 64-bit words instead of one table lookup per byte. The value is the same at any buffer alignment, so the two ends agree wherever they hold the frame. Signed-off-by: mazhuang <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/rpmsg/rpmsg_port_spi.c | 6 +++--- drivers/rpmsg/rpmsg_port_spi_slave.c | 4 ++-- drivers/rpmsg/rpmsg_port_uart.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/rpmsg_port_spi.c b/drivers/rpmsg/rpmsg_port_spi.c index e53e0967374..62839deee15 100644 --- a/drivers/rpmsg/rpmsg_port_spi.c +++ b/drivers/rpmsg/rpmsg_port_spi.c @@ -28,8 +28,8 @@ #include <errno.h> #include <stdio.h> +#include <nuttx/lib/xorsum.h> #include <nuttx/nuttx.h> -#include <nuttx/crc16.h> #include <nuttx/kmalloc.h> #include <nuttx/kthread.h> #include <nuttx/power/pm.h> @@ -45,8 +45,8 @@ ****************************************************************************/ #ifdef CONFIG_RPMSG_PORT_SPI_CRC -# define rpmsg_port_spi_crc16(hdr) crc16ibm((FAR uint8_t *)&(hdr)->cmd, \ - (hdr)->len - sizeof((hdr)->crc)) +# define rpmsg_port_spi_crc16(hdr) xorsum16(&(hdr)->cmd, \ + (hdr)->len - sizeof((hdr)->crc)) #else # define rpmsg_port_spi_crc16(hdr) 0 #endif diff --git a/drivers/rpmsg/rpmsg_port_spi_slave.c b/drivers/rpmsg/rpmsg_port_spi_slave.c index ef3ca9e8774..247c88d986f 100644 --- a/drivers/rpmsg/rpmsg_port_spi_slave.c +++ b/drivers/rpmsg/rpmsg_port_spi_slave.c @@ -29,9 +29,9 @@ #include <stdio.h> #include <nuttx/atomic.h> -#include <nuttx/crc16.h> #include <nuttx/kmalloc.h> #include <nuttx/kthread.h> +#include <nuttx/lib/xorsum.h> #include <nuttx/nuttx.h> #include <nuttx/power/pm.h> #include <nuttx/irq.h> @@ -46,7 +46,7 @@ ****************************************************************************/ #ifdef CONFIG_RPMSG_PORT_SPI_CRC -# define rpmsg_port_spi_crc16(hdr) crc16ibm((FAR uint8_t *)&(hdr)->cmd, \ +# define rpmsg_port_spi_crc16(hdr) xorsum16(&(hdr)->cmd, \ (hdr)->len - sizeof((hdr)->crc)) #else # define rpmsg_port_spi_crc16(hdr) 0 diff --git a/drivers/rpmsg/rpmsg_port_uart.c b/drivers/rpmsg/rpmsg_port_uart.c index 92ef98d2ac1..8c425d35532 100644 --- a/drivers/rpmsg/rpmsg_port_uart.c +++ b/drivers/rpmsg/rpmsg_port_uart.c @@ -32,11 +32,11 @@ #include <stdint.h> #include <stdio.h> -#include <nuttx/crc16.h> #include <nuttx/event.h> #include <nuttx/fs/fs.h> #include <nuttx/kmalloc.h> #include <nuttx/kthread.h> +#include <nuttx/lib/xorsum.h> #include <nuttx/mutex.h> #include <nuttx/nuttx.h> #include <nuttx/power/pm.h> @@ -84,8 +84,8 @@ #define RPMSG_PORT_UART_EVT_TX (1 << 3) /* TX is ready or not */ #ifdef CONFIG_RPMSG_PORT_UART_CRC -# define rpmsg_port_uart_crc16(hdr) crc16ibm((FAR uint8_t *)&(hdr)->cmd, \ - (hdr)->len - sizeof((hdr)->crc)) +# define rpmsg_port_uart_crc16(hdr) xorsum16(&(hdr)->cmd, \ + (hdr)->len - sizeof((hdr)->crc)) #else # define rpmsg_port_uart_crc16(hdr) 0 #endif
