From 491b5016b26aba3c33afe8cbcbc53be427b82d05 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Mon, 8 Mar 2021 14:24:41 +0000 Subject: [PATCH 1/7] dts: bindings: Add bindings for Zephyr partition types The commit adds bindings for following compatibles: zephyr,mcuboot-image zephyr,mcuboot-scratch zephyr,application-image These compatobles may be used to specify partitions that are capable to be used for mcuboot image, mcuboot scratch and application image respectively. Signed-off-by: Dominik Ermel --- dts/bindings/mtd/zephyr,application-image.yaml | 15 +++++++++++++++ dts/bindings/mtd/zephyr,mcuboot-image.yaml | 15 +++++++++++++++ dts/bindings/mtd/zephyr,mcuboot-scratch.yaml | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 dts/bindings/mtd/zephyr,application-image.yaml create mode 100644 dts/bindings/mtd/zephyr,mcuboot-image.yaml create mode 100644 dts/bindings/mtd/zephyr,mcuboot-scratch.yaml diff --git a/dts/bindings/mtd/zephyr,application-image.yaml b/dts/bindings/mtd/zephyr,application-image.yaml new file mode 100644 index 00000000000000..b92372ff11ec0d --- /dev/null +++ b/dts/bindings/mtd/zephyr,application-image.yaml @@ -0,0 +1,15 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Partition or other storage area for application binary image. + +compatible: "zephyr,application-image" + +include: base.yaml + +properties: + label: + required: true + reg: + required: true diff --git a/dts/bindings/mtd/zephyr,mcuboot-image.yaml b/dts/bindings/mtd/zephyr,mcuboot-image.yaml new file mode 100644 index 00000000000000..fe2d2823501813 --- /dev/null +++ b/dts/bindings/mtd/zephyr,mcuboot-image.yaml @@ -0,0 +1,15 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Partition or other storage area for mcuboot bootloader image. + +compatible: "zephyr,mcuboot-image" + +include: base.yaml + +properties: + label: + required: true + reg: + required: true diff --git a/dts/bindings/mtd/zephyr,mcuboot-scratch.yaml b/dts/bindings/mtd/zephyr,mcuboot-scratch.yaml new file mode 100644 index 00000000000000..f972a93d1b45de --- /dev/null +++ b/dts/bindings/mtd/zephyr,mcuboot-scratch.yaml @@ -0,0 +1,15 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Partition or other storage area for mcuboot bootloader scratch. + +compatible: "zephyr,mcuboot-scratch" + +include: base.yaml + +properties: + label: + required: true + reg: + required: true From 3d8054eb0814b33421e2224ff2ce01e329bbd373 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Mon, 8 Mar 2021 14:29:01 +0000 Subject: [PATCH 2/7] storage/flash_map: Add filed for area type field flash_area structure The flash_area structure has been extended with flash area type filed, fa_type, that is supposed to have one of FLASH_AREA_TYPE_* predefined values which represent the purpose of the area. Signed-off-by: Dominik Ermel --- include/storage/flash_map.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/storage/flash_map.h b/include/storage/flash_map.h index 2d3a720eabcb98..1fd6002b6b9025 100644 --- a/include/storage/flash_map.h +++ b/include/storage/flash_map.h @@ -55,7 +55,8 @@ struct flash_area { uint8_t fa_id; /** Provided for compatibility with MCUboot */ uint8_t fa_device_id; - uint16_t pad16; + uint8_t fa_type; + uint8_t pad8; /** Start offset from the beginning of the flash device */ off_t fa_off; /** Total size */ @@ -67,6 +68,12 @@ struct flash_area { const char *fa_dev_name; }; +#define FLASH_AREA_TYPE_UNSPECIFIED 0x00 /* No type */ +#define FLASH_AREA_TYPE_MCUBOOT 0x01 /* zephyr,mcuboot,image */ +#define FLASH_AREA_TYPE_MCUBOOT_SCRATCH 0x02 /* zephyr,mcuboot,scratch */ +#define FLASH_AREA_TYPE_ZEPHYR_APPLICATION 0x10 /* zephyr,application,image */ +#define FLASH_AREA_TYPE_UNKNOWN 0xff /* Reserved for unknown compatible */ + /** * @brief Structure for transfer flash sector boundaries * From b7798a0d40096632e127beb5e4f83212019f3144 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Mon, 8 Mar 2021 14:43:01 +0000 Subject: [PATCH 3/7] flash_area: Add flash area type support macros The commit adds macros that allows to extract flash area type and translate it from C specific "compatible" identifier, for example zephyr_application_image, to FLASH_AREA_TYPE_* constants. The commit modifies defaullt flash_map generator with new macros to assign the area type to fa_type for each partition. Signed-off-by: Dominik Ermel --- include/storage/flash_map.h | 14 ++++++++++++++ subsys/storage/flash_map/flash_map_default.c | 1 + 2 files changed, 15 insertions(+) diff --git a/include/storage/flash_map.h b/include/storage/flash_map.h index 1fd6002b6b9025..88076cd14bde68 100644 --- a/include/storage/flash_map.h +++ b/include/storage/flash_map.h @@ -275,6 +275,20 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); #define FLASH_AREA_SIZE(label) \ DT_REG_SIZE(DT_NODE_BY_FIXED_PARTITION_LABEL(label)) +#define FLASH_AREA_NODE_COMPAT_TYPE(n, c, t) COND_CODE_1(DT_NODE_HAS_COMPAT(n, c), (t), ()) + +#define FLASH_AREA_NODE_TYPE(n) \ + FLASH_AREA_NODE_COMPAT_TYPE(n, zephyr_mcuboot_image, FLASH_AREA_TYPE_MCUBOOT) \ + FLASH_AREA_NODE_COMPAT_TYPE(n, zephyr_mcuboot_scratch, FLASH_AREA_TYPE_MCUBOOT_SCRATCH) \ + FLASH_AREA_NODE_COMPAT_TYPE(n, zephyr_application_image, FLASH_AREA_TYPE_ZEPHYR_APPLICATION) + +#define FLASH_AREA_NODE_TYPE_OR_UNSPECIFIED(n) \ + COND_CODE_0( \ + IS_EMPTY(FLASH_AREA_NODE_TYPE(n)), \ + (FLASH_AREA_NODE_TYPE(n)), \ + (FLASH_AREA_TYPE_UNSPECIFIED) \ + ) + #ifdef __cplusplus } #endif diff --git a/subsys/storage/flash_map/flash_map_default.c b/subsys/storage/flash_map/flash_map_default.c index 4f2830571afebb..94dd193811e4d6 100644 --- a/subsys/storage/flash_map/flash_map_default.c +++ b/subsys/storage/flash_map/flash_map_default.c @@ -13,6 +13,7 @@ #define FLASH_AREA_FOO(part) \ {.fa_id = DT_FIXED_PARTITION_ID(part), \ .fa_off = DT_REG_ADDR(part), \ + .fa_type = FLASH_AREA_NODE_TYPE_OR_UNSPECIFIED(part), \ .fa_dev_name = DT_LABEL(DT_MTD_FROM_FIXED_PARTITION(part)), \ .fa_size = DT_REG_SIZE(part),}, From edceabb15f472c91a9bd69c6853b7e1962862e11 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Mon, 8 Mar 2021 14:46:37 +0000 Subject: [PATCH 4/7] boards: nrf: Example usage of flash area type compatibles The is example of zephyr,mcuboot-image, zephyr,mcuboot-scratch and zaphyr,applicaiton-image usage. [TODO] Other boards. Signed-off-by: Dominik Ermel --- boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts b/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts index 7f6f191fac8cc4..bd17d89be9b55f 100644 --- a/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts +++ b/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts @@ -247,18 +247,22 @@ arduino_spi: &spi3 { #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mcuboot,image"; label = "mcuboot"; reg = <0x000000000 0x0000C000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,application-image"; label = "image-0"; reg = <0x0000C000 0x00067000>; }; slot1_partition: partition@73000 { + compatible = "zephyr,application-image"; label = "image-1"; reg = <0x00073000 0x00067000>; }; scratch_partition: partition@da000 { + compatible = "zephyr,mcuboot-scratch"; label = "image-scratch"; reg = <0x000da000 0x0001e000>; }; From 02de5492ac0d2409e44feafa58b231c655b2f049 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Tue, 9 Mar 2021 15:39:34 +0000 Subject: [PATCH 5/7] storage/flash_map: Add macros for accessing flash area type The commit adds macros that allow to get information on currently active flash partition and perform operations on partitions of selected type. Following macros have been added in this commit: FLASH_AREA_ACTIVE_ID -- returns ID of flash area an active application is running from; FLASH_AREA_FOR_EACH_COMPATIBLE -- allows to invoke macro on each instance of compatible type partition/flash area. Signed-off-by: Dominik Ermel --- include/storage/flash_map.h | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/include/storage/flash_map.h b/include/storage/flash_map.h index 88076cd14bde68..18c5fe244a207b 100644 --- a/include/storage/flash_map.h +++ b/include/storage/flash_map.h @@ -277,11 +277,26 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); #define FLASH_AREA_NODE_COMPAT_TYPE(n, c, t) COND_CODE_1(DT_NODE_HAS_COMPAT(n, c), (t), ()) +/** + * @brief Macro attempts to translate DTS compatible to FLASH_AREA_* identifier + * + * @param n Compatible to translate in C identifier format, for example zephyr_application_image. + * @returns Value of FLASH_AREA_TYPE_* that matches the compatible or nothing. + */ #define FLASH_AREA_NODE_TYPE(n) \ FLASH_AREA_NODE_COMPAT_TYPE(n, zephyr_mcuboot_image, FLASH_AREA_TYPE_MCUBOOT) \ FLASH_AREA_NODE_COMPAT_TYPE(n, zephyr_mcuboot_scratch, FLASH_AREA_TYPE_MCUBOOT_SCRATCH) \ FLASH_AREA_NODE_COMPAT_TYPE(n, zephyr_application_image, FLASH_AREA_TYPE_ZEPHYR_APPLICATION) +/** + * @brief Macro translates DTS compatible to FLASH_AREA_TYPE_* identifier + * + * This is extension of FLASH_AREA_NODE_TYPE that, instead of returning nothing, will return + * FLASH_AREA_TYPE_UNSPECIFIED if unable to match any other FLASH_AREA_TYPE_*. + * + * @param n Compatible to translate in C identifier format, for example zephyr_application_image. + * @returns Value of FLASH_AREA_TYPE_* that matches the compatible or FLASH_AREA_TYPE_UNSPECIFIED. + */ #define FLASH_AREA_NODE_TYPE_OR_UNSPECIFIED(n) \ COND_CODE_0( \ IS_EMPTY(FLASH_AREA_NODE_TYPE(n)), \ @@ -289,6 +304,42 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); (FLASH_AREA_TYPE_UNSPECIFIED) \ ) +/* Macro returns ID of a partition the application is running from */ +#define FLASH_AREA_ACTIVE_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) + +/* Helper macro used to append argument to list of macro arguments */ +#define APPEND_ARG(f) EMPTY, f + +/** + * @brief The macro iterates through a list of "compatible" flash areas. + * + * The macro will evaluate provided @p fn macro for each flash area (partition) defined in DTS + * with @p compat compatible. + * The provided @p fn macro should accept two parameters: the first one would be the instance index + * of compatible, and the second will be the same identifier as passed to @p compat. + * To see how these are related see the DT_INST macro description. + * + * @param compat DTS compatible in C preprocessor form, for example zephry_application_image + * @param fn Macro to be invoked. + */ +#define FLASH_AREA_FOR_EACH_COMPATIBLE(compat, fn) \ + COND_CODE_1( \ + DT_HAS_COMPAT_STATUS_OKAY(compat), \ + (FOR_EACH_FIXED_ARG( \ + fn, \ + (), \ + compat, \ + LIST_DROP_EMPTY( \ + COND_CODE_1( \ + DT_HAS_COMPAT_STATUS_OKAY(compat), \ + (UTIL_CAT(DT_FOREACH_OKAY_INST_, compat)(APPEND_ARG)), \ + () \ + ) \ + ) \ + )), \ + () \ + ) + #ifdef __cplusplus } #endif From 38651efb095300d21548c45f2e6935c970702f8d Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Mon, 8 Mar 2021 14:49:41 +0000 Subject: [PATCH 6/7] flash_area: Partition type functions The commit adds: flash_area_active_app -- that returns pointer to flash_area occupied by active application flash_area_enum_type -- that enumerates flash_area for specified type [TODO] Tests Signed-off-by: Dominik Ermel --- include/storage/flash_map.h | 19 ++++++++++++ subsys/storage/flash_map/flash_map.c | 43 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/include/storage/flash_map.h b/include/storage/flash_map.h index 18c5fe244a207b..80f1f83d81004e 100644 --- a/include/storage/flash_map.h +++ b/include/storage/flash_map.h @@ -115,6 +115,25 @@ int flash_area_check_int_sha256(const struct flash_area *fa, const struct flash_area_check *fac); #endif +/** + * @brief Return pointer to flash_area occupied by running application. + * + * @return non-NULL pointer to @p flash_area structure holding information on area an application is + * running; NULL pointer if application is not running from any of the partitions in flash_map. + */ +const struct flash_area *flash_area_active(void); + +/** + * Enumerate flash areas of specified type. + * + * @param[in] current Pointer to flash_map entry to start after; if NULL the first entry is used. + * @param[in] type Type to match: one of FLASH_AREA_TYPE_* constants. + * + * @returns non-NULL pointer to flash area that matches a given type; NULL if there are no more + * areas to match. + */ +const struct flash_area *flash_area_enum_type(const struct flash_area *current, uint8_t type); + /** * @brief Retrieve partitions flash area from the flash_map. * diff --git a/subsys/storage/flash_map/flash_map.c b/subsys/storage/flash_map/flash_map.c index 926592595cb52e..86a11d01b6364b 100644 --- a/subsys/storage/flash_map/flash_map.c +++ b/subsys/storage/flash_map/flash_map.c @@ -55,6 +55,49 @@ void flash_area_foreach(flash_area_cb_t user_cb, void *user_data) } } +const struct flash_area *flash_area_active(void) +{ + const struct flash_area *active = NULL; + +#if DT_HAS_CHOSEN(zephyr_code_partitioN) + /* + * Search flash map for area that starts at the same offset as the "zephyr,code-partition" + * chosen: this will be the active partition. + */ + for (int i = 0; i < flash_map_entries; ++i) { + if (flash_map[i].fa_off == DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) { + active = &flash_map[i]; + break; + } + } +#endif + + return active; +} + +const struct flash_area *flash_area_enum_type(const struct flash_area *current, uint8_t type) +{ + if (current == NULL) { + /* The current is unconditionally increased at the beginning of the loop below */ + current = flash_map - 1; + } + + /* + * Find description of next area, after current, of given type and return pointer to its + * flash_area record. + */ + while (current != NULL) { + ++current; + if ((current - flash_map) >= flash_map_entries) { + current = NULL; + } else if (current->fa_type == type) { + break; + } + } + + return current; +} + int flash_area_open(uint8_t id, const struct flash_area **fap) { const struct flash_area *area; From 87287ea120798f4606b04efe5609783d14f6ab22 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Tue, 9 Mar 2021 15:22:20 +0000 Subject: [PATCH 7/7] samples/storage: Usage of flash_area API with partition types The flash_area_type sample has been added that presents how user may utilise flash_area_api, to get information on current active partition and enumerate list of partitions to access partitions of specified type. This sample presents usage of functions: flash_area_active flash_area_enum_type and macros FLASH_AREA_FOR_EACH_COMPATIBLE Signed-off-by: Dominik Ermel --- .../flash_map/flash_area_type/CMakeLists.txt | 9 ++ .../flash_map/flash_area_type/prj.conf | 10 ++ .../flash_map/flash_area_type/sample.yaml | 21 +++ .../flash_map/flash_area_type/src/main.c | 131 ++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 samples/subsys/storage/flash_map/flash_area_type/CMakeLists.txt create mode 100644 samples/subsys/storage/flash_map/flash_area_type/prj.conf create mode 100644 samples/subsys/storage/flash_map/flash_area_type/sample.yaml create mode 100644 samples/subsys/storage/flash_map/flash_area_type/src/main.c diff --git a/samples/subsys/storage/flash_map/flash_area_type/CMakeLists.txt b/samples/subsys/storage/flash_map/flash_area_type/CMakeLists.txt new file mode 100644 index 00000000000000..8c16653608f734 --- /dev/null +++ b/samples/subsys/storage/flash_map/flash_area_type/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(flash_area_type) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/samples/subsys/storage/flash_map/flash_area_type/prj.conf b/samples/subsys/storage/flash_map/flash_area_type/prj.conf new file mode 100644 index 00000000000000..745d3465756b93 --- /dev/null +++ b/samples/subsys/storage/flash_map/flash_area_type/prj.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_FLASH=y +CONFIG_FLASH_MAP=y +CONFIG_LOG=y +CONFIG_PRINTK=y diff --git a/samples/subsys/storage/flash_map/flash_area_type/sample.yaml b/samples/subsys/storage/flash_map/flash_area_type/sample.yaml new file mode 100644 index 00000000000000..00c23133d64749 --- /dev/null +++ b/samples/subsys/storage/flash_map/flash_area_type/sample.yaml @@ -0,0 +1,21 @@ +# +# Copyright (c) 2020 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +sample: + name: flash_area_type + description: Flash area type API usage for partition enumeration +common: + tags: flash_area +tests: + sample.storage.flash_area: + platform_allow: nrf52840dk_nrf52840 native_posix + tags: flash_area + harness: console + harness_config: + type: multi_line + regex: + - "Known types:(.*)" + - "(.*)" diff --git a/samples/subsys/storage/flash_map/flash_area_type/src/main.c b/samples/subsys/storage/flash_map/flash_area_type/src/main.c new file mode 100644 index 00000000000000..8d72e218615c25 --- /dev/null +++ b/samples/subsys/storage/flash_map/flash_area_type/src/main.c @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * Sample explains usage functions: + * flash_area_active + * flash_area_enum_type + * and macros: + * FLASH_AREA_FOR_EACH_COMPATIBLE + * + * for obtaining information on active partitions and generating code for user selected type of + * partitions. + */ + +#include +#include +#include + +#define MAKE_LIST_ITEM(type, compatible) { type, #type, compatible } + +const static struct type_meta { + int type; + const char *stype; + const char *compatible; +} types[] = { + MAKE_LIST_ITEM(FLASH_AREA_TYPE_UNSPECIFIED, "None"), + MAKE_LIST_ITEM(FLASH_AREA_TYPE_MCUBOOT, "zephyr,mcuboot,image"), + MAKE_LIST_ITEM(FLASH_AREA_TYPE_MCUBOOT_SCRATCH, "zephyr,mcyboot, scratch"), + MAKE_LIST_ITEM(FLASH_AREA_TYPE_ZEPHYR_APPLICATION, "zephyr,application,image"), + MAKE_LIST_ITEM(FLASH_AREA_TYPE_UNKNOWN, "Unknown") +}; + +/* + * This function will only present list of known types with C definitions for them and "compatible" + * string that they correspond to; function has been provided for convenience. + */ +static void list_known_types(void) +{ + size_t i = 0; + + printk("Known types:\n"); + while (i < ARRAY_SIZE(types)) { + printk("\t%s = 0x%x, compatible = %s\n", types[i].stype, types[i].type, + types[i].compatible); + ++i; + } +} + + +/* + * The function will enumerate, at run-time, partitions of all known types. Some list may be + * generated empty, when the DTS or overlay does not specify the partition or it has been + * disabled within DTS. + */ +static void enum_all_of_type(const struct type_meta *t) +{ + const struct flash_area *other = NULL; + + printk("\nList of all %s areas\n", t->stype); + printk(" Offset | ID\n"); + printk("========+====\n"); + while (1) { + other = flash_area_enum_type(other, t->type); + if (other == NULL) { + break; + } + + printk("%8lx|%4d\n", (unsigned long)other->fa_off, other->fa_id); + } + printk("--------+----\n"); +} + + +/* + * Macros given as function parameter to FLASH_AREA_FOR_EACH_COMPATIBLE take two parameters; first + * parameter is the instance index of compatible the second is the compatible string, same one + * that is passed as a first parameter to FLASH_AREA_FOR_EACH_COMPATIBLE. + * + * The exemplary macro below will expand each par of idx (index) and compat (compatible) to + * printk printing the partition ID and string representing the DT node that represents the + * partition. + */ +#define PRINT_ID_AND_NODE(idx, compat) \ + printk(" ID %d -> %s\n", \ + DT_FIXED_PARTITION_ID(DT_INST(idx, compat)), \ + STRINGIFY(DT_INST(idx, compat)) \ + ); \ + +/* + * Function, together with PRINT_ID_AND_NODE macro, provides example on how compile time expansion + * works; the FLASH_AREA_FOR_EACH_COMPATIBLE can be also used to generate structure at compile time. + */ +static void compile_time_expanded(void) +{ + printk("\nExamples of compile time expansions by 'compatible'\n"); + printk("===================================================\n"); + printk("List of zephyr,mcuboot,image:\n"); + FLASH_AREA_FOR_EACH_COMPATIBLE(zephyr_mcuboot_image, PRINT_ID_AND_NODE); + printk("List of zephyr,mcuboot,scratch:\n"); + FLASH_AREA_FOR_EACH_COMPATIBLE(zephyr_mcuboot_scratch, PRINT_ID_AND_NODE); + printk("List of zephyr,application,image:\n"); + FLASH_AREA_FOR_EACH_COMPATIBLE(zephyr_application_image, PRINT_ID_AND_NODE); + printk("List of fake, not exisitng partition (empty):\n"); + FLASH_AREA_FOR_EACH_COMPATIBLE(not_existing_junk, PRINT_ID_AND_NODE); +} + +void main(void) +{ + /* raw disk i/o */ + const struct flash_area *active = flash_area_active(); + + /* Just list know types for reference */ + list_known_types(); + + if (active == NULL) { + printk("\nActive flash area not found in flash map\n"); + } else { + printk("\nActive flash area is %p, ID is %d, type is 0x%x\n", active, active->fa_id, + active->fa_type); + } + + /* Go through the list of types and print lists of flash areas that have certain type */ + for (int i = 0; i < ARRAY_SIZE(types); ++i) { + enum_all_of_type(&types[i]); + } + + compile_time_expanded(); +}