Exemplo 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;
}
Exemplo n.º 2
0
/* main */
int main(int argc, char **argv)
{
	uint32_t dev_handle;
	uint64_t region_id;
	int result;

	netInitialize();

	udp_printf_init();

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

	dev_handle = 0;

	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;
	}

	result = lv2_storage_create_region(dev_handle, VFLASH_REGION_START_SECTOR, VFLASH_REGION_SECTOR_COUNT,
		0, VFLASH_REGION_LAID, &region_id);
	if (result) {
		PRINTF("%s:%d: lv2_storage_create_region failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

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

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

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

done:

	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;
}
Exemplo n.º 3
0
/*
 * main
 */
int main(int argc, char **argv)
{
	int vflash_on, result;

	//netInitialize();

	//udp_printf_init();

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

	vflash_on = is_vflash_on();

	printf("%s:%d: vflash %s\n", __func__, __LINE__, vflash_on ? "on" : "off");

	if (vflash_on) {
		result = setup_vflash();
		if (result) {
			printf("%s:%d: setup_vflash failed (0x%08x)\n", __func__, __LINE__, result);
			goto done;
		}
	} else {
		result = setup_flash();
		if (result) {
			printf("%s:%d: setup_flash failed (0x%08x)\n", __func__, __LINE__, result);
			goto done;
		}
	}

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

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

done:

	//udp_printf_deinit();

	//netDeinitialize();

	return 0;
}
Exemplo n.º 4
0
/* main */
int main(int argc, char **argv)
{
#ifndef USE_AIM
	uint64_t eid0_size;
	uint8_t eid0[4096];
#endif
	uint8_t value, idps[IDPS_SIZE], seed[TOKEN_SIZE], token[TOKEN_SIZE];
	AES_KEY aes_ctx;
	int i, result;

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

#ifdef USE_AIM 

	result = lv2_ss_aim_if(AIM_PACKET_ID_GET_DEV_ID, (uint64_t) &idps);
	if (result) {
		PRINTF("%s:%d: lv2_ss_aim_if(GET_DEV_ID) failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

#else

	result = lv2_ss_indi_info_mgr_if(INDI_INFO_MGR_PACKET_ID_GET_DATA_SIZE_BY_INDEX, EID0_INDEX, (uint64_t) &eid0_size, 0, 0);
	if (result) {
		PRINTF("%s:%d: lv2_ss_indi_info_mgr_if(GET_DATA_SIZE_BY_INDEX) failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	PRINTF("%s:%d: EID0 size %ld\n", __func__, __LINE__, eid0_size);

	result = lv2_ss_indi_info_mgr_if(INDI_INFO_MGR_PACKET_ID_GET_DATA_BY_INDEX, EID0_INDEX, (uint64_t) eid0, sizeof(eid0), (uint64_t) &eid0_size);
	if (result) {
		PRINTF("%s:%d: lv2_ss_indi_info_mgr_if(GET_DATA_BY_INDEX) failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	PRINTF("%s:%d: EID0 size %ld\n", __func__, __LINE__, eid0_size);

	memcpy(idps, eid0, IDPS_SIZE);

#endif

	PRINTF("%s: %d: IDPS: %02x %02x %02x %02x %02x %02x %02x %02x "
		"%02x %02x %02x %02x %02x %02x %02x %02x\n", __func__, __LINE__,
		idps[0], idps[1], idps[ 2], idps[ 3], idps[ 4], idps[ 5], idps[ 6], idps[ 7],
		idps[8], idps[9], idps[10], idps[11], idps[12], idps[13], idps[14], idps[15]);
	
	memset(seed, 0, TOKEN_SIZE);
	memcpy(seed + 4, idps, IDPS_SIZE);
	seed[3] = 1;

	hmac_sha1(hmac, sizeof(hmac), seed, 60, seed + 60);

	result = AES_set_encrypt_key(erk, 256, &aes_ctx);
	if (result) {
		PRINTF("%s:%d: AES_set_encrypt_key failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	AES_cbc_encrypt(iv, seed, token, TOKEN_SIZE, &aes_ctx);

	PRINTF("%s: %d: TOKEN SEED:\n", __func__, __LINE__);
	for (i = 0; i < TOKEN_SIZE; i += 16)
		PRINTF("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
			seed[i +  0], seed[i +  1], seed[i +  2], seed[i +  3], seed[i +  4], seed[i +  5],
			seed[i +  6], seed[i +  7], seed[i +  8], seed[i +  9], seed[i + 10], seed[i + 11],
			seed[i + 12], seed[i + 13], seed[i + 14], seed[i + 15]);

	PRINTF("%s: %d: TOKEN:\n", __func__, __LINE__);
	for (i = 0; i < TOKEN_SIZE; i += 16)
		PRINTF("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
			token[i +  0], token[i +  1], token[i +  2], token[i +  3], token[i +  4], token[i +  5],
			token[i +  6], token[i +  7], token[i +  8], token[i +  9], token[i + 10], token[i + 11],
			token[i + 12], token[i + 13], token[i + 14], token[i + 15]);

	result = lv2_ss_update_mgr_if(UPDATE_MGR_PACKET_ID_SET_TOKEN, (uint64_t) token, TOKEN_SIZE, 0, 0, 0, 0);
	if (result) {
		PRINTF("%s:%d: lv1_ss_update_mgr_if(SET_TOKEN) failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	result = lv2_ss_update_mgr_if(UPDATE_MGR_PACKET_ID_READ_EPROM, EPROM_QA_FLAG_OFFSET, (uint64_t) &value, 0, 0, 0, 0);
	if (result) {
		PRINTF("%s:%d: lv1_ss_update_mgr_if(READ_EPROM) failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

	PRINTF("%s:%d: current QA flag 0x%02x\n", __func__, __LINE__, value);

	result = lv2_ss_update_mgr_if(UPDATE_MGR_PACKET_ID_WRITE_EPROM, EPROM_QA_FLAG_OFFSET, 0xff /* disable QA token */, 0, 0, 0, 0);
	if (result) {
		PRINTF("%s:%d: lv1_ss_update_mgr_if(WRITE_EPROM) failed (0x%08x)\n", __func__, __LINE__, result);
		goto done;
	}

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

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

done:

	udp_printf_deinit();
	netDeinitialize();

	return 0;
}
Exemplo n.º 5
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
}
Exemplo n.º 6
0
/*
 * main
 */
int main(int argc, char **argv)
{
	uint32_t dev_handle;
	int start_sector, sector_count;
	struct storage_device_info info;
	uint8_t buf[VFLASH5_SECTOR_SIZE * 16];
	struct os_area_header *hdr;
	struct os_area_params *params;
	uint32_t unknown2;
	int result;

	netInitialize();

	udp_printf_init();

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

	dev_handle = 0;

	result = lv2_storage_get_device_info(VFLASH5_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%16llx)\n", __func__, __LINE__, info.capacity);

	if (info.capacity < VFLASH5_HEADER_SECTORS) {
		PRINTF("%s:%d: device capacity too small\n", __func__, __LINE__);
		goto done;
	}

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

	/* write os header and params */

	start_sector = 0;
	sector_count = VFLASH5_HEADER_SECTORS;

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

	memset(buf, 0, sizeof(buf));
	hdr = (struct os_area_header *) buf;
	params = (struct os_area_params *) (buf + OS_AREA_SEGMENT_SIZE);

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

	if (strncmp((const char *) hdr->magic, HEADER_MAGIC, sizeof(hdr->magic))) {
		PRINTF("%s:%d: invalid header magic\n", __func__, __LINE__, result);
		goto done;
	}

	if (hdr->version != HEADER_VERSION) {
		PRINTF("%s:%d: invalid header version\n", __func__, __LINE__, result);
		goto done;
	}

	if (params->boot_flag != PARAM_BOOT_FLAG_GAME_OS) {
		params->boot_flag = PARAM_BOOT_FLAG_GAME_OS;

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

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

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

done:

	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;
}
Exemplo n.º 7
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;
}