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

drivers: flash: qspi stm32 driver supporting requires_ulbpr #74534

Merged
merged 3 commits into from
Oct 1, 2024

Conversation

FRASTM
Copy link
Collaborator

@FRASTM FRASTM commented Jun 19, 2024

Add the support of the requires_ulbpr property when a Microchip quad-spi flash is mounted.
Set the CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=y flag to access the command

Fixes #68622

@FRASTM FRASTM added platform: STM32 ST Micro STM32 area: QSPI Quad SPI labels Jun 19, 2024
@FRASTM FRASTM force-pushed the qspi_ulbpr branch 2 times, most recently from 59c4136 to 648059c Compare June 19, 2024 13:45
@FRASTM
Copy link
Collaborator Author

FRASTM commented Jun 19, 2024

Not all the quad-spi have the SPI_NOR_CMD_ULBPR command: (for example it is not listed in the Micron MT25QL512 or Macronix MX25R6435)
--> Send the qspi_write_unprotect() command during the quad-spi flash init if CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=y

@FRASTM
Copy link
Collaborator Author

FRASTM commented Jun 19, 2024

Tested (samples/drivers/spi_flash) on a stm32l496g_disco which has a Macronix MX25R6435 quad-NOR with CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=n (no Microchip available)
Setting CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=y for a non-Microchip quad-NOR will fail !

@FRASTM FRASTM requested a review from erwango June 28, 2024 08:06
@FRASTM FRASTM removed the request for review from ajarmouni-st August 1, 2024 08:52
@henrikbrixandersen henrikbrixandersen removed their request for review August 20, 2024 07:49
@FRASTM FRASTM requested review from erwango and removed request for erwango September 2, 2024 12:36
@tt0776
Copy link

tt0776 commented Sep 30, 2024

@FRASTM what is the status on using this changes in 3.7 LTS, it looks like still waiting on something for using "USE_MICROCHIP_QSPI_FLASH_WITH_STM32"

Add the <requires-ulbpr> property from the "jedec,spi-nor-common.yaml"
to the existing st,stm32-qspi-nor.yaml. So that external quad-NOR with
unlock the Global Block Protection (BPR) (opcode 0x98) is accepted.

Signed-off-by: Francois Ramu <[email protected]>
Add the support of the requires_ulbpr property when a Microchip
quad-spi flash is mounted.
Set the CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=y flag to access
the command

Signed-off-by: Francois Ramu <[email protected]>
Add the write_unprotect command to the stm32 qspi flash driver
to un protect flash before any write operation to the external quad-NOR

Signed-off-by: Francois Ramu <[email protected]>
@aescolar aescolar merged commit ff34d57 into zephyrproject-rtos:main Oct 1, 2024
23 checks passed
@tt0776
Copy link

tt0776 commented Oct 2, 2024

@FRASTM just feedback and question on warning

Do you have an idea on what is not done correct configured or possible fix in zephyr/drivers/flash/flash_stm32_qspi.c?

I have checked out main and used it to flash for microchip sst26vf032b with sample "samples/drivers/spi_flash"
For easier reproduction warning, I have attached overlay for "stm32l476g_disco" to be placed in sample "boards"
(Need rename to .conf and .overlay to use)
stm32l476g_disco_conf.txt
stm32l476g_disco_overlay.txt

my_board is derived from nucleo_l476rg

Specific enable and using.
CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=y
requires-ulbpr;

I get warning on this and not sure on how to fix it or it will be a problem.
Warning (spi_bus_bridge): /soc/quadspi@a0001000: node name for SPI buses
Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge'

relevant devicetree part for sst26vf032b

sst26vf032b: qspi-nor-flash@90000000 {
		// https://docs.zephyrproject.org/latest/build/dts/api/bindings/flash_controller/st,stm32-qspi-nor.html
		compatible = "st,stm32-qspi-nor";
		reg = <0x90000000 DT_SIZE_M(32)>; // 4 MBytes
		qspi-max-frequency = <DT_FREQ_M(80)>;
		status = "okay"; // Is only to be enable when actually using external flash.
		//NOT IN USE// reset-gpios = <&gpiod 3 GPIO_ACTIVE_LOW>;
        //NOT IN USE// reset-gpios-duration = <1>; // The duration (in ms) for the flash memory reset pulse
		spi-bus-width = <4>;
		requires-ulbpr;		
		page-size = <4096>; // Force “Erase 4 Kbytes” (0x20) to insure using smalles possible page size possible to support
		writeoc = "PP_1_1_4";

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "nor";
				reg = <0x00000000 DT_SIZE_M(4)>;
			};
		};
	};
};

Full printout with some path substitutes

COMMAND: west build -p always /home/ ... /samples/drivers/spi_flash -d /home/ ... /build -b [email protected]  -- -DBOARD_ROOT=/home/ ... /pjt
-- west build: making build dir /home/ ... /build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/ ... /samples/drivers/spi_flash
-- CMake version: 3.30.2
-- Found Python3: /home/ ... /zephyrproject/.venv/bin/python3 (found suitable version "3.12.3", minimum required is "3.10") found components: Interpreter
-- Cache files will be written to: /home/ ... /.cache/zephyr
-- Zephyr version: 3.7.99 (/home/ ... /zephyrproject/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: my_board, Revision: 3.0.1, qualifiers: stm32l476xx
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.8 (/home/ ... /zephyr-sdk-0.16.8)
-- Found toolchain: zephyr 0.16.8 (/home/ ... /zephyr-sdk-0.16.8)
-- Found Dtc: /home/ ... /zephyr-sdk-0.16.8/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")

-- Including generated dts.cmake file: / ... /zephyr/dts.cmake
CMake Warning at /home/ ... /zephyrproject/zephyr/cmake/modules/dts.cmake:405 (message):
  dtc raised one or more warnings:


  /home/ ... / ... /zephyr/zephyr.dts:446.29-485.5:
  Warning (spi_bus_bridge): /soc/quadspi@a0001000: node name for SPI buses
  should be 'spi'

  <stdout>: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge'

Call Stack (most recent call first):
  /home/ ... /zephyrproject/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
  /home/ ... /zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/ ... /zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:4 (find_package)

...

'/home/ ... / ... /zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/ ... /zephyr-sdk-0.16.8/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/ ... /zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Setting build type to 'MinSizeRel' as none was specified.
-- Using ccache: /usr/bin/ccache
-- Configuring done (7.8s)
-- Generating done (0.3s)
-- Build files have been written to: /home/ ... /build
-- west build: building application
[1/165] Preparing syscall dependency handling

[3/165] Generating include/generated/zephyr/version.h
-- Zephyr version: 3.7.99 (/home/ ... /zephyrproject/zephyr), build: v3.7.0-3720-g9c0f92db475f
[165/165] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       42444 B         1 MB      4.05%
             RAM:        5888 B        96 KB      5.99%
        IDT_LIST:          0 GB        32 KB      0.00%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Flash area: QSPI Quad SPI platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"requires-ulbpr" is not implemented in stm32-qspi-nor driver
6 participants