view loadtools/romdump.c @ 1014:961efadd530a default tip

fc-shell TCH DL handler: add support for CSD modes TCH DL capture mechanism in FC Tourmaline firmware has been extended to support CSD modes in addition to speech - add the necessary support on the host tools side. It needs to be noted that this mechanism in its present state does NOT provide the debug utility value that was sought: as we learned only after the code was implemented, TI's DSP has a misfeature in that the buffer we are reading (a_dd_0[]) is zeroed out when the IDS block is enabled, i.e., we are reading all zeros and not the real DL bits we were after. But since the code has already been written, we are keeping it - perhaps we can do some tests with IDS disabled.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 26 Nov 2024 06:27:43 +0000
parents 464a531122ab
children
line wrap: on
line source

/*
 * 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;

char default_dspdump_image[] = "/opt/freecalypso/target-bin/dspdump.srec";

extern struct srecreader iramimage;
extern struct baudrate *current_baud_rate;
extern void (*default_exit)();

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:P:t:")) != 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 'P':
			if (find_bootctrl_entry(optarg) < 0)
				exit(1);	/* error msg already printed */
			continue;
		case 't':
			set_romload_timeout(optarg);
			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);
	pwon_if_needed();
	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);
}