summaryrefslogtreecommitdiffstats
path: root/sw/programmer
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-10-05 12:17:37 +0200
committerNao Pross <naopross@thearcway.org>2017-10-05 12:17:37 +0200
commitf000d406809d8a7a0e71c388ebfb15d7564728e4 (patch)
tree2284c66b0459e9456fb451feaa4290e5d99e4349 /sw/programmer
parentMerge remote-tracking branch 'origin/atlas' into naopross (diff)
downloadz80uPC-f000d406809d8a7a0e71c388ebfb15d7564728e4.tar.gz
z80uPC-f000d406809d8a7a0e71c388ebfb15d7564728e4.zip
Test units are now in their own folder 'z80_test', add programmer cli interface
Diffstat (limited to 'sw/programmer')
-rw-r--r--sw/programmer/linux/config.h26
-rw-r--r--sw/programmer/linux/src/main.c58
-rwxr-xr-xsw/programmer/linux/src/z80progbin0 -> 49856 bytes
3 files changed, 82 insertions, 2 deletions
diff --git a/sw/programmer/linux/config.h b/sw/programmer/linux/config.h
new file mode 100644
index 0000000..d319f43
--- /dev/null
+++ b/sw/programmer/linux/config.h
@@ -0,0 +1,26 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Name of package */
+#define PACKAGE "z80prog"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "naopross@tharcway.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "z80prog"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "z80prog 0.1"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "z80prog"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "0.1"
+
+/* Version number of package */
+#define VERSION "0.1"
diff --git a/sw/programmer/linux/src/main.c b/sw/programmer/linux/src/main.c
index 769992a..1bfd359 100644
--- a/sw/programmer/linux/src/main.c
+++ b/sw/programmer/linux/src/main.c
@@ -4,10 +4,64 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <unistd.h>
+#include <errno.h>
+
+void out(const char *msg)
+{
+ printf("%s", msg);
+}
int main(int argc, char *argv[])
{
- ui_init(&argc, &argv);
+ int opt;
+ int use_ui = 0;
+
+ unsigned long baudrate;
+ char *file, *device, *baud;
+
+ file = device = baud = NULL;
+
+ while ((opt = getopt(argc, argv, "gf:d:b:")) != -1) {
+ switch (opt) {
+ case 'g':
+ use_ui = 1;
+ break;
+ case 'f':
+ file = optarg;
+ break;
+ case 'd':
+ device = optarg;
+ break;
+ case 'b':
+ baud = optarg;
+ break;
+ }
+ }
+
+ if (use_ui) {
+ ui_init(&argc, &argv);
+ return 0;
+ }
+
+ if (file == NULL || device == NULL || baud == NULL) {
+ perror("Missing argument\n");
+ return -1;
+ }
+
+ baudrate = strtoul(baud, NULL, 0);
+ if (errno == ERANGE) {
+ perror("Invalid baudrate\n");
+ return -1;
+ }
+
+ if (flash_open(device, baudrate) < 0) {
+ perror("Failed to open device\n");
+ return -2;
+ }
+
+ flash_write(file, out);
+ flash_close();
+
return 0;
}
-
diff --git a/sw/programmer/linux/src/z80prog b/sw/programmer/linux/src/z80prog
new file mode 100755
index 0000000..9787e67
--- /dev/null
+++ b/sw/programmer/linux/src/z80prog
Binary files differ