Permalink
Browse files

dfu: Add support for one type of AVR32 device

Currently the only supported model is the AT32UC3A3256S, more to come...
  • Loading branch information...
hughsie committed Oct 26, 2017
1 parent d49f64f commit 3e1e8227be2690b19c6d2c61101dbd5448920668
View
@@ -169,6 +169,8 @@ dfu_version_to_string (DfuVersion version)
return "1.1";
if (version == DFU_VERSION_DFUSE)
return "DfuSe";
if (version == DFU_VERSION_ATMEL_AVR)
return "AtmelAVR";
return NULL;
}
View
@@ -163,6 +163,7 @@ typedef enum {
* @DFU_VERSION_DFU_1_0: DFU 1.0
* @DFU_VERSION_DFU_1_1: DFU 1.1
* @DFU_VERSION_DFUSE: DfuSe
* @DFU_VERSION_ATMEL_AVR: Atmel AVR
*
* The known versions of the DFU standard in BCD format.
**/
@@ -171,6 +172,7 @@ typedef enum {
DFU_VERSION_DFU_1_0 = 0x0100,
DFU_VERSION_DFU_1_1 = 0x0110,
DFU_VERSION_DFUSE = 0x011a, /* defined by ST */
DFU_VERSION_ATMEL_AVR = 0xff01, /* made up */
/*< private >*/
DFU_VERSION_LAST
} DfuVersion;
View
@@ -41,6 +41,7 @@
#include "dfu-common.h"
#include "dfu-device-private.h"
#include "dfu-target-avr.h"
#include "dfu-target-private.h"
#include "dfu-target-stm.h"
@@ -252,6 +253,7 @@ dfu_device_finalize (GObject *object)
g_object_unref (priv->dev_locker);
if (priv->dev != NULL)
g_object_unref (priv->dev);
g_free (priv->chip_id);
g_free (priv->display_name);
g_free (priv->serial_number);
g_free (priv->platform_id);
@@ -325,6 +327,10 @@ dfu_device_parse_iface_data (DfuDevice *device, GBytes *iface_data)
if (priv->version == DFU_VERSION_DFU_1_0 ||
priv->version == DFU_VERSION_DFU_1_1) {
g_debug ("basic DFU 1.1");
} else if (priv->version == 0x0101 &&
dfu_device_has_quirk (device, DFU_DEVICE_QUIRK_USE_ATMEL_AVR)) {
g_debug ("AVR-DFU support forced");
priv->version = DFU_VERSION_ATMEL_AVR;
} else if (priv->version == DFU_VERSION_DFUSE) {
g_debug ("STM-DFU support");
} else if (priv->version == 0x0101) {
@@ -419,6 +425,9 @@ dfu_device_add_targets (DfuDevice *device)
case DFU_VERSION_DFUSE:
target = dfu_target_stm_new ();
break;
case DFU_VERSION_ATMEL_AVR:
target = dfu_target_avr_new ();
break;
default:
target = dfu_target_new ();
break;
@@ -713,6 +722,10 @@ dfu_device_set_quirks (DfuDevice *device)
}
}
/* Atmel bootloader */
if (vid == 0x03eb)
priv->quirks |= DFU_DEVICE_QUIRK_USE_ATMEL_AVR;
/* the DSO Nano has uses 0 instead of 2 when in DFU mode */
// quirks |= DFU_DEVICE_QUIRK_USE_PROTOCOL_ZERO;
}
@@ -2361,6 +2374,8 @@ dfu_device_get_quirks_as_string (DfuDevice *device)
g_string_append_printf (str, "attach-extra-reset|");
if (priv->quirks & DFU_DEVICE_QUIRK_JABRA_MAGIC)
g_string_append_printf (str, "jabra-magic|");
if (priv->quirks & DFU_DEVICE_QUIRK_USE_ATMEL_AVR)
g_string_append_printf (str, "use-atmel-avr|");
/* a well behaved device */
if (str->len == 0) {
View
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
* Copyright (C) 2015-2017 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -65,6 +65,7 @@ typedef enum {
* @DFU_DEVICE_QUIRK_IGNORE_UPLOAD: Uploading from the device is broken
* @DFU_DEVICE_QUIRK_ATTACH_EXTRA_RESET: Device needs resetting twice for attach
* @DFU_DEVICE_QUIRK_JABRA_MAGIC: Device needs a magic replug sequence
* @DFU_DEVICE_QUIRK_USE_ATMEL_AVR: Device uses the ATMEL bootloader
*
* The workarounds for different devices.
**/
@@ -83,6 +84,7 @@ typedef enum {
DFU_DEVICE_QUIRK_IGNORE_UPLOAD = (1 << 10),
DFU_DEVICE_QUIRK_ATTACH_EXTRA_RESET = (1 << 11),
DFU_DEVICE_QUIRK_JABRA_MAGIC = (1 << 12),
DFU_DEVICE_QUIRK_USE_ATMEL_AVR = (1 << 13),
/*< private >*/
DFU_DEVICE_QUIRK_LAST
} DfuDeviceQuirks;
Oops, something went wrong.

0 comments on commit 3e1e822

Please sign in to comment.