annotate loadtools/ltmain.c @ 575:1d7a12925b8e

gsm-fw/L1/cfile: iramcode.o and xipcode.o built
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 11 Aug 2014 03:59:26 +0000
parents 833e8fa93330
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the main() function for fc-loadtool
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdint.h>
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <unistd.h>
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "srecreader.h"
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 extern char *target_ttydev;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 extern struct srecreader iramimage;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 extern char default_loadagent_image[];
29
dacf45e3d20f loadtool: scripting functionality implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
15 extern char hw_init_script[];
27
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 23
diff changeset
16 extern void (*default_exit)();
84
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 51
diff changeset
17 extern int gta_modem_poweron;
27
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 23
diff changeset
18
422
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
19 extern struct baudrate *find_baudrate_by_name();
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
20
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
21 static struct baudrate *reattach;
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
22
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 main(argc, argv)
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 char **argv;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 {
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 extern char *optarg;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 extern int optind;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 int c;
29
dacf45e3d20f loadtool: scripting functionality implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
29 char command[512];
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30
422
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
31 while ((c = getopt(argc, argv, "a:b:c:C:h:H:i:nr:")) != EOF)
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 switch (c) {
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 case 'a':
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 iramimage.filename = optarg;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 continue;
51
aa62352647f7 loadtools: -b option works in fc-loadtool
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
36 case 'b':
aa62352647f7 loadtools: -b option works in fc-loadtool
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
37 set_romload_baudrate(optarg);
aa62352647f7 loadtools: -b option works in fc-loadtool
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 45
diff changeset
38 continue;
380
5e0e9bb26060 fc-loadtool: compalstage support hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
39 case 'c':
5e0e9bb26060 fc-loadtool: compalstage support hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
40 set_compalstage_short(optarg);
5e0e9bb26060 fc-loadtool: compalstage support hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
41 continue;
5e0e9bb26060 fc-loadtool: compalstage support hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
42 case 'C':
5e0e9bb26060 fc-loadtool: compalstage support hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
43 set_compalstage_fullpath(optarg);
5e0e9bb26060 fc-loadtool: compalstage support hooked in
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
44 continue;
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 case 'h':
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 read_hwparam_file_shortname(optarg);
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 continue;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 case 'H':
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 read_hwparam_file_fullpath(optarg);
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 continue;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 case 'i':
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 set_beacon_interval(optarg);
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 continue;
84
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 51
diff changeset
54 case 'n':
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 51
diff changeset
55 gta_modem_poweron = 0;
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 51
diff changeset
56 continue;
422
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
57 case 'r':
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
58 reattach = find_baudrate_by_name(optarg);
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
59 if (!reattach)
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
60 exit(1); /* error msg already printed */
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
61 continue;
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 case '?':
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 default:
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 usage: fprintf(stderr,
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 "usage: fc-loadtool [options] ttyport\n");
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 exit(1);
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 }
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 if (argc - optind != 1)
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 goto usage;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 target_ttydev = argv[optind];
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 if (!iramimage.filename)
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 iramimage.filename = default_loadagent_image;
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 open_target_serial();
422
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
75 if (reattach)
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
76 switch_baud_rate(reattach);
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
77 else {
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
78 perform_compal_stage(1);
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
79 perform_romload();
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
80 putchar('\n');
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
81 if (tpinterf_pass_output(1) < 0)
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
82 exit(1);
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
83 putchar('\n');
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
84 if (hw_init_script[0]) {
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
85 printf("Executing init script %s\n", hw_init_script);
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
86 loadtool_exec_script(hw_init_script);
833e8fa93330 fc-loadtool -r (reattach) option implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 380
diff changeset
87 }
29
dacf45e3d20f loadtool: scripting functionality implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
88 }
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 for (;;) {
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 if (isatty(0)) {
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 fputs("loadtool> ", stdout);
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 fflush(stdout);
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 }
29
dacf45e3d20f loadtool: scripting functionality implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
94 if (!fgets(command, sizeof command, stdin))
27
ae6294b8a015 loadtool: exit jump0 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 23
diff changeset
95 default_exit();
29
dacf45e3d20f loadtool: scripting functionality implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 27
diff changeset
96 loadtool_dispatch_cmd(command, 0);
22
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 }
e658a84b37df loadtool coming along
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 }