Commit Graph

107 Commits

Author SHA1 Message Date
Richard Hughes
b73e70b205 trivial: Use the shared fu_test_compare_lines() in the dfu plugin 2018-01-11 09:59:34 +00:00
Richard Hughes
5060246526 trivial: Move the USB quirks from FuPlugin to FuUsbDevice
Also rename some general USB quirks that are not specific to any one plugin.
2017-12-11 10:47:18 +00:00
Richard Hughes
a29711c4a1 Move the FuQuirks reference down from DfuDevice to FuDevice 2017-12-11 10:47:18 +00:00
Richard Hughes
ae252cd83c trivial: Add some common functionality from reading and writing to a buffer 2017-12-08 20:07:09 +00:00
Richard Hughes
e755d6bb05 Add a more general quirk for adding GUIDs to devices
This replaces fwupd-dfu-alternate-vidpid which was only useful in the DFU plugin
and somewhat poorly defined.
2017-12-04 17:00:22 +00:00
Richard Hughes
524343ac63 trivial: Remove DfuMode
We can get all this information just from looking at the device state.
2017-12-04 17:00:22 +00:00
Richard Hughes
a2fff1f44e dfu: Remove DfuContext
Use the power of FuUsbDevice in DfuDevice to remove a lot of complicated code.
2017-12-04 17:00:22 +00:00
Richard Hughes
831bea1024 trivial: Manually call the initial DFU refresh to simplify the DfuDevice code 2017-12-04 17:00:22 +00:00
Richard Hughes
92ced1cfbf trivial: Move the detach and attach to the DFU client tool
This isn't used by the daemon and makes the DfuDevice client simpler.
2017-12-04 17:00:22 +00:00
Richard Hughes
01d152e2ef trivial: Make DfuDevice derive from GUsbDevice 2017-12-04 17:00:22 +00:00
Richard Hughes
1a16cc5e41 trivial: Remove the use of GCancellable in the dfu plugin
We're not using this, and we can simplify the code considerably now that the
library is not installed for external users.
2017-12-04 17:00:22 +00:00
Philip Withnall
a68a050f39 plugins: Remove various unused variables
Fix some compiler warnings to reduce the build noise.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-11-30 13:44:41 +00:00
Richard Hughes
2e9df07dc5 trivial: Remove the DFU-specific hardware tests
We have end-to-end installed tests using the daemon now.
2017-11-29 16:00:25 +00:00
Richard Hughes
d0cff7caec Remove autoconf-isms from the meson configure options
See https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting
2017-11-27 18:07:53 +00:00
Richard Hughes
51bc3e3d47 Add devices in DFU mode
By filtering out the devices not in runtime we have two problems:

* We can't use fwupdmgr to 'fix' any devices that failed to flash and are
  stuck in bootloader mode

* We can't transition from a runtime-less FuDevice to a DFU-capable FuDevice.

This allows the Nitrokey to be updated using fwupd.
2017-11-24 14:42:27 +00:00
Richard Hughes
4713f23f7f dfu: Fix attaching AVR32 devices like the XMEGA
Also, add a self test that uses the XMEGA A3BU XPLAINED board, see
https://github.com/hughsie/fwupd-test-firmware/tree/master/AVR/XMEGA-A3BU-XPLAINED-1.23
for more details about how to build the bootloader and firmware.
2017-11-23 18:48:03 +00:00
Richard Hughes
af652da167 dfu: Ignore an EP STALL when detaching
Some devices just detach without completing the transaction.
2017-11-23 10:46:26 +00:00
Richard Hughes
68327f3abd trivial: Add some missing debug information when detaching 2017-11-23 10:45:54 +00:00
Richard Hughes
aa6a56205f dfu: Assume DFU version is 1.1 if unspecified 2017-11-21 15:55:29 +00:00
Richard Hughes
3bc2f3bbb6 trivial: Parse the IHEX record types 02 and 03
Although we don't quite do the right thing, we only need to typically work out
the start offset of the firmware. This fixes 'dfu-tool dump foo.hex' for files
produced for the ATMEL ATXMEGA architechure.
2017-11-18 11:06:38 +00:00
Jan Tojnar
cc9f934787 build: Refactor directory selection
Previously, the various install paths were obtained using get_option
as needed.

This patch unifies the directory selection inside the top-level meson
file as requested in https://github.com/hughsie/colord/pull/62.
2017-11-17 17:11:51 +00:00
Richard Hughes
352ba1b833 dfu: Add support for the original AVR DFU protocol
This allows us to flash hardware like the Retrode and other devices using chips
like the AT90USB1287.

The test files can be re-generated using the sample code found here:
https://github.com/hughsie/fwupd-test-firmware and are designed
to be used on the AT90USBKEY2 development board.
2017-11-16 15:30:30 +00:00
Richard Hughes
c83ebad885 dfu: Ensure the progress callbacks are connected for all devices
This ensures the device always reports the correct status always (but just once)
to the client.
2017-11-16 15:30:30 +00:00
Richard Hughes
ee46fb6d09 dfu: Allow wildcarded VIDs and PIDs when loading from a .cab file
The logic is that this will have been matched using the GUID before it gets to
the writing stage.
2017-11-16 15:30:30 +00:00
Richard Hughes
fd4697188a dfu: Invalidate the DFU mode, state and status when replugging 2017-11-16 15:30:30 +00:00
Richard Hughes
5826838987 trivial: Fix the comments in the DFU quirk file to be more helpful 2017-11-16 15:30:30 +00:00
Richard Hughes
b6f79556f1 Use a SHA1 hash for the internal DeviceID
It's actually less scary to see a SHA1 hash than it is to see a path like
/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2. It's also way easier to
copy and paste into the various fwupdmgr command that require a device ID and
also means we can match a partial prefix much like git allows.

