annotate loadtools/sertool.c @ 842:a862a41f26b7

gsm-fw/cfgmagic/processconf.sh: g23m-glue added to the build for GSM
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 25 Apr 2015 19:40:45 +0000
parents 7b3fd0e2a352
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
50
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
2 * This module contains the main() function for fc-iram, previously
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
3 * called fc-sertool: the simplest of the FreeCalypso loading tools,
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
4 * which sends the user-specified IRAM SREC image to the boot ROM
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
5 * and then switches into serial tty pass-through.
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 */
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <sys/types.h>
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdint.h>
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdio.h>
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <stdlib.h>
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include <unistd.h>
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "srecreader.h"
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern char *target_ttydev;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern struct srecreader iramimage;
84
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
17 extern int gta_modem_poweron;
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 main(argc, argv)
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 char **argv;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 {
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 extern char *optarg;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 extern int optind;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 int c;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
379
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
26 while ((c = getopt(argc, argv, "b:c:C:h:H:i:n")) != EOF)
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 switch (c) {
50
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
28 case 'b':
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
29 set_romload_baudrate(optarg);
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
30 continue;
379
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
31 case 'c':
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
32 set_compalstage_short(optarg);
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
33 continue;
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
34 case 'C':
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
35 set_compalstage_fullpath(optarg);
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
36 continue;
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
37 case 'h':
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
38 read_hwparam_file_shortname(optarg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
39 continue;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
40 case 'H':
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
41 read_hwparam_file_fullpath(optarg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
42 continue;
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 case 'i':
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 set_beacon_interval(optarg);
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 continue;
84
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
46 case 'n':
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
47 gta_modem_poweron = 0;
ccc5161848c7 loadtools: support building for GTA0x AP
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
48 continue;
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 case '?':
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 default:
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 usage: fprintf(stderr,
50
f1df95eed62c loadtools: -b option works in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 28
diff changeset
52 "usage: fc-iram [options] ttyport iramimage.srec\n");
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 exit(1);
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 }
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 if (argc - optind != 2)
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 goto usage;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 target_ttydev = argv[optind];
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 iramimage.filename = argv[optind+1];
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 open_target_serial();
379
7b3fd0e2a352 loadtools: compalstage support implemented in fc-iram
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 84
diff changeset
61 perform_compal_stage(1);
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 perform_romload();
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 tty_passthru();
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 exit(0);
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 }