Flashing operations working, cleaning up a few items.
usb_Func_write updates buffer status if bytes remaining is zero. Not the best solution as a buffer could be over/under run, define MAKECHECKS to have buffer mark itself if full. This method is faster and we always have transfer sizes match buffer sizes anyway.
This commit is contained in:
parent
52a1b306c9
commit
748c474ddb
|
|
@ -303,12 +303,15 @@ USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len) {
|
||||||
data_cur++;
|
data_cur++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAKECHECKS
|
||||||
//need to account for the fact that cur_byte will roll over being 8bit value
|
//need to account for the fact that cur_byte will roll over being 8bit value
|
||||||
if ( cur_usb_load_buff->last_idx == (cur_usb_load_buff->cur_byte + len - 1) ) {
|
if ( cur_usb_load_buff->last_idx == (cur_usb_load_buff->cur_byte + len - 1) ) {
|
||||||
//this signals to buffer.c so it can update cur_usb_load_buf
|
//this signals to buffer.c so it can update cur_usb_load_buf
|
||||||
//and start tasking this buffer to programming
|
//and start tasking this buffer to programming
|
||||||
cur_usb_load_buff->status = USB_FULL;
|
cur_usb_load_buff->status = USB_FULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//update counters and status
|
//update counters and status
|
||||||
cur_usb_load_buff->cur_byte += len;
|
cur_usb_load_buff->cur_byte += len;
|
||||||
|
|
@ -320,7 +323,8 @@ USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len) {
|
||||||
|
|
||||||
|
|
||||||
if ( incoming_bytes_remain == 0 ) { //done with OUT transfer
|
if ( incoming_bytes_remain == 0 ) { //done with OUT transfer
|
||||||
// cur_usb_load_buff->status = USB_FULL;
|
//alternate to MAKECHECKS should be faster but require transfer sizes to match buffer size
|
||||||
|
cur_usb_load_buff->status = USB_FULL;
|
||||||
return PAYLD_DONE;
|
return PAYLD_DONE;
|
||||||
} else { //more data packets remain to complete OUT transfer
|
} else { //more data packets remain to complete OUT transfer
|
||||||
return NOT_DONE;
|
return NOT_DONE;
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ int flash_cart( USBtransfer* transfer, rom_image *rom, cartridge *cart )
|
||||||
|
|
||||||
for( i=0; i<(32*KByte/buff_size); i++) {
|
for( i=0; i<(32*KByte/buff_size); i++) {
|
||||||
//for( i=0; i<8; i++) {
|
//for( i=0; i<8; i++) {
|
||||||
debug("\n\npayload out #%d", i);
|
//debug("\n\npayload out #%d", i);
|
||||||
//get_operation( transfer );
|
//get_operation( transfer );
|
||||||
//get_buff_elements( transfer, buff0 );
|
//get_buff_elements( transfer, buff0 );
|
||||||
//get_buff_elements( transfer, buff1 );
|
//get_buff_elements( transfer, buff1 );
|
||||||
|
|
@ -146,10 +146,9 @@ int flash_cart( USBtransfer* transfer, rom_image *rom, cartridge *cart )
|
||||||
//ensure cur_buff is EMPTY prior to sending data
|
//ensure cur_buff is EMPTY prior to sending data
|
||||||
check(! get_cur_buff_status( transfer, &cur_buff_status ), "Error retrieving cur_buff->status");
|
check(! get_cur_buff_status( transfer, &cur_buff_status ), "Error retrieving cur_buff->status");
|
||||||
while (cur_buff_status != EMPTY ) {
|
while (cur_buff_status != EMPTY ) {
|
||||||
debug("cur_buff->status: %x ", cur_buff_status);
|
//debug("cur_buff->status: %x ", cur_buff_status);
|
||||||
check(! get_cur_buff_status( transfer, &cur_buff_status ), "Error retrieving cur_buff->status");
|
check(! get_cur_buff_status( transfer, &cur_buff_status ), "Error retrieving cur_buff->status");
|
||||||
}
|
}
|
||||||
debug("cur_buff->status: %x\n", cur_buff_status);
|
|
||||||
|
|
||||||
//send data
|
//send data
|
||||||
check(! payload_out( transfer, data, buff_size ), "Error with payload OUT");
|
check(! payload_out( transfer, data, buff_size ), "Error with payload OUT");
|
||||||
|
|
@ -158,41 +157,21 @@ int flash_cart( USBtransfer* transfer, rom_image *rom, cartridge *cart )
|
||||||
}
|
}
|
||||||
check(! get_cur_buff_status( transfer, &cur_buff_status ), "Error retrieving cur_buff->status");
|
check(! get_cur_buff_status( transfer, &cur_buff_status ), "Error retrieving cur_buff->status");
|
||||||
debug("\n\n\ncur_buff->status: %x\n", cur_buff_status);
|
debug("\n\n\ncur_buff->status: %x\n", cur_buff_status);
|
||||||
|
//TODO add check to ensure both buffers are done and operation is okay
|
||||||
|
//currently just make a few extra get elements calls to waste time
|
||||||
|
|
||||||
get_operation( transfer );
|
get_operation( transfer );
|
||||||
get_buff_elements( transfer, buff0 );
|
get_buff_elements( transfer, buff0 );
|
||||||
get_buff_elements( transfer, buff1 );
|
get_buff_elements( transfer, buff1 );
|
||||||
get_buff_elements( transfer, buff0 );
|
|
||||||
get_buff_elements( transfer, buff1 );
|
|
||||||
get_buff_elements( transfer, buff0 );
|
|
||||||
get_buff_elements( transfer, buff1 );
|
|
||||||
get_operation( transfer );
|
get_operation( transfer );
|
||||||
debug("payload done");
|
debug("payload done");
|
||||||
|
|
||||||
//end operation at reset
|
//end operation at reset
|
||||||
//check(! set_operation( transfer, RESET ), "Unable to set buffer operation");
|
check(! set_operation( transfer, RESET ), "Unable to set buffer operation");
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
//for( i=0; i<(512*KByte/buff_size); i++) {
|
|
||||||
for( i=0; i<(32*KByte/buff_size); i++) {
|
|
||||||
//for( i=0; i<(8*KByte/buff_size); i++) {
|
|
||||||
check(! read_from_file( rom, data, buff_size ), "Error with file read");
|
|
||||||
check(! payload_out( transfer, data, buff_size ), "Error with payload OUT");
|
|
||||||
//if ( i % 256 == 0 ) debug("payload in #%d", i);
|
|
||||||
if ( i % 32 == 0 ) debug("payload out #%d", i);
|
|
||||||
}
|
|
||||||
debug("payload done");
|
|
||||||
//need to delay further USB commands until last buffer is flashed
|
|
||||||
//TODO spin while buff1 status == FLASHING
|
|
||||||
//currently this takes about as long as two get elements
|
|
||||||
get_buff_elements( transfer, buff1 );
|
|
||||||
get_buff_elements( transfer, buff1 );
|
|
||||||
get_buff_elements( transfer, buff1 );
|
|
||||||
|
|
||||||
tstop = clock();
|
tstop = clock();
|
||||||
float timediff = ( (float)(tstop-tstart) / CLOCKS_PER_SEC);
|
float timediff = ( (float)(tstop-tstart) / CLOCKS_PER_SEC);
|
||||||
printf("total time: %fsec, speed: %fKBps\n", timediff, (512/timediff));
|
printf("total time: %fsec, speed: %fKBps\n", timediff, (32/timediff));
|
||||||
//TODO flush file from time to time..?
|
//TODO flush file from time to time..?
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -200,6 +179,7 @@ int flash_cart( USBtransfer* transfer, rom_image *rom, cartridge *cart )
|
||||||
// or not..? just reset buffers and start next memory or quit
|
// or not..? just reset buffers and start next memory or quit
|
||||||
//reset buffers and setup to dump CHR-ROM
|
//reset buffers and setup to dump CHR-ROM
|
||||||
|
|
||||||
|
/*
|
||||||
check(! reset_buffers( transfer ), "Unable to reset device buffers");
|
check(! reset_buffers( transfer ), "Unable to reset device buffers");
|
||||||
check(! allocate_buffers( transfer, num_buffers, buff_size ), "Unable to allocate buffers");
|
check(! allocate_buffers( transfer, num_buffers, buff_size ), "Unable to allocate buffers");
|
||||||
check(! set_mem_n_part( transfer, buff0, CHRROM, SST_MANF_ID ), "Unable to set mem_type and part");
|
check(! set_mem_n_part( transfer, buff0, CHRROM, SST_MANF_ID ), "Unable to set mem_type and part");
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ int test_function( cartridge *cart, USBtransfer *transfer )
|
||||||
dictionary_call( transfer, DICT_PINPORT, ROMSEL_HI, 0, 0, USB_IN, NULL, 1);
|
dictionary_call( transfer, DICT_PINPORT, ROMSEL_HI, 0, 0, USB_IN, NULL, 1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
//spansion/cypress A18-11 are don't care, that translates to A19-12 for byte mode I think
|
//spansion/cypress A18-11 are don't care, that translates to A19-12 for byte mode I think
|
||||||
//$AAA / AA
|
//$AAA / AA
|
||||||
dictionary_call( transfer, DICT_NES, NES_CPU_WR, 0x8AAA, 0xAA,
|
dictionary_call( transfer, DICT_NES, NES_CPU_WR, 0x8AAA, 0xAA,
|
||||||
|
|
@ -41,22 +40,24 @@ int test_function( cartridge *cart, USBtransfer *transfer )
|
||||||
//$AAA / 90 manf ID
|
//$AAA / 90 manf ID
|
||||||
dictionary_call( transfer, DICT_NES, NES_CPU_WR, 0x8AAA, 0x90,
|
dictionary_call( transfer, DICT_NES, NES_CPU_WR, 0x8AAA, 0x90,
|
||||||
USB_IN, NULL, 1);
|
USB_IN, NULL, 1);
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
dictionary_call_debug( transfer, DICT_NES, EMULATE_NES_CPU_RD, 0x8000, 0,
|
||||||
|
USB_IN, NULL, 2);
|
||||||
|
dictionary_call_debug( transfer, DICT_NES, EMULATE_NES_CPU_RD, 0x8002, 0,
|
||||||
|
USB_IN, NULL, 2);
|
||||||
|
|
||||||
|
/*
|
||||||
dictionary_call_debug( transfer, DICT_NES, NES_PPU_RD, 0x0000, 0,
|
dictionary_call_debug( transfer, DICT_NES, NES_PPU_RD, 0x0000, 0,
|
||||||
USB_IN, NULL, 2);
|
USB_IN, NULL, 2);
|
||||||
dictionary_call_debug( transfer, DICT_NES, NES_PPU_RD, 0x0055, 0,
|
dictionary_call_debug( transfer, DICT_NES, NES_PPU_RD, 0x0055, 0,
|
||||||
USB_IN, NULL, 2);
|
USB_IN, NULL, 2);
|
||||||
dictionary_call_debug( transfer, DICT_NES, NES_PPU_RD, 0x00AA, 0,
|
dictionary_call_debug( transfer, DICT_NES, NES_PPU_RD, 0x00AA, 0,
|
||||||
USB_IN, NULL, 2);
|
USB_IN, NULL, 2);
|
||||||
|
*/
|
||||||
dictionary_call_debug( transfer, DICT_NES, EMULATE_NES_CPU_RD, 0x8000, 0,
|
|
||||||
USB_IN, NULL, 2);
|
|
||||||
dictionary_call_debug( transfer, DICT_NES, EMULATE_NES_CPU_RD, 0x8002, 0,
|
|
||||||
USB_IN, NULL, 2);
|
|
||||||
//RESET write F0 anywhere
|
//RESET write F0 anywhere
|
||||||
// dictionary_call( transfer, DICT_NES, NES_CPU_WR, 0x8000, 0xF0,
|
dictionary_call( transfer, DICT_NES, NES_CPU_WR, 0x8000, 0xF0,
|
||||||
// USB_IN, NULL, 1);
|
USB_IN, NULL, 1);
|
||||||
|
|
||||||
dictionary_call_debug( transfer, DICT_NES, EMULATE_NES_CPU_RD, 0x8000, 0,
|
dictionary_call_debug( transfer, DICT_NES, EMULATE_NES_CPU_RD, 0x8000, 0,
|
||||||
USB_IN, NULL, 2);
|
USB_IN, NULL, 2);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue