subsys/mgmt/hawkbit: Use dts for "storage" partition

Use devicetree for the "storage" partition.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
Yong Cong Sin 2021-07-31 12:59:23 +08:00 committed by Christopher Friedt
commit 73668323cf

View file

@ -51,6 +51,9 @@ LOG_MODULE_REGISTER(hawkbit, CONFIG_HAWKBIT_LOG_LEVEL);
#define SLOT1_SIZE FLASH_AREA_SIZE(image_1) #define SLOT1_SIZE FLASH_AREA_SIZE(image_1)
#define HTTP_HEADER_CONTENT_TYPE_JSON "application/json;charset=UTF-8" #define HTTP_HEADER_CONTENT_TYPE_JSON "application/json;charset=UTF-8"
#define STORAGE_NODE DT_NODE_BY_FIXED_PARTITION_LABEL(storage)
#define FLASH_NODE DT_MTD_FROM_FIXED_PARTITION(STORAGE_NODE)
#if ((CONFIG_HAWKBIT_POLL_INTERVAL > 1) && (CONFIG_HAWKBIT_POLL_INTERVAL < 43200)) #if ((CONFIG_HAWKBIT_POLL_INTERVAL > 1) && (CONFIG_HAWKBIT_POLL_INTERVAL < 43200))
static uint32_t poll_sleep = (CONFIG_HAWKBIT_POLL_INTERVAL * 60 * MSEC_PER_SEC); static uint32_t poll_sleep = (CONFIG_HAWKBIT_POLL_INTERVAL * 60 * MSEC_PER_SEC);
#else #else
@ -597,11 +600,12 @@ int hawkbit_init(void)
int ret = 0, rc = 0; int ret = 0, rc = 0;
struct flash_pages_info info; struct flash_pages_info info;
int32_t action_id; int32_t action_id;
const struct device *flash_dev;
flash_dev = DEVICE_DT_GET(FLASH_NODE);
fs.offset = FLASH_AREA_OFFSET(storage); fs.offset = FLASH_AREA_OFFSET(storage);
rc = flash_get_page_info_by_offs( rc = flash_get_page_info_by_offs(flash_dev, fs.offset, &info);
device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL),
fs.offset, &info);
if (rc) { if (rc) {
LOG_ERR("Unable to get storage page info"); LOG_ERR("Unable to get storage page info");
return -EIO; return -EIO;
@ -610,7 +614,7 @@ int hawkbit_init(void)
fs.sector_size = info.size; fs.sector_size = info.size;
fs.sector_count = 3U; fs.sector_count = 3U;
rc = nvs_init(&fs, DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL); rc = nvs_init(&fs, flash_dev->name);
if (rc) { if (rc) {
LOG_ERR("Storage flash Init failed"); LOG_ERR("Storage flash Init failed");
return -ENODEV; return -ENODEV;