Commit graph

164 commits

Author SHA1 Message Date
Angus Gratton
4d50427e87 Merge branch 'feature/nvs_util_backport' into 'master'
nvs_util: Add changes for utility to support old and new multipage blob

See merge request idf/esp-idf!3270
2018-09-24 11:53:29 +08:00
Shivani Tipnis
ca3acef82c nvs_util: Add support for old and new multipage blob 2018-09-19 22:00:08 +05:30
Roland Dobai
7183112cc4 nvs_flash: fix division for Python 2 & 3 2018-09-17 16:01:54 +02:00
Renz Christian Bagaporo
d9939cedd9 cmake: make main a component again 2018-09-11 09:44:12 +08:00
Angus Gratton
cff2ef695a Merge branch 'master' into feature/cmake 2018-09-06 20:23:04 +08:00
Sagar Bijwe
db7c257f33 nvs_flash: Minor changes to NVS documentation
1) Change API doc to reflect new limits on string and blob length.
2) Add "version" field to Page Header structure in README.

Fixes: https://github.com/espressif/esp-idf/issues/2321
2018-09-04 18:51:31 +05:30
Angus Gratton
a9c4ed7139 Merge branch 'master' into feature/cmake 2018-08-30 18:51:01 +08:00
Sagar Bijwe
911f96ad21 nvs_flash: Fix nvs_set_blob hang when partition is near to FULL
Marking a page full does not skip it from page selection process and the
same page might get returned if there is no other page with more unused
entries. Added a check for the same while storing blobs.

Fixes: https://github.com/espressif/esp-idf/issues/2313
2018-08-21 17:08:46 +05:30
Angus Gratton
3012b0f887 Merge branch 'feature/nvs_multi_page_util' into 'master'
Bugfix: multi page blob creation was failing if only one entry was left in page

See merge request idf/esp-idf!2971
2018-08-16 15:23:11 +08:00
Angus Gratton
ff2404a272 Merge branch 'master' into feature/cmake 2018-08-16 17:14:17 +10:00
Shivani Tipnis
dfde105f25 Add support for input custom partition size 2018-08-16 11:54:46 +05:30
Shivani Tipnis
5ce40fce0c Add nvs part gen utility multi page blob support update 2018-08-16 11:46:25 +05:30
Ivan Grokhotkov
5fc6397589 nvs: fix memory leak when writing a blob
Introduced in 5a27a63.
Clear usedPages list in all exit conditions, add test.
2018-08-09 10:35:19 +03:00
Sagar Bijwe
1df85e0039 nvs_flash: Version compatibility check for nvs storage
This change adds a check for compatibility between the nvs version
found on nvs flash and the one assumed by running code during nvs
initialization. Any mismatch is reported to the user using new error
code ESP_ERR_NVS_NEW_VERSION_FOUND.
2018-08-05 00:00:56 +00:00
Sagar Bijwe
8ef7a49cc3 nvs_flash: Bump up nvs version 2018-08-05 00:00:56 +00:00
Sagar Bijwe
5a27a63541 nvs-flash: Support for blobs larger than half of SPI Flash sector size
This change removes the earlier limitation of 1984 bytes for storing data-blobs.
Blobs larger than the sector size are split and stored on multiple sectors.
For this purpose, two new datatypes (multi-page index and multi-page data) are
added for entries stored in the sectors. The underlying read, write, erase and find
operations are modified to support these large blobs. The change is transparent
to users of the library and no special APIs need to be used to store these large
blobs.
2018-07-20 00:13:15 +05:30
Piyush Shah
e7ddd47716 nvs_partition_generator: Add support for base64 representation of Binary data 2018-07-02 15:40:21 +05:30
Piyush Shah
8369bd244b nvs_partition_generator: Modifications to enable using the utility as a Python library
And also use directly as an executable
2018-07-02 15:39:52 +05:30
Ivan Grokhotkov
d9f8311b9d docs: add error codes reference 2018-06-15 15:49:24 +08:00
Paul Reimer
c83c3b64cd Add declarations of private nvs functions (nvs_*) in nvs_flash component to fix C++ -Wmissing-declarations warning
Merges https://github.com/espressif/esp-idf/pull/1956
2018-06-04 16:36:44 +10:00
Roland Dobai
07acbb5664 ESP_ERROR_CHECK converts error code to text
If CONFIG_ESP_ERR_TO_NAME_LOOKUP is enabled, ESP_ERROR_CHECK
prints error message in addition to the error code.
2018-05-31 12:53:37 +02:00
Angus Gratton
6b9784cc45 Merge branch 'master' into feature/cmake_update 2018-05-31 14:46:23 +10:00
Ivan Grokhotkov
cb649e452f remove executable permission from source files 2018-05-29 20:07:45 +08:00
Angus Gratton
3d92c6cccd nvs README: Remove section about encryption capability 2018-05-15 18:02:28 +08:00
Ivan Grokhotkov
73ec743a0a Merge branch 'bugfix/nvs_page_compaction' into 'master'
nvs: Fix recovery from power-off while page is being freed

