FreeCalypso > hg > freecalypso-tools
view loadtools/simmain.c @ 995:74024eb17e04
fc-loadtool help: improve language regarding 16 MiB flash chips
In FC project history, 16 MiB flash originally meant Pirelli DP-L10.
Then we got FCDEV3B with the same flash (our own design), but now we are
discovering more Calypso devices that used such large flash, both late
Calypso era (Sony Ericsson K2x0) as well as much earlier ones (FIC FLUID
devices.txt file with 2004 dates, Leonardo+ rev 5). Hence we need to
migrate to more generic or neutral language in associated documentation,
without giving elevated status to specific examples that drove our
early project history.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Dec 2023 21:11:12 +0000 |
parents | 02490e26f53d |
children |
line wrap: on
line source
/* * This module contains the main() function for fc-simint. */ #include <sys/types.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> #include "../libserial/baudrate.h" #include "srecreader.h" char *target_ttydev; extern struct srecreader iramimage; extern struct baudrate *current_baud_rate; extern void (*default_exit)(); extern struct baudrate *find_baudrate_by_name(); static char simagent_pathname[] = "/opt/freecalypso/target-bin/simagent.srec"; static char simtool_pathname[] = "/opt/freecalypso/bin/fc-simtool"; static char uicc_tool_pathname[] = "/opt/freecalypso/bin/fc-uicc-tool"; static char *selected_simtool = simtool_pathname; static struct baudrate *session_baudrate; int sim_voltage_mode_1v8; int sim_allow_spenh = 1; static void tool_select_arg(arg) char *arg; { if (!strcmp(arg, "sim")) selected_simtool = simtool_pathname; else if (!strcmp(arg, "uicc")) selected_simtool = uicc_tool_pathname; else { fprintf(stderr, "error: invalid -T argument\n"); exit(1); } } static void voltage_select_arg(arg) char *arg; { if (!strcmp(arg, "1.8")) sim_voltage_mode_1v8 = 1; else if (!strcmp(arg, "3") || !strcmp(arg, "3.0")) sim_voltage_mode_1v8 = 0; else { fprintf(stderr, "error: invalid -v argument\n"); exit(1); } } static void exec_simtool(passon_argc, passon_argv) char **passon_argv; { char **exec_argv, *prog_base_name; char **sp, **dp; extern int target_fd; char desc_arg[16]; prog_base_name = rindex(selected_simtool, '/') + 1; sprintf(desc_arg, "-C%d", target_fd); exec_argv = (char **) malloc(sizeof(char *) * (passon_argc + 3)); if (!exec_argv) { perror("malloc argv for execv"); exit(1); } sp = passon_argv; dp = exec_argv; *dp++ = prog_base_name; *dp++ = desc_arg; while (*sp) *dp++ = *sp++; *dp = NULL; execv(selected_simtool, exec_argv); fprintf(stderr, "Unable to exec %s\n", selected_simtool); exit(1); } main(argc, argv) char **argv; { extern char *optarg; extern int optind; int c; while ((c = getopt(argc, argv, "a:b:B:c:C:h:H:i:nP:t:T:v:")) != EOF) switch (c) { case 'a': iramimage.filename = optarg; continue; case 'b': set_romload_baudrate(optarg); continue; case 'B': session_baudrate = find_baudrate_by_name(optarg); if (!session_baudrate) exit(1); /* error msg already printed */ continue; case 'c': set_compalstage_short(optarg); continue; case 'C': set_compalstage_fullpath(optarg); continue; case 'h': read_hwparam_file_shortname(optarg); continue; case 'H': read_hwparam_file_fullpath(optarg); continue; case 'i': set_beacon_interval(optarg); continue; case 'n': sim_allow_spenh = 0; continue; case 'P': if (find_bootctrl_entry(optarg) < 0) exit(1); /* error msg already printed */ continue; case 't': set_romload_timeout(optarg); continue; case 'T': tool_select_arg(optarg); continue; case 'v': voltage_select_arg(optarg); continue; case '?': default: usage: fprintf(stderr, "usage: fc-simint [options] ttyport [batch command]\n"); exit(1); } if (argc - optind < 1) goto usage; target_ttydev = argv[optind]; if (!iramimage.filename) iramimage.filename = simagent_pathname; open_serial_port(target_ttydev); pwon_if_needed(); perform_compal_stage(); perform_romload(); /* simagent target program should be running now */ putchar('\n'); if (tpinterf_pass_output(1) < 0) exit(1); putchar('\n'); if (session_baudrate && session_baudrate != current_baud_rate) { c = loadagent_switch_baud(session_baudrate); if (c) exit(1); } do_sim_up(); sim_atr_validate(); sim_spenh_logic(); exec_simtool(argc - optind - 1, argv + optind + 1); }