Commit graph

22 commits

Author SHA1 Message Date
Francois Ramu 7795558ad5 drivers: flash: stm32 flash base address from the DTS node
For the flash driver, the base address is the MCU internal flash
address (usually 0x8000000). This PR gets the that address
from the device tree node "st,stm32-nv-flash"
instead of relying on the CONFIG_FLASH_BASE_ADDRESS
which might differ when building for another flash memory.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-01-29 14:12:47 -06:00
Adam Mitchell df1897c122 drivers: flash: Add RDP (readout protection) support for STM32G4x flash
Add support for Flash readout protection on the STM32G4x series
Signed-off-by: Adam Mitchell <adam.mitchell@brillpower.com>
2023-10-27 12:31:41 +02:00
Florian Vaussard 8bac51be1e drivers: flash: stm32: add a weak flash_stm32_valid_range()
Most implementations have the same logic, with only a different write
block size. Now that we are using write-block-size from the device tree,
it is possible to use a default implementation that can be overridden if
necessary.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2023-07-28 09:02:17 +00:00
Cyril Fougeray 9bc639dd59 drivers: flash: stm32: allow to overwrite zeros
On stm32g0, stm32g4, stm32l4, stm32l5, stm32u5,
and stm32wbx, it is allowed to write a zeroed dword
on unerased flash.

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2022-10-17 10:14:32 +02:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Francois Ramu bf49a04dcf drivers: flash: stm32 definition of all registered bitfield
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>
2022-04-13 13:55:34 -07:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Alexandre Bourdiol 5e11fbfbe1 drivers: flash: stm32g4: implement data cache errata
Disable data cache to avoid the silicon errata ES0430 Rev 7 2.2.2
"Data cache might be corrupted during Flash memory read-while-write
operation"

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-06-28 14:17:40 -04:00
Andrzej Puzdrowski 6acc4a2521 drivers/flash/flash_stm32g4x: fixed build issue
This driver file couldn't be compiled due the syntax error.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-03-29 13:43:55 -04:00
Flavio Ceolin 169144afa1 drivers: flash: Fix variable type
erase_page returns a negative value in case of error. We should
not use an unsigned type.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-26 07:13:13 -04:00
Alexander Wachter 09fea5cc5e drivers: flash: stm32g4: Flush caches after erase
This commit fixes sporadic kernel panics when writing big data chunks
to the flash. (data bus errors)
Reference manual:
If an erase operation in Flash memory also concerns data in the data
or instruction cache, you have to make sure that these data are
rewritten before they are accessed during code execution.
If this cannot be done safely, it is recommended to flush the caches
by setting the DCRST and ICRST bits in the Flash access control
register (FLASH_ACR).

Signed-off-by: Alexander Wachter <alexander.wachter@leica-geosystems.com>
2021-02-11 13:55:35 -05:00
Martin Jäger 6181184163 drivers: flash: stm32g4x: fix LOG_ERR compiler warning
off_t can be 32-bit or 64-bit depending on the platform. STM32 flash
addresses are always 32-bit so it's safe to use long here.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-12-20 12:40:19 -05:00
Martin Jäger b0db87193e drivers: flash: stm32g4x: Fix include for dual bank
The LL header include was missing for the functions used for STM32G474
MCUs with dual bank feature.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-12-10 16:21:35 -06:00
Alexandre Bourdiol 522cda3f7d divers: flash: flash_stm32: add flash configuration check
Add weak function to check flash configuration.
On stm32g4: single bank configuration not supported
when dual bank capable.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Alexandre Bourdiol 7f62a92917 drivers: flash: flash_stm32g4x.c: take into account bank swap
When erasing flash page, take into account a potential bank swap.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Alexandre Bourdiol 496e2cab3d drivers: flash: flash_stm32g4x.c: rework flash_stm32_block_erase_loop
Remove hardcode bank1 page limit (128) which is not always valid
(not valid for soc stm32g474rct)
Manage bank1/2 discontinuity when flash is Dualbank and
flash size is lower than 512K.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Alexandre Bourdiol a993601179 drivers: flash: flash_stm32g4x.c: manage bank1/2 discontinuity
When flash is Dualbank and flash size is lower than 512K,
then there is a discontinuity between bank1 and bank2.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-12-10 13:00:04 +01:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Alexander Wachter 802552414c drivers: flash: stm32g4: Fix erase on wrong bank
In the default configuration of the stm32g4 is the dual bank mode.
In dual bank mode, the flash is split into two banks with 256k each.
The erase pages have a range form 0 to 127, where each page has 2k.
If one wants to erase an area above 256k, the driver has to switch
to bank 2 befor erasing. Otherwise it will erase the page moulo 127.

Signed-off-by: Alexander Wachter <alexander.wacher@leica-geosystems.com>
2020-03-24 14:25:47 -05:00
Sarvesh Patkar 4f2c107389 drivers: flash: stm32: Update flash driver implementation
Remove soc/arm/st_stm32/stm32YY/flash_registers.h files.
Change register accesses in stm32 flash drivers to use FLASH_TypeDef
from modules/hal/stm32/stm32cube/stm32YYxx/soc/stm32xxxxxx.h.

Fixes #16235

Signed-off-by: Sarvesh Patkar <psarvesh314@gmail.com>
2020-01-28 15:30:12 -06:00
Richard Osterloh c68e027c28 drivers: flash: Add STM32G4X flash support
Add flash driver support for STM32G4X SoC series.

Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
2019-10-04 18:44:24 -07:00