See merge request idf/esp-idf!2327
2018-05-07 09:08:23 +08:00
Sagar Bijwe
7ae1df1c5e nvs: Fix recovery from power-off while page is being freed
Currently when page is being freed, items are individually moved from
FREEING page to ACTIVE page and erased. If power-off happens during the
process, the remaining entries are moved to ACTIVE page during recovery.
The problem with this approach is there may not be enough space on
ACTIVE page for all items if an item was partially written before
power-off and erased during recovery. This change moves all the items
from FREEING to ACTIVE page and then erased the FREEING page, If
power-off happens during the process, then ACTIVE page is erased and the
process is restarted.
2018-05-02 12:18:02 +05:30
Ivan Grokhotkov
5f956125c1 Merge branch 'feature/mfg_bin_create_utility' into 'master'
nvs_flash: Add external binary creation support for NVS partition.

See merge request idf/esp-idf!2031
2018-05-02 11:58:38 +08:00
Angus Gratton
1cb5712463 cmake: Add component dependency support
Components should set the COMPONENT_REQUIRES & COMPONENT_PRIVATE_REQUIRES variables to define their
requirements.
2018-04-30 09:59:20 +10:00
Angus Gratton
4f1a856dbf cmake: Remove defaults for COMPONENT_SRCDIRS, COMPONENT_SRCS, COMPONENT_ADD_INCLUDEDIRS
* Philosophical: "explicit is better than implicit".
* Practical: Allows useful errors if invalid directories given in components as the defaults aren't
  always used. Also trims the -I path from a number of components that have no actual include
  directory.
* Simplifies knowing which components will be header-only and which won't
2018-04-30 09:59:20 +10:00
Angus Gratton
c671a0c3eb build system: Initial cmake support, work in progress 2018-04-30 09:59:20 +10:00
Amit Sheth
aa357a32bc nvs_flash: Add binary creation support for NVS partition.
Ideally suited for generating a binary externally, containing key-value pairs specific
to device manufacturers. Utility allows creation of a binary, compatible
with NVS structure, which can be separately flashed onto a new
partition. This helps device manufacturers set different values for
different devices, e.g. serial numbers, but using a single firmaware
image.
2018-04-23 00:27:29 +05:30
Ivan Grokhotkov
6f504deed0 nvs: run all test by default, exclude long tests by tag
Reduces the chance of new tests being skipped in CI
2018-04-19 15:08:08 +08:00
Ivan Grokhotkov
f8cb95d0b8 nvs: print progress in nvs API tests, reduce number of iterations 2018-04-19 15:08:08 +08:00
Ivan Grokhotkov
17ab60d642 Merge branch 'bugfix/nvs_failed_crc_assert' into 'master'
nvs: don’t expect items with bad CRC to be in cache

See merge request idf/esp-idf!2239
2018-04-18 11:01:21 +08:00
Sagar Bijwe
9a3c4b7134 nvs: Fix recovery after power-off during erase operation
Current code for recovery after power-off do not clean-up partially
erased items for FULL pages. If the erasure was part of modification
operation, this gets luckily cleaned-up because of duplicate detection
logic. For erase-only operation, the problem still exists. This patch
adds the recovery for FULL pages also.

