aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac36
-rw-r--r--src/qmi-firmware-update/qfu-device-selection.c73
-rw-r--r--src/qmi-firmware-update/qfu-device-selection.h4
-rw-r--r--src/qmi-firmware-update/qfu-main.c87
-rw-r--r--src/qmi-firmware-update/qfu-operation-update.c4
-rw-r--r--src/qmi-firmware-update/qfu-operation.h5
-rw-r--r--src/qmi-firmware-update/qfu-reseter.c1
-rw-r--r--src/qmi-firmware-update/qfu-udev-helpers.c15
-rw-r--r--src/qmi-firmware-update/qfu-udev-helpers.h22
-rw-r--r--src/qmi-firmware-update/qfu-updater.c165
-rw-r--r--src/qmi-firmware-update/qfu-updater.h4
11 files changed, 297 insertions, 119 deletions
diff --git a/configure.ac b/configure.ac
index a00cbb3..dd1937c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,12 +65,12 @@ AC_SUBST(QMI_GLIB_LT_REVISION)
AC_SUBST(QMI_GLIB_LT_AGE)
dnl Required dependency versions
-GLIB_REQUIRED=2.36
-GUDEV_REQUIRED=147
+GLIB_VERSION=2.36
+GUDEV_VERSION=147
dnl GLib, GIO...
PKG_CHECK_MODULES(GLIB,
- glib-2.0 >= $GLIB_REQUIRED
+ glib-2.0 >= $GLIB_VERSION
gobject-2.0
gio-2.0
gio-unix-2.0)
@@ -80,12 +80,23 @@ AC_SUBST(GLIB_LIBS)
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
AC_SUBST(GLIB_MKENUMS)
-dnl GUdev
-PKG_CHECK_MODULES(GUDEV,
- [gudev-1.0 >= $GUDEV_REQUIRED],
- [have_gudev=yes],[have_gudev=no])
-AC_SUBST(GUDEV_CFLAGS)
-AC_SUBST(GUDEV_LIBS)
+dnl udev support is optional, enabled by default
+AC_ARG_WITH(udev, AS_HELP_STRING([--without-udev], [Build without udev support]), [], [with_udev=yes])
+case $with_udev in
+ yes)
+ PKG_CHECK_MODULES(GUDEV, [gudev-1.0 >= $GUDEV_VERSION], [have_gudev=yes],[have_gudev=no])
+ if test "x$have_gudev" = "xno"; then
+ AC_MSG_ERROR([Couldn't find gudev >= $GUDEV_VERSION. Install it, or otherwise configure using --without-udev to disable udev support.])
+ else
+ AC_DEFINE(WITH_UDEV, 1, [Define if you want udev support])
+ AC_SUBST(GUDEV_CFLAGS)
+ AC_SUBST(GUDEV_LIBS)
+ fi
+ ;;
+ *)
+ with_udev=no
+ ;;
+esac
dnl qmi-firmware-update is optional, enabled by default
AC_ARG_ENABLE([firmware-update],
@@ -93,11 +104,6 @@ AC_ARG_ENABLE([firmware-update],
[enable compilation of `qmi-firmware-update' [default=yes]]),
[build_firmware_update=$enableval],
[build_firmware_update=yes])
-if test "x$build_firmware_update" = "xyes"; then
- if test "x$have_gudev" = "xno"; then
- AC_MSG_ERROR([Cannot build `qmi-firmware-update' if GUDev >= GUDEV_REQUIRED is not available. Install it, or otherwise configure using --disable-firmware-update to disable building `qmi-firmware-update'.])
- fi
-fi
AM_CONDITIONAL([BUILD_FIRMWARE_UPDATE], [test "x$build_firmware_update" = "xyes"])
dnl Documentation
@@ -202,5 +208,5 @@ echo "
Built items:
libqmi-glib: yes
qmicli: yes
- qmi-firmware-update: ${build_firmware_update}
+ qmi-firmware-update: ${build_firmware_update} (with udev: ${with_udev})
"
diff --git a/src/qmi-firmware-update/qfu-device-selection.c b/src/qmi-firmware-update/qfu-device-selection.c
index 136840b..a367548 100644
--- a/src/qmi-firmware-update/qfu-device-selection.c
+++ b/src/qmi-firmware-update/qfu-device-selection.c
@@ -23,7 +23,6 @@
#include <string.h>
#include <gio/gio.h>
-#include <gudev/gudev.h>
#include <libqmi-glib.h>
@@ -39,14 +38,19 @@ struct _QfuDeviceSelectionPrivate {
guint16 preferred_pid;
guint preferred_busnum;
guint preferred_devnum;
+
+#if defined WITH_UDEV
/* sysfs path */
gchar *sysfs_path;
/* generic udev monitor */
QfuUdevHelperGenericMonitor *monitor;
+#endif
};
/******************************************************************************/
+#if defined WITH_UDEV
+
static GFile *
device_selection_get_single (QfuDeviceSelection *self,
QfuUdevHelperDeviceType device_type)
@@ -92,6 +96,23 @@ device_selection_get_single (QfuDeviceSelection *self,
return NULL;
}
+#else
+
+static GFile *
+device_selection_get_single (QfuDeviceSelection *self,
+ QfuUdevHelperDeviceType device_type)
+{
+
+ if (!self->priv->preferred_devices[device_type]) {
+ g_warning ("[qfu,device-selection] no %s device defined", qfu_udev_helper_device_type_to_string (device_type));
+ return NULL;
+ }
+
+ return g_file_new_for_commandline_arg (self->priv->preferred_devices[device_type]);
+}
+
+#endif
+
GFile *
qfu_device_selection_get_single_cdc_wdm (QfuDeviceSelection *self)
{
@@ -105,6 +126,7 @@ qfu_device_selection_get_single_tty (QfuDeviceSelection *self)
}
/******************************************************************************/
+#if defined WITH_UDEV
static GList *
device_selection_get_multiple (QfuDeviceSelection *self,
@@ -143,14 +165,25 @@ device_selection_get_multiple (QfuDeviceSelection *self,
return NULL;
}
+#endif
+
GList *
qfu_device_selection_get_multiple_ttys (QfuDeviceSelection *self)
{
+#if defined WITH_UDEV
return device_selection_get_multiple (self, QFU_UDEV_HELPER_DEVICE_TYPE_TTY);
+#else
+ GFile *single;
+
+ single = qfu_device_selection_get_single_tty (self);
+ return (single ? g_list_append (NULL, single) : NULL);
+#endif
}
/******************************************************************************/
+#if defined WITH_UDEV
+
GFile *
qfu_device_selection_wait_for_cdc_wdm_finish (QfuDeviceSelection *self,
GAsyncResult *res,
@@ -215,6 +248,8 @@ qfu_device_selection_wait_for_tty (QfuDeviceSelection *self,
task);
}
+#endif
+
/******************************************************************************/
QfuDeviceSelection *
@@ -259,21 +294,25 @@ qfu_device_selection_new (const gchar *preferred_cdc_wdm,
self->priv->preferred_busnum = preferred_busnum;
self->priv->preferred_devnum = preferred_devnum;
- /* Initialize sysfs path from inputs */
- if (preferred_vid || preferred_devnum)
- self->priv->sysfs_path = qfu_udev_helper_find_by_device_info (preferred_vid, preferred_pid, preferred_busnum, preferred_devnum, error);
- else if (preferred_cdc_wdm || preferred_tty)
- self->priv->sysfs_path = qfu_udev_helper_find_by_file_path (preferred_cdc_wdm ? preferred_cdc_wdm : preferred_tty, error);
- else
- g_assert_not_reached ();
-
- if (!self->priv->sysfs_path) {
- g_object_unref (self);
- return NULL;
+#if defined WITH_UDEV
+ {
+ /* Initialize sysfs path from inputs */
+ if (preferred_vid || preferred_devnum)
+ self->priv->sysfs_path = qfu_udev_helper_find_by_device_info (preferred_vid, preferred_pid, preferred_busnum, preferred_devnum, error);
+ else if (preferred_cdc_wdm || preferred_tty)
+ self->priv->sysfs_path = qfu_udev_helper_find_by_file_path (preferred_cdc_wdm ? preferred_cdc_wdm : preferred_tty, error);
+ else
+ g_assert_not_reached ();
+
+ if (!self->priv->sysfs_path) {
+ g_object_unref (self);
+ return NULL;
+ }
+
+ /* Initialize right away the generic udev monitor for this sysfs path */
+ self->priv->monitor = qfu_udev_helper_generic_monitor_new (self->priv->sysfs_path);
}
-
- /* Initialize right away the generic udev monitor for this sysfs path */
- self->priv->monitor = qfu_udev_helper_generic_monitor_new (self->priv->sysfs_path);
+#endif
return self;
}
@@ -290,12 +329,14 @@ finalize (GObject *object)
QfuDeviceSelection *self = QFU_DEVICE_SELECTION (object);
guint i;
+#if defined WITH_UDEV
if (self->priv->monitor)
qfu_udev_helper_generic_monitor_free (self->priv->monitor);
+ g_free (self->priv->sysfs_path);
+#endif
for (i = 0; i < QFU_UDEV_HELPER_DEVICE_TYPE_LAST; i++)
g_free (self->priv->preferred_devices[i]);
- g_free (self->priv->sysfs_path);
G_OBJECT_CLASS (qfu_device_selection_parent_class)->finalize (object);
}
diff --git a/src/qmi-firmware-update/qfu-device-selection.h b/src/qmi-firmware-update/qfu-device-selection.h
index 9ceb262..5e9c0f9 100644
--- a/src/qmi-firmware-update/qfu-device-selection.h
+++ b/src/qmi-firmware-update/qfu-device-selection.h
@@ -57,6 +57,7 @@ QfuDeviceSelection *qfu_device_selection_new (const gchar *preferred_cdc_w
GError **error);
GFile *qfu_device_selection_get_single_cdc_wdm (QfuDeviceSelection *self);
+#if defined WITH_UDEV
void qfu_device_selection_wait_for_cdc_wdm (QfuDeviceSelection *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -64,9 +65,11 @@ void qfu_device_selection_wait_for_cdc_wdm (QfuDeviceSelection *self,
GFile *qfu_device_selection_wait_for_cdc_wdm_finish (QfuDeviceSelection *self,
GAsyncResult *res,
GError **error);
+#endif /* WITH_UDEV */
GFile *qfu_device_selection_get_single_tty (QfuDeviceSelection *self);
GList *qfu_device_selection_get_multiple_ttys (QfuDeviceSelection *self);
+#if defined WITH_UDEV
void qfu_device_selection_wait_for_tty (QfuDeviceSelection *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -74,6 +77,7 @@ void qfu_device_selection_wait_for_tty (QfuDeviceSelection *self,
GFile *qfu_device_selection_wait_for_tty_finish (QfuDeviceSelection *self,
GAsyncResult *res,
GError **error);
+#endif /* WITH_UDEV */
G_END_DECLS
diff --git a/src/qmi-firmware-update/qfu-main.c b/src/qmi-firmware-update/qfu-main.c
index ac9c056..cb9e4a3 100644
--- a/src/qmi-firmware-update/qfu-main.c
+++ b/src/qmi-firmware-update/qfu-main.c
@@ -41,26 +41,26 @@
/* Options */
/* Generic device selections */
-static guint busnum;
-static guint devnum;
-static guint16 vid;
-static guint16 pid;
-static gchar *cdc_wdm_str;
-static gchar *tty_str;
-
+#if defined WITH_UDEV
+static guint busnum;
+static guint devnum;
+static guint16 vid;
+static guint16 pid;
+#endif
+static gchar *cdc_wdm_str;
+static gchar *tty_str;
+
+#if defined WITH_UDEV
/* Update */
static gboolean action_update_flag;
static gchar *firmware_version_str;
static gchar *config_version_str;
static gchar *carrier_str;
-static gboolean device_open_proxy_flag;
-static gboolean device_open_qmi_flag;
-static gboolean device_open_mbim_flag;
-static gboolean device_open_auto_flag;
static gboolean ignore_version_errors_flag;
static gboolean override_download_flag;
static gint modem_storage_index_int;
static gboolean skip_validation_flag;
+#endif
/* Reset */
static gboolean action_reset_flag;
@@ -73,6 +73,10 @@ static gboolean action_verify_flag;
/* Main */
static gchar **image_strv;
+static gboolean device_open_proxy_flag;
+static gboolean device_open_qmi_flag;
+static gboolean device_open_mbim_flag;
+static gboolean device_open_auto_flag;
static gboolean stdout_verbose_flag;
static gboolean stdout_silent_flag;
static gchar *verbose_log_str;
@@ -80,6 +84,8 @@ static gboolean version_flag;
static gboolean help_flag;
static gboolean help_examples_flag;
+#if defined WITH_UDEV
+
static gboolean
parse_busnum_devnum (const gchar *option_name,
const gchar *value,
@@ -175,7 +181,10 @@ out:
return result;
}
+#endif /* WITH_UDEV */
+
static GOptionEntry context_selection_entries[] = {
+#if defined WITH_UDEV
{ "busnum-devnum", 's', 0, G_OPTION_ARG_CALLBACK, &parse_busnum_devnum,
"Select device by bus and device number (in decimal).",
"[BUS:]DEV"
@@ -184,6 +193,7 @@ static GOptionEntry context_selection_entries[] = {
"Select device by device vendor and product id (in hexadecimal).",
"VID[:PID]"
},
+#endif /* WITH_UDEV */
{ "cdc-wdm", 'w', 0, G_OPTION_ARG_FILENAME, &cdc_wdm_str,
"Select device by QMI/MBIM cdc-wdm device path (e.g. /dev/cdc-wdm0).",
"[PATH]"
@@ -195,6 +205,7 @@ static GOptionEntry context_selection_entries[] = {
{ NULL }
};
+#if defined WITH_UDEV
static GOptionEntry context_update_entries[] = {
{ "update", 'u', 0, G_OPTION_ARG_NONE, &action_update_flag,
"Launch firmware update process.",
@@ -230,6 +241,7 @@ static GOptionEntry context_update_entries[] = {
},
{ NULL }
};
+#endif /* WITH_UDEV */
static GOptionEntry context_reset_entries[] = {
{ "reset", 'b', 0, G_OPTION_ARG_NONE, &action_reset_flag,
@@ -345,6 +357,7 @@ print_help (GOptionContext *context)
static void
print_help_examples (void)
{
+#if defined WITH_UDEV
g_print ("\n"
"********************************************************************************\n"
"\n"
@@ -427,6 +440,8 @@ print_help_examples (void)
" --cdc-wdm /dev/cdc-wdm0 \\\n"
" 9999999_9999999_9200_03.05.14.00_00_generic_000.000_001_SPKG_MC.cwe\n");
+#endif /* WITH_UDEV */
+
g_print ("\n"
"********************************************************************************\n"
"\n"
@@ -442,7 +457,7 @@ print_help_examples (void)
" -d /dev/cdc-wdm0 \\\n"
" --dms-set-firmware-preference=\"05.05.58.00,005.025_002,Generic\" \\\n"
"\n"
- " b) Request power cycle \\\n"
+ " b) Request power cycle:\n"
" $ sudo qmicli \\\n"
" -d /dev/cdc-wdm0 \\\n"
" --dms-set-operating-mode=offline \\\n"
@@ -450,7 +465,9 @@ print_help_examples (void)
" -d /dev/cdc-wdm0 \\\n"
" --dms-set-operating-mode=reset \\\n"
"\n"
- " c) Run updater operation while in QDL download mode:\n"
+ " c) Wait for the /dev/ttyUSB device to appear.\n"
+ "\n"
+ " d) Run updater operation while in QDL download mode:\n"
" $ sudo " PROGRAM_NAME " \\\n"
" -t /dev/ttyUSB0 \\\n"
" --update-qdl \\\n"
@@ -473,13 +490,15 @@ print_help_examples (void)
" -d 1199:68a2 \\\n"
" --reset\n"
"\n"
- " b) Run updater operation while in QDL download mode:\n"
+ " b) Wait for the /dev/ttyUSB device to appear.\n"
+ "\n"
+ " c) Run updater operation while in QDL download mode:\n"
" $ sudo " PROGRAM_NAME " \\\n"
" -d 1199:68a2 \\\n"
" --update-qdl \\\n"
" 9999999_9999999_9200_03.05.14.00_00_generic_000.000_001_SPKG_MC.cwe\n"
"\n"
- " c) Now wait for the device to fully reboot, may take up to several minutes.\n");
+ " d) Now wait for the device to fully reboot, may take up to several minutes.\n");
g_print ("\n"
@@ -511,6 +530,9 @@ int main (int argc, char **argv)
GOptionContext *context;
GOptionGroup *group;
guint n_actions;
+ guint n_actions_images_needed;
+ guint n_actions_device_needed;
+ guint n_actions_cdc_wdm_needed;
gboolean result = FALSE;
QfuDeviceSelection *device_selection = NULL;
QmiDeviceOpenFlags device_open_flags = QMI_DEVICE_OPEN_FLAGS_NONE;
@@ -525,9 +547,11 @@ int main (int argc, char **argv)
g_option_group_add_entries (group, context_selection_entries);
g_option_context_add_group (context, group);
+#if defined WITH_UDEV
group = g_option_group_new ("update", "Update options (normal mode)", "", NULL, NULL);
g_option_group_add_entries (group, context_update_entries);
g_option_context_add_group (context, group);
+#endif
group = g_option_group_new ("reset", "Reset options (normal mode)", "", NULL, NULL);
g_option_group_add_entries (group, context_reset_entries);
@@ -571,11 +595,24 @@ int main (int argc, char **argv)
/* Initialize logging */
qfu_log_init (stdout_verbose_flag, stdout_silent_flag, verbose_log_str);
+
+ /* Total actions */
+ n_actions = (action_verify_flag + action_update_qdl_flag + action_reset_flag);
+ /* Actions that require images specified */
+ n_actions_images_needed = (action_verify_flag + action_update_qdl_flag);
+ /* Actions that require a device specified */
+ n_actions_device_needed = (action_update_qdl_flag + action_reset_flag);
+ /* Actions that allow using a cdc-wdm device */
+ n_actions_cdc_wdm_needed = (action_reset_flag);
+
+#if defined WITH_UDEV
+ n_actions += action_update_flag;
+ n_actions_cdc_wdm_needed += action_update_flag;
+ n_actions_images_needed += action_update_flag;
+ n_actions_device_needed += action_update_flag;
+#endif
+
/* We don't allow multiple actions at the same time */
- n_actions = (action_verify_flag +
- action_update_flag +
- action_update_qdl_flag +
- action_reset_flag);
if (n_actions == 0) {
g_printerr ("error: no actions specified\n");
goto out;
@@ -586,14 +623,18 @@ int main (int argc, char **argv)
}
/* A list of images must be provided for update and verify operations */
- if ((action_verify_flag || action_update_flag || action_update_qdl_flag) && !image_strv) {
+ if (n_actions_images_needed && !image_strv) {
g_printerr ("error: no firmware images specified\n");
goto out;
}
/* device selection must be performed for update and reset operations */
- if (action_update_flag || action_update_qdl_flag || action_reset_flag) {
+ if (n_actions_device_needed) {
+#if defined WITH_UDEV
device_selection = qfu_device_selection_new (cdc_wdm_str, tty_str, vid, pid, busnum, devnum, &error);
+#else
+ device_selection = qfu_device_selection_new (cdc_wdm_str, tty_str, 0, 0, 0, 0, &error);
+#endif
if (!device_selection) {
g_printerr ("error: couldn't select device:: %s\n", error->message);
g_error_free (error);
@@ -602,7 +643,7 @@ int main (int argc, char **argv)
}
/* Validate device open flags */
- if (action_update_flag || action_reset_flag) {
+ if (n_actions_cdc_wdm_needed) {
if (device_open_mbim_flag + device_open_qmi_flag + device_open_auto_flag > 1) {
g_printerr ("error: cannot specify multiple mode flags to open device\n");
goto out;
@@ -617,6 +658,7 @@ int main (int argc, char **argv)
/* Run */
+#if defined WITH_UDEV
if (action_update_flag) {
g_assert (QFU_IS_DEVICE_SELECTION (device_selection));
@@ -639,6 +681,7 @@ int main (int argc, char **argv)
skip_validation_flag);
goto out;
}
+#endif /* WITH_UDEV */
if (action_update_qdl_flag) {
g_assert (QFU_IS_DEVICE_SELECTION (device_selection));
diff --git a/src/qmi-firmware-update/qfu-operation-update.c b/src/qmi-firmware-update/qfu-operation-update.c
index e96309d..af061e9 100644
--- a/src/qmi-firmware-update/qfu-operation-update.c
+++ b/src/qmi-firmware-update/qfu-operation-update.c
@@ -115,6 +115,8 @@ operation_update_run (QfuUpdater *updater,
return operation.result;
}
+#if defined WITH_UDEV
+
gboolean
qfu_operation_update_run (const gchar **images,
QfuDeviceSelection *device_selection,
@@ -146,6 +148,8 @@ qfu_operation_update_run (const gchar **images,
return result;
}
+#endif
+
gboolean
qfu_operation_update_qdl_run (const gchar **images,
QfuDeviceSelection *device_selection)
diff --git a/src/qmi-firmware-update/qfu-operation.h b/src/qmi-firmware-update/qfu-operation.h
index 5f30439..b1ddced 100644
--- a/src/qmi-firmware-update/qfu-operation.h
+++ b/src/qmi-firmware-update/qfu-operation.h
@@ -22,12 +22,15 @@
#ifndef QFU_OPERATION_H
#define QFU_OPERATION_H
+#include "config.h"
+
#include <glib.h>
#include <libqmi-glib.h>
#include "qfu-device-selection.h"
G_BEGIN_DECLS
+#if defined WITH_UDEV
gboolean qfu_operation_update_run (const gchar **images,
QfuDeviceSelection *device_selection,
const gchar *firmware_version,
@@ -38,6 +41,8 @@ gboolean qfu_operation_update_run (const gchar **images,
gboolean override_download,
guint8 modem_storage_index,
gboolean skip_validation);
+#endif
+
gboolean qfu_operation_update_qdl_run (const gchar **images,
QfuDeviceSelection *device_selection);
gboolean qfu_operation_verify_run (const gchar **images);
diff --git a/src/qmi-firmware-update/qfu-reseter.c b/src/qmi-firmware-update/qfu-reseter.c
index 87a9b0a..541d390 100644
--- a/src/qmi-firmware-update/qfu-reseter.c
+++ b/src/qmi-firmware-update/qfu-reseter.c
@@ -23,7 +23,6 @@
#include <string.h>
#include <gio/gio.h>
-#include <gudev/gudev.h>
#include <libqmi-glib.h>
diff --git a/src/qmi-firmware-update/qfu-udev-helpers.c b/src/qmi-firmware-update/qfu-udev-helpers.c
index 89a80eb..40e4723 100644
--- a/src/qmi-firmware-update/qfu-udev-helpers.c
+++ b/src/qmi-firmware-update/qfu-udev-helpers.c
@@ -22,12 +22,12 @@
#include <stdlib.h>
#include <gio/gio.h>
-#include <gudev/gudev.h>
-#include "qfu-udev-helpers.h"
+#if defined WITH_UDEV
+# include <gudev/gudev.h>
+#endif
-static const gchar *tty_subsys_list[] = { "tty", NULL };
-static const gchar *cdc_wdm_subsys_list[] = { "usbmisc", "usb", NULL };
+#include "qfu-udev-helpers.h"
/******************************************************************************/
@@ -46,6 +46,11 @@ qfu_udev_helper_device_type_to_string (QfuUdevHelperDeviceType type)
/******************************************************************************/
+#if defined WITH_UDEV
+
+static const gchar *tty_subsys_list[] = { "tty", NULL };
+static const gchar *cdc_wdm_subsys_list[] = { "usbmisc", "usb", NULL };
+
static gboolean
udev_helper_get_udev_device_details (GUdevDevice *device,
gchar **out_sysfs_path,
@@ -641,3 +646,5 @@ qfu_udev_helper_generic_monitor_new (const gchar *sysfs_path)
g_signal_connect (self->udev, "uevent", G_CALLBACK (handle_uevent_generic), NULL);
return self;
}
+
+#endif /* WITH_UDEV */
diff --git a/src/qmi-firmware-update/qfu-udev-helpers.h b/src/qmi-firmware-update/qfu-udev-helpers.h
index b12b8df..6f6eac0 100644
--- a/src/qmi-firmware-update/qfu-udev-helpers.h
+++ b/src/qmi-firmware-update/qfu-udev-helpers.h
@@ -22,10 +22,22 @@
#ifndef QFU_UDEV_HELPERS_H
#define QFU_UDEV_HELPERS_H
+#include "config.h"
+
#include <gio/gio.h>
G_BEGIN_DECLS
+typedef enum {
+ QFU_UDEV_HELPER_DEVICE_TYPE_TTY,
+ QFU_UDEV_HELPER_DEVICE_TYPE_CDC_WDM,
+ QFU_UDEV_HELPER_DEVICE_TYPE_LAST
+} QfuUdevHelperDeviceType;
+
+const gchar *qfu_udev_helper_device_type_to_string (QfuUdevHelperDeviceType type);
+
+#if defined WITH_UDEV
+
gchar *qfu_udev_helper_find_by_file (GFile *file,
GError **error);
gchar *qfu_udev_helper_find_by_file_path (const gchar *path,
@@ -36,14 +48,6 @@ gchar *qfu_udev_helper_find_by_device_info (guint16 vid,
guint devnum,
GError **error);
-typedef enum {
- QFU_UDEV_HELPER_DEVICE_TYPE_TTY,
- QFU_UDEV_HELPER_DEVICE_TYPE_CDC_WDM,
- QFU_UDEV_HELPER_DEVICE_TYPE_LAST
-} QfuUdevHelperDeviceType;
-
-const gchar *qfu_udev_helper_device_type_to_string (QfuUdevHelperDeviceType type);
-
GList *qfu_udev_helper_list_devices (QfuUdevHelperDeviceType device_type,
const gchar *sysfs_path);
@@ -59,6 +63,8 @@ typedef struct _QfuUdevHelperGenericMonitor QfuUdevHelperGenericMonitor;
QfuUdevHelperGenericMonitor *qfu_udev_helper_generic_monitor_new (const gchar *sysfs_path);
void qfu_udev_helper_generic_monitor_free (QfuUdevHelperGenericMonitor *self);
+#endif
+
G_END_DECLS
#endif /* QFU_UDEV_HELPERS_H */
diff --git a/src/qmi-firmware-update/qfu-updater.c b/src/qmi-firmware-update/qfu-updater.c
index ead15c9..53c2315 100644
--- a/src/qmi-firmware-update/qfu-updater.c
+++ b/src/qmi-firmware-update/qfu-updater.c
@@ -23,7 +23,6 @@
#include <string.h>
#include <gio/gio.h>
-#include <gudev/gudev.h>
#include <libqmi-glib.h>
@@ -42,13 +41,16 @@ G_DEFINE_TYPE (QfuUpdater, qfu_updater, G_TYPE_OBJECT)
typedef enum {
UPDATER_TYPE_UNKNOWN,
+#if defined WITH_UDEV
UPDATER_TYPE_GENERIC,
+#endif
UPDATER_TYPE_QDL,
} UpdaterType;
struct _QfuUpdaterPrivate {
UpdaterType type;
QfuDeviceSelection *device_selection;
+#if defined WITH_UDEV
gchar *firmware_version;
gchar *config_version;
gchar *carrier;
@@ -57,6 +59,7 @@ struct _QfuUpdaterPrivate {
gboolean override_download;
guint8 modem_storage_index;
gboolean skip_validation;
+#endif
};
/******************************************************************************/
@@ -82,32 +85,39 @@ static const gchar *progress[] = {
#define WAIT_FOR_BOOT_RETRIES 12
typedef enum {
+#if defined WITH_UDEV
RUN_CONTEXT_STEP_QMI_CLIENT,
RUN_CONTEXT_STEP_GET_FIRMWARE_PREFERENCE,
RUN_CONTEXT_STEP_SET_FIRMWARE_PREFERENCE,
RUN_CONTEXT_STEP_POWER_CYCLE,
RUN_CONTEXT_STEP_CLEANUP_QMI_DEVICE,
RUN_CONTEXT_STEP_WAIT_FOR_TTY,
+#endif
RUN_CONTEXT_STEP_QDL_DEVICE,
RUN_CONTEXT_STEP_SELECT_IMAGE,
RUN_CONTEXT_STEP_DOWNLOAD_IMAGE,
RUN_CONTEXT_STEP_CLEANUP_IMAGE,
RUN_CONTEXT_STEP_CLEANUP_QDL_DEVICE,
+#if defined WITH_UDEV
RUN_CONTEXT_STEP_WAIT_FOR_CDC_WDM,
RUN_CONTEXT_STEP_WAIT_FOR_BOOT,
RUN_CONTEXT_STEP_QMI_CLIENT_AFTER,
RUN_CONTEXT_STEP_CLEANUP_QMI_DEVICE_FULL,
+#endif
RUN_CONTEXT_STEP_LAST
} RunContextStep;
typedef struct {
/* Device selection */
+#if defined WITH_UDEV
GFile *cdc_wdm_file;
+#endif
GFile *serial_file;
/* Context step */
RunContextStep step;
+#if defined WITH_UDEV
/* Old/New info and capabilities */
gchar *revision;
gboolean supports_stored_image_management;
@@ -120,35 +130,39 @@ typedef struct {
gboolean new_supports_firmware_preference_management;
QmiMessageDmsGetFirmwarePreferenceOutput *new_firmware_preference;
QmiMessageDmsSwiGetCurrentFirmwareOutput *new_current_firmware;
+#endif
/* List of pending QfuImages to download, and the current one being
* processed. */
GList *pending_images;
QfuImage *current_image;
+#if defined WITH_UDEV
/* QMI device and client */
QmiDevice *qmi_device;
QmiClientDms *qmi_client;
- /* QDL device */
- QfuQdlDevice *qdl_device;
-
/* Reset configuration */
gboolean boothold_reset;
/* Information gathered from the firmware images themselves */
- gchar *firmware_version;
- gchar *config_version;
- gchar *carrier;
+ gchar *firmware_version;
+ gchar *config_version;
+ gchar *carrier;
/* Waiting for boot */
guint wait_for_boot_seconds_elapsed;
guint wait_for_boot_retries;
+#endif
+
+ /* QDL device */
+ QfuQdlDevice *qdl_device;
} RunContext;
static void
run_context_free (RunContext *ctx)
{
+#if defined WITH_UDEV
if (ctx->current_firmware)
qmi_message_dms_swi_get_current_firmware_output_unref (ctx->current_firmware);
if (ctx->new_current_firmware)
@@ -162,8 +176,7 @@ run_context_free (RunContext *ctx)
g_free (ctx->firmware_version);
g_free (ctx->config_version);
g_free (ctx->carrier);
- if (ctx->qdl_device)
- g_object_unref (&ctx->qdl_device);
+
if (ctx->qmi_client) {
g_assert (ctx->qmi_device);
/* This release only happens when cleaning up from an error,
@@ -178,13 +191,19 @@ run_context_free (RunContext *ctx)
qmi_device_close_async (ctx->qmi_device, 10, NULL, NULL, NULL);
g_object_unref (ctx->qmi_device);
}
+ if (ctx->cdc_wdm_file)
+ g_object_unref (ctx->cdc_wdm_file);
+#endif
+
+ if (ctx->qdl_device)
+ g_object_unref (&ctx->qdl_device);
+ if (ctx->serial_file)
+ g_object_unref (ctx->serial_file);
+
if (ctx->current_image)
g_object_unref (ctx->current_image);
g_list_free_full (ctx->pending_images, (GDestroyNotify) g_object_unref);
- if (ctx->serial_file)
- g_object_unref (ctx->serial_file);
- if (ctx->cdc_wdm_file)
- g_object_unref (ctx->cdc_wdm_file);
+
g_slice_free (RunContext, ctx);
}
@@ -196,6 +215,8 @@ qfu_updater_run_finish (QfuUpdater *self,
return g_task_propagate_boolean (G_TASK (res), error);
}
+#if defined WITH_UDEV
+
static void
print_firmware_preference (QmiMessageDmsGetFirmwarePreferenceOutput *firmware_preference,
const gchar *prefix)
@@ -263,62 +284,80 @@ print_current_firmware (QmiMessageDmsSwiGetCurrentFirmwareOutput *current_firmwa
g_print ("%sConfig version: %s\n", prefix, config_version);
}
+#endif /* WITH_UDEV */
+
static void
run_context_step_last (GTask *task)
{
RunContext *ctx;
+ QfuUpdater *self;
ctx = (RunContext *) g_task_get_task_data (task);
+ g_assert (ctx);
- /* Dump output report */
- g_print ("\n"
- "------------------------------------------------------------------------\n");
+ self = g_task_get_source_object (task);
- g_print ("\n"
- " original firmware revision was:\n"
- " %s\n", ctx->revision ? ctx->revision : "unknown");
- if (ctx->current_firmware) {
- g_print (" original running firmware details:\n");
- print_current_firmware (ctx->current_firmware, " ");
- }
- if (ctx->firmware_preference) {
- g_print (" original firmware preference details:\n");
- print_firmware_preference (ctx->firmware_preference, " ");
+ if (self->priv->type == UPDATER_TYPE_QDL) {
+ g_task_return_boolean (task, TRUE);
+ g_object_unref (task);
+ return;
}
- g_print ("\n"
- " new firmware revision is:\n"
- " %s\n", ctx->new_revision ? ctx->new_revision : "unknown");
- if (ctx->new_current_firmware) {
- g_print (" new running firmware details:\n");
- print_current_firmware (ctx->new_current_firmware, " ");
- }
- if (ctx->new_firmware_preference) {
- g_print (" new firmware preference details:\n");
- print_firmware_preference (ctx->new_firmware_preference, " ");
- }
+#if defined WITH_UDEV
+ if (self->priv->type == UPDATER_TYPE_GENERIC) {
+ g_print ("\n"
+ "------------------------------------------------------------------------\n");
- if (ctx->new_supports_stored_image_management)
g_print ("\n"
- " NOTE: this device supports stored image management\n"
- " with qmicli operations:\n"
- " --dms-list-stored-images\n"
- " --dms-select-stored-image\n"
- " --dms-delete-stored-image\n");
+ " original firmware revision was:\n"
+ " %s\n", ctx->revision ? ctx->revision : "unknown");
+ if (ctx->current_firmware) {
+ g_print (" original running firmware details:\n");
+ print_current_firmware (ctx->current_firmware, " ");
+ }
+ if (ctx->firmware_preference) {
+ g_print (" original firmware preference details:\n");
+ print_firmware_preference (ctx->firmware_preference, " ");
+ }
- if (ctx->new_supports_firmware_preference_management)
g_print ("\n"
- " NOTE: this device supports firmware preference management\n"
- " with qmicli operations:\n"
- " --dms-get-firmware-preference\n"
- " --dms-set-firmware-preference\n");
+ " new firmware revision is:\n"
+ " %s\n", ctx->new_revision ? ctx->new_revision : "unknown");
+ if (ctx->new_current_firmware) {
+ g_print (" new running firmware details:\n");
+ print_current_firmware (ctx->new_current_firmware, " ");
+ }
+ if (ctx->new_firmware_preference) {
+ g_print (" new firmware preference details:\n");
+ print_firmware_preference (ctx->new_firmware_preference, " ");
+ }
- g_print ("\n"
- "------------------------------------------------------------------------\n"
- "\n");
+ if (ctx->new_supports_stored_image_management)
+ g_print ("\n"
+ " NOTE: this device supports stored image management\n"
+ " with qmicli operations:\n"
+ " --dms-list-stored-images\n"
+ " --dms-select-stored-image\n"
+ " --dms-delete-stored-image\n");
+
+ if (ctx->new_supports_firmware_preference_management)
+ g_print ("\n"
+ " NOTE: this device supports firmware preference management\n"
+ " with qmicli operations:\n"
+ " --dms-get-firmware-preference\n"
+ " --dms-set-firmware-preference\n");
+
+ g_print ("\n"
+ "------------------------------------------------------------------------\n"
+ "\n");
+
+ g_task_return_boolean (task, TRUE);
+ g_object_unref (task);
+ return;
+ }
+#endif /* WITH_UDEV */
- g_task_return_boolean (task, TRUE);
- g_object_unref (task);
+ g_assert_not_reached ();
}
static void run_context_step (GTask *task);
@@ -342,6 +381,8 @@ run_context_step_next (GTask *task, RunContextStep next)
g_idle_add ((GSourceFunc) run_context_step_cb, task);
}
+#if defined WITH_UDEV
+
static void
run_context_step_next_no_idle (GTask *task, RunContextStep next)
{
@@ -582,6 +623,8 @@ run_context_step_wait_for_cdc_wdm (GTask *task)
task);
}
+#endif /* WITH_UDEV */
+
static void
run_context_step_cleanup_qdl_device (GTask *task)
{
@@ -755,6 +798,8 @@ run_context_step_qdl_device (GTask *task)
run_context_step_next (task, ctx->step + 1);
}
+#if defined WITH_UDEV
+
static void
wait_for_tty_ready (QfuDeviceSelection *device_selection,
GAsyncResult *res,
@@ -1311,23 +1356,29 @@ run_context_step_qmi_client (GTask *task)
task);
}
+#endif /* WITH_UDEV */
+
typedef void (* RunContextStepFunc) (GTask *task);
static const RunContextStepFunc run_context_step_func[] = {
+#if defined WITH_UDEV
[RUN_CONTEXT_STEP_QMI_CLIENT] = run_context_step_qmi_client,
[RUN_CONTEXT_STEP_GET_FIRMWARE_PREFERENCE] = run_context_step_get_firmware_preference,
[RUN_CONTEXT_STEP_SET_FIRMWARE_PREFERENCE] = run_context_step_set_firmware_preference,
[RUN_CONTEXT_STEP_POWER_CYCLE] = run_context_step_power_cycle,
[RUN_CONTEXT_STEP_CLEANUP_QMI_DEVICE] = run_context_step_cleanup_qmi_device,
[RUN_CONTEXT_STEP_WAIT_FOR_TTY] = run_context_step_wait_for_tty,
+#endif
[RUN_CONTEXT_STEP_QDL_DEVICE] = run_context_step_qdl_device,
[RUN_CONTEXT_STEP_SELECT_IMAGE] = run_context_step_select_image,
[RUN_CONTEXT_STEP_DOWNLOAD_IMAGE] = run_context_step_download_image,
[RUN_CONTEXT_STEP_CLEANUP_IMAGE] = run_context_step_cleanup_image,
[RUN_CONTEXT_STEP_CLEANUP_QDL_DEVICE] = run_context_step_cleanup_qdl_device,
+#if defined WITH_UDEV
[RUN_CONTEXT_STEP_WAIT_FOR_CDC_WDM] = run_context_step_wait_for_cdc_wdm,
[RUN_CONTEXT_STEP_WAIT_FOR_BOOT] = run_context_step_wait_for_boot,
[RUN_CONTEXT_STEP_QMI_CLIENT_AFTER] = run_context_step_qmi_client_after,
[RUN_CONTEXT_STEP_CLEANUP_QMI_DEVICE_FULL] = run_context_step_cleanup_qmi_device_full,
+#endif
};
G_STATIC_ASSERT (G_N_ELEMENTS (run_context_step_func) == RUN_CONTEXT_STEP_LAST);
@@ -1411,6 +1462,7 @@ qfu_updater_run (QfuUpdater *self,
}
switch (self->priv->type) {
+#if defined WITH_UDEV
case UPDATER_TYPE_GENERIC:
ctx->step = RUN_CONTEXT_STEP_QMI_CLIENT;
ctx->cdc_wdm_file = qfu_device_selection_get_single_cdc_wdm (self->priv->device_selection);
@@ -1421,6 +1473,7 @@ qfu_updater_run (QfuUpdater *self,
return;
}
break;
+#endif
case UPDATER_TYPE_QDL:
ctx->step = RUN_CONTEXT_STEP_QDL_DEVICE;
ctx->serial_file = qfu_device_selection_get_single_tty (self->priv->device_selection);
@@ -1440,6 +1493,8 @@ qfu_updater_run (QfuUpdater *self,
/******************************************************************************/
+#if defined WITH_UDEV
+
QfuUpdater *
qfu_updater_new (QfuDeviceSelection *device_selection,
const gchar *firmware_version,
@@ -1470,6 +1525,8 @@ qfu_updater_new (QfuDeviceSelection *device_selection,
return self;
}
+#endif
+
QfuUpdater *
qfu_updater_new_qdl (QfuDeviceSelection *device_selection)
{
@@ -1504,11 +1561,13 @@ dispose (GObject *object)
static void
finalize (GObject *object)
{
+#if defined WITH_UDEV
QfuUpdater *self = QFU_UPDATER (object);
g_free (self->priv->firmware_version);
g_free (self->priv->config_version);
g_free (self->priv->carrier);
+#endif
G_OBJECT_CLASS (qfu_updater_parent_class)->finalize (object);
}
diff --git a/src/qmi-firmware-update/qfu-updater.h b/src/qmi-firmware-update/qfu-updater.h
index 392bcb7..9e421c7 100644
--- a/src/qmi-firmware-update/qfu-updater.h
+++ b/src/qmi-firmware-update/qfu-updater.h
@@ -50,6 +50,8 @@ struct _QfuUpdaterClass {
};
GType qfu_updater_get_type (void);
+
+#if defined WITH_UDEV
QfuUpdater *qfu_updater_new (QfuDeviceSelection *device_selection,
const gchar *firmware_version,
const gchar *config_version,
@@ -59,6 +61,8 @@ QfuUpdater *qfu_updater_new (QfuDeviceSelection *device_selection,
gboolean override_download,
guint8 modem_storage_index,
gboolean skip_validation);
+#endif
+
QfuUpdater *qfu_updater_new_qdl (QfuDeviceSelection *device_selection);
void qfu_updater_run (QfuUpdater *self,
GList *image_file_list,