If we also move to a model where plugins can be changed during different stages
of the update (e.g. during detach) then the device might change connection type
and then the sysfs path not only becomes difficult to paste, but incorrect.

Session software doesn't care about the format of the device ID (it is supposed
to be an implementation detail) and so there's no API or ABI break here. A few
plugins also needed to be ported, but nothing too worrying.
2017-11-16 07:18:36 +00:00
Richard Hughes
49fafec020 Set environment variables to allow easy per-plugin debugging
This allows end-users testing a specific plugin to start fwupd with an extra
command line parameter, e.g. `--plugin-verbose=unifying` to output a lot of
debugging information to the console for that specific plugin.

This replaces a lot of ad-hoc environment variables with different naming
conventions.
2017-11-14 14:22:02 +00:00
Richard Hughes
2adee9082b dfu: Use the new update_detach() and update_attach() vfuncs 2017-11-14 10:49:43 +00:00
Richard Hughes
31830aaea3 dfu: Ensure the mode is set correctly for fake runtimes 2017-11-13 16:01:57 +00:00
Richard Hughes
959e3d8a76 dfu: Add quirk for AT32UC3B1256 as used in the RubberDucky 2017-11-13 14:25:02 +00:00
Richard Hughes
ff3efe77b4 trivial: Fix the DFU self tests when the ColorHug+ is connected 2017-11-13 14:07:50 +00:00
Richard Hughes
85dbcbf534 dfu: Add trivial helpers to get the current vid/pid/release 2017-11-11 21:06:18 +00:00
Richard Hughes
37906f6aae trivial: Fix NULL/FALSE confusion in the dfu plugin 2017-11-09 14:32:25 +00:00
Richard Hughes
69fcb73a74 dfu: Fix a trivial unused variable spotted by clang 2017-11-09 12:16:12 +00:00
Richard Hughes
d25e2d543a trivial: Add some self tests that use the Atmel Xplained boards in DFU mode
This does mean the tests have to be run as root to work, but they are just
skipped if run as a user.
2017-11-07 12:40:25 +00:00
Richard Hughes
21852821c5 dfu: Add ChipID quirks for various XMEGA parts
This also adds an *almost* throw-away python script to import the chip-ids from
the default conf file from the avrdude project. I've imported it here in case we
have to start caring about different page sizes or application offsets.
2017-11-07 12:40:25 +00:00
Richard Hughes
8517464eac dfu: Use a 24-byte chip ID for XMEGA parts so we match signature values with dfu-programmer 2017-11-07 12:40:25 +00:00
Richard Hughes
d44a5ee56d dfu: Add support for XMEGA chips
Notably, bootloaders for this class of device export an incorrect DFU interface.

Additionally, allow setting the buffer size for the UPLOAD to a larger size
than the defined device transfer size, which allows us to return the full
packet from the larger XMEGA devices.
2017-11-07 12:40:25 +00:00
Richard Hughes
ac9fa21eda dfu: Use a GError chain to properly report parsing failures 2017-11-07 12:40:25 +00:00
Richard Hughes
bdb6d7027a dfu: Allow setting a specific DFU version for hardware
Ignoring the warning is not good enough when we're setting policy based on the
specific version. Use the new quirk functionality to do this easily, which
also allows us to remove one more thing in the quirk mega-bitfield.
2017-11-07 12:40:25 +00:00
Richard Hughes
387017c331 trivial: Don't show (null) in the UI when the DFU status is unknown 2017-11-07 12:40:25 +00:00
Richard Hughes
a1c09e1b16 dfu: Fix a potential divide by zero issue
If page_sz == 0, which is supported, then we try to take the modulus of it
which is undefined behaviour and can cause a division by zero crash.

Found using Coverity.
2017-11-07 09:41:07 +00:00
Richard Hughes
8a0ec158bd dfu: Return failure when getting device status fails 2017-11-06 20:10:26 +00:00
Richard Hughes
79d08a327b trivial: Use a #define value for signature reads 2017-11-06 12:56:38 +00:00
Richard Hughes
674ed347d2 dfu: Use FuQuirk to map the chip ID to the AVR32 UM0424 alt-name 2017-11-02 19:08:51 +00:00
Richard Hughes
adeefcd4e0 dfu: Use FuQuirk to encode the Jabra magic packet contents
This allows us to remove the Jabra-specific quirk entry in the device bitfield,
and more importantly allows us to support some more Jabra devices in the future
without code changes.
2017-11-02 19:08:51 +00:00
Richard Hughes
6a32b92ef8 dfu: Move some code to allow re-use 2017-11-02 19:08:51 +00:00
Richard Hughes
24c452297d dfu: Use the FuQuirk infrastructure to move the quirks out of the code
This is slightly more verbose than desired as we also have to include the quirk
information when running the dfu-tool, which does not have an already set-up
FuQuirks object as it has no plugin.
2017-11-02 19:08:51 +00:00
Richard Hughes
78c1e6c009 dfu: Correctly output Intel HEX files with > 16bit offset addresses
Also, fix the checksum to actually produce valid files...
2017-10-31 18:30:05 +00:00