Closes TW<20284>
2018-04-17 12:24:21 +05:30
Konstantin Kondrashov
6a4033b8a7 nvs: fix nvs_get_stats unit test
Changed check for the returned parameter from ESP_ERR_NVS_PART_NOT_FOUND to ESP_ERR_NVS_NOT_INITIALIZED.
2018-04-16 13:28:45 +00:00
Ivan Grokhotkov
2c3644a09f nvs: don’t expect items with bad CRC to be in cache
When erasing a variable length item with an incorrect CRC32, the span
value of the item can not be trusted, so the item will be erased with
span = 1. Subsequent entries represent the data of the variable
length item, and these will be treated as separate items. For each
entry CRC32 is checked, the check most likely fails (because the
entry contains arbitrary data, and not a proper NVS item), and the
entry is erased. Erase function assumed that every item should be
present in cache, but it is not the case for the entries which are
just parts of item’s payload. This change allows for the item to be
not found in the hashlist, if the CRC32 check fails.
2018-04-16 09:36:17 +00:00
Ivan Grokhotkov
20405fbbcc nvs: make nvs_flash_deinit useable from unit tests 2018-04-16 14:06:52 +08:00
Ivan Grokhotkov
fa3bd16d75 nvs: deinit NVS in nvs_stats unit test
This fixes the failure when this test runs after another test which
leaves NVS initialized.
2018-04-16 12:50:57 +08:00
Ivan Grokhotkov
d0d314d8f8 Merge branch 'bugfix/nvs_page_selection' into 'master'
nvs: Fix page selection algo to consider free entry counts as well

See merge request idf/esp-idf!2240
2018-04-16 10:32:01 +08:00
Sagar Bijwe
7e79471ece nvs: Fix page selection algo to consider free entry counts as well
Current page selection algorithm selects a page for compaction based on just erased counts
and gives up when it does not find any page with erased count greater than 0. This is
problematic since the current allocation procedure skips the active page if there is not
enough room for the item in that page leaving free chunks on the pages. This change modifies
the algorithm to consider both erased as well as free counts on the candidate pages.

Closes TW<20297>
2018-04-13 14:49:05 +05:30
konstantin
c93626db3f nvs:Add functions for calculating used/free entries
Users needs functions to count the number of free and used entries.

1. `nvs_get_stats()` This function return structure of statistic about the uspace NVS.
(Struct: used_entries, free_entries, total_entries and namespace_count)
2. `nvs_get_used_entry_count()` The second function return amount of entries in the namespace (by handler)
3. Added unit tests.

Closes TW<12282>
2018-04-13 10:34:13 +05:00
Roman Valls Guimera
519edc332d Fix compilation errors when using gcc-7.2.0 for the crosstool-ng toolchain
* Change snprintf for strlcat does not complain w/gcc7.2.0 and it is safer, thanks @projectgus
* Use proper quotes for character literals

Merges https://github.com/espressif/esp-idf/pull/1163
2017-12-04 10:18:40 +11:00
Ivan Grokhotkov
ab13db0e45 nvs: fix nvs_flash_init_partition initializing default partition
Fixes https://github.com/espressif/esp-idf/issues/1052.

Ref TW15698.
2017-10-13 07:19:16 +08:00
Ivan Grokhotkov
9325f2a7a4 nvs_flash: emulator: fix issues in load function, add save function 2017-09-19 10:39:44 +08:00
Ivan Grokhotkov
fe30789149 nvs_flash: delete Storage if init fails
Previously, nvs_flash_init_custom would not be called if Storage for a
particular partition was already created. This caused issues if the
first call to nvs_flash_init failed due to Storage init error. This issue
exhibited itself as random failures of NVS CI test.

