From cffe98d9dec08176a58adbdb174e341f86998992 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 26 Sep 2022 12:13:43 -0400 Subject: [PATCH] crc: Make the build of crc function dependent on a Kconfig Add CONFIG_CRC for building CRC related routines. CRC routines are now being built for each application, whether used or not and are add in the build system unconditionally. Keep CONFIG_CRC enabled by default for now and until all users have converted to use the new option. Partial fix for #50654 Signed-off-by: Anas Nashif --- drivers/adc/Kconfig.lmp90xxx | 1 + drivers/console/Kconfig.gsm_mux | 1 + drivers/ieee802154/Kconfig.cc13xx_cc26xx | 1 + drivers/net/Kconfig | 1 + drivers/sdhc/Kconfig.spi | 1 + drivers/sensor/sgp40/Kconfig | 1 + drivers/sensor/sht3xd/Kconfig | 1 + drivers/sensor/sht4x/Kconfig | 1 + drivers/sensor/shtcx/Kconfig | 1 + drivers/sensor/si7055/Kconfig | 1 + drivers/w1/Kconfig | 1 + lib/os/CMakeLists.txt | 12 +++++++----- lib/os/Kconfig | 6 ++++++ modules/canopennode/Kconfig | 1 + samples/arch/smp/pktqueue/prj.conf | 1 + samples/boards/nrf/system_off/prj.conf | 1 + subsys/fs/fcb/Kconfig | 1 + subsys/fs/nvs/Kconfig | 1 + subsys/mgmt/mcumgr/Kconfig | 1 + subsys/mgmt/osdp/Kconfig | 1 + subsys/modbus/Kconfig | 1 + subsys/net/lib/dns/Kconfig | 1 + tests/net/lib/dns_packet/prj.conf | 1 + tests/net/ppp/driver/prj.conf | 1 + tests/subsys/cpp/cxx/prj.conf | 1 + tests/unit/crc/prj.conf | 1 + 26 files changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/adc/Kconfig.lmp90xxx b/drivers/adc/Kconfig.lmp90xxx index 714c47da4f..20c4048391 100644 --- a/drivers/adc/Kconfig.lmp90xxx +++ b/drivers/adc/Kconfig.lmp90xxx @@ -12,6 +12,7 @@ config ADC_LMP90XXX DT_HAS_TI_LMP90099_ENABLED || DT_HAS_TI_LMP90100_ENABLED select SPI select ADC_CONFIGURABLE_INPUTS + select CRC help Enable LMP90xxx ADC driver. diff --git a/drivers/console/Kconfig.gsm_mux b/drivers/console/Kconfig.gsm_mux index 44852bea55..14ef6b66da 100644 --- a/drivers/console/Kconfig.gsm_mux +++ b/drivers/console/Kconfig.gsm_mux @@ -3,6 +3,7 @@ config GSM_MUX bool "GSM 07.10 muxing protocol" + select CRC help Enable GSM 07.10 muxing protocol defined in https://www.etsi.org/deliver/etsi_ts/101300_101399/101369/07.01.00_60/ts_101369v070100p.pdf diff --git a/drivers/ieee802154/Kconfig.cc13xx_cc26xx b/drivers/ieee802154/Kconfig.cc13xx_cc26xx index 99c2fa3707..a901528381 100644 --- a/drivers/ieee802154/Kconfig.cc13xx_cc26xx +++ b/drivers/ieee802154/Kconfig.cc13xx_cc26xx @@ -5,6 +5,7 @@ menuconfig IEEE802154_CC13XX_CC26XX bool "TI CC13xx / CC26xx IEEE 802.15.4 driver support" + select CRC default y depends on DT_HAS_TI_CC13XX_CC26XX_IEEE802154_ENABLED diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 24b31d81f0..dc4ac6ccbb 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -14,6 +14,7 @@ menuconfig NET_PPP depends on NET_L2_PPP depends on NET_NATIVE select RING_BUFFER + select CRC select UART_MUX if GSM_MUX if NET_PPP diff --git a/drivers/sdhc/Kconfig.spi b/drivers/sdhc/Kconfig.spi index 9136253372..555f11619b 100644 --- a/drivers/sdhc/Kconfig.spi +++ b/drivers/sdhc/Kconfig.spi @@ -6,6 +6,7 @@ config SPI_SDHC default y depends on DT_HAS_ZEPHYR_SDHC_SPI_SLOT_ENABLED select SPI + select CRC select SDHC_SUPPORTS_SPI_MODE help Enable the SPI SD host controller driver diff --git a/drivers/sensor/sgp40/Kconfig b/drivers/sensor/sgp40/Kconfig index 2ec5021243..a394c4c559 100644 --- a/drivers/sensor/sgp40/Kconfig +++ b/drivers/sensor/sgp40/Kconfig @@ -8,5 +8,6 @@ config SGP40 default y depends on DT_HAS_SENSIRION_SGP40_ENABLED select I2C + select CRC help Enable driver for SGP40 Multipixel Gas Sensor. diff --git a/drivers/sensor/sht3xd/Kconfig b/drivers/sensor/sht3xd/Kconfig index 7bb04f2f9f..b19af19557 100644 --- a/drivers/sensor/sht3xd/Kconfig +++ b/drivers/sensor/sht3xd/Kconfig @@ -8,6 +8,7 @@ menuconfig SHT3XD default y depends on DT_HAS_SENSIRION_SHT3XD_ENABLED select I2C + select CRC help Enable driver for SHT3xD temperature and humidity sensors. diff --git a/drivers/sensor/sht4x/Kconfig b/drivers/sensor/sht4x/Kconfig index f906a7bab7..927883c42a 100644 --- a/drivers/sensor/sht4x/Kconfig +++ b/drivers/sensor/sht4x/Kconfig @@ -8,5 +8,6 @@ config SHT4X default y depends on DT_HAS_SENSIRION_SHT4X_ENABLED select I2C + select CRC help Enable driver for SHT4x temperature and humidity sensors. diff --git a/drivers/sensor/shtcx/Kconfig b/drivers/sensor/shtcx/Kconfig index 826f740fc6..3fa55336e4 100644 --- a/drivers/sensor/shtcx/Kconfig +++ b/drivers/sensor/shtcx/Kconfig @@ -8,5 +8,6 @@ config SHTCX default y depends on DT_HAS_SENSIRION_SHTCX_ENABLED select I2C + select CRC help Enable driver for SHTC1 and SHTC3 temperature and humidity sensors. diff --git a/drivers/sensor/si7055/Kconfig b/drivers/sensor/si7055/Kconfig index caec6e4505..d6ab5c6983 100644 --- a/drivers/sensor/si7055/Kconfig +++ b/drivers/sensor/si7055/Kconfig @@ -7,6 +7,7 @@ menuconfig SI7055 default y depends on DT_HAS_SILABS_SI7055_ENABLED select I2C + select CRC help Enable I2C-based driver for Si7055 Temperature Sensor. diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig index 088450d31e..f14f024dd4 100644 --- a/drivers/w1/Kconfig +++ b/drivers/w1/Kconfig @@ -6,6 +6,7 @@ menuconfig W1 bool prompt "1-Wire Drivers" + select CRC help Enable 1-Wire Drivers diff --git a/lib/os/CMakeLists.txt b/lib/os/CMakeLists.txt index f34c83e649..51f7040b89 100644 --- a/lib/os/CMakeLists.txt +++ b/lib/os/CMakeLists.txt @@ -4,11 +4,6 @@ zephyr_sources_ifdef(CONFIG_BASE64 base64.c) zephyr_sources( cbprintf_packaged.c - crc32c_sw.c - crc32_sw.c - crc16_sw.c - crc8_sw.c - crc7_sw.c dec.c fdtable.c hex.c @@ -25,6 +20,13 @@ zephyr_sources( zephyr_sources_ifdef(CONFIG_ONOFF onoff.c) zephyr_sources_ifdef(CONFIG_NOTIFY notify.c) +zephyr_sources_ifdef(CONFIG_CRC + crc32c_sw.c + crc32_sw.c + crc16_sw.c + crc8_sw.c + crc7_sw.c + ) zephyr_sources_ifdef(CONFIG_CBPRINTF_COMPLETE cbprintf_complete.c) zephyr_sources_ifdef(CONFIG_CBPRINTF_NANO cbprintf_nano.c) diff --git a/lib/os/Kconfig b/lib/os/Kconfig index 57d0a680ff..5779b5ae67 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -26,6 +26,12 @@ config BASE64 help Enable base64 encoding and decoding functionality +config CRC + bool "Cyclic redundancy check (CRC) Support" + default y + help + Enable use of CRC. + config PRINTK_SYNC bool "Serialize printk() calls" default y if SMP && MP_NUM_CPUS > 1 && !(EFI_CONSOLE && LOG) diff --git a/modules/canopennode/Kconfig b/modules/canopennode/Kconfig index 415f352cc2..9be571229b 100644 --- a/modules/canopennode/Kconfig +++ b/modules/canopennode/Kconfig @@ -8,6 +8,7 @@ config ZEPHYR_CANOPENNODE_MODULE config CANOPENNODE bool "CANopenNode support" + select CRC depends on CAN && !CAN_FD_MODE help This option enables the CANopenNode library. diff --git a/samples/arch/smp/pktqueue/prj.conf b/samples/arch/smp/pktqueue/prj.conf index cbe6b045a7..40a56c94ac 100644 --- a/samples/arch/smp/pktqueue/prj.conf +++ b/samples/arch/smp/pktqueue/prj.conf @@ -5,3 +5,4 @@ CONFIG_TEST_RANDOM_GENERATOR=y # Enable SMP CONFIG_SMP=y +CONFIG_CRC=y diff --git a/samples/boards/nrf/system_off/prj.conf b/samples/boards/nrf/system_off/prj.conf index 8eb237b76e..f32cffde85 100644 --- a/samples/boards/nrf/system_off/prj.conf +++ b/samples/boards/nrf/system_off/prj.conf @@ -4,3 +4,4 @@ CONFIG_PM_DEVICE=y CONFIG_GPIO=y # Optional select RAM retention (nRF52 only) #CONFIG_APP_RETENTION=y +CONFIG_CRC=y diff --git a/subsys/fs/fcb/Kconfig b/subsys/fs/fcb/Kconfig index b50fd7c63b..c6605bce91 100644 --- a/subsys/fs/fcb/Kconfig +++ b/subsys/fs/fcb/Kconfig @@ -10,5 +10,6 @@ config FCB bool "Flash Circular Buffer support" depends on FLASH_MAP + select CRC help Enable support of Flash Circular Buffer. diff --git a/subsys/fs/nvs/Kconfig b/subsys/fs/nvs/Kconfig index 4bfe39824d..de4f282ee9 100644 --- a/subsys/fs/nvs/Kconfig +++ b/subsys/fs/nvs/Kconfig @@ -5,6 +5,7 @@ config NVS bool "Non-volatile Storage" + select CRC help Enable support of Non-volatile Storage. diff --git a/subsys/mgmt/mcumgr/Kconfig b/subsys/mgmt/mcumgr/Kconfig index c5074937a9..7d8737beec 100644 --- a/subsys/mgmt/mcumgr/Kconfig +++ b/subsys/mgmt/mcumgr/Kconfig @@ -6,6 +6,7 @@ menuconfig MCUMGR bool "mcumgr Support" select NET_BUF select ZCBOR + select CRC help This option enables the mcumgr management library. diff --git a/subsys/mgmt/osdp/Kconfig b/subsys/mgmt/osdp/Kconfig index f100dab214..2fce0f33bc 100644 --- a/subsys/mgmt/osdp/Kconfig +++ b/subsys/mgmt/osdp/Kconfig @@ -9,6 +9,7 @@ menuconfig OSDP select RING_BUFFER imply SERIAL_SUPPORT_INTERRUPT imply UART_INTERRUPT_DRIVEN + select CRC help Add support for Open Supervised Device Protocol (OSDP) diff --git a/subsys/modbus/Kconfig b/subsys/modbus/Kconfig index 6182ef1088..614afdd834 100644 --- a/subsys/modbus/Kconfig +++ b/subsys/modbus/Kconfig @@ -3,6 +3,7 @@ menuconfig MODBUS bool "Modbus support" + select CRC if MODBUS diff --git a/subsys/net/lib/dns/Kconfig b/subsys/net/lib/dns/Kconfig index a008a273c8..7ef2d16c35 100644 --- a/subsys/net/lib/dns/Kconfig +++ b/subsys/net/lib/dns/Kconfig @@ -4,6 +4,7 @@ config DNS_RESOLVER bool "DNS resolver" depends on NET_NATIVE + select CRC help This option enables the DNS client side support for Zephyr diff --git a/tests/net/lib/dns_packet/prj.conf b/tests/net/lib/dns_packet/prj.conf index 80ca03dfa6..c757cbeca6 100644 --- a/tests/net/lib/dns_packet/prj.conf +++ b/tests/net/lib/dns_packet/prj.conf @@ -14,3 +14,4 @@ CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y CONFIG_MAIN_STACK_SIZE=1280 +CONFIG_CRC=y diff --git a/tests/net/ppp/driver/prj.conf b/tests/net/ppp/driver/prj.conf index efe2762abf..d1421d0248 100644 --- a/tests/net/ppp/driver/prj.conf +++ b/tests/net/ppp/driver/prj.conf @@ -26,3 +26,4 @@ CONFIG_NET_CONFIG_AUTO_INIT=n CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y #CONFIG_NET_PPP_LOG_LEVEL_DBG=y +CONFIG_CRC=y diff --git a/tests/subsys/cpp/cxx/prj.conf b/tests/subsys/cpp/cxx/prj.conf index 8736a75af8..8a7c012691 100644 --- a/tests/subsys/cpp/cxx/prj.conf +++ b/tests/subsys/cpp/cxx/prj.conf @@ -4,3 +4,4 @@ CONFIG_ZTEST=y CONFIG_ZTEST_STACK_SIZE=2048 CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=128 CONFIG_ZTEST_NEW_API=y +CONFIG_CRC=y diff --git a/tests/unit/crc/prj.conf b/tests/unit/crc/prj.conf index 963087265c..fd4e42e2de 100644 --- a/tests/unit/crc/prj.conf +++ b/tests/unit/crc/prj.conf @@ -1 +1,2 @@ CONFIG_ZTEST_NEW_API=y +CONFIG_CRC=y