FreeCalypso > hg > freecalypso-tools
changeset 548:2e4ab60919b9
fc-dspromdump front end program implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Oct 2019 22:08:38 +0000 |
parents | a28e4ddd09a6 |
children | 9354a4f83fe8 |
files | .hgignore loadtools/Makefile loadtools/defpath.c loadtools/romdump.c |
diffstat | 4 files changed, 130 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Mon Oct 28 21:35:23 2019 +0000 +++ b/.hgignore Mon Oct 28 22:08:38 2019 +0000 @@ -21,6 +21,7 @@ ^loadtools/fc-buzplay$ ^loadtools/fc-compalram$ +^loadtools/fc-dspromdump$ ^loadtools/fc-iram$ ^loadtools/fc-loadtool$ ^loadtools/fc-xram$
--- a/loadtools/Makefile Mon Oct 28 21:35:23 2019 +0000 +++ b/loadtools/Makefile Mon Oct 28 22:08:38 2019 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -PROGS= fc-iram fc-loadtool fc-xram fc-compalram fc-buzplay +PROGS= fc-iram fc-loadtool fc-xram fc-compalram fc-buzplay fc-dspromdump INSTALL_PREFIX= /opt/freecalypso @@ -30,6 +30,10 @@ hexdecode.o hwparam.o labaud.o ltexit.o ltpassthru.o romload.o \ srecreader.o tpinterf.o ${EXTRA_OBJ} +ROMDUMP_OBJS= defpath.o flashstubs.o hexdecode.o hwparam.o labaud.o ltexit.o \ + romdump.o romload.o srecreader.o tpinterf.o tpinterf2.o \ + ${EXTRA_OBJ} + LIBSERIAL= ../libserial/libserial.a all: ${PROGS} @@ -49,6 +53,9 @@ fc-buzplay: ${BUZPLAY_OBJS} ${LIBSERIAL} ${CC} ${CFLAGS} -o $@ ${BUZPLAY_OBJS} ${LIBSERIAL} +fc-dspromdump: ${ROMDUMP_OBJS} ${LIBSERIAL} + ${CC} ${CFLAGS} -o $@ ${ROMDUMP_OBJS} ${LIBSERIAL} + install: mkdir -p ${INSTBIN} install -c ${PROGS} ${INSTBIN}
--- a/loadtools/defpath.c Mon Oct 28 21:35:23 2019 +0000 +++ b/loadtools/defpath.c Mon Oct 28 22:08:38 2019 +0000 @@ -8,4 +8,5 @@ char default_compalstage_dir[] = "/opt/freecalypso/target-bin"; char default_loadagent_image[] = "/opt/freecalypso/target-bin/loadagent.srec"; char default_buzplayer_image[] = "/opt/freecalypso/target-bin/buzplayer.srec"; +char default_dspdump_image[] = "/opt/freecalypso/target-bin/dspdump.srec"; char loadtool_help_file[] = "/opt/freecalypso/helpfiles/loadtool.help";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/romdump.c Mon Oct 28 22:08:38 2019 +0000 @@ -0,0 +1,120 @@ +/* + * This module contains the main() function for fc-dspromdump. + */ + +#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 char default_dspdump_image[]; +extern struct baudrate *current_baud_rate; +extern void (*default_exit)(); +extern int gta_modem_poweron; + +extern struct baudrate *find_baudrate_by_name(); + +static struct baudrate *romdump_baudrate; +static char *output_filename; +static FILE *outfile; + +static +dump_receiver(line) + char *line; +{ + if (!strncmp(line, "DSP dump:", 9) || !strncmp(line, "ERROR:", 6)) + puts(line); + fprintf(outfile, "%s\n", line); + return(1); +} + +main(argc, argv) + char **argv; +{ + extern char *optarg; + extern int optind; + int c; + struct baudrate *br; + char *targv[2]; + + while ((c = getopt(argc, argv, "a:b:B:c:C:h:H:i:n")) != 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 */ + romdump_baudrate = br; + 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': + gta_modem_poweron = 0; + continue; + case '?': + default: +usage: fprintf(stderr, + "usage: fc-dspromdump [options] ttyport output-file\n"); + exit(1); + } + if (argc - optind != 2) + goto usage; + target_ttydev = argv[optind]; + output_filename = argv[optind+1]; + if (!iramimage.filename) + iramimage.filename = default_dspdump_image; + + open_serial_port(target_ttydev); + perform_compal_stage(); + perform_romload(); + /* dspdump target program should be running now */ + if (tpinterf_pass_output(1) < 0) + exit(1); + if (romdump_baudrate && romdump_baudrate != current_baud_rate) { + c = loadagent_switch_baud(romdump_baudrate); + if (c) + exit(1); + } + outfile = fopen(output_filename, "w"); + if (!outfile) { + perror(output_filename); + exit(1); + } + printf("Requesting DSP ROM dump\n"); + targv[0] = "fulldump"; + targv[1] = 0; + tpinterf_make_cmd(targv); + if (tpinterf_send_cmd() < 0) + exit(1); + c = tpinterf_capture_output(2, dump_receiver); + fclose(outfile); + if (c < 0) + exit(1); + default_exit(0); +}