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 controller for the stm32u5 soc serie #42538

Merged
merged 5 commits into from Apr 13, 2022

Conversation

FRASTM
Copy link
Collaborator

@FRASTM FRASTM commented Feb 7, 2022

This PR adds the flash controller driver for the stm32U5xx soc
It defines the flash controller node in the DTS
It defines a partition for the flash memory.
The drivers/flash/flash_stm32u5x.c is adapted from the drivers/flash/flash_stm32l5x.c
Applicable on the stm32U575/585 devices where the Flash memory is organized as two banks of 1 Mbyte each containing 128 pages of 8 Kbytes ( 137 bits wide data read and write = 128 effective bits plus 9 ECC bits)

Fixes #42478

Signed-off-by: Francois Ramu francois.ramu@st.com

@github-actions github-actions bot added area: Boards area: Devicetree area: Tests Issues related to a particular existing or missing test platform: STM32 ST Micro STM32 labels Feb 7, 2022
@FRASTM FRASTM marked this pull request as draft February 7, 2022 13:39
@FRASTM
Copy link
Collaborator Author

FRASTM commented Feb 7, 2022

$ west build -p auto -b b_u585i_iot02a tests/drivers/flash

*** Booting Zephyr OS build v3.0.0-rc1-252-g7de53a4c47a2  ***                   
Running test suite flash_driver_test                                            
===================================================================             
START - test_setup                                                              
 PASS - test_setup in 0.1 seconds                                               
===================================================================             
START - test_read_unaligned_address                                             
 PASS - test_read_unaligned_address in 0.4 seconds                              
===================================================================             
Test suite flash_driver_test succeeded                                          
===================================================================             
PROJECT EXECUTION SUCCESSFUL 

@FRASTM
Copy link
Collaborator Author

FRASTM commented Feb 7, 2022

adding the DTS for the b_u585i_iot02a_ns target with a image-1-nonsecure partition

@FRASTM
Copy link
Collaborator Author

FRASTM commented Feb 7, 2022

rebase

}

/* Check if this double word is erased */
if ((flash[0] != 0xFFFFFFFFUL) || (flash[1] != 0xFFFFFFFFUL)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note: a write will still fail if the ECC is already written.
ECC can be set if a programmer/ previous write was done with 0xFF...FF as data.
Maybe good to add this in the check?

@FRASTM FRASTM force-pushed the flash_u5 branch 2 times, most recently from d7459dc to 1328800 Compare March 15, 2022 16:34
@FRASTM
Copy link
Collaborator Author

FRASTM commented Mar 15, 2022

merging drivers/flash/flash_stm32l5x.c and drivers/flash/flash_stm32u5x.c in a common drivers/flash/flash_stm32l5_u5.c
for both stm32U5 and stm32l5 series.
rebase and fix merge conflict on drivers/flash/flash_stm32.h

Note that stm32U5 has 128-bit pages and on or two (consecutive) banks "of 1 Mbyte each containing 128 pages of
8 Kbytes. "

@FRASTM FRASTM marked this pull request as ready for review March 15, 2022 16:37
drivers/flash/flash_stm32.h Outdated Show resolved Hide resolved
dts/arm/st/u5/stm32u5.dtsi Outdated Show resolved Hide resolved
drivers/flash/flash_stm32l5_u5.c Outdated Show resolved Hide resolved
@FRASTM
Copy link
Collaborator Author

FRASTM commented Mar 16, 2022

rebase on ae71444
deleting flash_stm32l5.c

@FRASTM
Copy link
Collaborator Author

FRASTM commented Mar 17, 2022

add a commit 4a94eedbc1a428f1013a662a318022a6d5499eb9 to change FLASH_STM32_xx bitfield

@FRASTM FRASTM force-pushed the flash_u5 branch 3 times, most recently from f3e9b08 to 7cc144b Compare March 18, 2022 13:02
@FRASTM
Copy link
Collaborator Author

FRASTM commented Mar 18, 2022

rebase on 574e166
reorder commits
fix compilation error on some stm32l4 boards

drivers/flash/flash_stm32l5_u5.c Outdated Show resolved Hide resolved
boards/arm/b_u585i_iot02a/b_u585i_iot02a.dts Show resolved Hide resolved
tests/drivers/flash/boards/b_u585i_iot02a.overlay Outdated Show resolved Hide resolved
@FRASTM
Copy link
Collaborator Author

FRASTM commented Mar 18, 2022

with optimized Kconfig writing and dts

This adds the stm32U5 soc family to the flash driver
The flash controller has particular register names in the Non-Secure
area to be adapted for the driver.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Adds the stm32u5 flash controller driver for this serie
to the existing stm32l5 flash driver part
Only 1 or 2 MB devices exist today (4MB is possible in the future).
This flash controller driver is adapted from the flash_stm32l5.c

Signed-off-by: Francois Ramu <francois.ramu@st.com>
redefine all the stm32 flash register bit Name from
FLASH_NSCR_xxx to FLASH_STM32_FLASH_NSCR_xxx
in all the zephyr drivers.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit adds a flash_controller node for the stm32u5 soc family
blocks of 8K and erase time given by the Datasheet (with margin).

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Enables the flash controller node for the stm32u585 disco kit
with an arbitrary definition of the board partitions
to fill the 1MB bank1 of the flash memory,
for the secure and non-secure targets.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Comment on lines 57 to 60
#define FLASH_NSCR_NSLOCK FLASH_NSCR_LOCK
#define FLASH_OPTR_DBANK FLASH_OPTR_DUALBANK
#define FLASH_NSCR_NSPG FLASH_NSCR_PG
#define FLASH_NSCR_NSBKER_Msk FLASH_NSCR_BKER_Msk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole part should ideally be moved into initial commit "drivers: flash stm32 flash driver includes stm32u5 serie".
But I agree this require a full rework of the PR, so ok to keep it that way.

@mbolivar-nordic
Copy link
Contributor

Merging since @nvlsianpu is on leave

@mbolivar-nordic mbolivar-nordic merged commit 03231fb into zephyrproject-rtos:main Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Boards area: Devicetree area: Flash area: Tests Issues related to a particular existing or missing test platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to build mcuboot for b_u585i_iot02a
4 participants