Ejemplo n.º 1
0
/*
 * main
 */
int main(int argc, char **argv)
{
	FILE *fp;
	uint64_t off, val;
	int result;

	printf("%s:%d: start\n", __func__, __LINE__);

	fp = open_dump();
	if (!fp)
		goto done;

	for (off = DUMP_OFFSET; off < DUMP_OFFSET + DUMP_SIZE; off += sizeof(uint64_t)) {
		val = lv2_lv1_peek(off);

		result = fwrite(&val, 1, sizeof(val), fp);
		if (result != sizeof(val)) {
			printf("%s:%d: fwrite failed (0x%08x)\n", __func__, __LINE__, result);
			goto done;
		}
	}

	fclose(fp);

	printf("%s:%d: end\n", __func__, __LINE__);

	lv2_sm_ring_buzzer(0x1004, 0xa, 0x1b6);

done:

	if (fp)
		fclose(fp);

	return 0;
}
Ejemplo n.º 2
0
void dump(char type, uint32_t timestamp, void *data, int data_size) {
	// timestamp can be at most 10 characters, we have a few extra
	double cur_time = get_time();
	FILE *fp;
	last_timestamp = timestamp;
	switch (type) {
	case 'd':
		fp = open_dump(type, cur_time, timestamp, data_size, "pgm");
		dump_depth(fp, data, data_size);
		fclose(fp);
		break;
	case 'r':
		fp = open_dump(type, cur_time, timestamp, data_size, "ppm");
		dump_rgb(fp, data, data_size);
		fclose(fp);
		break;
	case 'a':
		fp = open_dump(type, cur_time, timestamp, data_size, "dump");
		fwrite(data, data_size, 1, fp);
		fclose(fp);
		break;
	}
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    char *ptr;
    //open_dump("test.out");
    open_dump("-");

    struct dumper d;
    d.width = 16;
    d.height = 2;
    d.data = malloc( sizeof(char) * d.width * d.height );
    memset(d.data, '0', sizeof(char) * d.width * d.height);
    ptr = d.data;
    ptr[5] = '1';

    write_dump(&d);
    dump_close();

    return 0;
}
Ejemplo n.º 4
0
/*
 * dump_nand_flash
 */
int dump_nand_flash(void)
{
#define NSECTORS	16

	uint32_t dev_handle;
	struct storage_device_info info;
	FILE *fp;
	int start_sector, sector_count;
	uint32_t unknown2;
	uint8_t buf[NAND_FLASH_SECTOR_SIZE * NSECTORS];
	int result;

	dev_handle = 0;
	fp = NULL;

	result = lv2_storage_open(NAND_FLASH_DEV_ID, &dev_handle);
	if (result) {
		printf("%s:%d: lv2_storage_open failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	fp = open_dump();
	if (!fp)
		goto done;

	result = lv2_storage_get_device_info(NAND_FLASH_DEV_ID, &info);
	if (result) {
		printf("%s:%d: lv2_storage_get_device_info failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	printf("%s:%d: capacity (0x%016llx)\n", __func__, __LINE__, info.capacity);

	start_sector = NAND_FLASH_START_SECTOR;
	//sector_count = info.capacity;
	sector_count = EEID_SIZE;

	while (sector_count >= NSECTORS) {
		printf("%s:%d: reading data start_sector (0x%08x) sector_count (0x%08x)\n",
			__func__, __LINE__, start_sector, NSECTORS);

		result = fread(buf, 1, NSECTORS * NAND_FLASH_SECTOR_SIZE, fp);
		if (result < 0) {
			printf("%s:%d: fread failed (0x%08x)\n", __func__, __LINE__, result);
			goto done;
		}

		printf("%s:%d: writing data start_sector (0x%08x) sector_count (0x%08x)\n",
			__func__, __LINE__, start_sector, NSECTORS);

		result = lv2_storage_write(dev_handle, 0, start_sector, NSECTORS, buf, &unknown2, NAND_FLASH_FLAGS);
		if (result) {
			printf("%s:%d: lv2_storage_write failed (0x%08x)\n", __func__, __LINE__, result);
			goto done;
		}

		start_sector += NSECTORS;
		sector_count -= NSECTORS;
	}

	while (sector_count) {
		printf("%s:%d: reading data start_sector (0x%08x) sector_count (0x%08x)\n",
			__func__, __LINE__, start_sector, 1);

		result = fread(buf, 1, NAND_FLASH_SECTOR_SIZE, fp);
		if (result < 0) {
			printf("%s:%d: fread failed (0x%08x)\n", __func__, __LINE__, result);
			goto done;
		}

		printf("%s:%d: writing data start_sector (0x%08x) sector_count (0x%08x)\n",
			__func__, __LINE__, start_sector, 1);

		result = lv2_storage_write(dev_handle, 0, start_sector, 1, buf, &unknown2, NAND_FLASH_FLAGS);
		if (result) {
			printf("%s:%d: lv2_storage_write failed (0x%08x)\n", __func__, __LINE__, result);
			goto done;
		}

		start_sector += 1;
		sector_count -= 1;
	}

	lv2_sm_ring_buzzer(0x1004, 0xa, 0x1b6); //write finished
	fclose(fp);

	return 0;

done:

	if (fp)
		fclose(fp);

	result = lv2_storage_close(dev_handle);
	if (result)
		printf("%s:%d: lv2_storage_close failed (0x%08x)\n", __func__, __LINE__, result);

	return result;

#undef NSECTORS
}
Ejemplo n.º 5
0
/*
 * main
 */
int main(int argc, char **argv)
{
	uint32_t dev_handle;
	FILE *fp;
	int start_sector, sector_count;
	uint32_t unknown2;
	uint8_t buf[VFLASH_SECTOR_SIZE * VFLASH_SECTOR_COUNT];
	int result;

	netInitialize();
	udp_printf_init();
	PRINTF("%s:%d: start\n", __func__, __LINE__);

	dev_handle = 0;
	fp = NULL;

	result = lv2_storage_open(VFLASH_DEV_ID, &dev_handle);
	if (result) {
		PRINTF("%s:%d: lv2_storage_open failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	fp = open_dump();
	if (!fp)
		goto done;

	start_sector = VFLASH_START_SECTOR;
	sector_count = VFLASH_SECTOR_COUNT;

	PRINTF("%s:%d: reading data start_sector (0x%08x) sector_count (0x%08x)\n", __func__, __LINE__, start_sector, sector_count);

	result = lv2_storage_read(dev_handle, 0, start_sector, sector_count, buf, &unknown2, VFLASH_FLAGS);
	if (result) {
		PRINTF("%s:%d: lv2_storage_read failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	usleep(10000);

	PRINTF("%s:%d: dumping data\n", __func__, __LINE__, start_sector, sector_count);

	result = fwrite(buf, 1, VFLASH_SECTOR_COUNT * VFLASH_SECTOR_SIZE, fp);
	if (result < 0) {
		PRINTF("%s:%d: fwrite failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	fclose(fp);

	PRINTF("%s:%d: end\n", __func__, __LINE__);

	lv2_sm_ring_buzzer(0x1004, 0xa, 0x1b6);

done:

	if (fp)
		fclose(fp);

	result = lv2_storage_close(dev_handle);
	if (result)
		PRINTF("%s:%d: lv2_storage_close failed (0x%08x)\n", __func__, __LINE__, result);

	udp_printf_deinit();

	netDeinitialize();

	return 0;
}