With this change, storage object is deleted (and not added to storage
list) if initialization fails.
2017-09-19 10:39:44 +08:00
Ivan Grokhotkov
f32b25ebe2 nvs_flash: add functions to deinitialize storage 2017-09-19 10:39:44 +08:00
Amey Inamdar
c8945bb82a nvs: minor - removed unused header inclusion
Signed-off-by: Amey Inamdar <amey.inamdar@gmail.com>
2017-09-18 17:02:32 +05:30
baohongde
87031f9457 component/bt: fix nvs_get_str_or_blob length output error 2017-09-08 12:02:35 +08:00
baohongde
e1bd51af80 component/bt: fix nvs_get_str_or_blob length output error 2017-09-08 12:02:35 +08:00
baohongde
f3be0395d2 component/bt: fix nvs_get_str_or_blob length output error 2017-09-08 12:02:35 +08:00
Ivan Grokhotkov
c0269bc1cd nvs: check CRC of items on full pages
Previously NVS did check CRC values of key-value pairs on the active
page, but the check for full pages was missing. This adds the necessary
check and a test for it.
2017-09-04 14:37:33 +08:00
Amey Inamdar
a2dcf7faa8 nvs: Support for handling multiple NVS partitions
This commit adds support for multiple NVS partitions. This provides application a flexibility to have multiple NVS
partitions such as separate partition with read-only manufacturing data and read-write partition with configuration.
Application can also use this to separate out application's configuration storage from system configuration.

This feature does not change any of the basic property of NVS subsystem. The same-named namespaces across partitions are
considered to be different namespaces. The original NVS API available for the applications remains unchanged. The only
difference is that instead of first NVS partition in the partition table, it now operates on the partition with label
"nvs" (which is default in the IDF provided partition table files). Additional APIs are provided to open a handle and
erase NVS with partition name as a parameter.

A test case is added in the host tests and it is made sure that all the host tests pass. nvs_rw_value app is also tested
with multiple partitions.

Signed-off-by: Amey Inamdar <amey.inamdar@gmail.com>
2017-08-22 13:48:14 +05:30
Amey Inamdar
3e4e4dd07a nvs_flash: Reduced visibility of handle counter
Monotonically increasing handle counter need not be visible outside the HandleEntry class.

Signed-off-by: Amey Inamdar <amey.inamdar@gmail.com>
2017-08-22 12:58:56 +05:30
Ivan Grokhotkov
979fce0df5 bt: call nvs_flash_init in examples, show error if NVS is not initialized
NVS is used to store PHY calibration data, WiFi configuration, and BT
configuration. Previously BT examples did not call nvs_flash_init,
relying on the fact that it is called during PHY init. However PHY init
did not handle possible NVS initialization errors.

This change moves PHY init procedure into the application, and adds
diagnostic messages to BT config management routines if NVS is not
initialized.
2017-07-17 21:29:50 +08:00
Ivan Grokhotkov
f045123691 nvs: add test for ESP_ERR_NVS_INVALID_LENGTH 2017-06-27 11:28:37 +08:00
Simon Werner
dacb053546 ESP_ERR_NVS_VALUE_TOO_LONG had conflicting value.
`ESP_ERR_NVS_VALUE_TOO_LONG` had conflicting value, its original value was `0x0c`, which is the same as `ESP_ERR_NVS_INVALID_LENGTH`
2017-06-27 11:58:49 +12:00
Ivan Grokhotkov
a25a4a0a7c nvs: check value size before writing, document limitations
Writing values longer than half of the page size (with header taken into
account) causes fragmentation issues. Previously it was suggested on the
forum that using long values may cause issues, but this wasn’t checked
in the library itself, and wasn’t documented. This change adds necessary
checks and introduces the new error code.

Documentation is also fixed to reflect the fact that the maximum length
of the key is 15 characters, not 16.
2017-05-31 12:59:24 +08:00
Ivan Grokhotkov
bf01525fc1 nvs: remove search cache at page level
Since read cache was introduced at page level, search cache became
useless in terms of reducing the number of flash read operations.
In addition to that, search cache used an assumption that if pointers to
keys are identical, the keys are also identical, which was proven wrong
by applications which generate key names dynamically.

This change removes CachedFindInfo, and all its uses. This is done at
expense of a small extra number of CPU operations (looking up a value in
the read cache is slightly more expensive) but no extra flash read
operations.

