summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/avrdude-fix-libusb.patch
blob: 13d0eca91cafac08e196bc9b34588f0313b5040e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
Avrdude cannot build with our version of libusb. This patch fixes that.
See http://savannah.nongnu.org/bugs/?41854

diff --git a/dfu.c b/dfu.c
index 7d349bc..0f80440 100644
--- a/dfu.c
+++ b/dfu.c
@@ -36,13 +36,14 @@
 
 #ifndef HAVE_LIBUSB
 
-int dfu_open(struct dfu_dev *dfu, char *port_name) {
+struct dfu_dev * dfu_open(char *port_spec) {
   fprintf(stderr, "%s: Error: No USB support in this compile of avrdude\n",
     progname);
-  return -1;
+  return NULL;
 }
 
-int dfu_init(struct dfu_dev *dfu, unsigned short usb_pid) {
+int dfu_init(struct dfu_dev *dfu,
+  unsigned short vid, unsigned short pid) {
   return -1;
 }
 
diff --git a/flip1.c b/flip1.c
index b891d80..0959996 100644
--- a/flip1.c
+++ b/flip1.c
@@ -164,6 +164,8 @@ static void flip1_setup(PROGRAMMER * pgm);
 static void flip1_teardown(PROGRAMMER * pgm);
 
 /* INTERNAL PROGRAMMER FUNCTION PROTOTYPES */
+#ifdef HAVE_LIBUSB
+// The internal ones are made conditional, as they're not defined further down #ifndef HAVE_LIBUSB
 
 static void flip1_show_info(struct flip1 *flip1);
 
@@ -177,6 +179,8 @@ static const char * flip1_mem_unit_str(enum flip1_mem_unit mem_unit);
 static int flip1_set_mem_page(struct dfu_dev *dfu, unsigned short page_addr);
 static enum flip1_mem_unit flip1_mem_unit(const char *name);
 
+#endif /* HAVE_LIBUSB */
+
 /* THE INITPGM FUNCTION DEFINITIONS */
 
 void flip1_initpgm(PROGRAMMER *pgm)
@@ -201,6 +205,7 @@ void flip1_initpgm(PROGRAMMER *pgm)
   pgm->teardown         = flip1_teardown;
 }
 
+#ifdef HAVE_LIBUSB
 /* EXPORTED PROGRAMMER FUNCTION DEFINITIONS */
 
 int flip1_open(PROGRAMMER *pgm, char *port_spec)
@@ -876,3 +881,82 @@ enum flip1_mem_unit flip1_mem_unit(const char *name) {
     return FLIP1_MEM_UNIT_EEPROM;
   return FLIP1_MEM_UNIT_UNKNOWN;
 }
+#else /* HAVE_LIBUSB */
+// Dummy functions
+int flip1_open(PROGRAMMER *pgm, char *port_spec)
+{
+  fprintf(stderr, "%s: Error: No USB support in this compile of avrdude\n",
+    progname);
+  return NULL;
+}
+
+int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
+{
+  return -1;
+}
+
+void flip1_close(PROGRAMMER* pgm)
+{
+}
+
+void flip1_enable(PROGRAMMER* pgm)
+{
+}
+
+void flip1_disable(PROGRAMMER* pgm)
+{
+}
+
+void flip1_display(PROGRAMMER* pgm, const char *prefix)
+{
+}
+
+int flip1_program_enable(PROGRAMMER* pgm, AVRPART *part)
+{
+  return -1;
+}
+
+int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part)
+{
+  return -1;
+}
+
+int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned long addr, unsigned char *value)
+{
+  return -1;
+}
+
+int flip1_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned long addr, unsigned char value)
+{
+  return -1;
+}
+
+int flip1_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned int page_size, unsigned int addr, unsigned int n_bytes)
+{
+  return -1;
+}
+
+int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned int page_size, unsigned int addr, unsigned int n_bytes)
+{
+  return -1;
+}
+
+int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
+{
+  return -1;
+}
+
+void flip1_setup(PROGRAMMER * pgm)
+{
+}
+
+void flip1_teardown(PROGRAMMER * pgm)
+{
+}
+
+
+#endif /* HAVE_LIBUSB */
\ No newline at end of file

diff --git a/flip2.c b/flip2.c
index ed8e996..16c4bf8 100644
--- a/flip2.c
+++ b/flip2.c
@@ -151,6 +151,8 @@ static void flip2_setup(PROGRAMMER * pgm);
 static void flip2_teardown(PROGRAMMER * pgm);
 
 /* INTERNAL PROGRAMMER FUNCTION PROTOTYPES */
+#ifdef HAVE_LIBUSB
+// The internal ones are made conditional, as they're not defined further down #ifndef HAVE_LIBUSB
 
 static void flip2_show_info(struct flip2 *flip2);
 
@@ -171,6 +173,8 @@ static const char * flip2_status_str(const struct dfu_status *status);
 static const char * flip2_mem_unit_str(enum flip2_mem_unit mem_unit);
 static enum flip2_mem_unit flip2_mem_unit(const char *name);
 
+#endif /* HAVE_LIBUSB */
+
 /* THE INITPGM FUNCTION DEFINITIONS */
 
 void flip2_initpgm(PROGRAMMER *pgm)
@@ -195,6 +199,7 @@ void flip2_initpgm(PROGRAMMER *pgm)
   pgm->teardown         = flip2_teardown;
 }
 
+#ifdef HAVE_LIBUSB
 /* EXPORTED PROGRAMMER FUNCTION DEFINITIONS */
 
 int flip2_open(PROGRAMMER *pgm, char *port_spec)
@@ -922,3 +927,85 @@ enum flip2_mem_unit flip2_mem_unit(const char *name) {
     return FLIP2_MEM_UNIT_SIGNATURE;
   return FLIP2_MEM_UNIT_UNKNOWN;
 }
+
+#else /* HAVE_LIBUSB */
+
+/* EXPORTED PROGRAMMER FUNCTION DEFINITIONS */
+
+int flip2_open(PROGRAMMER *pgm, char *port_spec)
+{
+  fprintf(stderr, "%s: Error: No USB support in this compile of avrdude\n",
+    progname);
+  return NULL;
+}
+
+int flip2_initialize(PROGRAMMER* pgm, AVRPART *part)
+{
+  return -1;
+}
+
+void flip2_close(PROGRAMMER* pgm)
+{
+}
+
+void flip2_enable(PROGRAMMER* pgm)
+{
+}
+
+void flip2_disable(PROGRAMMER* pgm)
+{
+}
+
+void flip2_display(PROGRAMMER* pgm, const char *prefix)
+{
+}
+
+int flip2_program_enable(PROGRAMMER* pgm, AVRPART *part)
+{
+  return -1;
+}
+
+int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part)
+{
+  return -1;
+}
+
+int flip2_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned long addr, unsigned char *value)
+{
+  return -1;
+}
+
+int flip2_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned long addr, unsigned char value)
+{
+  return -1;
+}
+
+int flip2_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned int page_size, unsigned int addr, unsigned int n_bytes)
+{
+  return -1;
+}
+
+int flip2_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
+  unsigned int page_size, unsigned int addr, unsigned int n_bytes)
+{
+  return -1;
+}
+
+int flip2_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
+{
+  return -1;
+}
+
+void flip2_setup(PROGRAMMER * pgm)
+{
+}
+
+void flip2_teardown(PROGRAMMER * pgm)
+{
+}
+
+
+#endif /* HAVE_LIBUSB */