FreeCalypso > hg > freecalypso-sw
changeset 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 | 1c50add5e202 |
children | eee03b6ac615 |
files | .hgignore loadtools/Makefile loadtools/chainload.c loadtools/clmain.c |
diffstat | 4 files changed, 178 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Jun 16 07:31:23 2013 +0000 +++ b/.hgignore Mon Jun 17 07:18:04 2013 +0000 @@ -7,6 +7,7 @@ ^loadtools/fc-loadtool ^loadtools/fc-sertool +^loadtools/fc-xram ^target-utils/.*/crt0\.S$
--- a/loadtools/Makefile Sun Jun 16 07:31:23 2013 +0000 +++ b/loadtools/Makefile Mon Jun 17 07:18:04 2013 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -PROGS= fc-loadtool fc-sertool +PROGS= fc-loadtool fc-sertool fc-xram SCRIPTS=scripts/pirelli.config scripts/pirelli.init INSTBIN=/usr/local/bin INSTSCR=/usr/local/share/freecalypso @@ -12,6 +12,9 @@ ltdump.o ltexit.o ltmain.o ltpassthru.o ltscript.o romload.o \ sercomm.o srecreader.o tpinterf.o tpinterf2.o +XRAM_OBJS= chainload.o clmain.o defpath.o hexdecode.o hwparam.o romload.o \ + sercomm.o srecreader.o tpinterf.o ttypassthru.o + all: ${PROGS} fc-sertool: ${SERTOOL_OBJS} @@ -20,6 +23,9 @@ fc-loadtool: ${LOADTOOL_OBJS} ${CC} -o $@ ${LOADTOOL_OBJS} +fc-xram: ${XRAM_OBJS} + ${CC} -o $@ ${XRAM_OBJS} + install: #install -c ${PROGS} ${INSTBIN} install -c ${SCRIPTS} ${INSTSCR}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/chainload.c Mon Jun 17 07:18:04 2013 +0000 @@ -0,0 +1,101 @@ +/* + * This module implements the chain-loading of XRAM images via loadagent. + */ + +#include <sys/types.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "srecreader.h" + +struct srecreader xramimage; + +static void +make_ml_arg(rec, buf) + u_char *rec; + char *buf; +{ + register int i, len; + register char *s; + + len = rec[0] + 1; + s = buf; + for (i = 0; i < len; i++) { + sprintf(s, "%02X", rec[i]); + s += 2; + } + *s = '\0'; +} + +perform_chain_load() +{ + int resp; + unsigned long rec_count; + char *argv[3], srecarg[516]; + + if (open_srec_file(&xramimage) < 0) + exit(1); + argv[0] = "ML"; + argv[1] = srecarg; + argv[2] = 0; + for (rec_count = 0; ; ) { + if (read_s_record(&xramimage) < 0) + exit(1); + switch (xramimage.record_type) { + case '0': + if (xramimage.lineno == 1) + continue; + fprintf(stderr, + "%s: S0 record found in line %d (expected in line 1 only)\n", + xramimage.filename, xramimage.lineno); + exit(1); + case '3': + case '7': + if (s3s7_get_addr_data(&xramimage) < 0) + exit(1); + break; + default: + fprintf(stderr, + "%s line %d: S%c record type not supported\n", + xramimage.filename, xramimage.lineno, + xramimage.record_type); + exit(1); + } + if (xramimage.record_type == '7') + break; + /* must be S3 */ + if (xramimage.datalen < 1) { + fprintf(stderr, + "%s line %d: S3 record has zero data length\n", + xramimage.filename, xramimage.lineno); + exit(1); + } + make_ml_arg(xramimage.record, srecarg); + tpinterf_make_cmd(argv); + if (tpinterf_send_cmd()) + exit(1); + if (tpinterf_pass_output(1)) + exit(1); + putchar('.'); + fflush(stdout); + rec_count++; + } + /* got S7 */ + fclose(xramimage.openfile); + if (!rec_count) { + fprintf(stderr, + "%s line %d: S7 without any preceding S3 data records\n", + xramimage.filename, xramimage.lineno); + exit(1); + } + sprintf(srecarg, "%lX", (u_long) xramimage.addr); + argv[0] = "jump"; + tpinterf_make_cmd(argv); + if (tpinterf_send_cmd()) + exit(1); + printf("Sent \"%s %s\": XRAM image should now be running!\n", + argv[0], argv[1]); + return(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/clmain.c Mon Jun 17 07:18:04 2013 +0000 @@ -0,0 +1,69 @@ +/* + * This module contains the main() function for the XRAM chain-loading + * utility fc-xram. + */ + +#include <sys/types.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include "srecreader.h" + +extern char *target_ttydev; +extern struct srecreader iramimage; +extern char default_loadagent_image[]; +extern struct srecreader xramimage; + +main(argc, argv) + char **argv; +{ + extern char *optarg; + extern int optind; + int c; + + while ((c = getopt(argc, argv, "a:h:H:i:")) != EOF) + switch (c) { + case 'a': + iramimage.filename = 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 '?': + default: +usage: fprintf(stderr, + "usage: fc-xram [options] ttyport xramimage.srec\n"); + exit(1); + } + if (argc - optind != 2) + goto usage; + target_ttydev = argv[optind]; + xramimage.filename = argv[optind+1]; + if (!iramimage.filename) + iramimage.filename = default_loadagent_image; + + open_target_serial(); + perform_romload(); + /* loadagent should be running now */ + if (tpinterf_pass_output(1) < 0) + exit(1); + /* hw_init_script execution will go here */ + printf("Sending XRAM image to loadagent\n"); + perform_chain_load(); + tty_passthru(); + exit(0); +} + +/* called from hwparam.c config file parser */ +/* stub needed for fc-xram to link */ +void +set_default_exit_mode() +{ +}