Skip to content

Commit

Permalink
patches: add stm32h7_m4 patchset
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Oct 26, 2023
1 parent 9f04816 commit 373e7c6
Show file tree
Hide file tree
Showing 5 changed files with 34,865 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 547edd2014933a15cd0e48fe1f2f5f9b9ce094fd Mon Sep 17 00:00:00 2001
From: Martino Facchin <[email protected]>
Date: Thu, 26 Oct 2023 16:37:54 +0200
Subject: [PATCH 209/213] portenta_h7: make sure configuration is only executed
by M7

---
.../TARGET_STM32H747xI/TARGET_PORTENTA_H7/portenta_power.cpp | 3 ++-
.../TARGET_PORTENTA_H7/system_clock_override.c | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/portenta_power.cpp b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/portenta_power.cpp
index 13ba1042de..59e6ac6cca 100644
--- a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/portenta_power.cpp
+++ b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/portenta_power.cpp
@@ -26,6 +26,7 @@
******************************************************************************/
void enableEthPowerSupply(void)
{
+#ifndef CORE_CM4
/* Ensure ETH power supply */
mbed::I2C i2c(PB_7, PB_6);

@@ -48,5 +49,5 @@ void enableEthPowerSupply(void)
data[0] = 0x35;
data[1] = 0xF;
i2c.write(8 << 1, data, sizeof(data));
-
+#endif
}
diff --git a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/system_clock_override.c b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/system_clock_override.c
index ae7821ede0..e47b7d258c 100644
--- a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/system_clock_override.c
+++ b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/system_clock_override.c
@@ -129,6 +129,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
}
}

+#ifndef CORE_CM4
/* Enable oscillator pin */
__HAL_RCC_GPIOH_CLK_ENABLE();
GPIO_InitTypeDef gpio_osc_init_structure;
@@ -139,6 +140,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed)
HAL_GPIO_Init(GPIOH, &gpio_osc_init_structure);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOH, GPIO_PIN_1, 1);
+#endif

/* Supply configuration update enable */
#if HSE_VALUE == 27000000
--
2.42.0

44 changes: 44 additions & 0 deletions patches/0210-giga-remove-stray-function.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From cb4587fa30a8f49bf27a16dda20fb21947d385ed Mon Sep 17 00:00:00 2001
From: Martino Facchin <[email protected]>
Date: Thu, 26 Oct 2023 16:38:15 +0200
Subject: [PATCH 210/213] giga: remove stray function

---
.../TARGET_GIGA/giga_power.cpp | 23 -------------------
1 file changed, 23 deletions(-)

diff --git a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_GIGA/giga_power.cpp b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_GIGA/giga_power.cpp
index a47a758e1d..1954ff50cc 100644
--- a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_GIGA/giga_power.cpp
+++ b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_GIGA/giga_power.cpp
@@ -26,27 +26,4 @@
******************************************************************************/
void enableEthPowerSupply(void)
{
- /* Ensure ETH power supply */
- mbed::I2C i2c(PB_7, PB_6);
-
- char data[2];
-
- // LDO3 to 1.2V
- data[0] = 0x52;
- data[1] = 0x9;
- i2c.write(8 << 1, data, sizeof(data));
- data[0] = 0x53;
- data[1] = 0xF;
- i2c.write(8 << 1, data, sizeof(data));
-
- // SW2 to 3.3V (SW2_VOLT)
- data[0] = 0x3B;
- data[1] = 0xF;
- i2c.write(8 << 1, data, sizeof(data));
-
- // SW1 to 3.0V (SW1_VOLT)
- data[0] = 0x35;
- data[1] = 0xF;
- i2c.write(8 << 1, data, sizeof(data));
-
}
--
2.42.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From f0fb6a21e7eb398c0b7279bce7859ae77debcc64 Mon Sep 17 00:00:00 2001
From: Martino Facchin <[email protected]>
Date: Thu, 26 Oct 2023 16:39:04 +0200
Subject: [PATCH 211/213] stm32h7 dual core: allow override of
HAL_RCC_GetSysClockFreq

