Skip to content

stm32 QSPI flash driver enables XiP on external NOR flash #68607

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

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/st/stm32f746g_disco/stm32f746g_disco.dts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ zephyr_udc0: &usbotg_fs {
&quadspi_bk1_io0_pd11 &quadspi_bk1_io1_pd12
&quadspi_bk1_io2_pe2 &quadspi_bk1_io3_pd13>;
pinctrl-names = "default";
flash-id = <1>; /* One quad NOR : single flash mode */
status = "okay";

n25q128a1: qspi-nor-flash@90000000 {
Expand Down
22 changes: 21 additions & 1 deletion boards/st/stm32h747i_disco/stm32h747i_disco_stm32h747xx_m7.dts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,flash-controller = &mt25ql512ab1;
};

sdram2: sdram@d0000000 {
Expand All @@ -31,6 +30,14 @@
zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_RAM) )>;
};

quad_nor: memory@90000000 {
compatible = "zephyr,memory-region";
reg = <0x90000000 DT_SIZE_K(800)>; /* size of the slot partition */
zephyr,memory-region = "EXTMEM";
/* The ATTR_MPU_EXTMEM attribut causing a MPU FAULT */
zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>;
};

leds {
green_led_1:led_1 {
status = "okay";
Expand Down Expand Up @@ -111,6 +118,19 @@
#address-cells = <1>;
#size-cells = <1>;

boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(64)>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 DT_SIZE_K(60)>;
};

scratch_partition: partition@1f000 {
label = "image-scratch";
reg = <0x0001f000 DT_SIZE_K(2)>;
};
/* Set 2KB of storage at the end of first 1MB flash */
storage_partition: partition@ff800 {
label = "storage";
Expand Down
38 changes: 36 additions & 2 deletions boards/st/stm32h750b_dk/stm32h750b_dk.dts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
zephyr,shell-uart = &usart3;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,flash-controller = &mt25ql512ab1;
};

sdram2: sdram@d0000000 {
Expand All @@ -29,6 +28,14 @@
zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_RAM) )>;
};

quad_nor: memory@90000000 {
compatible = "zephyr,memory-region";
reg = <0x90000000 DT_SIZE_K(800)>; /* size of the slot partition */
zephyr,memory-region = "EXTMEM";
/* The ATTR_MPU_EXTMEM attribut causing a MPU FAULT */
zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>;
};

leds {
compatible = "gpio-leds";
red_led: led_1 {
Expand Down Expand Up @@ -92,14 +99,41 @@
status = "okay";
};

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

boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(64)>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 DT_SIZE_K(60)>;
};

scratch_partition: partition@1f000 {
label = "image-scratch";
reg = <0x0001f000 DT_SIZE_K(2)>;
};
storage_partition: partition@1f800 {
label = "storage";
reg = <0x0001f800 DT_SIZE_K(2)>;
};

};
};

&quadspi {
pinctrl-names = "default";
pinctrl-0 = <&quadspi_clk_pf10 &quadspi_bk1_ncs_pg6
&quadspi_bk1_io0_pd11 &quadspi_bk1_io1_pf9
&quadspi_bk1_io2_pf7 &quadspi_bk1_io3_pf6
&quadspi_bk2_io0_ph2 &quadspi_bk2_io1_ph3
&quadspi_bk2_io2_pg9 &quadspi_bk2_io3_pg14>;
flash-id = <1>;

status = "okay";

mt25ql512ab1: qspi-nor-flash-1@90000000 {
Expand Down
8 changes: 8 additions & 0 deletions boards/st/stm32h7b3i_dk/stm32h7b3i_dk.dts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_RAM_NOCACHE) )>;
};

octo_nor: memory@90000000 {
compatible = "zephyr,memory-region";
reg = <0x90000000 DT_SIZE_K(800)>; /* size of the slot partition */
zephyr,memory-region = "EXTMEM";
/* The ATTR_MPU_EXTMEM attribut causing a MPU FAULT */
zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>;
};

transceiver0: can-phy0 {
compatible = "microchip,mcp2562fd", "can-transceiver-gpio";
standby-gpios = <&gpioh 8 GPIO_ACTIVE_HIGH>;
Expand Down
10 changes: 10 additions & 0 deletions boards/st/stm32l496g_disco/stm32l496g_disco.dts
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,15 @@ zephyr_udc0: &usbotg_fs {
status = "okay";
spi-bus-width = <4>;
writeoc = "PP_1_4_4";

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

partition@0 {
reg = <0x00000000 DT_SIZE_M(8)>;
};
};
};
};
10 changes: 10 additions & 0 deletions drivers/clock_control/clock_stm32_ll_h7.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,16 @@ __unused
static int set_up_plls(void)
{
#if defined(STM32_PLL_ENABLED) || defined(STM32_PLL2_ENABLED) || defined(STM32_PLL3_ENABLED)

/*
* Skip if PLL1 is already configured by the McuBoot
* with ext NOR in MemMapped : application running in external NOR in XiP
* has not necessarily the CONFIG_STM32_MEMMAP
*/
if (LL_RCC_PLL1_IsReady()) {
return 0;
}

int r;
uint32_t vco_input_range;
uint32_t vco_output_range;
Expand Down
7 changes: 7 additions & 0 deletions drivers/flash/Kconfig.stm32
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,11 @@ config FLASH_STM32_BLOCK_REGISTERS
registers improves system security, because flash content (or
protection settings) can't be changed even when exploit was found.

config STM32_MEMMAP
bool "NOR Flash in MemoryMapped for XiP"
depends on XIP
help
This option enables the XIP mode for the external NOR flash
mounted on STM32 boards.

endif # SOC_FLASH_STM32
Loading
Loading