FreeCalypso > hg > freecalypso-tools
annotate loadtools/ltmain.c @ 845:aec320fe2653
fc-tmsync: new madc command reads all 8 MADC channels
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 31 Jul 2021 22:23:05 +0000 |
parents | 752aef91cc95 |
children |
rev | line source |
---|---|
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the main() function for fc-loadtool |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdint.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
686
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
9 #include <string.h> |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
10 #include <strings.h> |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <unistd.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "srecreader.h" |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
250
8c011177adb9
loadtools reworked to use factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
232
diff
changeset
|
14 char *target_ttydev; |
8c011177adb9
loadtools reworked to use factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
232
diff
changeset
|
15 |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern struct srecreader iramimage; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern char default_loadagent_image[]; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern char hw_init_script[]; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern void (*default_exit)(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 extern struct baudrate *find_baudrate_by_name(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
232
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
23 static struct baudrate *reattach, *batch_baud; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 main(argc, argv) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 char **argv; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 extern char *optarg; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 extern int optind; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 int c; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 char command[512]; |
686
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
32 char *batch_script; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
683
ecea01f65146
loadtools: implemented -t option for boot ROM wait timeout
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
34 while ((c = getopt(argc, argv, "a:b:B:c:C:h:H:i:P:r:t:")) != EOF) |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 switch (c) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 case 'a': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 iramimage.filename = optarg; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 continue; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 case 'b': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 set_romload_baudrate(optarg); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 continue; |
232
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
42 case 'B': |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
43 batch_baud = find_baudrate_by_name(optarg); |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
44 if (!batch_baud) |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
45 exit(1); /* error msg already printed */ |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
46 continue; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 case 'c': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 set_compalstage_short(optarg); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 continue; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 case 'C': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 set_compalstage_fullpath(optarg); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 continue; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 case 'h': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 read_hwparam_file_shortname(optarg); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 continue; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 case 'H': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 read_hwparam_file_fullpath(optarg); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 continue; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 case 'i': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 set_beacon_interval(optarg); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 continue; |
575
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
574
diff
changeset
|
62 case 'P': |
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
574
diff
changeset
|
63 if (find_bootctrl_entry(optarg) < 0) |
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
574
diff
changeset
|
64 exit(1); /* error msg already printed */ |
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
574
diff
changeset
|
65 continue; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 case 'r': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 reattach = find_baudrate_by_name(optarg); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 if (!reattach) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 exit(1); /* error msg already printed */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 continue; |
683
ecea01f65146
loadtools: implemented -t option for boot ROM wait timeout
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
71 case 't': |
ecea01f65146
loadtools: implemented -t option for boot ROM wait timeout
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
72 set_romload_timeout(optarg); |
ecea01f65146
loadtools: implemented -t option for boot ROM wait timeout
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
73 continue; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 case '?': |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 default: |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 usage: fprintf(stderr, |
686
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
77 "usage: fc-loadtool [options] ttyport [batch command]\n"); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 exit(1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 } |
686
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
80 if (argc - optind < 1) |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 goto usage; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 target_ttydev = argv[optind]; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 if (!iramimage.filename) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 iramimage.filename = default_loadagent_image; |
686
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
85 if (argc - optind > 1) { |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
86 if (reattach) { |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
87 fprintf(stderr, |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
88 "error: -r option and batch mode are incompatible\n"); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
89 exit(1); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
90 } |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
91 if (argc - optind == 2) |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
92 batch_script = argv[optind+1]; |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
93 else if (!strcmp(argv[optind+1], "exec")) { |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
94 if (argc - optind == 3) |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
95 batch_script = argv[optind+2]; |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
96 else |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
97 goto invalid_batch; |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
98 } else if (!strcmp(argv[optind+1], "flash") || |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
99 !strcmp(argv[optind+1], "flash2")) |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
100 batch_script = 0; |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
101 else { |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
102 invalid_batch: fprintf(stderr, |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
103 "error: non-understood batch mode command\n"); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
104 exit(1); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
105 } |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
106 } |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 |
250
8c011177adb9
loadtools reworked to use factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
232
diff
changeset
|
108 open_serial_port(target_ttydev); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 if (reattach) |
250
8c011177adb9
loadtools reworked to use factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
232
diff
changeset
|
110 set_serial_baudrate(reattach); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 else { |
575
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
574
diff
changeset
|
112 pwon_if_needed(); |
250
8c011177adb9
loadtools reworked to use factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
232
diff
changeset
|
113 perform_compal_stage(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 perform_romload(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 putchar('\n'); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 if (tpinterf_pass_output(1) < 0) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 exit(1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 putchar('\n'); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 if (hw_init_script[0]) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 printf("Executing init script %s\n", hw_init_script); |
230
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
121 c = loadtool_exec_script(hw_init_script, 1); |
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
122 } else |
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
123 c = 0; |
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
124 if (argc - optind > 1) { |
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
125 if (c) |
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
126 exit(1); |
232
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
127 if (batch_baud) { |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
128 c = loadagent_switch_baud(batch_baud); |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
129 if (c) |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
130 exit(1); |
353218c38996
fc-loadtool batch mode: added -B option
Mychaela Falconia <falcon@freecalypso.org>
parents:
230
diff
changeset
|
131 } |
686
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
132 if (batch_script) { |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
133 printf("Executing command script %s\n", |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
134 batch_script); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
135 c = loadtool_exec_script(batch_script, 0); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
136 } else { |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
137 printf("Executing batch command\n"); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
138 c = cmd_flash(argc - optind - 1, |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
139 argv + optind + 1); |
752aef91cc95
fc-loadtool batch mode extended to support single commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
683
diff
changeset
|
140 } |
230
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
141 if (c) |
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
142 exit(1); |
a91dc7157544
fc-loadtool: automated command script mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
229
diff
changeset
|
143 default_exit(0); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 for (;;) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 if (isatty(0)) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 fputs("loadtool> ", stdout); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 fflush(stdout); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 if (!fgets(command, sizeof command, stdin)) |
229
96332d875fc9
loadtools: preparations for loadtool exit code possibly being nonzero
Mychaela Falconia <falcon@freecalypso.org>
parents:
227
diff
changeset
|
152 default_exit(0); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 loadtool_dispatch_cmd(command, 0); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 } |