view loadtools/lacrc32.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 5385aca4d813
children
line wrap: on
line source

/*
 * This module implements the function for getting a CRC-32 computation
 * from loadagent.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>

extern char target_response_line[];

crc32_on_target(area_base, area_len, retptr)
	u_long area_base, area_len, *retptr;
{
	char arg1[10], arg2[10], *argv[4];
	int stat;
	char *strtoul_endp;

	sprintf(arg1, "%lx", area_base);
	sprintf(arg2, "%lx", area_len);
	argv[0] = "crc32";
	argv[1] = arg1;
	argv[2] = arg2;
	argv[3] = 0;
	tpinterf_make_cmd(argv);
	if (tpinterf_send_cmd() < 0)
		return(-1);
	stat = tpinterf_capture_output_oneline(10);	/* 10 s timeout */
	if (stat != 1) {
errout:		fprintf(stderr, "error: malformed response to crc32 command\n");
		return(-1);
	}
	if (strlen(target_response_line) != 8)
		goto errout;
	*retptr = strtoul(target_response_line, &strtoul_endp, 16);
	if (strtoul_endp != target_response_line + 8)
		goto errout;
	return(0);
}