Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing peripheral support on STM32F1 #81181

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

benjaminbjornsson
Copy link
Member

This PR aims at resolving #79809 which requests adding support for these peripherals to the STM32F1 series:

  • I2S
  • FSMC
  • SDIO

This commit remove an interrupt that doesn't exist
for the STM32F103 line which caused gen_isr_tables.py
to fail with error: IRQ 60 (offset=0) exceeds the maximum of 59.
The interrupt does exist for STM32F105 and STM32F107 so most
likely a copy-paste error.

Signed-off-by: Benjamin Björnsson <[email protected]>
This commit adds missing I2S nodes for the F1 series.

Signed-off-by: Benjamin Björnsson <[email protected]>
@benjaminbjornsson
Copy link
Member Author

I successfully built samples/drivers/i2s/output using waveshare_open103z with these local changes:

diff --git a/boards/waveshare/open103z/waveshare_open103z.dts b/boards/waveshare/open103z/waveshare_open103z.dts
index 72dd744c4c2..41ae01b380f 100644
--- a/boards/waveshare/open103z/waveshare_open103z.dts
+++ b/boards/waveshare/open103z/waveshare_open103z.dts
@@ -82,6 +82,7 @@
 		led3 = &led_4;
 		sw0 = &button;
 		watchdog0 = &iwdg;
+		i2s-tx = &i2s2;
 	};
 };
 
@@ -105,6 +106,14 @@
 	/* usbpre not set: USB clock = 72 / 1.5: 48MHz */
 };
 
+&dma1 {
+	status = "okay";
+};
+
+&dma2 {
+	status = "okay";
+};
+
 &usart1 {
 	pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
 	pinctrl-names = "default";
@@ -130,6 +139,18 @@
 	pinctrl-0 = <&spi2_nss_master_pb12 &spi2_sck_master_pb13
 		     &spi2_miso_master_pb14 &spi2_mosi_master_pb15>;
 	pinctrl-names = "default";
+	status = "disabled";
+};
+
+&i2s2 {
+	pinctrl-0 = <&i2s2_ws_pb12 &i2s2_sd_pb15>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
+&i2s3 {
+	pinctrl-0 = <&i2s3_ws_pa15 &i2s3_sd_pb5>;
+	pinctrl-names = "default";
 	status = "okay";
 };

@rruuaanng rruuaanng added the platform: STM32 ST Micro STM32 label Nov 10, 2024
This commit updates hal_stm32 submodule after adding
SDIO to F1 series pinctrl.

Signed-off-by: Benjamin Björnsson <[email protected]>
Extend sdmmc driver to support the F1 series.

This includes removing the RCC peripheral reset when building
for F1 since this series doensn't have reset register for AHB
peripherals.
Therefore, it was neccesary to add an F1 specific
compatible that removes the required resets property,
as well as if-def the usage of reset in the device driver.

Signed-off-by: Benjamin Björnsson <[email protected]>
Add sdmmc node to f103, this should cover all F1 series
DTS files since SDIO exists on f103x(e-g) and f103xg dts
file includes f103xe dtsi.

Signed-off-by: Benjamin Björnsson <[email protected]>
@zephyrbot
Copy link
Collaborator

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
hal_stm32 zephyrproject-rtos/hal_stm32@019d825 (main) zephyrproject-rtos/hal_stm32#239 zephyrproject-rtos/hal_stm32#239/files

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_stm32 DNM This PR should not be merged (Do Not Merge) labels Nov 13, 2024
@benjaminbjornsson
Copy link
Member Author

Successfully built tests/drivers/disk/disk_access using waveshare_open103z with these local changes:

diff --git a/boards/waveshare/open103z/waveshare_open103z.dts b/boards/waveshare/open103z/waveshare_open103z.dts
index 72dd744c4c2..0f9866d119e 100644
--- a/boards/waveshare/open103z/waveshare_open103z.dts
+++ b/boards/waveshare/open103z/waveshare_open103z.dts
@@ -82,6 +82,7 @@
                led3 = &led_4;
                sw0 = &button;
                watchdog0 = &iwdg;
+               sdhc0 = &sdmmc1;
        };
 };
 
@@ -189,3 +190,14 @@ zephyr_udc0: &usb {
        pinctrl-names = "default";
        status = "okay";
 };
+
+&sdmmc1 {
+       status = "okay";
+       pinctrl-0 = <&sdio_d0_pc8
+                    &sdio_d1_pc9
+                    &sdio_d2_pc10
+                    &sdio_d3_pc11
+                    &sdio_ck_pc12
+                    &sdio_cmd_pd2>;
+       pinctrl-names = "default";
+};

@@ -21,6 +21,7 @@
LOG_MODULE_REGISTER(stm32_sdmmc, CONFIG_SDMMC_LOG_LEVEL);

#define STM32_SDMMC_USE_DMA DT_NODE_HAS_PROP(DT_DRV_INST(0), dmas)
#define STM32_SDMMC_USE_RESET !DT_NODE_HAS_COMPAT(DT_DRV_INST(0), st_stm32f1_sdmmc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not DT_NODE_HAS_PROP(DT_DRV_INST(0), reset) ?

@@ -302,11 +305,13 @@ static int stm32_sdmmc_access_init(struct disk_info *disk)
return err;
}

#if STM32_SDMMC_USE_RESET
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Using IS_ENABLED() to preserve readability (may have the consequence of having .reset always present in the structure, but if we consider we're building a SDMMC application, so it can be seen as neglectible).

This being said proposed code is aligned with DMA handling, so keeping it this way could be ok as well. This is readability vs consistency ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM This PR should not be merged (Do Not Merge) manifest manifest-hal_stm32 platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants