cancel
Showing results for 
Search instead for 
Did you mean: 

stm32mp157c quad spi flash driver

aliMesut
Associate III

Hi,

I'm working the stm32mp157c som and trying to boot external quad spi flash (cypress S25HL512T). I added this to dts.

&qspi {
 
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&quadspi_pins_mx>;
	pinctrl-1 = <&quadspi_sleep_pins_mx>;
	status = "okay";
 
	#address-cells = <1>;
	#size-cells = <0>;
	flash0: flash@0 {
		compatible = "n25q512a","micron,m25p80";
		reg = <0x0>;
		#address-cells = <1>;
		#size-cells = <1>;
		spi-max-frequency = <50000000>;
		partition@0x00000000 {
			label = "boot";
			reg = <0x00000000 0x00500000>;
		};
		partition@0x00500000 {
			label = "bootenv";
			reg = <0x00500000 0x00020000>;
		};
		partition@0x00520000 {
			label = "kernel";
			reg = <0x00520000 0x01ae0000>;
		};
		partition@0x02000000 {
			label = "spare";
			reg = <0x02000000 0x00000000>;
		};
	};
};
aliases {
		spi6 = &qspi;
	};

On the kernel side, I followed the following link.

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

But when it running, the following statement is included in the debug messages.

spi-nor spi6.0: unrecognized JEDEC id bytes: 34 2a 0f 03 90

Where did i go wrong?

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
Kevin HUBER
ST Employee

Hello @aliMesut​ ,

The JEDEC Id of the flash S25HL512T is normally "0x342a1a"

This flash is not supported by default by our U-boot and or linux kernel version.

For U-boot, it was added by a patch from Infineon in 2021, which is not yet integrated in our U-Boot.

I didn't find their patch for the kernel Linux, so I advise you to contact them and ask them, because the manufacturer is responsible for adding the new flashes.

While waiting for their answer, you can modify the files by yourself and add the supports of this flash.

You must specify it at u-boot level and kernel level.

The goal is to describe all the features managed by the flash and its ID.

U-Boot

Concerning the u-boot source code, the existing patch of Infineon is visible here :

https://lists.denx.de/pipermail/u-boot/2021-February/441565.html

You can take exemple on it and add the description of your flash into the spi_nor_ids array, in the spansion part (spansion and cypress merged since 2014).

The array to modify is located in the file: drivers/mtd/spi/spi-nor-ids.c

For your flash, the interesting part is this one:

+	{ INFO6("s25hl512t",  0x342a1a, 0x0f0390, 256 * 1024, 256,
+		SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES |
+		USE_CLSR) },

But you can add all the flashes of the patches.

Once it's done, verify inside your u-boot "make menuconfig" that the configuration CONFIG_SPI_FLASH_SPANSION

is enabled. Which is normally the case in the developer package.

0693W00000JN7vwQAD.pngMore information about the menuconfig are available on the wiki: https://wiki.st.com/stm32mpu/wiki/Menuconfig_or_how_to_configure_kernel#Linux_configuration_genericity

Linux level

You have to do the same modification to support this flash, but in a different file.

At linux level, the file to modify is: drivers/mtd/spi-nor/spansion.c

You need to add the flashes in the array spansion_parts[] and as you can see the syntax is mostly the same.

Once it's done, your flash id must be recognized in U-boot and Linux.

Hope it helps you,

Regards,

Kevin

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.

View solution in original post

4 REPLIES 4
Kevin HUBER
ST Employee

Hello @aliMesut​ ,

The JEDEC Id of the flash S25HL512T is normally "0x342a1a"

This flash is not supported by default by our U-boot and or linux kernel version.

For U-boot, it was added by a patch from Infineon in 2021, which is not yet integrated in our U-Boot.

I didn't find their patch for the kernel Linux, so I advise you to contact them and ask them, because the manufacturer is responsible for adding the new flashes.

