Commit 48deccaa authored by Dominik Ermel's avatar Dominik Ermel Committed by David Brown
Browse files

boot_serial: Allow direct image upload



The commit provides support for "image" parameter in mcumgr image
update frame, that is used to select image number to be updated;
for the purpose, the option MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD
that enables the feature.
Platform that enables the feature needs, to provide an implementation
of the flash_area_id_from_direct_image function that will match
the image number to flash area to upload to.

Signed-off-by: default avatarDominik Ermel <dominik.ermel@nordicsemi.no>
parent 8c5ec5a6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -288,7 +288,11 @@ bs_upload(char *buf, int len)
        goto out_invalid_data;
    }

#if !defined(MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD)
    rc = flash_area_open(flash_area_id_from_multi_image_slot(img_num, 0), &fap);
#else
    rc = flash_area_open(flash_area_id_from_direct_image(img_num), &fap);
#endif
    if (rc) {
        rc = MGMT_ERR_EINVAL;
        goto out;
+13 −0
Original line number Diff line number Diff line
@@ -69,6 +69,19 @@ struct nmgr_hdr {
void boot_serial_input(char *buf, int len);
extern const struct boot_uart_funcs *boot_uf;

/**
 * @brief Selects direct image to upload according to the "image"
 * parameter of the mcumgr update frame.
 *
 * @param[in] image_id  the value of the "image" parameter of the
 *                      mcumgr update frame to be translated.
 *
 * @return flash area ID for the image if defined;
 *         -EINVAL when flash area for given image number has not been
 *         defined.
 */
extern int flash_area_id_from_direct_image(int image_id);

#ifdef __cplusplus
}
#endif