Commit graph

18 commits

Author SHA1 Message Date
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
Kumar Gala 613dba7fac drivers: flash: stm32: Convert to new DT macros
Replace DT_FLASH_SIZE with new DT_REG_SIZE macro.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 06:22:40 -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
Erwan Gouriou 0381e8cbe9 drivers/flash: stm32l4: Handle pages_per_bank for all variants
Variable pages_per_bank has been introduced to ease page erase
in dual bank configurations. This has been implemented using
FLASH_OPTR_DUALBANK definition.
It happen that this was not taking into account L4+ series that
use FLASH_OPTR_DBANK instead of FLASH_OPTR_DUALBANK. This lead
to compilation issue for this driver in case of L4+ series.
So, this patch is adding the support of FLASH_OPTR_DBANK definition.

Besides, FLASH_OPTR_DUALBANK (as FLASH_OPTR_DBANK) are actually
defining availability of an option byte to configure use of Dual
Bank. So besides of its definition, its value in flash OPTR register
should be checked to ensure Dual Bank configuration is used.
This patch is taking this into account by adding the check of this
byte. Error -ENOTSUP is returned in case Single Bank is configured
since it has not be validated yet (in case Dual Bank is possible but
not configured).

Fixes #18246 for nucleo_l4r5zi

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-08-17 20:05:21 +02:00
Ioannis Konstantelias 4fffe790be drivers: flash: stm32l4x: Support SOCs with < 1MB
Up to now, the only SOC that was supported in the STM32L496 series was
STM32L496XG with flash of 1MB. With the recent support of STM32L496XE,
this implementation is not correct. This patch adds support for the
other SOCs that come with flashes of 512KB and 256KB.

Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
2019-07-29 09:53:58 -04:00
Anas Nashif fe051a9055 cleanup: include/: move flash.h to drivers/flash.h
move flash.h to drivers/flash.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Florian Vaussard 2320973fea flash: stm32l4: disable dcache before writting
Disable the data cache before writing to Flash, in order to workaround
silicon errata 2.2.3: "Data cache might be corrupted during Flash memory
read-while-write operation". The data cache is conditionally re-enabled
once the write is completed.

This silicon bug has been encountered while stress testing the
implementation. Here are the events leading to the fault:
- Code is executing from Flash bank 1
- A write to Flash bank 2 is initiated
- The Cortex SysTick interrupt fires while waiting for Flash write
  completion

In that case, the Flash controller will perform a read-while-write
operation in order to execute the ISR code. As the data cache is enabled
by default after reset, a corruption occurs due to the silicon bug,
leading to bizarre data bus faults or unaligned access faults inside
_timer_int_handler() or one of the functions called by the ISR.

Applying the workaround devised by ST fixes the problem.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2019-03-19 09:56:01 -05:00
Erwan Gouriou 652efa530f drivers/flash: stm32l4: Prepare for unaligned accesses in flash writes
On STM32L4, flash writes operations are performed 8 bytes at a time.
Though, it is possible that *data in flash_write functions is not
aligned. To avoid issues, use UNALIGNED_GET macro to access *data.

Issue has been detected using settings subsystem on STM32WB, which has
same 8bytes write block size. The patch is extended to STM32L4 series
for same reason.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-03-15 06:43:24 -05:00
Anas Nashif ffb75da2ea drivers: flash: move to new logger
Move drivers to new logger and change samples enabling logging in
prj.conf.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 10:22:01 -04:00
Pushpal Sidhu 5bc5bb2c7f flash: stm32l4x: Correct getting page number from STM32L4R/S devices
These devices increase the page size from 2k (standard STM32L4) to 4K,
so we must account for this.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2018-10-08 12:52:00 -04:00
Neil Armstrong 958acd1b4e flash: stm32l4x: fix build
Fix build since current file directly is no more in the include path.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-12-04 10:53:12 -06:00
Marti Bolivar c0672938da flash: stm32: stm32l4: add page layout support
L4 parts have a constant page size, so just rely on the HAL defines
that provide it, along with a read to the register which contains this
SoC's total size.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-09-11 11:41:57 -04:00
Marti Bolivar 4fea6dfe76 flash: stm32: clean up L4/F4 internal API
This is a prep work commit for adding flash page layout support.

The internal flash APIs for STM32 on L4 and F4 are a bit
inconsistent. Some routines take a pointer to the private data, others
don't. Those that do take it as a last argument instead of a
first. Additionally, some APIs are declared in flash_stm32.h that
aren't ever used by the family-specific files.

Clean this up by making everything take a struct device*, and marking
routines static in the common driver code when possible.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-09-11 11:41:57 -04:00
Kumar Gala 4b82e2bc75 flash: stm32l4x: Cleanup use of C99 types
We introduced some see C99 types, so convert them over to the Zephyr
types.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-06-22 13:47:28 -04:00
Michel Jaouen e9153979f0 flash: stm32: distinguish read/write for flash range valid
L4 write access requires 64 bits alignment
while L4 read access does not require any alignment.
To support specific check according to read/write,erase
a parameter is added to stm32_valid_range.

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-06-16 16:18:12 -04:00
Michel Jaouen 8ba73a79b3 flash: stm32: fix for l4 writing wrong data
L4 have 64 bits write access.
The cast to 64 bits data address in write_dword
requires 3 right shifts on i (byte index) else the
data taken are wrong for i different from 0

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-06-16 16:18:12 -04:00
Neil Armstrong a9183cd518 flash: Rework and add flash device support for STM32L4x SoCs
The STM32L4x SoCs embeds a slightly different embedded flash controller
from the STM32F4x SoCs.

This particular controller has the following properties :
 - Up to 2 512KiB banks divided in 2KiB pages
 - Flash can be accessed in any sizes
 - Flash must be written in 64bit aligned 64bit double-words

The drivers/flash/flash_stm32f4x.c is refactored into a new common
drivers/flash/flash_stm32.c and drivers/flash/flash_stm32l4x.c is
created with the STM32L4x specific functions.

To ease the refactoring and keep common functions, the STM32L4x flash
headers are slightly modified to match the hardware reference naming
and solve compilation issues.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-19 10:06:48 -04:00