Beispiel #1
0
/* tell the target to write a block of memory */
void target_write_block(unsigned addr, const char *buf,
			unsigned size, unsigned progress)
{
	assert(portfd >= 0);
	while (size > 0) {
		char checksum = 0;
		int step = min(size, SERIAL_BLOCKSIZE);
		
		put_char('W');
		put_word(addr);
		put_word(step);
		xawrite(portfd, buf, step);
		addr += step;
		size -= step;
		progress += step;
		while (step-- > 0) {
			checksum += *buf++;
		}
		if (checksum != (char)get_char()) {
			printf("\nSerial checksum error\n");
			exit(1);
		}
		printf("0x%08x\r", progress);
		fflush(NULL);
	}
}
static void target_write_serial(target_context_t *tc,
				const void *data, size_t count)
{
	assert(tc->mtu == SERIAL_MTU);
	assert(count <= tc->mtu);
	xawrite(tc->portfd, data, count);
#ifndef WIN32
	tcdrain(tc->portfd);
#endif
}
Beispiel #3
0
void put_block(const char *buf, unsigned size)
{
	assert(portfd >= 0);
	xawrite(portfd, buf, size);
}