Commit graph

22 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
Peter A. Bigot
e3ba01ec76 subsys/storage/flash_map: detect missing flash device
If the flash device is not configured, return an error rather than
dereferencing a null device pointer.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-24 09:20:56 -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
Anas Nashif
83508a5677 cleanup: include/: move flash_map.h to storage/flash_map.h
move flash_map.h to storage/flash_map.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
Radoslaw Koppel
3fd417a1c9 subsys/storage/flash_map: Fix returned error codes
Fix that removes magic numbers from the code that
leaded to the error codes that was hard to explain.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2019-05-24 11:13:41 +02:00
Anas Nashif
1e5d02fcd2 flash_map: add function to iterate over areas
A new foreach iterator to go over all flash areas in a flash map.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-19 13:41:02 -05:00
Andrzej Puzdrowski
3fe98838c9 storage/flash_map: API for get driver belongs to the flash_area.
Introduce API for get driver structure belongs to the flash_area.

Some more complex operation on flash areas might want to be done using
driver directly. It not make sense to wrap every possible flash related
operation by flash_map API.

For instance mcuboot will require this patch.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-03-19 17:11:52 +01:00
Marti Bolivar
8bf2a4c246 storage: flash_map: fix copyright assignment
Zephyr's flash_map code is largely copied wholesale from MCUboot, but
the copyrights were done incorrectly when the copy/pasting happened.

The current copyright holders are listed as Nordic and Runtime. This
is the patch which removed it from MCUboot; there is no copyright
holder explicitly named:

b788c71c08 (diff-e4c0c184210793513328934f14840a4c)

In fact, I was the author of a nontrivial portion of it, introduced
here:

dc4c42bf62 (diff-e4c0c184210793513328934f14840a4c)

At the time, I was working for Linaro, so add their copyright to the
copy of this file introduced into Zephyr.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-11 20:40:47 -06:00
Findlay Feng
69c15f0ed1 dts: flash_map: Automatically generate of the list of flash area
This Patch add functionality for automatic generation of the flash map
using DTS description. Automatic generation allows to replace
C-hardcoded flash_map.

We generate a set of defines based on the index of a partiion:
	#define DT_FLASH_AREA_<IDX>_OFFSET	0
	#define DT_FLASH_AREA_<IDX>_SIZE	131072
	#define DT_FLASH_AREA_<IDX>_DEV		"FLASH_CTRL"
	#define DT_FLASH_AREA_<IDX>_LABEL	MCUBOOT

Additionally we also define:
	#define DT_FLASH_AREA_NUM		4

and:
	#define DT_FLASH_AREA_<PARTNAME>_ID	0

Signed-off-by: Findlay Feng <i@fengch.me>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-07 10:31:27 -06:00
Rajavardhan Gundi
75f6f1b279 drivers: flash: spi_nor: Enable Flash Page Layout and Map
This patch enables the support for FLASH_PAGE_LAYOUT and
FLASH_MAP for the generic spin nor flash driver.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-01-16 21:22:56 -05:00
Patrik Flykt
b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Rajavardhan Gundi
4e8e0748e8 storage: flash_map: Make flash_map as extern
flash_map should be made extern in flash_map.c since it is defined
in flash_map_default.c. Not having flash_map as extern will result
in build errors.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-11-20 11:15:16 +01:00
Andrzej Głąbek
20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Andrzej Puzdrowski
5df93af87a subsys: storage: flash_map: add API for check flash driver support
Some applications might want to check whether flash_areas binds to
any flash drive in the system. It might be better to do that while
sanity check at application start-up then while regular run process.
Example of such application is the mcuboot.

This patch introduce such API for checking whether device bindings
were resolved properly during system startup.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-09-27 16:24:21 +02:00
Andrzej Puzdrowski
51527e07ef subsys: storage: flash_map: Fix Coverity issues
Loop counter was type of signed int while it was compared
to unsigned lvalue in loop condition.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-03-08 10:18:57 +01:00
Christopher Collins
821dc37f3f subsys: storage: flash_map: Fix warning
Prior to this commit, `flash_area_layout()` was being passed a pointer
to the incorrect type (`uint32_t *` where `int *` was expected).  This
caused the following warning to be reported:

```
[...]/subsys/storage/flash_map/flash_map.c: In
function 'flash_area_get_sectors':
[...]/subsys/storage/flash_map/flash_map.c:191:32:
warning: passing argument 2 of 'flash_area_layout' from incompatible
pointer type [-Wincompatible-pointer-types]
  return flash_area_layout(idx, cnt, ret, get_sectors_cb, &data);
                                ^~~
[...]/subsys/storage/flash_map/flash_map.c:136:12:
note: expected 'int *' but argument is of type 'uint32_t * {aka long
unsigned int *}'
 static int flash_area_layout(int idx, int *cnt, void *ret,
            ^~~~~~~~~~~~~~~~~
```

This commit changes the argument type to `u32_t` for both functions.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-14 14:36:52 -05:00
Christopher Collins
aa8850b42a subsys: storage: flash_map - Use correct macro
Prior to this commit, the old `FLASH_DRIVER_NAME` macro was being used
in the definition of the flash drivers array.  This caused the array to
have a size of 0.

This commit changes the code to use the newer `FLASH_DEV_NAME` macro,
causing the configured flash device to be present in the table.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-08 23:29:23 -05:00
Christopher Collins
ffc90dd496 subsys: storage: flash_map - Remove some code duplication
This patch cleans up flash_map code.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-07 09:51:26 -05:00
Christopher Collins
ffef30d39a storage: flash_map - Fix typo
get_flah_dev_from_id --> get_flash_dev_from_id

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-07 09:51:26 -05:00
Erwan Gouriou
c734c2972f flash: remove obsolete FLASH_DRIVER_NAME
Replace seldom occurrences of FLASH_DRIVER_NAME by equivalent
and commonly used FLASH_DEV_NAME.

Fixes #5919.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-02-06 11:48:53 -06:00
Andrzej Puzdrowski
f8a674b45e subsys: storage: flash_map: devices bindings fetch optimalization
Moved fetch of flash device bindings to early initialization of the
application.
Device bindings are constant while the application is running so
it is better to fetch it at startup, and not every time flash_map
procedures are called.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Andrzej Puzdrowski
25269fb0ed subsys: storage: Add flash_map abstraction module
Introduce flas_map module is abstraction over flash memory and its
driver for using flash memories along with description of
available flash areas.
Module provides simple API for write/read/erase and so one.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00