FreeCalypso > hg > freecalypso-sw
changeset 53:604648026e9c
fc-xram: baud rate switching implemented per original intent
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 23 Jun 2013 05:16:47 +0000 |
parents | b015036286f3 |
children | 50b652bc3a4f |
files | loadtools/Makefile loadtools/chainload.c loadtools/clmain.c loadtools/labaud.c |
diffstat | 4 files changed, 46 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/loadtools/Makefile Sun Jun 23 04:34:22 2013 +0000 +++ b/loadtools/Makefile Sun Jun 23 05:16:47 2013 +0000 @@ -14,8 +14,8 @@ romload.o sercomm.o srecreader.o tpinterf.o tpinterf2.o XRAM_OBJS= chainload.o clmain.o defpath.o hexdecode.o hwparam.o \ - initscript.o romload.o sercomm.o srecreader.o tpinterf.o \ - ttypassthru.o + initscript.o labaud.o romload.o sercomm.o srecreader.o \ + tpinterf.o ttypassthru.o all: ${PROGS}
--- a/loadtools/chainload.c Sun Jun 23 04:34:22 2013 +0000 +++ b/loadtools/chainload.c Sun Jun 23 05:16:47 2013 +0000 @@ -12,6 +12,9 @@ struct srecreader xramimage; +extern struct baudrate *current_baud_rate; +extern struct baudrate *xram_run_baudrate; + static void make_ml_arg(rec, buf) u_char *rec; @@ -90,6 +93,11 @@ xramimage.filename, xramimage.lineno); exit(1); } + if (xram_run_baudrate != current_baud_rate) { + resp = loadagent_switch_baud(xram_run_baudrate); + if (resp) + exit(1); + } printf("Sending jump command\n"); sprintf(srecarg, "%lX", (u_long) xramimage.addr); argv[0] = "jump";
--- a/loadtools/clmain.c Sun Jun 23 04:34:22 2013 +0000 +++ b/loadtools/clmain.c Sun Jun 23 05:16:47 2013 +0000 @@ -7,7 +7,9 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <termios.h> #include <unistd.h> +#include "baudrate.h" #include "srecreader.h" extern char *target_ttydev; @@ -15,6 +17,13 @@ extern char default_loadagent_image[]; extern struct srecreader xramimage; extern char hw_init_script[]; +extern struct baudrate baud_rate_table[]; +extern struct baudrate *current_baud_rate; + +extern struct baudrate *find_baudrate_by_name(); + +struct baudrate *xram_load_baudrate; +struct baudrate *xram_run_baudrate = baud_rate_table; /* 1st entry default */ main(argc, argv) char **argv; @@ -22,12 +31,22 @@ extern char *optarg; extern int optind; int c; + struct baudrate *br; - while ((c = getopt(argc, argv, "a:h:H:i:")) != EOF) + while ((c = getopt(argc, argv, "a:b:B:h:H:i:")) != EOF) switch (c) { case 'a': iramimage.filename = optarg; continue; + case 'b': + set_romload_baudrate(optarg); + continue; + case 'B': + br = find_baudrate_by_name(optarg); + if (!br) + exit(1); /* error msg already printed */ + xram_load_baudrate = br; + continue; case 'h': read_hwparam_file_shortname(optarg); continue; @@ -40,15 +59,23 @@ case '?': default: usage: fprintf(stderr, - "usage: fc-xram [options] ttyport xramimage.srec\n"); + "usage: fc-xram [options] ttyport xramimage.srec [runbaud]\n"); exit(1); } - if (argc - optind != 2) + if (argc - optind < 2) goto usage; target_ttydev = argv[optind]; xramimage.filename = argv[optind+1]; if (!iramimage.filename) iramimage.filename = default_loadagent_image; + if (argc - optind >= 3) { + if (argc - optind > 3) + goto usage; + br = find_baudrate_by_name(argv[optind+2]); + if (!br) + exit(1); /* error msg already printed */ + xram_run_baudrate = br; + } open_target_serial(); perform_romload(); @@ -61,6 +88,11 @@ if (c) exit(1); } + if (xram_load_baudrate && xram_load_baudrate != current_baud_rate) { + c = loadagent_switch_baud(xram_load_baudrate); + if (c) + exit(1); + } printf("Sending XRAM image to loadagent\n"); perform_chain_load(); tty_passthru();