2025-01-05 06:53 PM
Hi All,
I've had the external SPI Flash driver working on the STM32H745_M7, using Zephyr SDK 4.0.0.
But when I setup it up on the M4 side the driver initialization is failing with error:
[1;31m<err> spi_ll_stm32: Could not select SPI domain clock
Further investigation shows that stm32_clock_control_configure(), is called from spi_stm32_init(), and fails to setup the clock path. In particular it is seeing that PLL_Q clock is not enabled. PLL 1 is setup on the M7 side and it doesn't look like I should be enabling it again in the M4's device tree again.
How do I get the correct clock path setup for the SPI driver on the M4 side? I need to run the external SPI flash from the M4.
Thanks,
Simon
2025-01-06 05:55 AM - edited 2025-01-06 05:55 AM
Hello @Simon33rd, Could you share the dts for the M4 side?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-01-06 12:02 PM
Hi Sarra,
My board .dts settings and the resulting build zephyr.dts attached.
I did also try and use PLL3 given that PLL1 is setup on the M7 side, but I still get the same error.
by the way what is < &rcc 0x9 0xec50 > doing? I can see the first part is enabling SPI123 clock.
clocks = < &rcc 0xf0 0x1000 >, < &rcc 0x9 0xec50 >;
2025-01-13 05:50 PM
Hi Sarra,
Have you been able to look at this for me?
2025-01-20 01:04 PM
Hi @Sarra.S could you respond please?
2025-01-27 08:58 PM
Hi All,
I managed to find a workaround to the problem I was having. On the M7 side I was able to get SPI1 to use either the PLL1_Q clock or the PLL3_P clock. I wanted to use the PLL3_P clock to maximize the SPI clock to 50MHz, as it's 48MHz when using PLL1_Q (because I'm running at 480MHz and the highest DIVQ1 can be is /5).
On the M4 side I setup the PLL3 in the device tree (for the M4 Zephyr OS) and select this clock in &spi1:
clocks = <&rcc STM32_CLOCK(APB2, 12U)>,
<&rcc STM32_SRC_PLL3_P SPI123_SEL(2)>;
This doesn't and I get this runtime error:
[00:00:00.200,000] [1;31m<err> spi_ll_stm32: Timeout waiting for transfer complete[0m
[00:00:00.200,000] [1;31m<err> spi_nor: Failed to wait until flash is ready (-116)[0m
*** Booting Zephyr OS build v4.0.0 ***
is25le01g@0: device not ready.
It looks like the SPI123 clock is not being setup. After some trial and error. I found that enabling the PLL3 (on the M4 side) but selecting the PLL1_Q clock on the clock Mux worked (SPI123_SEL(0)), and I get the 48MHZ SPI_CLK.
My device tree setup is as follows:
&clk_hse {
clock-frequency = <DT_FREQ_M(32)>;
status = "okay";
};
&pll3 {
div-m = <2>;
mul-n = <50>;
div-p = <4>;
div-q = <4>;
div-r = <4>;
clocks = <&clk_hse>;
status = "okay";
};
// External SPI NOR flash
&spi1{
status = "okay";
pinctrl-0 = < &spi1_nss_pg10 &spi1_sck_pg11
&spi1_miso_pg9 &spi1_mosi_pb5>;
pinctrl-names = "default";
clocks = <&rcc STM32_CLOCK(APB2, 12U)>,
<&rcc STM32_SRC_PLL3_P SPI123_SEL(0)>;
// cs-gpios must be disabled to use hardware SS
//cs-gpios = <&gpiog 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
fifo-enable;
spi_nor_1g: is25le01g@0 {
compatible = "jedec,spi-nor";
reg = < 0x0 >;
status = "okay";
// 50MHz max frequency for standard SPI
spi-max-frequency = < 50000000 >;
jedec-id = [ 9D 60 1B ];
size = < 0x40000000 >;
//spi-cpol; /* Clock Polarity: 1 = idle high */
//spi-cpha; /* Clock Phase: 1 = sample on rising edge */
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
storage_partition: partition@00000 {
label = "storage";
reg = <0x00000000 DT_SIZE_M(132)>;
};
};
};
};
Not ideal but it's working.
Simon