Ref TW12505
Ref https://github.com/espressif/arduino-esp32/issues/365
2017-05-12 12:18:08 +08:00
Ivan Grokhotkov
8f76fe1d7f move Catch framework header into tools directory 2017-04-17 11:01:18 +08:00
Ivan Grokhotkov
57e380fa99 nvs_flash, wear_levelling: ignore host test files 2017-04-17 11:01:18 +08:00
Ivan Grokhotkov
447ffb23d5 nvs: print page state as text in nvs_dump 2017-03-15 17:28:07 +08:00
Ivan Grokhotkov
4813ab2d28 examples: check return value of nvs_flash_init
nvs_flash_init may return an error code in some cases, and applications
should check this error code (or at least assert on it being ESP_OK, to
make potential issues more immediately obvious).

This change modifies all the examples which use NVS to check the error
code. Most examples get a simple ESP_ERROR_CHECK assert, while NVS
examples, OTA example, and NVS unit tests get a more verbose check which
may be used in real applications.
2017-03-15 10:44:54 +08:00
Ivan Grokhotkov
5a23ec4dc4 nvs: check that storage has at least one free page
This change adds a check for the free page count to nvs_flash_init.
Under normal operation, NVS keeps at least one free page available,
except for transient states such as freeing up new page. Due to external
factors (such as NVS partition size reduction) this free page could be
lost, making NVS operation impossible. Previously this would cause an
error when performing any nvs_set operation or opening a new namespace.
With this change, an error is returned from nvs_flash_init to indicate
that NVS partition is in such a state.
2017-03-14 22:03:39 +08:00
Ivan Grokhotkov
817bbb4bf9 nvs: add missing error code descriptions 2017-03-14 22:03:39 +08:00
Angus Gratton
d6f183fbb9 esp_err: Use separate code path for ESP_ERROR_CHECK assertion
* Minimum code size overhead
* Makes function safe to use when flash cache is disabled

Builds on #339 https://github.com/espressif/esp-idf/pull/339
2017-03-03 15:33:23 +11:00
Ivan Grokhotkov
c47cc63489 newlib: change definition of assert for release builds
One common pattern of using assert function looks as follows:
    int ret = do_foo();
    assert(ret == 0);   // which reads as: “do_foo should never fail here, by design”
The problem with such code is that if ‘assert’ is removed by the preprocessor in release build,
variable ret is no longer used, and the compiler issues a warning about this.
Changing assert definition in the way done here make the variable used, from language syntax perspective.
Semantically, the variable is still unused at run time (as sizeof can be evaluated at compile time), so the compiler
can optimize things away if possible.
2017-01-17 00:49:38 +08:00
antti
83a3ce882f add updated nvs flash test 2016-11-23 11:29:36 +08:00
antti
d390449371 add unit tests to esp-idf
rename nvs host test folder, modify .gitlab-ci.yml

remove unit-test-app build

re-format unit test files

remove extra newlines in project.mk

some refactoring for unit test part in project.mk

add build files of unit-test-app in gitignore

add README.md for unit test app

correct headings in README.md

remove files and make minor tweaks in unit test app

update .gitlab-ci.yml to use unit test app

delete unused lines in component_wrapper.mk

delete periph_i2s.h and lcd test

add text floating point in components/esp32/test/Kconfig

correct idf test build paths in .gitlab-ci.yml
2016-11-22 14:45:50 +08:00
Ivan Grokhotkov
0b265dc2a7 nvs, spi_flash: handle case when source data is in DROM 2016-11-18 20:11:17 +08:00
Ivan Grokhotkov
541b142654 phy_init: reduce the amount of hardwired logic, add coexist init 2016-11-18 20:11:17 +08:00
Ivan Grokhotkov
6e97936bac nvs: allow nvs_flash_init to be called more than once
Also don’t assert in nvs_* functions if nvs_flash_init wasn’t called,
and make nvs_flash_init_custom an internal API for unit tests.
2016-11-18 20:11:16 +08:00
Ivan Grokhotkov
51021b06f8 nvs: initialize using layout from partition table 2016-11-18 20:11:16 +08:00
Ivan Grokhotkov
3bbe41c34d Merge branch 'feature/docs_general_notes' into 'master'
Docs: new documentation and warnings cleanup

