flash: Convert DT_FLASH_AREA to FLASH_AREA macros
Convert with a combo of scripts and by hand fixups: git grep -l DT_FLASH_AREA_.*_ID | \ xargs sed -i -r 's/DT_FLASH_AREA_(.*)_ID/FLASH_AREA_ID(\L\1)/' git grep -l DT_FLASH_AREA_.*_OFFSET | \ xargs sed -i -r 's/DT_FLASH_AREA_(.*)_OFFSET/FLASH_AREA_OFFSET(\L\1)/' git grep -l DT_FLASH_AREA_.*_SIZE | \ xargs sed -i -r 's/DT_FLASH_AREA_(.*)_SIZE/FLASH_AREA_SIZE(\L\1)/' Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
7310eb9e4a
commit
ff579a3af3
31 changed files with 77 additions and 73 deletions
|
@ -440,7 +440,7 @@ static enum updatehub_response install_update(void)
|
||||||
int verification_download = 0;
|
int verification_download = 0;
|
||||||
int attempts_download = 0;
|
int attempts_download = 0;
|
||||||
|
|
||||||
if (boot_erase_img_bank(DT_FLASH_AREA_IMAGE_1_ID) != 0) {
|
if (boot_erase_img_bank(FLASH_AREA_ID(image_1)) != 0) {
|
||||||
LOG_ERR("Failed to init flash and erase second slot");
|
LOG_ERR("Failed to init flash and erase second slot");
|
||||||
ctx.code_status = UPDATEHUB_FLASH_INIT_ERROR;
|
ctx.code_status = UPDATEHUB_FLASH_INIT_ERROR;
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -10,7 +10,7 @@ bool updatehub_get_firmware_version(char *version, int version_len)
|
||||||
{
|
{
|
||||||
struct mcuboot_img_header header;
|
struct mcuboot_img_header header;
|
||||||
|
|
||||||
if (boot_read_bank_header(DT_FLASH_AREA_IMAGE_0_ID, &header,
|
if (boot_read_bank_header(FLASH_AREA_ID(image_0), &header,
|
||||||
version_len) != 0) {
|
version_len) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <display/cfb.h>
|
#include <display/cfb.h>
|
||||||
#include <sys/printk.h>
|
#include <sys/printk.h>
|
||||||
#include <drivers/flash.h>
|
#include <drivers/flash.h>
|
||||||
|
#include <storage/flash_map.h>
|
||||||
#include <drivers/sensor.h>
|
#include <drivers/sensor.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -579,8 +580,8 @@ static int erase_storage(void)
|
||||||
|
|
||||||
dev = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
|
dev = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
|
||||||
|
|
||||||
return flash_erase(dev, DT_FLASH_AREA_STORAGE_OFFSET,
|
return flash_erase(dev, FLASH_AREA_OFFSET(storage),
|
||||||
DT_FLASH_AREA_STORAGE_SIZE);
|
FLASH_AREA_SIZE(storage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_refresh_display(void)
|
void board_refresh_display(void)
|
||||||
|
|
|
@ -7,14 +7,15 @@
|
||||||
|
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <drivers/flash.h>
|
#include <drivers/flash.h>
|
||||||
|
#include <storage/flash_map.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
|
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
|
||||||
#define FLASH_TEST_OFFSET DT_FLASH_AREA_IMAGE_1_NONSECURE_OFFSET
|
#define FLASH_TEST_OFFSET FLASH_AREA_OFFSET(image_1_nonsecure)
|
||||||
#else
|
#else
|
||||||
#define FLASH_TEST_OFFSET DT_FLASH_AREA_IMAGE_1_OFFSET
|
#define FLASH_TEST_OFFSET FLASH_AREA_OFFSET(image_1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 4096
|
#define FLASH_PAGE_SIZE 4096
|
||||||
|
|
|
@ -21,7 +21,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
|
||||||
static struct fs_mount_t lfs_storage_mnt = {
|
static struct fs_mount_t lfs_storage_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &storage,
|
.fs_data = &storage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/lfs",
|
.mnt_point = "/lfs",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
||||||
static struct fs_mount_t littlefs_mnt = {
|
static struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &cstorage,
|
.fs_data = &cstorage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/lfs"
|
.mnt_point = "/lfs"
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <drivers/flash.h>
|
#include <drivers/flash.h>
|
||||||
|
#include <storage/flash_map.h>
|
||||||
#include <fs/nvs.h>
|
#include <fs/nvs.h>
|
||||||
|
|
||||||
static struct nvs_fs fs;
|
static struct nvs_fs fs;
|
||||||
|
@ -71,9 +72,9 @@ void main(void)
|
||||||
/* define the nvs file system by settings with:
|
/* define the nvs file system by settings with:
|
||||||
* sector_size equal to the pagesize,
|
* sector_size equal to the pagesize,
|
||||||
* 3 sectors
|
* 3 sectors
|
||||||
* starting at DT_FLASH_AREA_STORAGE_OFFSET
|
* starting at FLASH_AREA_OFFSET(storage)
|
||||||
*/
|
*/
|
||||||
fs.offset = DT_FLASH_AREA_STORAGE_OFFSET;
|
fs.offset = FLASH_AREA_OFFSET(storage);
|
||||||
rc = flash_get_page_info_by_offs(
|
rc = flash_get_page_info_by_offs(
|
||||||
device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL),
|
device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL),
|
||||||
fs.offset, &info);
|
fs.offset, &info);
|
||||||
|
|
|
@ -426,7 +426,7 @@ static void example_initialization(void)
|
||||||
static struct fs_mount_t littlefs_mnt = {
|
static struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &cstorage,
|
.fs_data = &cstorage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/ff"
|
.mnt_point = "/ff"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
|
||||||
static struct fs_mount_t fs_mnt = {
|
static struct fs_mount_t fs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &storage,
|
.fs_data = &storage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/lfs",
|
.mnt_point = "/lfs",
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -188,7 +188,7 @@ static inline CO_SDO_abortCode_t canopen_program_cmd_clear(void)
|
||||||
if (!IS_ENABLED(CONFIG_IMG_ERASE_PROGRESSIVELY)) {
|
if (!IS_ENABLED(CONFIG_IMG_ERASE_PROGRESSIVELY)) {
|
||||||
LOG_DBG("erasing flash area");
|
LOG_DBG("erasing flash area");
|
||||||
|
|
||||||
err = boot_erase_img_bank(DT_FLASH_AREA_IMAGE_1_ID);
|
err = boot_erase_img_bank(FLASH_AREA_ID(image_1));
|
||||||
if (err) {
|
if (err) {
|
||||||
LOG_ERR("failed to erase image bank (err %d)", err);
|
LOG_ERR("failed to erase image bank (err %d)", err);
|
||||||
CO_errorReport(ctx.em, CO_EM_NON_VOLATILE_MEMORY,
|
CO_errorReport(ctx.em, CO_EM_NON_VOLATILE_MEMORY,
|
||||||
|
@ -302,9 +302,9 @@ static CO_SDO_abortCode_t canopen_odf_1f56(CO_ODF_arg_t *odf_arg)
|
||||||
* started upon receiveing the next 'start' command.
|
* started upon receiveing the next 'start' command.
|
||||||
*/
|
*/
|
||||||
if (ctx.flash_written) {
|
if (ctx.flash_written) {
|
||||||
fa_id = DT_FLASH_AREA_IMAGE_1_ID;
|
fa_id = FLASH_AREA_ID(image_1);
|
||||||
} else {
|
} else {
|
||||||
fa_id = DT_FLASH_AREA_IMAGE_0_ID;
|
fa_id = FLASH_AREA_ID(image_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = boot_read_bank_header(fa_id, &header, sizeof(header));
|
err = boot_read_bank_header(fa_id, &header, sizeof(header));
|
||||||
|
|
|
@ -72,17 +72,17 @@ struct mcuboot_v1_raw_header {
|
||||||
#define FLASH_MIN_WRITE_SIZE \
|
#define FLASH_MIN_WRITE_SIZE \
|
||||||
DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)
|
DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)
|
||||||
|
|
||||||
/* DT_FLASH_AREA_IMAGE_XX_YY values used below are auto-generated by DT */
|
/* FLASH_AREA_ID() values used below are auto-generated by DT */
|
||||||
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
|
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
|
||||||
#define FLASH_AREA_IMAGE_PRIMARY DT_FLASH_AREA_IMAGE_0_NONSECURE_ID
|
#define FLASH_AREA_IMAGE_PRIMARY FLASH_AREA_ID(image_0_nonsecure)
|
||||||
#define FLASH_AREA_IMAGE_SECONDARY DT_FLASH_AREA_IMAGE_1_NONSECURE_ID
|
#define FLASH_AREA_IMAGE_SECONDARY FLASH_AREA_ID(image_1_nonsecure)
|
||||||
#else
|
#else
|
||||||
#define FLASH_AREA_IMAGE_PRIMARY DT_FLASH_AREA_IMAGE_0_ID
|
#define FLASH_AREA_IMAGE_PRIMARY FLASH_AREA_ID(image_0)
|
||||||
#define FLASH_AREA_IMAGE_SECONDARY DT_FLASH_AREA_IMAGE_1_ID
|
#define FLASH_AREA_IMAGE_SECONDARY FLASH_AREA_ID(image_1)
|
||||||
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
|
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
|
||||||
|
|
||||||
#ifdef DT_FLASH_AREA_IMAGE_SCRATCH_ID
|
#if FLASH_AREA_LABEL_EXISTS(image_scratch)
|
||||||
#define FLASH_AREA_IMAGE_SCRATCH DT_FLASH_AREA_IMAGE_SCRATCH_ID
|
#define FLASH_AREA_IMAGE_SCRATCH FLASH_AREA_ID(image_scratch)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MCUBOOT_TRAILER_SWAP_TYPE
|
#ifdef CONFIG_MCUBOOT_TRAILER_SWAP_TYPE
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <devicetree.h>
|
#include <devicetree.h>
|
||||||
/* DT_FLASH_AREA_IMAGE_XX_YY values used below are auto-generated by DT */
|
/* FLASH_AREA_ID() values used below are auto-generated by DT */
|
||||||
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
|
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
|
||||||
#define FLASH_AREA_IMAGE_SECONDARY DT_FLASH_AREA_IMAGE_1_NONSECURE_ID
|
#define FLASH_AREA_IMAGE_SECONDARY FLASH_AREA_ID(image_1_nonsecure)
|
||||||
#else
|
#else
|
||||||
#define FLASH_AREA_IMAGE_SECONDARY DT_FLASH_AREA_IMAGE_1_ID
|
#define FLASH_AREA_IMAGE_SECONDARY FLASH_AREA_ID(image_1)
|
||||||
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
|
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
|
||||||
|
|
||||||
#define FLASH_WRITE_BLOCK_SIZE \
|
#define FLASH_WRITE_BLOCK_SIZE \
|
||||||
|
|
|
@ -36,7 +36,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(lfs_data);
|
||||||
static struct fs_mount_t littlefs_mnt = {
|
static struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &lfs_data,
|
.fs_data = &lfs_data,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ int settings_fcb_src(struct settings_fcb *cf)
|
||||||
cf->cf_fcb.f_scratch_cnt = 1;
|
cf->cf_fcb.f_scratch_cnt = 1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
rc = fcb_init(DT_FLASH_AREA_STORAGE_ID, &cf->cf_fcb);
|
rc = fcb_init(FLASH_AREA_ID(storage), &cf->cf_fcb);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ int settings_backend_init(void)
|
||||||
int rc;
|
int rc;
|
||||||
const struct flash_area *fap;
|
const struct flash_area *fap;
|
||||||
|
|
||||||
rc = flash_area_get_sectors(DT_FLASH_AREA_STORAGE_ID, &cnt,
|
rc = flash_area_get_sectors(FLASH_AREA_ID(storage), &cnt,
|
||||||
settings_fcb_area);
|
settings_fcb_area);
|
||||||
if (rc == -ENODEV) {
|
if (rc == -ENODEV) {
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -399,7 +399,7 @@ int settings_backend_init(void)
|
||||||
rc = settings_fcb_src(&config_init_settings_fcb);
|
rc = settings_fcb_src(&config_init_settings_fcb);
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);
|
rc = flash_area_open(FLASH_AREA_ID(storage), &fap);
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
rc = flash_area_erase(fap, 0, fap->fa_size);
|
rc = flash_area_erase(fap, 0, fap->fa_size);
|
||||||
|
|
|
@ -269,12 +269,12 @@ int settings_backend_init(void)
|
||||||
struct flash_sector hw_flash_sector;
|
struct flash_sector hw_flash_sector;
|
||||||
u32_t sector_cnt = 1;
|
u32_t sector_cnt = 1;
|
||||||
|
|
||||||
rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fa);
|
rc = flash_area_open(FLASH_AREA_ID(storage), &fa);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = flash_area_get_sectors(DT_FLASH_AREA_STORAGE_ID, §or_cnt,
|
rc = flash_area_get_sectors(FLASH_AREA_ID(storage), §or_cnt,
|
||||||
&hw_flash_sector);
|
&hw_flash_sector);
|
||||||
if (rc == -ENODEV) {
|
if (rc == -ENODEV) {
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -300,7 +300,7 @@ struct dfu_data_t {
|
||||||
static struct dfu_data_t dfu_data = {
|
static struct dfu_data_t dfu_data = {
|
||||||
.state = appIDLE,
|
.state = appIDLE,
|
||||||
.status = statusOK,
|
.status = statusOK,
|
||||||
.flash_area_id = DT_FLASH_AREA_IMAGE_1_ID,
|
.flash_area_id = FLASH_AREA_ID(image_1),
|
||||||
.alt_setting = 0,
|
.alt_setting = 0,
|
||||||
.bwPollTimeout = CONFIG_USB_DFU_DEFAULT_POLLTIMEOUT,
|
.bwPollTimeout = CONFIG_USB_DFU_DEFAULT_POLLTIMEOUT,
|
||||||
};
|
};
|
||||||
|
@ -444,7 +444,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
|
||||||
k_poll_signal_reset(&dfu_signal);
|
k_poll_signal_reset(&dfu_signal);
|
||||||
|
|
||||||
if (dfu_data.flash_area_id !=
|
if (dfu_data.flash_area_id !=
|
||||||
DT_FLASH_AREA_IMAGE_1_ID) {
|
FLASH_AREA_ID(image_1)) {
|
||||||
dfu_data.status = errWRITE;
|
dfu_data.status = errWRITE;
|
||||||
dfu_data.state = dfuERROR;
|
dfu_data.state = dfuERROR;
|
||||||
LOG_ERR("This area can not be overwritten");
|
LOG_ERR("This area can not be overwritten");
|
||||||
|
@ -669,11 +669,11 @@ static int dfu_custom_handle_req(struct usb_setup_packet *pSetup,
|
||||||
switch (pSetup->wValue) {
|
switch (pSetup->wValue) {
|
||||||
case 0:
|
case 0:
|
||||||
dfu_data.flash_area_id =
|
dfu_data.flash_area_id =
|
||||||
DT_FLASH_AREA_IMAGE_0_ID;
|
FLASH_AREA_ID(image_0);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
dfu_data.flash_area_id =
|
dfu_data.flash_area_id =
|
||||||
DT_FLASH_AREA_IMAGE_1_ID;
|
FLASH_AREA_ID(image_1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_WRN("Invalid DFU alternate setting");
|
LOG_WRN("Invalid DFU alternate setting");
|
||||||
|
@ -745,7 +745,7 @@ static void dfu_work_handler(struct k_work *item)
|
||||||
* image collection, so not erase whole bank at DFU beginning
|
* image collection, so not erase whole bank at DFU beginning
|
||||||
*/
|
*/
|
||||||
#ifndef CONFIG_IMG_ERASE_PROGRESSIVELY
|
#ifndef CONFIG_IMG_ERASE_PROGRESSIVELY
|
||||||
if (boot_erase_img_bank(DT_FLASH_AREA_IMAGE_1_ID)) {
|
if (boot_erase_img_bank(FLASH_AREA_ID(image_1))) {
|
||||||
dfu_data.state = dfuERROR;
|
dfu_data.state = dfuERROR;
|
||||||
dfu_data.status = errERASE;
|
dfu_data.status = errERASE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,7 +25,7 @@ int flash_region_is_empty(u32_t off, void *dst, u32_t len)
|
||||||
int rc;
|
int rc;
|
||||||
const struct flash_area *fap;
|
const struct flash_area *fap;
|
||||||
|
|
||||||
rc = flash_area_open(DT_FLASH_AREA_IMAGE_SCRATCH_ID, &fap);
|
rc = flash_area_open(FLASH_AREA_ID(image_scratch), &fap);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
LOG_ERR("SPI flash area open failed!\n");
|
LOG_ERR("SPI flash area open failed!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -21,7 +21,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
||||||
static struct fs_mount_t mnt = {
|
static struct fs_mount_t mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &cstorage,
|
.fs_data = &cstorage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/mnt"
|
.mnt_point = "/mnt"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ void test_init_id(void)
|
||||||
ret = flash_img_init(&ctx_no_id);
|
ret = flash_img_init(&ctx_no_id);
|
||||||
zassert_true(ret == 0, "Flash img init");
|
zassert_true(ret == 0, "Flash img init");
|
||||||
|
|
||||||
ret = flash_img_init_id(&ctx_id, DT_FLASH_AREA_IMAGE_1_ID);
|
ret = flash_img_init_id(&ctx_id, FLASH_AREA_ID(image_1));
|
||||||
zassert_true(ret == 0, "Flash img init id");
|
zassert_true(ret == 0, "Flash img init id");
|
||||||
|
|
||||||
/* Verify that the default partition ID is IMAGE_1 */
|
/* Verify that the default partition ID is IMAGE_1 */
|
||||||
|
@ -25,10 +25,10 @@ void test_init_id(void)
|
||||||
"Default partition ID is incorrect");
|
"Default partition ID is incorrect");
|
||||||
|
|
||||||
/* Note: IMAGE_0, not IMAGE_1 as above */
|
/* Note: IMAGE_0, not IMAGE_1 as above */
|
||||||
ret = flash_img_init_id(&ctx_id, DT_FLASH_AREA_IMAGE_0_ID);
|
ret = flash_img_init_id(&ctx_id, FLASH_AREA_ID(image_0));
|
||||||
zassert_true(ret == 0, "Flash img init id");
|
zassert_true(ret == 0, "Flash img init id");
|
||||||
|
|
||||||
zassert_equal(ctx_id.flash_area->fa_id, DT_FLASH_AREA_IMAGE_0_ID,
|
zassert_equal(ctx_id.flash_area->fa_id, FLASH_AREA_ID(image_0),
|
||||||
"Partition ID is not set correctly");
|
"Partition ID is not set correctly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ void test_collecting(void)
|
||||||
u8_t erase_buf[8];
|
u8_t erase_buf[8];
|
||||||
(void)memset(erase_buf, 0xff, sizeof(erase_buf));
|
(void)memset(erase_buf, 0xff, sizeof(erase_buf));
|
||||||
|
|
||||||
ret = flash_area_open(DT_FLASH_AREA_IMAGE_1_ID, &fa);
|
ret = flash_area_open(FLASH_AREA_ID(image_1), &fa);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Flash driver was not found!\n");
|
printf("Flash driver was not found!\n");
|
||||||
return;
|
return;
|
||||||
|
@ -84,7 +84,7 @@ void test_collecting(void)
|
||||||
"fail");
|
"fail");
|
||||||
|
|
||||||
|
|
||||||
ret = flash_area_open(DT_FLASH_AREA_IMAGE_1_ID, &fa);
|
ret = flash_area_open(FLASH_AREA_ID(image_1), &fa);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Flash driver was not found!\n");
|
printf("Flash driver was not found!\n");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,7 +23,7 @@ void test_bank_erase(void)
|
||||||
off_t offs;
|
off_t offs;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = flash_area_open(DT_FLASH_AREA_IMAGE_1_ID, &fa);
|
ret = flash_area_open(FLASH_AREA_ID(image_1), &fa);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Flash driver was not found!\n");
|
printf("Flash driver was not found!\n");
|
||||||
return;
|
return;
|
||||||
|
@ -38,7 +38,7 @@ void test_bank_erase(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zassert(boot_erase_img_bank(DT_FLASH_AREA_IMAGE_1_ID) == 0,
|
zassert(boot_erase_img_bank(FLASH_AREA_ID(image_1)) == 0,
|
||||||
"pass", "fail");
|
"pass", "fail");
|
||||||
|
|
||||||
for (offs = 0; offs < fa->fa_size; offs += sizeof(temp)) {
|
for (offs = 0; offs < fa->fa_size; offs += sizeof(temp)) {
|
||||||
|
@ -62,7 +62,7 @@ void test_request_upgrade(void)
|
||||||
u32_t readout[ARRAY_SIZE(expectation)];
|
u32_t readout[ARRAY_SIZE(expectation)];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = flash_area_open(DT_FLASH_AREA_IMAGE_1_ID, &fa);
|
ret = flash_area_open(FLASH_AREA_ID(image_1), &fa);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Flash driver was not found!\n");
|
printf("Flash driver was not found!\n");
|
||||||
return;
|
return;
|
||||||
|
@ -77,7 +77,7 @@ void test_request_upgrade(void)
|
||||||
zassert(memcmp(expectation, readout, sizeof(expectation)) == 0,
|
zassert(memcmp(expectation, readout, sizeof(expectation)) == 0,
|
||||||
"pass", "fail");
|
"pass", "fail");
|
||||||
|
|
||||||
boot_erase_img_bank(DT_FLASH_AREA_IMAGE_1_ID);
|
boot_erase_img_bank(FLASH_AREA_ID(image_1));
|
||||||
|
|
||||||
zassert(boot_request_upgrade(true) == 0, "pass", "fail");
|
zassert(boot_request_upgrade(true) == 0, "pass", "fail");
|
||||||
|
|
||||||
|
@ -98,13 +98,13 @@ void test_write_confirm(void)
|
||||||
const struct flash_area *fa;
|
const struct flash_area *fa;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = flash_area_open(DT_FLASH_AREA_IMAGE_0_ID, &fa);
|
ret = flash_area_open(FLASH_AREA_ID(image_0), &fa);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Flash driver was not found!\n");
|
printf("Flash driver was not found!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
zassert(boot_erase_img_bank(DT_FLASH_AREA_IMAGE_0_ID) == 0,
|
zassert(boot_erase_img_bank(FLASH_AREA_ID(image_0)) == 0,
|
||||||
"pass", "fail");
|
"pass", "fail");
|
||||||
|
|
||||||
ret = flash_area_read(fa, fa->fa_size - sizeof(img_magic),
|
ret = flash_area_read(fa, fa->fa_size - sizeof(img_magic),
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TEST_FCB_FLASH_AREA_ID DT_FLASH_AREA_IMAGE_1_ID
|
#define TEST_FCB_FLASH_AREA_ID FLASH_AREA_ID(image_1)
|
||||||
|
|
||||||
extern struct fcb test_fcb;
|
extern struct fcb test_fcb;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(small);
|
||||||
struct fs_mount_t testfs_small_mnt = {
|
struct fs_mount_t testfs_small_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &small,
|
.fs_data = &small,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_SMALL_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(small),
|
||||||
.mnt_point = TESTFS_MNT_POINT_SMALL,
|
.mnt_point = TESTFS_MNT_POINT_SMALL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(medium, MEDIUM_IO_SIZE, MEDIUM_IO_SIZE,
|
||||||
struct fs_mount_t testfs_medium_mnt = {
|
struct fs_mount_t testfs_medium_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &medium,
|
.fs_data = &medium,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_MEDIUM_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(medium),
|
||||||
.mnt_point = TESTFS_MNT_POINT_MEDIUM,
|
.mnt_point = TESTFS_MNT_POINT_MEDIUM,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ static struct fs_littlefs large = {
|
||||||
struct fs_mount_t testfs_large_mnt = {
|
struct fs_mount_t testfs_large_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &large,
|
.fs_data = &large,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_LARGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(large),
|
||||||
.mnt_point = TESTFS_MNT_POINT_LARGE,
|
.mnt_point = TESTFS_MNT_POINT_LARGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
|
||||||
struct fs_mount_t littlefs_mnt = {
|
struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &storage,
|
.fs_data = &storage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/littlefs"
|
.mnt_point = "/littlefs"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <drivers/flash.h>
|
#include <drivers/flash.h>
|
||||||
|
#include <storage/flash_map.h>
|
||||||
#include <zephyr/types.h>
|
#include <zephyr/types.h>
|
||||||
#include <ztest_assert.h>
|
#include <ztest_assert.h>
|
||||||
|
|
||||||
static u8_t rambuf[DT_FLASH_AREA_STORAGE_SIZE];
|
static u8_t rambuf[FLASH_AREA_SIZE(storage)];
|
||||||
|
|
||||||
static int test_ram_flash_init(struct device *dev)
|
static int test_ram_flash_init(struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +30,7 @@ static int test_flash_ram_erase(struct device *dev, off_t offset, size_t len)
|
||||||
off_t end_offset = offset + len;
|
off_t end_offset = offset + len;
|
||||||
|
|
||||||
zassert_true(offset >= 0, "invalid offset");
|
zassert_true(offset >= 0, "invalid offset");
|
||||||
zassert_true(offset + len <= DT_FLASH_AREA_STORAGE_SIZE,
|
zassert_true(offset + len <= FLASH_AREA_SIZE(storage),
|
||||||
"flash address out of bounds");
|
"flash address out of bounds");
|
||||||
|
|
||||||
while (offset < end_offset) {
|
while (offset < end_offset) {
|
||||||
|
@ -45,7 +46,7 @@ static int test_flash_ram_write(struct device *dev, off_t offset,
|
||||||
const void *data, size_t len)
|
const void *data, size_t len)
|
||||||
{
|
{
|
||||||
zassert_true(offset >= 0, "invalid offset");
|
zassert_true(offset >= 0, "invalid offset");
|
||||||
zassert_true(offset + len <= DT_FLASH_AREA_STORAGE_SIZE,
|
zassert_true(offset + len <= FLASH_AREA_SIZE(storage),
|
||||||
"flash address out of bounds");
|
"flash address out of bounds");
|
||||||
|
|
||||||
memcpy(rambuf + offset, data, len);
|
memcpy(rambuf + offset, data, len);
|
||||||
|
@ -57,7 +58,7 @@ static int test_flash_ram_read(struct device *dev, off_t offset, void *data,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
zassert_true(offset >= 0, "invalid offset");
|
zassert_true(offset >= 0, "invalid offset");
|
||||||
zassert_true(offset + len <= DT_FLASH_AREA_STORAGE_SIZE,
|
zassert_true(offset + len <= FLASH_AREA_SIZE(storage),
|
||||||
"flash address out of bounds");
|
"flash address out of bounds");
|
||||||
|
|
||||||
memcpy(data, rambuf + offset, len);
|
memcpy(data, rambuf + offset, len);
|
||||||
|
|
|
@ -25,7 +25,7 @@ void test_clear_flash(void)
|
||||||
int rc;
|
int rc;
|
||||||
const struct flash_area *fap;
|
const struct flash_area *fap;
|
||||||
|
|
||||||
rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);
|
rc = flash_area_open(FLASH_AREA_ID(storage), &fap);
|
||||||
zassert_equal(rc, 0, "Opening flash area for erase [%d]\n", rc);
|
zassert_equal(rc, 0, "Opening flash area for erase [%d]\n", rc);
|
||||||
|
|
||||||
rc = flash_area_erase(fap, 0, fap->fa_size);
|
rc = flash_area_erase(fap, 0, fap->fa_size);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <fs/nvs.h>
|
#include <fs/nvs.h>
|
||||||
#include "nvs_priv.h"
|
#include "nvs_priv.h"
|
||||||
|
|
||||||
#define TEST_FLASH_AREA_STORAGE_OFFSET DT_FLASH_AREA_STORAGE_OFFSET
|
#define TEST_FLASH_AREA_STORAGE_OFFSET FLASH_AREA_OFFSET(storage)
|
||||||
#define TEST_DATA_ID 1
|
#define TEST_DATA_ID 1
|
||||||
#define TEST_SECTOR_COUNT 5U
|
#define TEST_SECTOR_COUNT 5U
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ void test_nvs_init(void)
|
||||||
const struct flash_area *fa;
|
const struct flash_area *fa;
|
||||||
struct flash_pages_info info;
|
struct flash_pages_info info;
|
||||||
|
|
||||||
err = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fa);
|
err = flash_area_open(FLASH_AREA_ID(storage), &fa);
|
||||||
zassert_true(err == 0, "flash_area_open() fail: %d", err);
|
zassert_true(err == 0, "flash_area_open() fail: %d", err);
|
||||||
|
|
||||||
fs.offset = TEST_FLASH_AREA_STORAGE_OFFSET;
|
fs.offset = TEST_FLASH_AREA_STORAGE_OFFSET;
|
||||||
|
|
|
@ -187,7 +187,7 @@ void config_wipe_fcb(struct flash_sector *fs, int cnt)
|
||||||
int rc;
|
int rc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);
|
rc = flash_area_open(FLASH_AREA_ID(storage), &fap);
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
rc = flash_area_erase(fap, fs[i].fs_off, fs[i].fs_size);
|
rc = flash_area_erase(fap, fs[i].fs_off, fs[i].fs_size);
|
||||||
|
@ -347,7 +347,7 @@ void tests_settings_check_target(void)
|
||||||
int rc;
|
int rc;
|
||||||
u8_t wbs;
|
u8_t wbs;
|
||||||
|
|
||||||
rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);
|
rc = flash_area_open(FLASH_AREA_ID(storage), &fap);
|
||||||
zassert_true(rc == 0, "Can't open storage flash area");
|
zassert_true(rc == 0, "Can't open storage flash area");
|
||||||
|
|
||||||
wbs = flash_area_align(fap);
|
wbs = flash_area_align(fap);
|
||||||
|
|
|
@ -24,7 +24,7 @@ static u32_t val32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* leverage that this area has to be embededd flash part */
|
/* leverage that this area has to be embededd flash part */
|
||||||
#ifdef DT_FLASH_AREA_IMAGE_0_ID
|
#if FLASH_AREA_LABEL_EXISTS(image_0)
|
||||||
#define FLASH_WRITE_BLOCK_SIZE \
|
#define FLASH_WRITE_BLOCK_SIZE \
|
||||||
DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)
|
DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)
|
||||||
static const volatile __attribute__((section(".rodata")))
|
static const volatile __attribute__((section(".rodata")))
|
||||||
|
@ -82,7 +82,7 @@ void test_init(void)
|
||||||
|
|
||||||
void test_prepare_storage(void)
|
void test_prepare_storage(void)
|
||||||
{
|
{
|
||||||
#ifdef DT_FLASH_AREA_IMAGE_0_ID
|
#if FLASH_AREA_LABEL_EXISTS(image_0)
|
||||||
/* This procedure uses mark which is stored inside SoC embedded program
|
/* This procedure uses mark which is stored inside SoC embedded program
|
||||||
* flash. It will not work on devices on which read/write to them is not
|
* flash. It will not work on devices on which read/write to them is not
|
||||||
* possible.
|
* possible.
|
||||||
|
@ -94,13 +94,13 @@ void test_prepare_storage(void)
|
||||||
|
|
||||||
if (prepared_mark[0] == ERASED_VAL) {
|
if (prepared_mark[0] == ERASED_VAL) {
|
||||||
TC_PRINT("First run: erasing the storage\r\n");
|
TC_PRINT("First run: erasing the storage\r\n");
|
||||||
err = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fa);
|
err = flash_area_open(FLASH_AREA_ID(storage), &fa);
|
||||||
zassert_true(err == 0, "Can't open storage flash area");
|
zassert_true(err == 0, "Can't open storage flash area");
|
||||||
|
|
||||||
err = flash_area_erase(fa, 0, fa->fa_size);
|
err = flash_area_erase(fa, 0, fa->fa_size);
|
||||||
zassert_true(err == 0, "Can't erase storage flash area");
|
zassert_true(err == 0, "Can't erase storage flash area");
|
||||||
|
|
||||||
err = flash_area_open(DT_FLASH_AREA_IMAGE_0_ID, &fa);
|
err = flash_area_open(FLASH_AREA_ID(image_0), &fa);
|
||||||
zassert_true(err == 0, "Can't open storage flash area");
|
zassert_true(err == 0, "Can't open storage flash area");
|
||||||
|
|
||||||
dev = flash_area_get_device(fa);
|
dev = flash_area_get_device(fa);
|
||||||
|
|
|
@ -31,7 +31,7 @@ static void test_clear_settings(void)
|
||||||
{
|
{
|
||||||
#if IS_ENABLED(CONFIG_SETTINGS_FCB) || IS_ENABLED(CONFIG_SETTINGS_NVS)
|
#if IS_ENABLED(CONFIG_SETTINGS_FCB) || IS_ENABLED(CONFIG_SETTINGS_NVS)
|
||||||
const struct flash_area *fap;
|
const struct flash_area *fap;
|
||||||
int rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);
|
int rc = flash_area_open(FLASH_AREA_ID(storage), &fap);
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
rc = flash_area_erase(fap, 0, fap->fa_size);
|
rc = flash_area_erase(fap, 0, fap->fa_size);
|
||||||
|
@ -46,7 +46,7 @@ static void test_clear_settings(void)
|
||||||
static struct fs_mount_t littlefs_mnt = {
|
static struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &cstorage,
|
.fs_data = &cstorage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_STORAGE_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/ff"
|
.mnt_point = "/ff"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
||||||
static struct fs_mount_t littlefs_mnt = {
|
static struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &cstorage,
|
.fs_data = &cstorage,
|
||||||
.storage_dev = (void *)DT_FLASH_AREA_LITTLEFS_DEV_ID,
|
.storage_dev = (void *)FLASH_AREA_ID(littlefs_dev),
|
||||||
.mnt_point = TEST_FS_MPTR,
|
.mnt_point = TEST_FS_MPTR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ void config_setup_littlefs(void)
|
||||||
int rc;
|
int rc;
|
||||||
const struct flash_area *fap;
|
const struct flash_area *fap;
|
||||||
|
|
||||||
rc = flash_area_open(DT_FLASH_AREA_LITTLEFS_DEV_ID, &fap);
|
rc = flash_area_open(FLASH_AREA_ID(littlefs_dev), &fap);
|
||||||
zassert_true(rc == 0, "opening flash area for erase [%d]\n", rc);
|
zassert_true(rc == 0, "opening flash area for erase [%d]\n", rc);
|
||||||
|
|
||||||
flash_area_erase(fap, fap->fa_off, fap->fa_size);
|
flash_area_erase(fap, fap->fa_off, fap->fa_size);
|
||||||
|
|
|
@ -26,7 +26,7 @@ void test_flash_area_get_sectors(void)
|
||||||
u8_t rd[256];
|
u8_t rd[256];
|
||||||
struct device *flash_dev;
|
struct device *flash_dev;
|
||||||
|
|
||||||
rc = flash_area_open(DT_FLASH_AREA_IMAGE_1_ID, &fa);
|
rc = flash_area_open(FLASH_AREA_ID(image_1), &fa);
|
||||||
zassert_true(rc == 0, "flash_area_open() fail");
|
zassert_true(rc == 0, "flash_area_open() fail");
|
||||||
|
|
||||||
/* First erase the area so it's ready for use. */
|
/* First erase the area so it's ready for use. */
|
||||||
|
@ -45,7 +45,7 @@ void test_flash_area_get_sectors(void)
|
||||||
(void)memset(wd, 0xa5, sizeof(wd));
|
(void)memset(wd, 0xa5, sizeof(wd));
|
||||||
|
|
||||||
sec_cnt = ARRAY_SIZE(fs_sectors);
|
sec_cnt = ARRAY_SIZE(fs_sectors);
|
||||||
rc = flash_area_get_sectors(DT_FLASH_AREA_IMAGE_1_ID, &sec_cnt,
|
rc = flash_area_get_sectors(FLASH_AREA_ID(image_1), &sec_cnt,
|
||||||
fs_sectors);
|
fs_sectors);
|
||||||
zassert_true(rc == 0, "flash_area_get_sectors failed");
|
zassert_true(rc == 0, "flash_area_get_sectors failed");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue