aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-01-16 21:59:16 +0100
committerAleksander Morgado <aleksander@aleksander.es>2017-01-16 22:16:38 +0100
commitca43e463eab3e44ec81d226b1752b4723ced964e (patch)
tree71e4754b8e6e34f2624af3edc405bd5ed08ccc6c
parent2e50146039089c61e11cea2f7c9b4125df4bfe19 (diff)
downloadexternal_libqmi-ca43e463eab3e44ec81d226b1752b4723ced964e.zip
external_libqmi-ca43e463eab3e44ec81d226b1752b4723ced964e.tar.gz
external_libqmi-ca43e463eab3e44ec81d226b1752b4723ced964e.tar.bz2
qmi-firmware-update: new --modem-storage-index option
-rw-r--r--src/qmi-firmware-update/qfu-main.c14
-rw-r--r--src/qmi-firmware-update/qfu-operation-update.c2
-rw-r--r--src/qmi-firmware-update/qfu-operation.h1
-rw-r--r--src/qmi-firmware-update/qfu-reseter.c2
-rw-r--r--src/qmi-firmware-update/qfu-updater.c21
-rw-r--r--src/qmi-firmware-update/qfu-updater.h1
-rw-r--r--src/qmi-firmware-update/qfu-utils.c21
-rw-r--r--src/qmi-firmware-update/qfu-utils.h1
8 files changed, 62 insertions, 1 deletions
diff --git a/src/qmi-firmware-update/qfu-main.c b/src/qmi-firmware-update/qfu-main.c
index 81ed304..331b36b 100644
--- a/src/qmi-firmware-update/qfu-main.c
+++ b/src/qmi-firmware-update/qfu-main.c
@@ -57,6 +57,7 @@ static gboolean device_open_proxy_flag;
static gboolean device_open_mbim_flag;
static gboolean ignore_version_errors_flag;
static gboolean override_download_flag;
+static gint modem_storage_index_int;
static gboolean skip_validation_flag;
/* Reset */
@@ -217,6 +218,10 @@ static GOptionEntry context_update_entries[] = {
"Download images even if module says it already has them.",
NULL
},
+ { "modem-storage-index", 0, 0, G_OPTION_ARG_INT, &modem_storage_index_int,
+ "Index storage for the modem image.",
+ "[INDEX]"
+ },
{ "skip-validation", 0, 0, G_OPTION_ARG_NONE, &skip_validation_flag,
"Don't wait to validate the running firmware after update.",
NULL
@@ -554,6 +559,14 @@ int main (int argc, char **argv)
if (action_update_flag) {
g_assert (QFU_IS_DEVICE_SELECTION (device_selection));
+
+ /* Validate storage index, just (0,G_MAXUINT8] for now. The value 0 is also not
+ * valid, but we use it to flag when no specific index has been requested. */
+ if (modem_storage_index_int < 0 || modem_storage_index_int > G_MAXUINT8) {
+ g_printerr ("error: invalid modem storage index\n");
+ goto out;
+ }
+
result = qfu_operation_update_run ((const gchar **) image_strv,
device_selection,
firmware_version_str,
@@ -563,6 +576,7 @@ int main (int argc, char **argv)
device_open_mbim_flag,
ignore_version_errors_flag,
override_download_flag,
+ (guint8) modem_storage_index_int,
skip_validation_flag);
goto out;
}
diff --git a/src/qmi-firmware-update/qfu-operation-update.c b/src/qmi-firmware-update/qfu-operation-update.c
index c81ec6d..8a58984 100644
--- a/src/qmi-firmware-update/qfu-operation-update.c
+++ b/src/qmi-firmware-update/qfu-operation-update.c
@@ -125,6 +125,7 @@ qfu_operation_update_run (const gchar **images,
gboolean device_open_mbim,
gboolean ignore_version_errors,
gboolean override_download,
+ guint8 modem_storage_index,
gboolean skip_validation)
{
QfuUpdater *updater = NULL;
@@ -140,6 +141,7 @@ qfu_operation_update_run (const gchar **images,
device_open_mbim,
ignore_version_errors,
override_download,
+ modem_storage_index,
skip_validation);
result = operation_update_run (updater, images);
g_object_unref (updater);
diff --git a/src/qmi-firmware-update/qfu-operation.h b/src/qmi-firmware-update/qfu-operation.h
index 2659051..95c2b5e 100644
--- a/src/qmi-firmware-update/qfu-operation.h
+++ b/src/qmi-firmware-update/qfu-operation.h
@@ -36,6 +36,7 @@ gboolean qfu_operation_update_run (const gchar **images,
gboolean device_open_mbim,
gboolean ignore_version_errors,
gboolean override_download,
+ guint8 modem_storage_index,
gboolean skip_validation);
gboolean qfu_operation_update_qdl_run (const gchar **images,
QfuDeviceSelection *device_selection);
diff --git a/src/qmi-firmware-update/qfu-reseter.c b/src/qmi-firmware-update/qfu-reseter.c
index e0dc7bf..1429551 100644
--- a/src/qmi-firmware-update/qfu-reseter.c
+++ b/src/qmi-firmware-update/qfu-reseter.c
@@ -331,7 +331,7 @@ new_client_dms_ready (gpointer unused,
if (!qfu_utils_new_client_dms_finish (res,
&ctx->qmi_device,
&ctx->qmi_client,
- NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
&error)) {
/* Jump to AT-based boothold */
g_debug ("[qfu-reseter] error: couldn't allocate QMI client: %s", error->message);
diff --git a/src/qmi-firmware-update/qfu-updater.c b/src/qmi-firmware-update/qfu-updater.c
index 3e9369f..7fe1112 100644
--- a/src/qmi-firmware-update/qfu-updater.c
+++ b/src/qmi-firmware-update/qfu-updater.c
@@ -56,6 +56,7 @@ struct _QfuUpdaterPrivate {
gboolean device_open_mbim;
gboolean ignore_version_errors;
gboolean override_download;
+ guint8 modem_storage_index;
gboolean skip_validation;
};
@@ -110,6 +111,7 @@ typedef struct {
/* Old/New info and capabilities */
gchar *revision;
gboolean supports_stored_image_management;
+ guint8 max_modem_storage_index;
gboolean supports_firmware_preference_management;
QmiMessageDmsGetFirmwarePreferenceOutput *firmware_preference;
gchar *new_revision;
@@ -301,6 +303,7 @@ new_client_dms_after_ready (gpointer unused,
&ctx->qmi_client,
&ctx->new_revision,
&ctx->new_supports_stored_image_management,
+ NULL, /* we don't care about the max number of images */
&ctx->new_supports_firmware_preference_management,
&ctx->new_firmware_preference,
&error)) {
@@ -896,6 +899,9 @@ run_context_step_set_firmware_preference (GTask *task)
if (self->priv->override_download)
qmi_message_dms_set_firmware_preference_input_set_download_override (input, TRUE, NULL);
+ if (self->priv->modem_storage_index > 0)
+ qmi_message_dms_set_firmware_preference_input_set_modem_storage_index (input, (guint8) self->priv->modem_storage_index, NULL);
+
g_debug ("[qfu-updater] setting firmware preference...");
g_debug ("[qfu-updater] modem image: unique id '%.16s', build id '%s'",
(gchar *) (modem_image_id.unique_id->data), modem_image_id.build_id);
@@ -1105,9 +1111,11 @@ new_client_dms_ready (gpointer unused,
GTask *task)
{
RunContext *ctx;
+ QfuUpdater *self;
GError *error = NULL;
ctx = (RunContext *) g_task_get_task_data (task);
+ self = g_task_get_source_object (task);
g_assert (!ctx->qmi_device);
g_assert (!ctx->qmi_client);
@@ -1117,6 +1125,7 @@ new_client_dms_ready (gpointer unused,
&ctx->qmi_client,
&ctx->revision,
&ctx->supports_stored_image_management,
+ &ctx->max_modem_storage_index,
&ctx->supports_firmware_preference_management,
&ctx->firmware_preference,
&error)) {
@@ -1125,6 +1134,16 @@ new_client_dms_ready (gpointer unused,
return;
}
+ /* Validate modem storage index, if one specified */
+ if (self->priv->modem_storage_index > ctx->max_modem_storage_index) {
+ g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "modem storage index out of bounds (%u > %u)",
+ self->priv->modem_storage_index,
+ ctx->max_modem_storage_index);
+ g_object_unref (task);
+ return;
+ }
+
/* Go on */
run_context_step_next (task, ctx->step + 1);
}
@@ -1289,6 +1308,7 @@ qfu_updater_new (QfuDeviceSelection *device_selection,
gboolean device_open_mbim,
gboolean ignore_version_errors,
gboolean override_download,
+ guint8 modem_storage_index,
gboolean skip_validation)
{
QfuUpdater *self;
@@ -1305,6 +1325,7 @@ qfu_updater_new (QfuDeviceSelection *device_selection,
self->priv->carrier = (carrier ? g_strdup (carrier) : NULL);
self->priv->ignore_version_errors = ignore_version_errors;
self->priv->override_download = override_download;
+ self->priv->modem_storage_index = modem_storage_index;
self->priv->skip_validation = skip_validation;
return self;
diff --git a/src/qmi-firmware-update/qfu-updater.h b/src/qmi-firmware-update/qfu-updater.h
index f8c98bf..c3e4a8f 100644
--- a/src/qmi-firmware-update/qfu-updater.h
+++ b/src/qmi-firmware-update/qfu-updater.h
@@ -58,6 +58,7 @@ QfuUpdater *qfu_updater_new (QfuDeviceSelection *device_selection,
gboolean device_open_mbim,
gboolean ignore_version_errors,
gboolean override_download,
+ guint8 modem_storage_index,
gboolean skip_validation);
QfuUpdater *qfu_updater_new_qdl (QfuDeviceSelection *device_selection);
void qfu_updater_run (QfuUpdater *self,
diff --git a/src/qmi-firmware-update/qfu-utils.c b/src/qmi-firmware-update/qfu-utils.c
index eb4a65f..01d950e 100644
--- a/src/qmi-firmware-update/qfu-utils.c
+++ b/src/qmi-firmware-update/qfu-utils.c
@@ -228,6 +228,7 @@ typedef struct {
gboolean revision_done;
gboolean supports_stored_image_management;
gboolean supports_stored_image_management_done;
+ guint8 max_storage_index;
gboolean supports_firmware_preference_management;
QmiMessageDmsGetFirmwarePreferenceOutput *firmware_preference;
gboolean supports_firmware_preference_management_done;
@@ -252,6 +253,7 @@ qfu_utils_new_client_dms_finish (GAsyncResult *res,
QmiClientDms **qmi_client,
gchar **revision,
gboolean *supports_stored_image_management,
+ guint8 *max_storage_index,
gboolean *supports_firmware_preference_management,
QmiMessageDmsGetFirmwarePreferenceOutput **firmware_preference,
GError **error)
@@ -270,6 +272,8 @@ qfu_utils_new_client_dms_finish (GAsyncResult *res,
*revision = (ctx->revision ? g_strdup (ctx->revision) : NULL);
if (supports_stored_image_management)
*supports_stored_image_management = ctx->supports_stored_image_management;
+ if (max_storage_index)
+ *max_storage_index = ctx->max_storage_index;
if (supports_firmware_preference_management)
*supports_firmware_preference_management = ctx->supports_firmware_preference_management;
if (firmware_preference)
@@ -334,6 +338,23 @@ dms_list_stored_images_ready (QmiClientDms *client,
output = qmi_client_dms_list_stored_images_finish (client, res, NULL);
ctx->supports_stored_image_management = (output && qmi_message_dms_list_stored_images_output_get_result (output, NULL));
+ if (ctx->supports_stored_image_management) {
+ GArray *array;
+ guint i;
+
+ qmi_message_dms_list_stored_images_output_get_list (output, &array, NULL);
+
+ for (i = 0; i < array->len; i++) {
+ QmiMessageDmsListStoredImagesOutputListImage *image;
+
+ image = &g_array_index (array, QmiMessageDmsListStoredImagesOutputListImage, i);
+ if (image->type == QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM) {
+ ctx->max_storage_index = image->maximum_images;
+ break;
+ }
+ }
+ }
+
if (output)
qmi_message_dms_list_stored_images_output_unref (output);
diff --git a/src/qmi-firmware-update/qfu-utils.h b/src/qmi-firmware-update/qfu-utils.h
index 63baca5..83ceb0c 100644
--- a/src/qmi-firmware-update/qfu-utils.h
+++ b/src/qmi-firmware-update/qfu-utils.h
@@ -57,6 +57,7 @@ gboolean qfu_utils_new_client_dms_finish (GAsyncResult *res,
QmiClientDms **qmi_client,
gchar **revision,
gboolean *supports_stored_image_management,
+ guint8 *max_storage_index,
gboolean *supports_firmware_preference_management,
QmiMessageDmsGetFirmwarePreferenceOutput **firmware_preference,
GError **error);