This change set

- adds a high-level description of application startup flow. Some parts are missing, but hopefully we can use this description as a base to expand on.
- adds a few notes about memory regions and their use in ESP-IDF.
- add SPI flash and partition APIs page
- fixes all Doxygen warnings in header files
- enables build failures on new Doxygen warnings

See merge request !201
2016-11-17 19:00:03 +08:00
Liu Zhi Fu
936b02216b docs/nvs_flash: update the nvs flash offset comment according review 2016-11-17 11:44:39 +08:00
Liu Zhi Fu
f12be7ebd8 nvs_flash: adjust the nvs_flash start sector number
Modify the nvs flash start sector from 6 to 9
2016-11-17 11:22:20 +08:00
Ivan Grokhotkov
13d4734399 docs: fix Doxygen warnings, fail CI build on Doxygen warnings 2016-11-16 22:44:22 +08:00
Angus Gratton
c15024e629 Merge branch 'master' into feature/build_component_project_vars 2016-11-14 14:54:41 +11:00
Angus Gratton
208e83def7 build system: Refactor component.mk to not need component_common.mk
New makefile component_wrapper.mk allows some variables to be set
before component.mk is evaluated. This properly fixes problems with
sdkconfig being hard to access in all phases of the build.

Including component_common.mk is no longer necessary and will print a
deprecation warning for components which use it.
2016-11-10 15:52:22 +11:00
Ivan Grokhotkov
e314f42b0c nvs: fix Page::findItem and Storage::findItem regression
When read caching was added, Page::findItem started modifying itemIndex reference argument even if item wasn't found.
Incidentally, Storage::findItem reused itemIndex when starting search at next page.
So,
- if the first page had a cached index (findItem was called for that page), and it pointed to a non-zero index,
- first page has a few empty items at the end (but is marked full),
- next search looked up the item on the second page,
- index of the item on the second page was less than the cached index on the first page,
then the search would fail because cached starting index was reused.

This change fixes both sides of the problem:
- Page::findItem shouldn't modify itemIndex argument if item is not found
- Storage::findItem should not reuse itemIndex between pages

Two tests have been added.
2016-11-03 20:18:30 +08:00
Ivan Grokhotkov
b8e940d645 Merge branch 'bugfix/nvs_write_failure' into 'master'
Fix spi_flash_write regression and nvs error recovery

In the previous set of changes related to spi_flash, new alignment checks were added. One of these checks, word alignment of `src` buffer in `nvs_flas_write`, was unnecessary.  ROM `SPIWrite` function can handle unaligned source buffers.

This change caused an error to be returned to nvs for some legitimate write operations. Due to a bug in nvs, further write operations were possible, while the internal state of `Page` instance was broken. In WiFi functional tests, this inflicted havoc on the nvs partition, creating multiple duplicate items in the affected page. Because multiple duplicate items per page were never supposed to be handled during page load, duplicates were not removed. Thankfully this caused an assert at a later point in the loading process, otherwise this bug would be very difficult to detect.

This change set fixes the original spi_flash regression, handling of `INVALID` state of `nvs::Page`, and handling of duplicate items.

