fix new debug routing and start debugging sram bulk

This commit is contained in:
David Voswinkel 2009-06-29 08:53:59 +02:00
parent f9724a3209
commit 2ebd2b75aa
9 changed files with 36 additions and 19 deletions

Binary file not shown.

View File

@ -15,8 +15,8 @@
*/ */
#define READ_BUFFER_SIZE 1024 #define READ_BUFFER_SIZE (1024 * 32)
#define SEND_BUFFER_SIZE 0x200 #define SEND_BUFFER_SIZE 128
#define BUFFER_CRC (1024 * 32) #define BUFFER_CRC (1024 * 32)
#define BANK_SIZE (1<<15) #define BANK_SIZE (1<<15)
#define BANK_SIZE_SHIFT 15 #define BANK_SIZE_SHIFT 15
@ -170,7 +170,6 @@ int main(int argc, char **argv)
crc_buffer = (unsigned char *) malloc(BUFFER_CRC); crc_buffer = (unsigned char *) malloc(BUFFER_CRC);
memset(crc_buffer, 0, BUFFER_CRC); memset(crc_buffer, 0, BUFFER_CRC);
addr = 0x000000; addr = 0x000000;
usb_control_msg(handle, usb_control_msg(handle,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,
USB_UPLOAD_INIT, BANK_SIZE_SHIFT , 0, NULL, 0, 5000); USB_UPLOAD_INIT, BANK_SIZE_SHIFT , 0, NULL, 0, 5000);
@ -192,11 +191,13 @@ int main(int argc, char **argv)
if (cnt < 0) { if (cnt < 0) {
fprintf(stderr, "USB error: %s\n", usb_strerror()); fprintf(stderr, "USB error: %s\n", usb_strerror());
usb_close(handle);
exit(-1); exit(-1);
} }
addr += SEND_BUFFER_SIZE; addr += SEND_BUFFER_SIZE;
break;
} }
dump_packet(0x00000,READ_BUFFER_SIZE, read_buffer); dump_packet(0x00000,SEND_BUFFER_SIZE, read_buffer);
memcpy(crc_buffer + cnt_crc, read_buffer, READ_BUFFER_SIZE); memcpy(crc_buffer + cnt_crc, read_buffer, READ_BUFFER_SIZE);
cnt_crc += READ_BUFFER_SIZE; cnt_crc += READ_BUFFER_SIZE;
if (cnt_crc >= READ_BUFFER_SIZE) { if (cnt_crc >= READ_BUFFER_SIZE) {
@ -206,6 +207,7 @@ int main(int argc, char **argv)
bank++; bank++;
cnt_crc = 0; cnt_crc = 0;
} }
break; break;
} }

View File

@ -5,6 +5,7 @@
#include "uart.h" #include "uart.h"
extern FILE uart_stdout; extern FILE uart_stdout;
extern int debug_level; /* the higher, the more messages... */ extern int debug_level; /* the higher, the more messages... */
@ -21,9 +22,10 @@ void debug(int level, char* format, ...) {
if (!(debug_level & level)) if (!(debug_level & level))
return; return;
va_start(args, format); va_start(args, format);
printf(format, args); vprintf(format, args);
va_end(args); va_end(args);
#endif /* NDEBUG */ #endif /* NDEBUG */
#endif /* NDEBUG && __GNUC__ */ #endif /* NDEBUG && __GNUC__ */
} }

View File

@ -18,4 +18,4 @@ void debug(int level, char *format, ...);
#endif /* DEBUG_H */ #endif /* DEBUG_H */

View File

@ -47,14 +47,19 @@ void dump_memory(uint32_t bottom_addr, uint32_t top_addr)
{ {
uint32_t addr; uint32_t addr;
uint8_t byte; uint8_t byte;
sram_bulk_read_start(bottom_addr);
//sram_bulk_read_start(bottom_addr);
bottom_addr = 0x00;
top_addr = 0x80;
printf("%08lx - %08lx\n",bottom_addr, top_addr);
printf("%08lx:", bottom_addr); printf("%08lx:", bottom_addr);
for ( addr = bottom_addr; addr < top_addr; addr++) { for ( addr = bottom_addr; addr < top_addr; addr++) {
if (addr%0x16 == 0) if (addr%0x10 == 0)
printf("\n%08lx:", bottom_addr); printf("\n%08lx:", addr);
byte = sram_bulk_read(); byte = sram_read(addr);
sram_bulk_read_next(); //sram_bulk_read_next();
printf(" %02x", byte); printf(" %02x", byte);
} }
sram_bulk_read_end(); //sram_bulk_read_end();
} }

