2021-12-03 07:40 AM
Looking at the code, i see file sf_probe.c with .id = UCLASS_SPI_FLASH, that performs the id reading. How can i use stm32_spi.c with .id = UCLASS_SPI, driver instead? and send "raw" spi data?
Solved! Go to Solution.
2021-12-14 02:02 AM
Hello,
I added an alias for the spi and the command started working.
aliases {
serial0 = &uart4;
serial1 = &usart3;
spi1 = &spi1;
};
thank you
2021-12-06 07:20 AM
Hi @Lmoio.1 ,
Can you share your Device Tree and particularly the spi node ?
Thx
Olivier
2021-12-06 07:45 AM
Hi @Community member,
My spi node definition in the device tree is the following:
&spi1 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi1_pins_a>;
pinctrl-1 = <&spi1_sleep_pins_a>;
status = "okay";
cs-gpios = <&gpioe 12 0>;
spidev@0 {
compatible = "stm32_spi";
reg = <0>; /* CS #0 */
spi-max-frequency = <10000000>;
};
};
I inlcude arch/arm/dts/stm32mp151.dtsi file so
spi1: spi@44004000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "st,stm32h7-spi";
reg = <0x44004000 0x400>;
interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&rcc SPI1_K>;
resets = <&rcc SPI1_R>;
dmas = <&dmamux1 37 0x400 0x01>,
<&dmamux1 38 0x400 0x01>;
dma-names = "rx", "tx";
power-domains = <&pd_core>;
status = "disabled";
};
I modified spi command to use the stm32 driver (but i'm not sure) instead of the spi_generic_drv driver:
ret = spi_get_bus_and_cs(bus, cs, freq, mode, "stm32_spi",
str, &dev, &slave);
I added some print in the driver files, and when doing sspi 0:0.0 8 a, i see that it performs sf_probe.c probing function (spi_flash_std_probe and spi_flash_probe_slave) and gives:
unrecognized JEDEC id bytes: 00, 00, 00.
I also tried disabling the spi flash driver, modifiying the defconfig with
CONFIG_ENV_IS_IN_SPI_FLASH=n
CONFIG_DM_SPI_FLASH=n
Now i see
spi_get_bus_and_cs: Binding new device 'generic_0:2', busnum=0, cs=2, driver=stm32_spi
But then it fails at line
priv->base = dev_remap_addr(dev);
in the stm32_spi.c file.
2021-12-09 08:50 AM
Hi @Community member
I worked some more on this issue and I noticed that inside spi-uclass.c file, the function ret = uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus);
put in bus a udevice parent with name spi@58003000 that is the QSPI base address, is this a possible issue? How can I force to use spi@44004000 that is SPI1?
Thanks
2021-12-09 09:08 AM
Hi @Lmoio.1 ,
Sorry for late reply.
Looking at your DT this is the comment I can do :
The node spidev@0 supposed to refer to the device connected on SPI.
The compatible = "stm32_spi"; supposed to refer to this device driver ... provider or in-house code.
In this case it refer to anything and anyway not to the stm32_spi driver.
compatible = "st,stm32h7-spi"; is the only and correct binding to call stm32_spi driver.
To be use SPI1 as raw I even wonder if you need to define a device node.
Did you try to remove it ?
Hope it help,
Olivier
2021-12-10 01:28 AM
Hi @Community member
I tried command dm tree and noticed the following:
spi 0 [ ] stm32_spi | |-- spi@44004000
spi 1 [ + ] stm32_qspi | |-- spi@58003000
so I figured out that qspi was actually enabled. I disabled it in the device tree and now I don't see its entry anymore. However there is no "+" on the spi entry.
Why does the spy not get probed?
I removed the node as you mentioned,
&spi1 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi1_pins_a>;
pinctrl-1 = <&spi1_sleep_pins_a>;
status = "okay";
cs-gpios = <&gpioe 12 0>;
};
now when i try sspi, i get
Invalid bus 0 (err=-19)
Are you able to use it somehow? Do you have a better idea if I need to send data to another stm32 mcu via spi during boot?
Thanks
Lidia
2021-12-14 02:02 AM
Hello,
I added an alias for the spi and the command started working.
aliases {
serial0 = &uart4;
serial1 = &usart3;
spi1 = &spi1;
};
thank you
2021-12-14 02:07 AM
Hi @Lmoio.1 ,
Well spotted !
For reference for others could you please confirm the working spi DT node for this usage ?
Thanks,
Olivier
2021-12-14 02:48 AM
Hi,
This is the device tree configuration i used
&spi1 {
u-boot,dm-spl;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi1_pins_a>;
pinctrl-1 = <&spi1_sleep_pins_a>;
status = "okay";
cs-gpios = <&gpioz 3 0>;
};
and i also reverted all modifications i did in the spi.c uboot command.
To summarize: