annotate loadtools/sertool.c @ 38:5b3d7398d2d9

target-utils top level Makefile buglet
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 13 May 2013 20:40:44 +0000
parents 768a3d012931
children f1df95eed62c
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 /*
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the main() function for fc-sertool: the simplest
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * of the FreeCalypso loading tools, which sends the user-specified
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 * IRAM SREC image to the boot ROM and then switches into serial tty
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * pass-through.
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;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 main(argc, argv)
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 char **argv;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 {
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 extern char *optarg;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 extern int optind;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 int c;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
25 while ((c = getopt(argc, argv, "h:H:i:")) != EOF)
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 switch (c) {
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
27 case 'h':
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
28 read_hwparam_file_shortname(optarg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
29 continue;
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
30 case 'H':
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
31 read_hwparam_file_fullpath(optarg);
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
32 continue;
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 case 'i':
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 set_beacon_interval(optarg);
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 continue;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 case '?':
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 default:
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 usage: fprintf(stderr,
17
24b88c119465 loadtools: hw parameter file reading implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 9
diff changeset
39 "usage: fc-sertool [options] ttyport iramimage.srec\n");
9
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 exit(1);
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 }
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 if (argc - optind != 2)
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 goto usage;
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 target_ttydev = argv[optind];
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 iramimage.filename = argv[optind+1];
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 open_target_serial();
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 perform_romload();
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 tty_passthru();
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 exit(0);
fea204bc7674 fc-sertool compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 }
28
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
52
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
53 /* called from hwparam.c config file parser */
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
54 /* stub needed for fc-sertool to link */
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
55 void
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
56 set_default_exit_mode()
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
57 {
768a3d012931 loadtool: default exit mode setting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 17
diff changeset
58 }