summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ao-tools/ao-stmload/Makefile.am2
-rw-r--r--ao-tools/ao-stmload/ao-stmload.c10
-rw-r--r--ao-tools/ao-stmload/ao-stmload.h8
-rw-r--r--ao-tools/lib/Makefile.am2
-rw-r--r--ao-tools/lib/ao-selfload.c (renamed from ao-tools/ao-stmload/ao-selfload.c)17
-rw-r--r--ao-tools/lib/ao-verbose.h1
6 files changed, 17 insertions, 23 deletions
diff --git a/ao-tools/ao-stmload/Makefile.am b/ao-tools/ao-stmload/Makefile.am
index 68b518f1..9ed286cc 100644
--- a/ao-tools/ao-stmload/Makefile.am
+++ b/ao-tools/ao-stmload/Makefile.am
@@ -11,7 +11,7 @@ ao_stmload_DEPENDENCIES = $(AO_STMLOAD_LIBS)
ao_stmload_LDADD=$(AO_STMLOAD_LIBS) $(LIBSTLINK_LIBS) $(LIBUSB_LIBS) -lelf
-ao_stmload_SOURCES=ao-stmload.c ao-stmload.h ao-selfload.c
+ao_stmload_SOURCES=ao-stmload.c ao-stmload.h
man_MANS = ao-stmload.1
diff --git a/ao-tools/ao-stmload/ao-stmload.c b/ao-tools/ao-stmload/ao-stmload.c
index a11d93de..71d1ec57 100644
--- a/ao-tools/ao-stmload/ao-stmload.c
+++ b/ao-tools/ao-stmload/ao-stmload.c
@@ -32,6 +32,8 @@
#include "cc-usb.h"
#include "cc.h"
#include "ao-stmload.h"
+#include "ao-selfload.h"
+#include "ao-verbose.h"
#define AO_USB_DESC_STRING 3
@@ -249,13 +251,13 @@ static const struct option options[] = {
{ .name = "device", .has_arg = 1, .val = 'D' },
{ .name = "cal", .has_arg = 1, .val = 'c' },
{ .name = "serial", .has_arg = 1, .val = 's' },
- { .name = "verbose", .has_arg = 0, .val = 'v' },
+ { .name = "verbose", .has_arg = 1, .val = 'v' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
- fprintf(stderr, "usage: %s [--stlink] [--verbose] [--device=<device>] [-tty=<tty>] [--cal=<radio-cal>] [--serial=<serial>] file.{elf,ihx}\n", program);
+ fprintf(stderr, "usage: %s [--stlink] [--verbose=<verbose>] [--device=<device>] [-tty=<tty>] [--cal=<radio-cal>] [--serial=<serial>] file.{elf,ihx}\n", program);
exit(1);
}
@@ -316,7 +318,7 @@ main (int argc, char **argv)
struct ao_sym *file_symbols;
int num_file_symbols;
- while ((c = getopt_long(argc, argv, "T:D:c:s:Sv", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "T:D:c:s:Sv:", options, NULL)) != -1) {
switch (c) {
case 'T':
tty = optarg;
@@ -346,7 +348,7 @@ main (int argc, char **argv)
}
}
- ao_self_verbose = verbose;
+ ao_verbose = verbose;
if (verbose > 1)
ccdbg_add_debug(CC_DEBUG_BITBANG);
diff --git a/ao-tools/ao-stmload/ao-stmload.h b/ao-tools/ao-stmload/ao-stmload.h
index 744dfa75..1ba9a977 100644
--- a/ao-tools/ao-stmload/ao-stmload.h
+++ b/ao-tools/ao-stmload/ao-stmload.h
@@ -33,12 +33,4 @@ ao_self_block_read(struct cc_usb *cc, uint32_t address, uint8_t block[256]);
void
ao_self_block_write(struct cc_usb *cc, uint32_t address, uint8_t block[256]);
-struct ao_hex_image *
-ao_self_read(struct cc_usb *cc, uint32_t address, uint32_t length);
-
-int
-ao_self_write(struct cc_usb *cc, struct ao_hex_image *image);
-
-extern int ao_self_verbose;
-
#endif /* _AO_STMLOAD_H_ */
diff --git a/ao-tools/lib/Makefile.am b/ao-tools/lib/Makefile.am
index ca32e121..5f47c089 100644
--- a/ao-tools/lib/Makefile.am
+++ b/ao-tools/lib/Makefile.am
@@ -44,5 +44,7 @@ libao_tools_a_SOURCES = \
ao-hex.h \
ao-elf.c \
ao-elf.h \
+ ao-selfload.c \
+ ao-selfload.h \
ao-verbose.c \
ao-verbose.h
diff --git a/ao-tools/ao-stmload/ao-selfload.c b/ao-tools/lib/ao-selfload.c
index dee1c3cb..bf036f33 100644
--- a/ao-tools/ao-stmload/ao-selfload.c
+++ b/ao-tools/lib/ao-selfload.c
@@ -21,16 +21,13 @@
#include <sysexits.h>
#include <unistd.h>
#include <string.h>
-#include "cc.h"
-#include "cc-usb.h"
-#include "ccdbg.h"
-#include "ao-stmload.h"
+#include "ao-hex.h"
+#include "ao-selfload.h"
+#include "ao-verbose.h"
-int ao_self_verbose;
+#define TRACE(...) ao_printf(AO_VERBOSE_SELF, __VA_ARGS__)
-#define TRACE(...) if (ao_self_verbose) printf (__VA_ARGS__)
-
-void
+static void
ao_self_block_read(struct cc_usb *cc, uint32_t address, uint8_t block[256])
{
int byte;
@@ -47,7 +44,7 @@ ao_self_block_read(struct cc_usb *cc, uint32_t address, uint8_t block[256])
}
}
-void
+static void
ao_self_block_write(struct cc_usb *cc, uint32_t address, uint8_t block[256])
{
int byte;
@@ -82,7 +79,7 @@ ao_self_read(struct cc_usb *cc, uint32_t address, uint32_t length)
return image;
}
-int
+bool
ao_self_write(struct cc_usb *cc, struct ao_hex_image *image)
{
uint8_t block[256];
diff --git a/ao-tools/lib/ao-verbose.h b/ao-tools/lib/ao-verbose.h
index 45a0559c..26c2fe41 100644
--- a/ao-tools/lib/ao-verbose.h
+++ b/ao-tools/lib/ao-verbose.h
@@ -24,6 +24,7 @@
uint32_t ao_verbose;
#define AO_VERBOSE_EXE 1
+#define AO_VERBOSE_SELF 2
void
ao_printf(uint32_t verbose, const char *format, ...);