From 500703077b63c7e99569813aa4e9753f0cd2af42 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 9 Jan 2021 18:10:56 -0500 Subject: [PATCH] Migrate to newer ChibiOS #710 --- firmware/docs/chibios_rusefi_20.patch | 172 +++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 6 deletions(-) diff --git a/firmware/docs/chibios_rusefi_20.patch b/firmware/docs/chibios_rusefi_20.patch index 8f385ce94e..7fdb81d875 100644 --- a/firmware/docs/chibios_rusefi_20.patch +++ b/firmware/docs/chibios_rusefi_20.patch @@ -1,9 +1,9 @@ diff -uwr Chibios.20_original/.git/FETCH_HEAD Chibios.20_rusefi/.git/FETCH_HEAD ---- Chibios.20_original/.git/FETCH_HEAD 2021-01-09 18:01:26.493993900 -0500 -+++ Chibios.20_rusefi/.git/FETCH_HEAD 2021-01-09 18:01:26.904158400 -0500 +--- Chibios.20_original/.git/FETCH_HEAD 2021-01-09 18:09:26.371949000 -0500 ++++ Chibios.20_rusefi/.git/FETCH_HEAD 2021-01-09 18:09:27.021382000 -0500 @@ -1,4 +1,4 @@ -d96c2af163e53c456bdd885c52056d20545b6dde branch 'stable_20.3.x' of https://github.com/rusefi/ChibiOS -+d96c2af163e53c456bdd885c52056d20545b6dde branch 'stable_20.3.x.rusefi' of https://github.com/rusefi/ChibiOS ++df4bd5b74baae726ae7c47948dacd557a3430a2d branch 'stable_20.3.x.rusefi' of https://github.com/rusefi/ChibiOS bbb700257e3e932f60e12e8a2c7dc2120cea3e26 not-for-merge branch 'master' of https://github.com/rusefi/ChibiOS a4b2c113e74e026dfc7cc02060b32ab3f047ae8d not-for-merge branch 'revert-10-master' of https://github.com/rusefi/ChibiOS e61ff3aa1c1fd0f1057e08ae4551abbc01595550 not-for-merge branch 'stable_1.0.x' of https://github.com/rusefi/ChibiOS @@ -11,7 +11,7 @@ diff -uwr Chibios.20_original/.git/FETCH_HEAD Chibios.20_rusefi/.git/FETCH_HEAD c807840cdcec4e09b3fd0d2268370d9a317f0b90 not-for-merge branch 'stable_2.2.x' of https://github.com/rusefi/ChibiOS 062803674562e117754c051992535d69a3762573 not-for-merge branch 'stable_2.4.x' of https://github.com/rusefi/ChibiOS 0b0e793cc832373af431029878bc4b6f8c3e5fa5 not-for-merge branch 'stable_2.6.x' of https://github.com/rusefi/ChibiOS --d96c2af163e53c456bdd885c52056d20545b6dde not-for-merge branch 'stable_20.3.x.rusefi' of https://github.com/rusefi/ChibiOS +-df4bd5b74baae726ae7c47948dacd557a3430a2d not-for-merge branch 'stable_20.3.x.rusefi' of https://github.com/rusefi/ChibiOS +d96c2af163e53c456bdd885c52056d20545b6dde not-for-merge branch 'stable_20.3.x' of https://github.com/rusefi/ChibiOS 7596c99a218929e8c93341e2afa353134b64e233 not-for-merge branch 'stable_3.0.x' of https://github.com/rusefi/ChibiOS 93fdc45672692a73b3734b0e77f5978944477a2b not-for-merge branch 'stable_rusefi' of https://github.com/rusefi/ChibiOS @@ -37,10 +37,11 @@ diff -uwr Chibios.20_original/.git/config Chibios.20_rusefi/.git/config Binary files Chibios.20_original/.git/index and Chibios.20_rusefi/.git/index differ diff -uwr Chibios.20_original/.git/logs/HEAD Chibios.20_rusefi/.git/logs/HEAD --- Chibios.20_original/.git/logs/HEAD 2021-01-09 18:01:23.042248300 -0500 -+++ Chibios.20_rusefi/.git/logs/HEAD 2021-01-09 17:58:02.262313800 -0500 -@@ -1 +1 @@ ++++ Chibios.20_rusefi/.git/logs/HEAD 2021-01-09 18:09:27.085416800 -0500 +@@ -1 +1,2 @@ -0000000000000000000000000000000000000000 d96c2af163e53c456bdd885c52056d20545b6dde rusefillc 1610233283 -0500 clone: from https://github.com/rusefi/ChibiOS +0000000000000000000000000000000000000000 d96c2af163e53c456bdd885c52056d20545b6dde rusefillc 1610233082 -0500 clone: from https://github.com/rusefi/ChibiOS ++d96c2af163e53c456bdd885c52056d20545b6dde df4bd5b74baae726ae7c47948dacd557a3430a2d rusefillc 1610233767 -0500 pull: Fast-forward Only in Chibios.20_original/.git/logs/refs/heads: stable_20.3.x Only in Chibios.20_rusefi/.git/logs/refs/heads: stable_20.3.x.rusefi diff -uwr Chibios.20_original/.git/logs/refs/remotes/origin/HEAD Chibios.20_rusefi/.git/logs/refs/remotes/origin/HEAD @@ -50,6 +51,12 @@ diff -uwr Chibios.20_original/.git/logs/refs/remotes/origin/HEAD Chibios.20_ruse -0000000000000000000000000000000000000000 bbb700257e3e932f60e12e8a2c7dc2120cea3e26 rusefillc 1610233283 -0500 clone: from https://github.com/rusefi/ChibiOS +0000000000000000000000000000000000000000 bbb700257e3e932f60e12e8a2c7dc2120cea3e26 rusefillc 1610233082 -0500 clone: from https://github.com/rusefi/ChibiOS Only in Chibios.20_rusefi/.git/logs/refs/remotes/origin: stable_20.3.x +diff -uwr Chibios.20_original/.git/logs/refs/remotes/origin/stable_20.3.x.rusefi Chibios.20_rusefi/.git/logs/refs/remotes/origin/stable_20.3.x.rusefi +--- Chibios.20_original/.git/logs/refs/remotes/origin/stable_20.3.x.rusefi 2021-01-09 18:09:26.371949000 -0500 ++++ Chibios.20_rusefi/.git/logs/refs/remotes/origin/stable_20.3.x.rusefi 2021-01-09 18:09:27.020421400 -0500 +@@ -1 +1 @@ +-d96c2af163e53c456bdd885c52056d20545b6dde df4bd5b74baae726ae7c47948dacd557a3430a2d rusefillc 1610233766 -0500 pull: fast-forward ++d96c2af163e53c456bdd885c52056d20545b6dde df4bd5b74baae726ae7c47948dacd557a3430a2d rusefillc 1610233767 -0500 pull: fast-forward Only in Chibios.20_original/.git/objects/pack: pack-668cff25d611c7199e7543d5cdd7c5662f4aa17b.idx Only in Chibios.20_original/.git/objects/pack: pack-668cff25d611c7199e7543d5cdd7c5662f4aa17b.pack Only in Chibios.20_rusefi/.git/objects/pack: pack-bbcef4de2c0001c4f9864417bebcfd4e562d8838.idx @@ -68,3 +75,156 @@ diff -uwr Chibios.20_original/.git/packed-refs Chibios.20_rusefi/.git/packed-ref Only in Chibios.20_original/.git/refs/heads: stable_20.3.x Only in Chibios.20_rusefi/.git/refs/heads: stable_20.3.x.rusefi Only in Chibios.20_rusefi/.git/refs/remotes/origin: stable_20.3.x +diff -uwr Chibios.20_original/os/ex/devices/ST/lis302dl.c Chibios.20_rusefi/os/ex/devices/ST/lis302dl.c +--- Chibios.20_original/os/ex/devices/ST/lis302dl.c 2021-01-09 18:01:24.595494400 -0500 ++++ Chibios.20_rusefi/os/ex/devices/ST/lis302dl.c 2021-01-09 18:09:27.076407000 -0500 +@@ -332,7 +332,7 @@ + static msg_t acc_set_full_scale(LIS302DLDriver *devp, lis302dl_acc_fs_t fs) { + float newfs, scale; + uint8_t i, cr; +- msg_t msg; ++ msg_t msg = MSG_OK; + + osalDbgCheck(devp != NULL); + +diff -uwr Chibios.20_original/os/hal/include/hal_uart.h Chibios.20_rusefi/os/hal/include/hal_uart.h +--- Chibios.20_original/os/hal/include/hal_uart.h 2021-01-09 18:01:24.844428300 -0500 ++++ Chibios.20_rusefi/os/hal/include/hal_uart.h 2021-01-09 18:09:27.077428300 -0500 +@@ -299,6 +299,26 @@ + } + + /** ++ * @brief Common ISR code for RX half-transfer data. ++ * @details This code handles the portable part of the ISR code: ++ * - Callback invocation. ++ * - Waiting thread wakeup, if any. ++ * - Driver state transitions. ++ * . ++ * @note This macro is meant to be used in the low level drivers ++ * implementation only. ++ * ++ * @param[in] uartp pointer to the @p UARTDriver object ++ * @param[in] full flag set to 1 for the second half, and 0 for the first half ++ * ++ * @notapi ++ */ ++#define _uart_rx_half_isr_code(uartp, full) { \ ++ if ((uartp)->config->rxhalf_cb != NULL) \ ++ (uartp)->config->rxhalf_cb(uartp, full); \ ++} ++ ++/** + * @brief Common ISR code for RX error. + * @details This code handles the portable part of the ISR code: + * - Callback invocation. +diff -uwr Chibios.20_original/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.c Chibios.20_rusefi/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.c +--- Chibios.20_original/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.c 2021-01-09 18:01:25.031427200 -0500 ++++ Chibios.20_rusefi/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.c 2021-01-09 18:09:27.078405700 -0500 +@@ -262,6 +262,11 @@ + /* Mustn't ever set TCIE here - if done, it causes an immediate + interrupt.*/ + cr1 = USART_CR1_UE | USART_CR1_PEIE | USART_CR1_TE | USART_CR1_RE; ++ ++ /* Add Idle interrupt if needed */ ++ if (uartp->config->timeout_cb != NULL) ++ cr1 |= USART_CR1_IDLEIE; ++ + u->CR1 = uartp->config->cr1 | cr1; + + /* Starting the receiver idle loop.*/ +@@ -290,6 +295,15 @@ + received character and then the driver stays in the same state.*/ + _uart_rx_idle_code(uartp); + } ++ /* DMA half-transter interrupt handling - for the 1st/2nd half transfers. */ ++ else if (uartp->config->rxhalf_cb != NULL) { ++ if ((flags & STM32_DMA_ISR_HTIF) != 0) { ++ _uart_rx_half_isr_code(uartp, 0); ++ } ++ else if ((flags & STM32_DMA_ISR_TCIF) != 0) { ++ _uart_rx_half_isr_code(uartp, 1); ++ } ++ } + else { + /* Receiver in active state, a callback is generated, if enabled, after + a completed transfer.*/ +@@ -975,8 +989,14 @@ + /* RX DMA channel preparation.*/ + dmaStreamSetMemory0(uartp->dmarx, rxbuf); + dmaStreamSetTransactionSize(uartp->dmarx, n); +- dmaStreamSetMode(uartp->dmarx, uartp->dmarxmode | STM32_DMA_CR_DIR_P2M | +- STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE); ++ ++ uint32_t mode = STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE; ++ ++ /* DMA half-transfer interrupt & circular mode, if needed */ ++ if (uartp->config->rxhalf_cb != NULL) ++ mode |= STM32_DMA_CR_HTIE | STM32_DMA_CR_CIRC; ++ ++ dmaStreamSetMode(uartp->dmarx, uartp->dmarxmode | mode); + + /* Starting transfer.*/ + dmaStreamEnable(uartp->dmarx); +diff -uwr Chibios.20_original/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h Chibios.20_rusefi/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h +--- Chibios.20_original/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h 2021-01-09 18:01:25.032427700 -0500 ++++ Chibios.20_rusefi/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h 2021-01-09 18:09:27.078405700 -0500 +@@ -578,6 +578,14 @@ + typedef void (*uartecb_t)(UARTDriver *uartp, uartflags_t e); + + /** ++ * @brief Receive Half-transfer UART notification callback type. ++ * ++ * @param[in] uartp pointer to the @p UARTDriver object ++ * @param[in] full flag set to 1 for the second half, and 0 for the first half ++ */ ++typedef void (*uarthcb_t)(UARTDriver *uartp, uartflags_t full); ++ ++/** + * @brief Driver configuration structure. + * @note It could be empty on some architectures. + */ +@@ -625,6 +633,11 @@ + * @brief Initialization value for the CR3 register. + */ + uint16_t cr3; ++ /* Additional (optional) handlers. Placed here for the struct compatibility.*/ ++ /** ++ * @brief Half-transfer receive buffer callback. ++ */ ++ uarthcb_t rxhalf_cb; + } UARTConfig; + + /** +diff -uwr Chibios.20_original/os/various/syscalls.c Chibios.20_rusefi/os/various/syscalls.c +--- Chibios.20_original/os/various/syscalls.c 2021-01-09 18:01:25.272773700 -0500 ++++ Chibios.20_rusefi/os/various/syscalls.c 2021-01-09 18:09:27.079382600 -0500 +@@ -169,29 +169,4 @@ + return 1; + } + +-/***************************************************************************/ +- +-__attribute__((used)) +-void _exit(int status) { +- (void) status; +- chSysHalt("exit"); +- abort(); +-} +- +-/***************************************************************************/ +- +-__attribute__((used)) +-int _kill(int pid, int sig) { +- (void) pid; +- (void) sig; +- return -1; +-} +- +-/***************************************************************************/ +- +-__attribute__((used)) +-int _getpid(void) { +- +- return 1; +-} + /*** EOF ***/