now anyone can recompile cgminer for me .. from bitmain ghithub dash miner wit this mod chance xcoin.c in groest.c (delete xcoin.c and rename groest.c in xcoin.c)
wasting time. read basic of programming.
groest.c used in xcoin.c and can't work else.
int PIC1704_update_pic_app_program_new(void)
{
unsigned char program_data[5000] = {0};
FILE * pic_program_file;
unsigned int filesize = 0,i=0,j;
unsigned char data_read[5]= {0,0,0,0,'\0'}, buf[16]= {0};
unsigned int data_int = 0;
struct stat statbuff;
unsigned char start_addr_h = PIC_FLASH_POINTER_START_ADDRESS_H_NEW, start_addr_l = PIC_FLASH_POINTER_START_ADDRESS_L_NEW;
unsigned char end_addr_h = PIC_FLASH_POINTER_END_ADDRESS_H, end_addr_l = PIC_FLASH_POINTER_END_ADDRESS_L;
unsigned int pic_flash_length=0;
int ret=0;
applog(LOG_NOTICE,"%s", __FUNCTION__);
// read upgrade file first, if it is wrong, don't erase pic, but just return;
pic_program_file = fopen(PIC16F1704_PROGRAM_NEW, "r");
if(!pic_program_file)
{
applog(LOG_ERR,"%s: open pic16f1704_app_new.txt failed\n", __FUNCTION__);
return;
}
fseek(pic_program_file,0,SEEK_SET);
memset(program_data, 0x0, 5000);
pic_flash_length = (((unsigned int)end_addr_h << 8) + end_addr_l) - (((unsigned int)start_addr_h << 8) + start_addr_l) + 1;
applog(LOG_NOTICE,"%s: pic_flash_length = %d\n", __FUNCTION__, pic_flash_length);
for(i=0; i {
fgets(data_read, MAX_CHAR_NUM - 1, pic_program_file);
//printf("data_read[0]=%c, data_read[1]=%c, data_read[2]=%c, data_read[3]=%c\n", data_read[0], data_read[1], data_read[2], data_read[3]);
data_int = strtoul(data_read, NULL, 16);
//printf("data_int = 0x%04x\n", data_int);
program_data[2*i + 0] = (unsigned char)((data_int >> 8) & 0x000000ff);
program_data[2*i + 1] = (unsigned char)(data_int & 0x000000ff);
//printf("program_data[%d]=0x%02x, program_data[%d]=0x%02x\n\n", 2*i + 0, program_data[2*i + 0], 2*i + 1, program_data[2*i + 1]);
}
fclose(pic_program_file);
// after read upgrade file correct, erase pic
ret = reset_PIC16F1704_pic_new();
if(ret == 0)
{
applog(LOG_ERR,"%s: reset pic error!\n\n", __FUNCTION__);
return 0;
}
ret = erase_PIC16F1704_app_flash_new();
if(ret == 0)
{
applog(LOG_ERR,"%s: erase flash error!\n\n", __FUNCTION__);
return 0;
}
ret = set_PIC16F1704_flash_pointer_new(PIC_FLASH_POINTER_START_ADDRESS_H_NEW, PIC_FLASH_POINTER_START_ADDRESS_L_NEW);
if(ret == 0)
{
applog(LOG_ERR,"%s: set flash pointer error!\n\n", __FUNCTION__);
return 0;
}
for(i=0; i {
memcpy(buf, program_data+i*16, 16);
/**/
applog(LOG_NOTICE,"send pic program time: %d",i);
for(j=0; j<16; j++)
{
applog(LOG_DEBUG,"buf[%d] = 0x%02x", j, *(buf+j));
}
send_data_to_PIC16F1704_new(buf);
write_data_into_PIC16F1704_flash_new();
}
ret = reset_PIC16F1704_pic_new();
if(ret == 0)
{
applog(LOG_ERR,"%s: reset pic error!\n\n", __FUNCTION__);
return 0;
}
return 1;
}