View File

@ -5,8 +5,9 @@
#include <stdint.h> #include <stdint.h>
#include <stdarg.h> #include <stdarg.h>
void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet);
void dump_memory(uint32_t bottom_addr, uint32_t top_addr); void dump_memory(uint32_t bottom_addr, uint32_t top_addr);
void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet);
#endif #endif

View File

@ -17,7 +17,7 @@
extern FILE uart_stdout; extern FILE uart_stdout;
uint8_t debug_level = ( DEBUG | DEBUG_USB ); uint8_t debug_level = ( DEBUG | DEBUG_USB | DEBUG_USB_TRANS | DEBUG_SRAM);
uint8_t read_buffer[TRANSFER_BUFFER_SIZE]; uint8_t read_buffer[TRANSFER_BUFFER_SIZE];
uint32_t req_addr = 0; uint32_t req_addr = 0;
@ -231,6 +231,7 @@ void test_read_write(){
} }
void test_bulk_read_write(){ void test_bulk_read_write(){
uint8_t i; uint8_t i;
@ -250,7 +251,7 @@ void test_bulk_read_write(){
while (addr <= 0x3fffff){ while (addr <= 0x3fffff){
printf("addr=0x%08lx %x\n",addr,sram_bulk_read()); printf("addr=0x%08lx %x\n",addr,sram_bulk_read());
sram_bulk_read_next(); sram_bulk_read_next();
addr ++; addr++;
} }
sram_bulk_read_end(); sram_bulk_read_end();
} }
@ -318,17 +319,21 @@ int main(void)
printf("USB poll done\n"); printf("USB poll done\n");
usbDeviceDisconnect(); usbDeviceDisconnect();
printf("USB disconnect\n"); printf("USB disconnect\n");
crc_check_bulk_memory(0x000000,0x1000);
crc_check_bulk_memory(0x000000,0x8000);
dump_memory(0x00,0x80);
printf("Disable snes WR\n"); printf("Disable snes WR\n");
snes_wr_disable(); snes_wr_disable();
printf("Use Snes lowrom\n"); printf("Use Snes lowrom\n");
snes_lorom(); snes_lorom();
printf("Activate Snes bus\n"); printf("Activate Snes bus\n");
snes_bus_active(); snes_bus_active();
while(1); while(1);
return 0; return 0;
} }

View File

@ -42,6 +42,8 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
rx_remaining -= len; rx_remaining -= len;
debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n", debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n",
req_addr, len, rx_remaining); req_addr, len, rx_remaining);
debug(DEBUG_USB_TRANS,"usbFunctionWrite %02x %02x %02x %02x %02x %02x %02x %x\n",
data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);
sram_copy(req_addr, data, len); sram_copy(req_addr, data, len);
req_addr += len; req_addr += len;
} else if (req_state == REQ_STATUS_BULK_UPLOAD) { } else if (req_state == REQ_STATUS_BULK_UPLOAD) {

View File

@ -114,7 +114,7 @@ section at the end of this file).
/* Define this to 1 if the device has its own power supply. Set it to 0 if the /* Define this to 1 if the device has its own power supply. Set it to 0 if the
* device is powered from the USB bus. * device is powered from the USB bus.
*/ */
#define USB_CFG_MAX_BUS_POWER 300 #define USB_CFG_MAX_BUS_POWER 200
/* Set this variable to the maximum USB bus power consumption of your device. /* Set this variable to the maximum USB bus power consumption of your device.
* The value is in milliamperes. [It will be divided by two since USB * The value is in milliamperes. [It will be divided by two since USB
* communicates power requirements in units of 2 mA.] * communicates power requirements in units of 2 mA.]