It's the only needed entry point to get the right timings for all peripherals
---
.../STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_rcc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_rcc.c b/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_rcc.c
index eb5485dc7d..f03be381a4 100644
--- a/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_rcc.c
+++ b/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_rcc.c
@@ -1354,7 +1354,7 @@ void HAL_RCC_DisableCSS(void)
*
* @retval SYSCLK frequency
*/
-uint32_t HAL_RCC_GetSysClockFreq(void)
+__attribute__((weak)) uint32_t HAL_RCC_GetSysClockFreq(void)
{
uint32_t pllp, pllsource, pllm, pllfracen, hsivalue;
float_t fracn1, pllvco;
--
2.42.0

238 changes: 238 additions & 0 deletions patches/0212-ble-remove-stray-specializations.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
From 46653cb9d8015361327cb0a8f9b394d6c008c841 Mon Sep 17 00:00:00 2001
From: Martino Facchin <[email protected]>
Date: Thu, 26 Oct 2023 16:39:59 +0200
Subject: [PATCH 212/213] ble: remove stray specializations

the standard one from Cypress driver is fine
---
.../TARGET_NICLA_VISION/cy_bt_cordio_cfg.cpp | 105 ------------------
.../TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp | 105 ------------------
2 files changed, 210 deletions(-)
delete mode 100644 connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_NICLA_VISION/cy_bt_cordio_cfg.cpp
delete mode 100644 connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp

diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_NICLA_VISION/cy_bt_cordio_cfg.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_NICLA_VISION/cy_bt_cordio_cfg.cpp
deleted file mode 100644
index 2d668fed9c..0000000000
--- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_NICLA_VISION/cy_bt_cordio_cfg.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
-* \file cy_bt_cordio_cfg.cpp
-* \version 1.0
-*
-*
-* Low Power Assist BT Pin configuration implementation.
-*
-********************************************************************************
-* \copyright
-* Copyright 2019 Cypress Semiconductor Corporation
-* SPDX-License-Identifier: Apache-2.0
-*
-* 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.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*******************************************************************************/
-
-#include <stdio.h>
-#include "ble/driver/CordioHCIDriver.h"
-#include "hci_api.h"
-#include "hci_cmd.h"
-#include "hci_core.h"
-#include "bstream.h"
-#include "assert.h"
-#include <stdbool.h>
-#include "hci_mbed_os_adaptation.h"
-#include "CyH4TransportDriver.h"
-
-#define cyhal_gpio_to_rtos(x) (x)
-#define CYCFG_BT_LP_ENABLED (1)
-#define CYCFG_BT_HOST_WAKE_IRQ_EVENT WAKE_EVENT_ACTIVE_LOW
-#define CYCFG_BT_DEV_WAKE_POLARITY WAKE_EVENT_ACTIVE_LOW
-
-/*******************************************************************************
-* Function Name: ble_cordio_get_h4_transport_driver
-********************************************************************************
-*
-* Strong implementation of function which calls CyH4TransportDriver constructor and return it
-*
-* \param none
-*
-* \return
-* Returns the transport driver object
-*******************************************************************************/
-ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver()
-{
-#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
-
-#if (defined(CYCFG_BT_LP_ENABLED))
- if (CYCFG_BT_LP_ENABLED) {
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE,
- cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE),
- cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE),
- CYCFG_BT_HOST_WAKE_IRQ_EVENT,
- CYCFG_BT_DEV_WAKE_POLARITY
- );
- return s_transport_driver;
- } else { /* CYCFG_BT_LP_ENABLED */
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE);
- return s_transport_driver;
- }
-#else /* (defined(CYCFG_BT_LP_ENABLED)) */
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE),
- cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE), cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE)
- );
- return s_transport_driver;
-#endif /* (defined(CYCFG_BT_LP_ENABLED)) */
-
-#else /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE);
- return s_transport_driver;
-#endif /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
-}
diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp
deleted file mode 100644
index 2d668fed9c..0000000000
--- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
-* \file cy_bt_cordio_cfg.cpp
-* \version 1.0
-*
-*
-* Low Power Assist BT Pin configuration implementation.
-*
-********************************************************************************
-* \copyright
-* Copyright 2019 Cypress Semiconductor Corporation
-* SPDX-License-Identifier: Apache-2.0
-*
-* 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.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*******************************************************************************/
-
-#include <stdio.h>
-#include "ble/driver/CordioHCIDriver.h"
-#include "hci_api.h"
-#include "hci_cmd.h"
-#include "hci_core.h"
-#include "bstream.h"
-#include "assert.h"
-#include <stdbool.h>
-#include "hci_mbed_os_adaptation.h"
-#include "CyH4TransportDriver.h"
-
-#define cyhal_gpio_to_rtos(x) (x)
-#define CYCFG_BT_LP_ENABLED (1)
-#define CYCFG_BT_HOST_WAKE_IRQ_EVENT WAKE_EVENT_ACTIVE_LOW
-#define CYCFG_BT_DEV_WAKE_POLARITY WAKE_EVENT_ACTIVE_LOW
-
-/*******************************************************************************
-* Function Name: ble_cordio_get_h4_transport_driver
-********************************************************************************
-*
-* Strong implementation of function which calls CyH4TransportDriver constructor and return it
-*
-* \param none
-*
-* \return
-* Returns the transport driver object
-*******************************************************************************/
-ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver()
-{
-#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
-
-#if (defined(CYCFG_BT_LP_ENABLED))
- if (CYCFG_BT_LP_ENABLED) {
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE,
- cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE),
- cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE),
- CYCFG_BT_HOST_WAKE_IRQ_EVENT,
- CYCFG_BT_DEV_WAKE_POLARITY
- );
- return s_transport_driver;
- } else { /* CYCFG_BT_LP_ENABLED */
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE);
- return s_transport_driver;
- }
-#else /* (defined(CYCFG_BT_LP_ENABLED)) */
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE),
- cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE), cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE)
- );
- return s_transport_driver;
-#endif /* (defined(CYCFG_BT_LP_ENABLED)) */
-
-#else /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
- static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
- /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
- /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
- /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
- /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
- /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
- DEF_BT_BAUD_RATE);
- return s_transport_driver;
-#endif /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
-}
--
2.42.0

Loading

0 comments on commit 373e7c6

Please sign in to comment.