See merge request !161
2016-11-01 22:26:37 +08:00
Krzysztof
12efd96fb4 Corrected documentation style
This is for better visuaization with Sphinx
2016-11-01 01:21:18 +08:00
Krzysztof
fa002b4909 Fixed headers to match python doc standard 2016-11-01 01:20:04 +08:00
Krzysztof
1263cd340e Add missing annotations 2016-11-01 01:20:04 +08:00
Ivan Grokhotkov
abea6c50f1 nvs_flash: delete all duplicate entries in a page while loading
Due to previous flash write bug it was possible to create multiple duplicate entries in a single page.
Recovery logic detected that case and bailed out with an assert.
This change adds graceful recovery from this condition.
Tests included.
2016-10-31 21:10:47 +08:00
Ivan Grokhotkov
d9cdc7de58 nvs_flash: don't allow more operation to be done on page in PageState::INVALID
Currently a restart is required to recover a page from invalid state.
The long-term solution is to detect such a condition and recover automatically (without a restart). This will be implemented in a separate change set.
2016-10-31 19:48:28 +08:00
Ivan Grokhotkov
413f2c00f6 nvs_flash: introduce write failures after each word written
Previously the test bench would check failure recovery by introducing error after each write operation.
This makes checks a bit more extensive (and much longer) by failing after every word written. Surprisingly, this change didn't expose any bugs.
2016-10-31 19:17:25 +08:00
Ivan Grokhotkov
269332f473 nvs_flash: use CRC-32 routine compatible with ROM version
Host tests used different flavour of CRC-32, which made it impossible to load NVS partition dumps created on the chip
2016-10-31 19:11:40 +08:00
Ivan Grokhotkov
e34fc7a46c Merge branch 'bugfix/nvs_leaks' into 'master'
nvs: fix memory leaks in HashList and nvs_close

Fixes TW8162.
Associated test case is run under Instruments on macOS, until I set up valgrind to test this automatically on Linux.

See merge request !150
2016-10-31 17:30:00 +08:00
Ivan Grokhotkov
9f0f05d520 spi_flash: change pointer type to void* 2016-10-27 17:58:42 +08:00
Ivan Grokhotkov
2c5340d47e spi_flash: change argument types
spi_flash_read and spi_flash_write currently have a limitation that source and destination must be word-aligned.
This can be fixed by adding code paths for various unaligned scenarios, but function signatures also need to be adjusted.
As a first step (since we are pre-1.0 and can still change function signatures) alignment checks are added, and pointer types are relaxed to uint8_t.
Later we will add handling of unaligned operations.
This change also introduces spi_flash_erase_range and spi_flash_get_chip_size functions.

We probably need something like spi_flash_chip_size_detect which will detect actual chip size.
This is to allow single application binary to be used on a variety of boards and modules.
2016-10-27 17:58:42 +08:00
Ivan Grokhotkov
74a658c765 nvs: fix memory leaks in HashList and nvs_close
Fixes TW8162.
Associated test case is run under Instruments on macOS, until I set up valgrind to test this automatically on Linux.
2016-10-26 12:25:53 +08:00
Ivan Grokhotkov
1cd572c7b9 Add test for compiling in release mode, fix warnings and errors which appeared 2016-10-17 13:40:10 +08:00
Angus Gratton
a98ab8d801 nvs: Remove flash layout arguments from nvs_init()
Add notes that current NVS layout defaults are a Work In Progress and
not yet integrated with the partition table.
2016-09-27 13:28:45 +10:00
Ivan Grokhotkov
6f2ed934d2 components/nvs: fix broken sentences in comment blocks 2016-09-26 12:41:04 +08:00
Ivan Grokhotkov
1c7508885c components/nvs: fix build, use log library instead of printf 2016-09-23 09:00:28 +08:00
Ivan Grokhotkov
2a68f60874 components/nvs: add erase function
This change exposes functions to erase single key and to erase all keys from namespace.
TW6769, TW6839
2016-09-23 08:08:03 +08:00
Ivan Grokhotkov
e87d80d478 components/nvs: fix formatting 2016-09-22 21:05:47 +08:00
Ivan Grokhotkov
076141aab9 components/nvs: batch writes when possible
Introduces new internal function, Page::alterEntryRangeState, which gathers changes to multiple elements of entry state table into a single write, provided that these changes fall into a single word. This allows changing state of up to 16 entries in a single write.
Also adds new function, writeEntryData, which writes the whole payload of SZ and BLOB type entries in one go, instead of splitting it into multiple 32-byte writes.
This reduces number of writes required for SZ and BLOB entries.
2016-09-22 21:05:17 +08:00
Ivan Grokhotkov
12a0786e2a components/nvs: maintain item hash list at page level 2016-09-21 18:02:52 +08:00