FreeCalypso > hg > fc-usbser-tools
annotate fteeprom/fteeprom-erase.c @ 9:ab506f6aa57c
libuwrap started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 07 Sep 2023 04:00:56 +0000 |
parents | 11b8a30333b3 |
children | af801ab43a33 |
rev | line source |
---|---|
0
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <stdio.h> |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <stdlib.h> |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <unistd.h> |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <ftdi.h> |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 main(argc, argv) |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 char **argv; |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 { |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 struct ftdi_context ftdi; |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 if (argc != 2) { |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 fprintf(stderr, "usage: %s device-selector\n"); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 exit(1); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 } |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 ftdi_init(&ftdi); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 if (ftdi_usb_open_string(&ftdi, argv[1]) < 0) { |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 exit(1); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 } |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (ftdi_erase_eeprom(&ftdi) < 0) { |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 fprintf(stderr, "EEPROM write error: %s\n", ftdi.error_str); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 exit(1); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ftdi_usb_close(&ftdi); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(0); |
11b8a30333b3
fteeprom: initial import from freecalypso-hwlab
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |