view target-utils/dspdump/dspops.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 27b5526ba1a8
children
line wrap: on
line source

#include "types.h"
#include "leadapi.h"
#include "dumpagent.h"

wait_for_dsp_ready()
{
	unsigned cnt;

	for (cnt = 0; cnt < 10000; cnt++)
		if (DOWNLOAD_STATUS == LEAD_READY)
			return(0);
	return(-1);
}

boot_dsp_dump_agent()
{
	const u16 *src;
	volatile u16 *api;
	unsigned n;

	/* put it into reset first */
	CLKM_CNTL_RST |= CLKM_LEAD_RST;
	/* generous 1 ms for the reset pulse */
	wait_ARM_cycles(13000);
	/* lift it out of reset */
	CLKM_CNTL_RST &= ~CLKM_LEAD_RST;
	/* another generous 1 ms */
	wait_ARM_cycles(13000);
	/* bootloader should be ready for us now */
	if (wait_for_dsp_ready() < 0) {
		printf("ERROR: DSP bootloader not ready out of reset\n");
		return(-1);
	}
	/* upload the agent code */
	src = dsp_agent_code;
	api = (volatile u16 *) APIF_ADDR;
	for (n = 0; n < DSP_DUMPCODE_LEN; n++)
		*api++ = *src++;
	DOWNLOAD_EXT_PAGE = 0;
	DOWNLOAD_SIZE = DSP_DUMPCODE_LEN;
	DOWNLOAD_ADDR = DSP_DUMPCODE_START;
	DOWNLOAD_STATUS = BLOCK_READY;
	if (wait_for_dsp_ready() < 0) {
		printf("ERROR: DSP bl not ready after block write\n");
		return(-1);
	}
	/* start it! */
	DOWNLOAD_EXT_PAGE = 0;
	DOWNLOAD_SIZE = 0;
	DOWNLOAD_ADDR = DSP_DUMPCODE_START;
	DOWNLOAD_STATUS = BLOCK_READY;
	if (wait_for_dsp_ready() < 0) {
		printf("ERROR: DSP not ready after commanded jump to agent\n");
		return(-1);
	}
}

dsp_read_op(mode, addr, blklen)
	u16 mode, blklen;
	u32 addr;
{
	int rc;

	APIRAM_FIRST_WORD = mode;
	DOWNLOAD_STATUS = PAGE_SELECTION;
	rc = wait_for_dsp_ready();
	if (rc < 0)
		return(rc);
	DOWNLOAD_EXT_PAGE = addr >> 16;
	DOWNLOAD_SIZE = blklen;
	DOWNLOAD_ADDR = addr;
	DOWNLOAD_STATUS = BLOCK_READY;
	rc = wait_for_dsp_ready();
	return(rc);
}