cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot enable SPI_STM32 in Kernel using menuconfig (conflicting information in WikiI)

AStev.2
Associate III

I would like to understand why I cannot find and enable STM32 SPI support in the Linux kernel and resolve conflicting information in the Wiki articles I am using.

When I use menuconfig, I cannot locate STM32 SPI support in the menu. If I use the search option (/) I can see the reasons are that SPI_STM32 depends on ARCH_STM32 which is set to [N]. In addition, ARCH_STM32 depends on ARM_SINGLE_ARMV7M which is also set to [N].

Are there any other parameters I should be adding to the invocation of 'make menuconfig'?

Any ideas why these variables are not set correctly and how to resolve the issue?

I suspected something about my environment. I am using the Developer Package and running the following to setup the terminal environment:

source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

I have applied the patches and fragments and not had an issue building or running the kernel or adding a device tree change from the Cube code generator.

Now, on to the Wiki conflicts.

In section 2 of the Wiki article at https://wiki.st.com/stm32mpu/wiki/Menuconfig_or_how_to_configure_kernel

it states that the CROSS_COMPILE environment should be 'arm-openstlinux_weston-linux-gnueabi-'

In section 5.1.1 of the Wiki article at https://wiki.st.com/stm32mpu/wiki/STM32MP1_Developer_Package

is states that the CROSS_COMPILE environment should be 'arm-ostl-linux-gnueabi-'.

I am getting 'arm-ostl-linux-gnueabi-'. Which article is correct?

4 REPLIES 4
Olivier GALLIEN
ST Employee

Hi @Community member​ ,

Once fragment and patch are properly applied you should have correct state :

 SPI_STM32 and ARCH_STM32 are both =y

Please double check using README.HOWTO.txt describing procedure.

For wiki "arm-ostl-linux-gnueabi" you have is the right one.

We will correct page containing 'arm-openstlinux_weston-linux-gnueabi-'

Olivier

Olivier GALLIEN
In order 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.
AStev.2
Associate III

Hi Olivier,

I had already checked the README.HOWTO.txt procedure. For your reference, this is how I prepared the kernel.

I have consulted the following Wiki articles but despite following the advice have not been able to activate it (no such issues getting SPI4 working on the M4):

https://wiki.st.com/stm32mpu/wiki/SPI_device_tree_configuration

https://wiki.st.com/stm32mpu/wiki/Menuconfig_or_how_to_configure_kernel

https://wiki.st.com/stm32mpu/wiki/STM32MP1_Developer_Package

https://wiki.st.com/stm32mpu/wiki/SPI_overview

I understand from the above articles I should see an 'STMicroelectronics STM32 SPI controller' listed in the 'Device Drivers->SPI Support' section of the Linux kernel configuration. This is not appearing when I invoke the config system with 'make ARCH=arm menuconfig'. Why not?

Additionally, when I boot the kernel on the target I see no SPI support:

'ls /dev' on the target shows no spidevX devices.

'ls /sys/class' on the target shows 'spi_master' and 'spidev' but no devices listed within.

My process to build the kernel was to:

1) Add SPI5 in the STM32CubeIDE and configure the PF9 for SPI5_MOSI and PF7 for SPI_SCK

2) Confirmed the appropriate device tree content was added to 'stm32mp157c-angelina-mx.dts' (see below for extracts from this file)

3) Opened a terminal and sourced the environment with:

   source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

4) Extracted the kernel source code

5) Copied my 'stm32mp157c-angelina-mx.dts' to 'linux-5.4.31/arch/arm/boot/dts'

6) Modified dts Makefile to add 'stm32mp157c-angelina-mx.dtb'

7) Applied all ST patches 1 through 23:

patch -p1 < ../0001-ARM-stm32mp1-r1-MACHINE.patch

patch -p1 < ../0002-ARM-stm32mp1-r1-CPUFREQ.patch

patch -p1 < ../0003-ARM-stm32mp1-r1-CRYPTO.patch

patch -p1 < ../0004-ARM-stm32mp1-r1-RNG-DEBUG-NVMEM.patch

patch -p1 < ../0005-ARM-stm32mp1-r1-CLOCK.patch

patch -p1 < ../0006-ARM-stm32mp1-r1-DMA.patch

patch -p1 < ../0007-ARM-stm32mp1-r1-DRM.patch

patch -p1 < ../0008-ARM-stm32mp1-r1-HWSPINLOCK.patch

patch -p1 < ../0009-ARM-stm32mp1-r1-I2C-IIO-IRQCHIP.patch

patch -p1 < ../0010-ARM-stm32mp1-r1-MAILBOX-REMOTEPROC-RPMSG.patch

