From 07468e6cb1449b4b8aff6910b79d54693f4bafe2 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Fri, 5 Aug 2022 01:29:10 +0200 Subject: [PATCH 1/5] Update SIO driver for ChibiOS driver rework --- platforms/chibios/drivers/serial_usart.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/platforms/chibios/drivers/serial_usart.c b/platforms/chibios/drivers/serial_usart.c index 6581a5b6e9b1..16732051ba99 100644 --- a/platforms/chibios/drivers/serial_usart.c +++ b/platforms/chibios/drivers/serial_usart.c @@ -72,27 +72,18 @@ inline void serial_transport_driver_clear(void) { #elif HAL_USE_SIO -void clear_rx_evt_cb(SIODriver* siop) { - osalSysLockFromISR(); - /* If errors occured during transactions this callback is invoked. We just - * clear the error sources and move on. We rely on the fact that we check - * for the success of the transaction by comparing the received/send bytes - * with the actual received/send bytes in the send/receive functions. */ - sioGetAndClearEventsI(serial_driver); - osalSysUnlockFromISR(); -} - -static const SIOOperation serial_usart_operation = {.rx_cb = NULL, .rx_idle_cb = NULL, .tx_cb = NULL, .tx_end_cb = NULL, .rx_evt_cb = &clear_rx_evt_cb}; - /** * @brief SIO Driver startup routine. */ static inline void usart_driver_start(void) { sioStart(serial_driver, &serial_config); - sioStartOperation(serial_driver, &serial_usart_operation); + sioStartOperation(serial_driver, NULL); } inline void serial_transport_driver_clear(void) { + if (sioHasRXErrorsX(serial_driver)) { + sioGetAndClearErrors(serial_driver); + } osalSysLock(); while (!sioIsRXEmptyX(serial_driver)) { (void)sioGetX(serial_driver); From 7f519378c0597c6b5689a3dfc55109e21a3be5db Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 10 Jan 2023 07:27:34 +1100 Subject: [PATCH 2/5] Update ChibiOS to 21.11.3, updated ChibiOS-Contrib to latest. --- lib/chibios | 2 +- lib/chibios-contrib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chibios b/lib/chibios index 0e9d558b525a..0062927e3058 160000 --- a/lib/chibios +++ b/lib/chibios @@ -1 +1 @@ -Subproject commit 0e9d558b525a8f28285f3bb509fd48a897c43151 +Subproject commit 0062927e3058a8b5ef587234bbd98d42fb4e595e diff --git a/lib/chibios-contrib b/lib/chibios-contrib index 1130173eae6b..b3fc9f7cc5ec 160000 --- a/lib/chibios-contrib +++ b/lib/chibios-contrib @@ -1 +1 @@ -Subproject commit 1130173eae6b7402443aff18ad68228acbe25cc4 +Subproject commit b3fc9f7cc5ec27eefcb67a5ca40b9b08e143ef93 From 40a9260aaa83ff791f724465ee0d0a29efc678c1 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 10 Jan 2023 08:29:09 +1100 Subject: [PATCH 3/5] Updated configs, updater. --- .../boards/BONSAI_C4/configs/mcuconf.h | 5 ++++- .../boards/PJRC_TEENSY_3_6/board/board.mk | 4 ++++ .../boards/QMK_PROTON_C/configs/halconf.h | 21 +++++++++++-------- .../chibios/boards/common/configs/halconf.h | 21 +++++++++++-------- util/chibios_conf_updater.sh | 6 ++---- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h b/platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h index 2f9e627c7e54..b381aed4fd1a 100644 --- a/platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h +++ b/platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h @@ -1,9 +1,12 @@ /* ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -246,4 +249,4 @@ */ #define STM32_WDG_USE_IWDG FALSE -#endif /* MCUCONF_H */ \ No newline at end of file +#endif /* MCUCONF_H */ diff --git a/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk b/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk index aba195db042a..9d493b138927 100644 --- a/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk +++ b/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk @@ -9,3 +9,7 @@ BOARDINC += $(BOARD_PATH)/board # Shared variables ALLCSRC += $(BOARDSRC) ALLINC += $(BOARDINC) + +# Fix for newer gcc's (12+?) with ChibiOS-Contrib having clock init warnings-turned-errors +CFLAGS += -Wno-error=misleading-indentation +CXXFLAGS += -Wno-error=misleading-indentation diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h b/platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h index 8367328a04c4..4a22e818e25f 100644 --- a/platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h +++ b/platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h @@ -29,7 +29,7 @@ #define HALCONF_H #define _CHIBIOS_HAL_CONF_ -#define _CHIBIOS_HAL_CONF_VER_8_0_ +#define _CHIBIOS_HAL_CONF_VER_8_4_ #include @@ -335,15 +335,18 @@ /*===========================================================================*/ /** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. + * @brief Timeout before assuming a failure while waiting for card idle. + * @note Time is in milliseconds. + */ +#if !defined(MMC_IDLE_TIMEOUT_MS) || defined(__DOXYGEN__) +#define MMC_IDLE_TIMEOUT_MS 1000 +#endif + +/** + * @brief Mutual exclusion on the SPI bus. */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE +#if !defined(MMC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define MMC_USE_MUTUAL_EXCLUSION TRUE #endif /*===========================================================================*/ diff --git a/platforms/chibios/boards/common/configs/halconf.h b/platforms/chibios/boards/common/configs/halconf.h index 1805a7743898..b0ccbc1f2f89 100644 --- a/platforms/chibios/boards/common/configs/halconf.h +++ b/platforms/chibios/boards/common/configs/halconf.h @@ -29,7 +29,7 @@ #define HALCONF_H #define _CHIBIOS_HAL_CONF_ -#define _CHIBIOS_HAL_CONF_VER_8_0_ +#define _CHIBIOS_HAL_CONF_VER_8_4_ #include @@ -335,15 +335,18 @@ /*===========================================================================*/ /** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. + * @brief Timeout before assuming a failure while waiting for card idle. + * @note Time is in milliseconds. + */ +#if !defined(MMC_IDLE_TIMEOUT_MS) || defined(__DOXYGEN__) +#define MMC_IDLE_TIMEOUT_MS 1000 +#endif + +/** + * @brief Mutual exclusion on the SPI bus. */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE +#if !defined(MMC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define MMC_USE_MUTUAL_EXCLUSION TRUE #endif /*===========================================================================*/ diff --git a/util/chibios_conf_updater.sh b/util/chibios_conf_updater.sh index 3c400ab63c28..4c68c678c637 100755 --- a/util/chibios_conf_updater.sh +++ b/util/chibios_conf_updater.sh @@ -13,10 +13,8 @@ umask 022 # sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ # sudo apt-get update && sudo apt-get install adoptopenjdk-8-hotspot # -# For Fedora 36-ish distros: -# # Prep yum repository from https://adoptium.net/installation/linux/ -# sudo dnf install -y ant temurin-8-jdk -# export JAVA_HOME=/usr/lib/jvm/temurin-8-jdk +# For Fedora 37-ish distros: +# sudo dnf install -y ant java-1.8.0-openjdk.x86_64 sinfo() { echo "$@" >&2 ; } shead() { sinfo "" ; sinfo "---------------------------------" ; sinfo "-- $@" ; sinfo "---------------------------------" ; } From dc581cea0924a052a5fc8045f44fff5ac177621b Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Tue, 10 Jan 2023 21:33:08 +0100 Subject: [PATCH 4/5] Update serial_usart driver with latest SIO changes --- platforms/chibios/drivers/serial_usart.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platforms/chibios/drivers/serial_usart.c b/platforms/chibios/drivers/serial_usart.c index 16732051ba99..6ebbf7c8ca1f 100644 --- a/platforms/chibios/drivers/serial_usart.c +++ b/platforms/chibios/drivers/serial_usart.c @@ -77,7 +77,6 @@ inline void serial_transport_driver_clear(void) { */ static inline void usart_driver_start(void) { sioStart(serial_driver, &serial_config); - sioStartOperation(serial_driver, NULL); } inline void serial_transport_driver_clear(void) { @@ -123,10 +122,10 @@ inline bool serial_transport_send(const uint8_t* source, const size_t size) { return serial_transport_receive(dump, bytes_left); # else /* The SIO driver directly accesses the hardware FIFOs of the USART - * peripheral. As these are limited in depth, the RX FIFO might have been - * overflowed by a large that we just send. Therefore we attempt to read - * back all the data we send or until the FIFO runs empty in case it - * overflowed and data was truncated. */ + * peripheral. As these are limited in depth, the RX FIFO might have + * been overflowed by a large transaction that we just send. Therefore + * we attempt to read back all the data we send or until the FIFO runs + * empty in case it overflowed and data was truncated. */ if (unlikely(sioSynchronizeTXEnd(serial_driver, TIME_MS2I(SERIAL_USART_TIMEOUT)) < MSG_OK)) { return false; } From 96dd4330d5e49eb0974ef0cbf353f13076b4fc65 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 12 Jan 2023 21:35:44 +1100 Subject: [PATCH 5/5] Updated ChibiOS-Contrib, rollback Kinesis "fix". --- lib/chibios-contrib | 2 +- platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/chibios-contrib b/lib/chibios-contrib index b3fc9f7cc5ec..a224be155ae1 160000 --- a/lib/chibios-contrib +++ b/lib/chibios-contrib @@ -1 +1 @@ -Subproject commit b3fc9f7cc5ec27eefcb67a5ca40b9b08e143ef93 +Subproject commit a224be155ae18d38deccf33a6c1d259b9a5ad8d3 diff --git a/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk b/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk index 9d493b138927..aba195db042a 100644 --- a/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk +++ b/platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk @@ -9,7 +9,3 @@ BOARDINC += $(BOARD_PATH)/board # Shared variables ALLCSRC += $(BOARDSRC) ALLINC += $(BOARDINC) - -# Fix for newer gcc's (12+?) with ChibiOS-Contrib having clock init warnings-turned-errors -CFLAGS += -Wno-error=misleading-indentation -CXXFLAGS += -Wno-error=misleading-indentation