comparison loadtools/clmain.c @ 42:5da0cbee2b89

fc-xram tool written, compiles, now needs to be debugged
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 17 Jun 2013 07:18:04 +0000
parents
children 16315ed6401a
comparison
equal deleted inserted replaced
41:1c50add5e202 42:5da0cbee2b89
1 /*
2 * This module contains the main() function for the XRAM chain-loading
3 * utility fc-xram.
4 */
5
6 #include <sys/types.h>
7 #include <stdint.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include "srecreader.h"
12
13 extern char *target_ttydev;
14 extern struct srecreader iramimage;
15 extern char default_loadagent_image[];
16 extern struct srecreader xramimage;
17
18 main(argc, argv)
19 char **argv;
20 {
21 extern char *optarg;
22 extern int optind;
23 int c;
24
25 while ((c = getopt(argc, argv, "a:h:H:i:")) != EOF)
26 switch (c) {
27 case 'a':
28 iramimage.filename = optarg;
29 continue;
30 case 'h':
31 read_hwparam_file_shortname(optarg);
32 continue;
33 case 'H':
34 read_hwparam_file_fullpath(optarg);
35 continue;
36 case 'i':
37 set_beacon_interval(optarg);
38 continue;
39 case '?':
40 default:
41 usage: fprintf(stderr,
42 "usage: fc-xram [options] ttyport xramimage.srec\n");
43 exit(1);
44 }
45 if (argc - optind != 2)
46 goto usage;
47 target_ttydev = argv[optind];
48 xramimage.filename = argv[optind+1];
49 if (!iramimage.filename)
50 iramimage.filename = default_loadagent_image;
51
52 open_target_serial();
53 perform_romload();
54 /* loadagent should be running now */
55 if (tpinterf_pass_output(1) < 0)
56 exit(1);
57 /* hw_init_script execution will go here */
58 printf("Sending XRAM image to loadagent\n");
59 perform_chain_load();
60 tty_passthru();
61 exit(0);
62 }
63
64 /* called from hwparam.c config file parser */
65 /* stub needed for fc-xram to link */
66 void
67 set_default_exit_mode()
68 {
69 }