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

cfg_page: provide/manage of configuration variables in flash #17092

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e4fc877
shell comments for cfg_page
mcr Oct 14, 2021
e568eb1
initial work on cfg_page
mcr Oct 14, 2021
ce6855e
added CFG_PAGE options to native board
mcr Oct 14, 2021
f317b3d
return serialno from cfg_page_validate, and remove debugging, fix int…
mcr Oct 18, 2021
f17368e
added cfg_page_format to initialize the new pages
mcr Oct 20, 2021
2e11c11
moved slot selection code out of tester, into cfg_page_init
mcr Oct 20, 2021
6f16a3b
changed struct cfg_page_desc_t to typedef
mcr Oct 20, 2021
23495ee
test case exits when done to permit shell script driven tests
mcr Oct 20, 2021
4b6ea52
added two more test cases, document test1
mcr Oct 20, 2021
d308f5d
re-intend with RIOT style: bsd w/4-spaces
mcr Oct 20, 2021
ff74bc7
added debug of crc value
mcr Oct 20, 2021
002a34d
when initializing, make sure entire page is erased
mcr Oct 20, 2021
aecaffd
prepare the flash file better: initialize to 0xff, and create proper …
mcr Oct 20, 2021
49650f8
initialize the flash space with 0xff properly
mcr Oct 20, 2021
1b76133
cfg_page: coded cfg_page_get_value that returns _last_ key from map
mcr Oct 20, 2021
c1f302c
cfg_page: added cfg_page_set_str_value writer function and test
mcr Oct 20, 2021
7b8bff0
cfg_page: correctly initialize test data with indefinite map, and the…
mcr Oct 20, 2021
b2fa52c
cfg_page: when writing, take care to split up the writes when they cr…
mcr Oct 21, 2021
79bd61d
cfg_page: added documentation on how cfg_page_swap_slotno is supposed…
mcr Oct 22, 2021
41e03f1
cfg_page: initialize the pointers correctly, and also point writer at…
mcr Oct 22, 2021
44de62e
cfg_page: push the contents to just before the 4k page blows up
mcr Oct 22, 2021
e37b034
cfg_page: cfg_page_print reads entire SECTOR rather than only PAGE of…
mcr Oct 22, 2021
ab48c8b
cfg_page: refactor out initialization of header
mcr Oct 23, 2021
7df4380
cfg_page: remember what the highest active serial number is
mcr Oct 23, 2021
1e50742
cfg_page: move initialize of map into page_format
mcr Oct 23, 2021
d3144f7
cfg_page: instead of re-initializing the end of values reader in the …
mcr Oct 23, 2021
236e7c0
cfg_page: rejig the loop when writing that does the slot swap. Moved…
mcr Oct 26, 2021
3fcd066
cfg_page: make sure that last copy of key is splatted after it is copied
mcr Oct 28, 2021
908898e
cfg_page: deal with keys that are bigger than one byte
mcr Oct 28, 2021
831ef3f
cfg_page: test with bigger key values
mcr Oct 28, 2021
a872ab3
cfg_page: clean up some debug for better readability
mcr Oct 28, 2021
2ef4655
cfg_page: deal with key size of 0
mcr Oct 28, 2021
9885e87
cfg_page: rework splat code, then realized that calculation of key si…
mcr Oct 29, 2021
eb99f27
cfg_page: turn off some debugging
mcr Oct 29, 2021
bfde775
cfg_page: bump test to 256 to get two iterations of slot swap
mcr Oct 29, 2021
45aefe8
cfg_page: move to variety of key sizes
mcr Oct 29, 2021
c0b3fb8
cfg_page: stock mtd_write only supports MTD_PAGE_SIZE blocks
mcr Oct 29, 2021
268f358
cfg_page: added wrap around for serial numbers
mcr Oct 29, 2021
0e3f5a6
cfg_page: added documentation for functions
mcr Oct 29, 2021
f132669
cfg_page: increment valuelen to accomodate key part
mcr Nov 1, 2021
a71b1e4
cfg_page: nanocbor_at_end() seems to not end in some circumstances, TBD
mcr Nov 1, 2021
fede9cb
cfg_page: name test file TEST4.bin
mcr Nov 1, 2021
43fc319
cfg_page: turn off debug
mcr Nov 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/native/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ FEATURES_PROVIDED += periph_qdec
# Various other features (if any)
FEATURES_PROVIDED += ethernet
FEATURES_PROVIDED += motor_driver

# Put other features for this board (in alphabetical order)
FEATURES_PROVIDED += riotboot
25 changes: 25 additions & 0 deletions boards/native/board_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#include "mtd_native.h"
#endif

#ifdef MODULE_CFG_PAGE
#include "cfg_page.h"
cfg_page_desc_t cfgpage;
#endif

/**
* Nothing to initialize at the moment.
* Turns the red LED on and the green LED off.
Expand All @@ -32,6 +37,9 @@ void board_init(void)
LED1_ON;

puts("RIOT native board initialized.");
#ifdef MODULE_CFG_PAGE
cfg_page_init(&cfgpage);
#endif
}

#ifdef MODULE_MTD
Expand All @@ -47,3 +55,20 @@ static mtd_native_dev_t mtd0_dev = {

mtd_dev_t *mtd0 = (mtd_dev_t *)&mtd0_dev;
#endif

#ifdef MODULE_CFG_PAGE
#ifndef MTD1_SECTOR_NUM
#define MTD1_SECTOR_NUM 2
#endif
static mtd_native_dev_t mtd1_dev = {
.dev = {
.driver = &native_flash_driver,
.sector_count = MTD1_SECTOR_NUM,
.pages_per_sector = MTD_SECTOR_SIZE / MTD_PAGE_SIZE,
.page_size = MTD_PAGE_SIZE,
},
.fname = MTD_NATIVE_CFG_FILENAME,
};

mtd_dev_t *mtd1 = (mtd_dev_t *)&mtd1_dev;
#endif
9 changes: 9 additions & 0 deletions boards/native/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,22 @@ void _native_LED_RED_TOGGLE(void);
#ifndef MTD_NATIVE_FILENAME
#define MTD_NATIVE_FILENAME "MEMORY.bin"
#endif
#ifndef MTD_NATIVE_CFG_FILENAME
#define MTD_NATIVE_CFG_FILENAME "CONFIG.bin"
#endif
/** @} */

/** Default MTD device */
#define MTD_0 mtd0

/** mtd flash emulation device */
extern mtd_dev_t *mtd0;

#ifdef MODULE_CFG_PAGE
#define MTD_1 mtd1
extern mtd_dev_t *mtd1;
#endif

#endif

#if defined(MODULE_SPIFFS) || DOXYGEN
Expand Down
10 changes: 10 additions & 0 deletions drivers/cfg_page/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2020 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#

config MODULE_CFG_PAGE
bool "Generic Configuration Data flash interface"
depends on TEST_KCONFIG
2 changes: 2 additions & 0 deletions drivers/cfg_page/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include $(RIOTBASE)/Makefile.base

1 change: 1 addition & 0 deletions drivers/cfg_page/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USEPKG += nanocbor
Loading