While waiting for their answer, you can modify the files by yourself and add the supports of this flash.

You must specify it at u-boot level and kernel level.

The goal is to describe all the features managed by the flash and its ID.

U-Boot

Concerning the u-boot source code, the existing patch of Infineon is visible here :

https://lists.denx.de/pipermail/u-boot/2021-February/441565.html

You can take exemple on it and add the description of your flash into the spi_nor_ids array, in the spansion part (spansion and cypress merged since 2014).

The array to modify is located in the file: drivers/mtd/spi/spi-nor-ids.c

For your flash, the interesting part is this one:

+	{ INFO6("s25hl512t",  0x342a1a, 0x0f0390, 256 * 1024, 256,
+		SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES |
+		USE_CLSR) },

But you can add all the flashes of the patches.

Once it's done, verify inside your u-boot "make menuconfig" that the configuration CONFIG_SPI_FLASH_SPANSION

is enabled. Which is normally the case in the developer package.

0693W00000JN7vwQAD.pngMore information about the menuconfig are available on the wiki: https://wiki.st.com/stm32mpu/wiki/Menuconfig_or_how_to_configure_kernel#Linux_configuration_genericity

Linux level

You have to do the same modification to support this flash, but in a different file.

At linux level, the file to modify is: drivers/mtd/spi-nor/spansion.c

You need to add the flashes in the array spansion_parts[] and as you can see the syntax is mostly the same.

Once it's done, your flash id must be recognized in U-boot and Linux.

Hope it helps you,

Regards,

Kevin

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.

Hi @Kevin HUBER​ ,

Thank you for quick responce.

I did what you said and the error is gone. Here's how I recognized qspi in dtsi.

&qspi {
 
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&quadspi_pins_mx>;
	pinctrl-1 = <&quadspi_sleep_pins_mx>;
	status = "okay";
 
	#address-cells = <1>;
	#size-cells = <0>;
	flash0: flash@0 {
		compatible = "s25hl512t","spansion";
		reg = <0x0>;
		#address-cells = <1>;
		#size-cells = <1>;
		spi-max-frequency = <50000000>;
		partition@0x00000000 {
			label = "boot";
			reg = <0x00000000 0x00500000>;
		};
		partition@0x00500000 {
			label = "bootenv";
			reg = <0x00500000 0x00020000>;
		};
		partition@0x00520000 {
			label = "kernel";
			reg = <0x00520000 0x01ae0000>;
		};
		partition@0x02000000 {
			label = "spare";
			reg = <0x02000000 0x00000000>;
		};
	};
};

The error message is gone, but the debug message did not print, which I will know if it works. How can I know if it is working or not?

Regards,

Ali Mesut

Hi @aliMesut​ ,

I advise you to read the QuadSPI wiki page: https://wiki.st.com/stm32mpu/wiki/QUADSPI_device_tree_configuration#DT_configuration_example

You have an example of spi-nor flash description:

 flash0: mx66l51235l@0 {                                 
           compatible = "jedec,spi-nor";
           reg = <0>;
           spi-rx-bus-width = <4>;
           spi-max-frequency = <108000000>;
           #address-cells = <1>;
           #size-cells = <1>;
       };

You can see that for a nor you have to put "jedec,spi-nor" in the compatible attribute.

Then since you are using a spansion flash, you can add information about the flash you use.

For that, I advise you to have a look at the other dts files in linux that already use a spansion flash. Have a look in the folder "arch/arm/boot/dts/". It can help you to configure yours.

You can write:

compatible = "spansion,s25hl512t", "jedec,spi-nor";

With this attribute, linux will search if there is a specific driver spansion for your flash available. If it is not the case, it will load the spi-nor driver.

Once you are sure about your dts, you can verify in linux with the MTD commands if everything is ok:

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

For example, with mtdinfo, you must see your partitions.

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

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.

Hi @Kevin HUBER​ ,

Thank you for your support.

Best regards,

Ali Mesut