This is an automated email from the ASF dual-hosted git repository. utzig pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git
The following commit(s) were added to refs/heads/master by this push: new 1e0f283 zephyr: Make direct image upload configurable 1e0f283 is described below commit 1e0f283c71d90ee3aa2ca2ca97db2bb824ffa34b Author: Dominik Ermel <dominik.er...@nordicsemi.no> AuthorDate: Wed Aug 25 08:22:12 2021 +0000 zephyr: Make direct image upload configurable Adds code that makes direct image upload, in Zephyr port, configurable via CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD. Signed-off-by: Dominik Ermel <dominik.er...@nordicsemi.no> --- cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 27 ++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c index afa3e6e..096c47c 100644 --- a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c +++ b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c @@ -131,20 +131,29 @@ zephyr_img_mgmt_flash_area_id(int slot) } /** - * The function will check if given slot is available, and allowed, for DFU; - * providing -1 as a parameter means find any unused and non-active available; - * if checks area positive, then area ID is returned, -1 is returned otherwise. - * Note that auto-selection is performed only between two first slots. + * In normal operation this function will select between first two slot + * (in reality it just checks whether second slot can be used), ignoring the + * slot parameter. + * When CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD is defined it will check if given + * slot is available, and allowed, for DFU; providing 0 as a parameter means + * find any unused and non-active available (auto-select); any other positive + * value is direct (slot + 1) to be used; if checks are positive, then area + * ID is returned, -1 is returned otherwise. + * Note that auto-selection is performed only between two two first slots. */ static int img_mgmt_get_unused_slot_area_id(int slot) { - /* Auto select slot; note that this is performed only between two first - * slots, at this pointi, which will require fix when Direct-XIP, which may - * support more slots, gets support within Zephyr. */ +#if defined(CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD) + slot--; if (slot < -1) { return -1; } else if (slot == -1) { +#endif + /* Auto select slot; note that this is performed only between two first + * slots, at this point, which will require fix when Direct-XIP, which + * may support more slots, gets support within Zephyr. + */ for (slot = 0; slot < 2; slot++) { if (img_mgmt_slot_in_use(slot) == 0) { int area_id = zephyr_img_mgmt_flash_area_id(slot); @@ -154,6 +163,7 @@ img_mgmt_get_unused_slot_area_id(int slot) } } return -1; +#if defined(CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD) } /* Direct selection; the first two slots are checked for being available * and unused; the all other slots are just checked for availability. */ @@ -163,6 +173,7 @@ img_mgmt_get_unused_slot_area_id(int slot) /* Return area ID for the slot or -1 */ return slot != -1 ? zephyr_img_mgmt_flash_area_id(slot) : -1; +#endif } /** @@ -505,7 +516,7 @@ img_mgmt_impl_upload_inspect(const struct img_mgmt_upload_req *req, } } - action->area_id = img_mgmt_get_unused_slot_area_id(req->image - 1); + action->area_id = img_mgmt_get_unused_slot_area_id(req->image); if (action->area_id < 0) { /* No slot where to upload! */ *errstr = img_mgmt_err_str_no_slot;