patch -p1 < ../0011-ARM-stm32mp1-r1-RESET-RTC-WATCHDOG.patch

patch -p1 < ../0012-ARM-stm32mp1-r1-MEDIA-SOC-THERMAL.patch

patch -p1 < ../0013-ARM-stm32mp1-r1-MFD.patch

patch -p1 < ../0014-ARM-stm32mp1-r1-MMC-NAND.patch

patch -p1 < ../0015-ARM-stm32mp1-r1-NET-TTY.patch

patch -p1 < ../0016-ARM-stm32mp1-r1-PHY-USB.patch

patch -p1 < ../0017-ARM-stm32mp1-r1-PINCTRL-REGULATOR-SPI-PWM.patch

patch -p1 < ../0018-ARM-stm32mp1-r1-SOUND.patch

patch -p1 < ../0019-ARM-stm32mp1-r1-MISC.patch

patch -p1 < ../0020-ARM-stm32mp1-r1-DEVICETREE.patch

patch -p1 < ../0021-ARM-stm32mp1-r1-CONFIG.patch

patch -p1 < ../0022-ARM-stm32mp1-r1-POWER.patch

patch -p1 < ../0023-ARM-stm32mp1-r1-PERF.patch

8) make ARCH=arm O="$PWD/../build" multi_v7_defconfig fragment*.config

9) Applied fragments 03 ot 06 with:

scripts/kconfig/merge_config.sh -m -r -O $PWD/../build $PWD/../build/.config ../fragment-03-systemd.config

scripts/kconfig/merge_config.sh -m -r -O $PWD/../build $PWD/../build/.config ../fragment-04-optee.config

scripts/kconfig/merge_config.sh -m -r -O $PWD/../build $PWD/../build/.config ../fragment-05-modules.config

scripts/kconfig/merge_config.sh -m -r -O $PWD/../build $PWD/../build/.config ../fragment-06-signature.config

10) Make ARCH=arm oldconfig O="$PWD/../build"

  I accepted all default answers

11) Build kernel:

make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040 O="$PWD/../build"

12) Confirmed that stm32mp157c-angelina-mx.dtb was made by the build

13) Build kernel modules:

 make ARCH=arm modules O="$PWD/../build"

14) Install kernel modules:

 make ARCH=arm INSTALL_MOD_PATH="$PWD/../build/install_artifact" modules_install O="$PWD/../build"

mkdir -p $PWD/../build/install_artifact/boot/

cp $PWD/../build/arch/arm/boot/uImage $PWD/../build/install_artifact/boot/

cp $PWD/../build/arch/arm/boot/dts/st*.dtb $PWD/../build/install_artifact/boot/

I have consulted the kernel boot logs and confirmed that the kernel I built is being loaded.

I now enclose extracts relevant to SPI5 from the DTS file generated by the STM32CubeIDE:

spi5_pins_mx: spi5_mx-0 {

pins {

pinmux = <STM32_PINMUX('F', 7, AF5)>, /* SPI5_SCK */

<STM32_PINMUX('F', 9, AF5)>; /* SPI5_MOSI */

bias-disable;

drive-push-pull;

slew-rate = <1>;

};

};

spi5_sleep_pins_mx: spi5_sleep_mx-0 {

pins {

pinmux = <STM32_PINMUX('F', 7, ANALOG)>, /* SPI5_SCK */

<STM32_PINMUX('F', 9, ANALOG)>; /* SPI5_MOSI */

};

};

&spi5{

pinctrl-names = "default", "sleep";

pinctrl-0 = <&spi5_pins_mx>;

pinctrl-1 = <&spi5_sleep_pins_mx>;

status = "okay";

/* USER CODE BEGIN spi5 */

/* USER CODE END spi5 */

};

Do I need to add anything to the above definitions to activate SPI5? I assumed that whatever I configure in the IDE is sufficient.

JFern.7
Associate

I have this same exact problem. Why has no one from ST answered this?

In my case the boot log shows the following.

[ OK ] Started Update UTMP about System Boot/Shutdown.

[ OK ] Started udev Coldplug all Devices.

[  13.683932] spi_stm32 4000b000.spi: clk rate = 0

[  13.706859] spi_stm32: probe of 4000b000.spi failed with error -22

[  13.762465] spi_stm32 44005000.spi: clk rate = 0

[  13.778909] spi_stm32: probe of 44005000.spi failed with error -22

[ OK ] Started Network Time Synchronization.

[ OK ] Reached target System Initialization.

Yves C
ST Employee

Hi @Community member​ 

If you didn't resolved your pb yet, Check the clocks spi.