From 77d9418ceee4153066f7ff650cc37a173c36f03a Mon Sep 17 00:00:00 2001 From: David Voswinkel Date: Mon, 29 Jun 2009 21:48:24 +0200 Subject: [PATCH] bank 0x00 upload working with crc --- avr/usbload/commandline/snesuploader | Bin 18552 -> 18552 bytes avr/usbload/commandline/snesuploader.c | 9 +++++---- avr/usbload/crc.c | 14 +++++++++----- avr/usbload/crc.h | 2 +- avr/usbload/dump.c | 15 ++++++--------- avr/usbload/main.c | 16 +++++++++++----- avr/usbload/sram.c | 2 +- avr/usbload/usbconfig.h | 2 +- 8 files changed, 34 insertions(+), 26 deletions(-) diff --git a/avr/usbload/commandline/snesuploader b/avr/usbload/commandline/snesuploader index 69070b2f93428226a0f42d0f79a8dcb00d8b430d..efc207e23e9080a5593b304cd7218894b25dab16 100755 GIT binary patch delta 1715 zcmZ`)ZERCz6n<}4Ms*+kT)$TLdAp&JIl><&AL%M(K!And0%pq=eu$z(jne3dOG~ar zn|fvPW+W0nB8l(=qAXJ;G0`ex&B)YXG%hh2s2J|-BA6_?jAhs7+`f0i#5L)?r_Xub zbDrniliS&TX|`YLKX;G6nz8NWjQIyYy=ifL-MRU}Sc|&R_sivXz8~1(=I4qYw)m@g ztK=P;FA9}#*}krBs)n%{jp4IbKR@JPER!6@Rli=qGRZSTN9>m+sf)KccSv)5!1-}W zdlh3^;lkTp$E0uhHCL7N314tkJDN%uOK*~`nGQMak+lZC+WnZ+Y^1u)R7_4=W$hFn zbU$r55#qY5%6aO)Ia`Qt_dI9$yONTQU(IBp=2JZHdDc-?DjLOVsM;U=K*hS|ohH~( zL*3sGGM4w|Qa9#xy$BZb_ZDIaaeBS1UEn`d^hC%o&!uiAj2(A5BAqp{yuro*OM zePl&dj*8q_KI(1sC}3>f-yWY*mE$7uJePdcbsb3LOLJDa3H7x$L7PyO0YPiwQQypl zpM98eF)EklHp#Y?;Nos2O{(%yaY2Q}kNYdKO;v^op@9~Yy6gN!|Dj+O6_h@klyGNO zYGGa1(UZ<=TeuYHuI)9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&AT()_4B(RQ$zRFlQEX$eTZg~3I%GPG*auW~_CY*zB;fd*c z9kyO~Y_)OMzv;AyiSqqt!s3;SQ0ko{~ z_GvKY%EPPBBs@5Hjk_JbOrO~vL7gSR#<@bQcWJq-Vbi7t+GwL@ybKN&UMvCu-2c4W zyn8|OgjM>~uSTp*L4dK)1@`bP=bYk5f{(55%3r&yLtu`Zj>?)6G zbvfe(2w^IXkC6n-&zCzL5IaqR>llg47_PJmfjt(Qibhgz?R%P%9(3 z`F|{*Vaa!9JNH_&d3b*Z!Kdj6IIHEHxZW;%PS6p5bL5~YigcrwYU4N-EBA6M*o9kG zZbW6CPi&HhD&L32f-4UM{QKxd=#$+K_k>STBasw63dC0-L{cI?Isl}uQi#7KQb(tPZN-sKuH>v=Cqy_ale3<# zZ>q`**9h^rM8dQMNEAp!B2kJ0nFX>>BD3@XkidE&MkErT`KGGsXMnsS5suk~hVOa2 zG#uZL%XzA6zOil_eEEQs0_j7{KTm5Bv)`bM*=dK21N2gJcq{ig4a5m0cX(RH+*?w{ k>~4W$)U@A(e-epvKbK|96U##m&cn0v%UB!lXsOBm4-37}1ONa4 diff --git a/avr/usbload/commandline/snesuploader.c b/avr/usbload/commandline/snesuploader.c index 2ac9864..6aa8f3f 100644 --- a/avr/usbload/commandline/snesuploader.c +++ b/avr/usbload/commandline/snesuploader.c @@ -195,20 +195,21 @@ int main(int argc, char **argv) exit(-1); } addr += SEND_BUFFER_SIZE; - break; + //break; } - dump_packet(0x00000,SEND_BUFFER_SIZE, read_buffer); + //dump_packet(0x00000,SEND_BUFFER_SIZE, read_buffer); memcpy(crc_buffer + cnt_crc, read_buffer, READ_BUFFER_SIZE); cnt_crc += READ_BUFFER_SIZE; if (cnt_crc >= READ_BUFFER_SIZE) { - crc = do_crc(crc_buffer, BANK_SIZE); + crc = do_crc(crc_buffer, READ_BUFFER_SIZE); printf ("bank=0x%02x crc=0x%04x\n", bank, crc); memset(crc_buffer, 0, BUFFER_CRC); bank++; cnt_crc = 0; + break; } - break; + //break; } /* diff --git a/avr/usbload/crc.c b/avr/usbload/crc.c index 1fae813..ef3ea5b 100644 --- a/avr/usbload/crc.c +++ b/avr/usbload/crc.c @@ -27,6 +27,7 @@ uint16_t do_crc(uint8_t * data, uint16_t size) uint16_t i; for (i = 0; i < size; i++) { crc = crc_xmodem_update(crc, data[i]); + } return crc; } @@ -41,15 +42,18 @@ uint16_t do_crc_update(uint16_t crc, uint8_t * data, uint16_t size) } -void crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr) +uint16_t crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr) { uint16_t crc = 0; uint32_t addr = 0; uint8_t req_bank = 0; sram_bulk_read_start(bottom_addr); + printf("crc_check_bulk_memory: bottom_addr=0x%08lx top_addr=0x%08lx\n", + bottom_addr, top_addr); + for (addr = bottom_addr; addr < top_addr; addr++) { if (addr && addr % 0x8000 == 0) { - printf("crc_check_bulk: bank=0x%02x addr=0x%08lx crc=0x%04x\n", + printf("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n", req_bank,addr,crc); req_bank++; crc = 0; @@ -57,11 +61,11 @@ void crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr) crc = crc_xmodem_update(crc, sram_bulk_read()); sram_bulk_read_next(); } - sram_bulk_read_end(); if (addr % 0x8000 == 0) - printf("crc_check_bulk: bank=0x%02x addr=0x%08lx crc=0x%04x\n", + printf("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n", req_bank,addr,crc); - + sram_bulk_read_end(); + return crc; } diff --git a/avr/usbload/crc.h b/avr/usbload/crc.h index 146ab4d..311d316 100644 --- a/avr/usbload/crc.h +++ b/avr/usbload/crc.h @@ -11,6 +11,6 @@ uint16_t do_crc(uint8_t * data,uint16_t size); uint16_t do_crc_update(uint16_t crc,uint8_t * data,uint16_t size); void crc_check_memory(uint32_t bottom_addr,uint32_t top_addr,uint8_t *buffer); uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,uint8_t *buffer); -void crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr); +uint16_t crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr); #endif diff --git a/avr/usbload/dump.c b/avr/usbload/dump.c index d242a98..7f02afb 100644 --- a/avr/usbload/dump.c +++ b/avr/usbload/dump.c @@ -47,19 +47,16 @@ void dump_memory(uint32_t bottom_addr, uint32_t top_addr) { uint32_t addr; uint8_t byte; - - //sram_bulk_read_start(bottom_addr); - bottom_addr = 0x00; - top_addr = 0x80; - - printf("%08lx - %08lx\n",bottom_addr, top_addr); + printf("dump_memory: bottom_addr=%08lx top_addr=%08lx\n",bottom_addr, top_addr); + sram_bulk_read_start(bottom_addr); printf("%08lx:", bottom_addr); for ( addr = bottom_addr; addr < top_addr; addr++) { if (addr%0x10 == 0) printf("\n%08lx:", addr); - byte = sram_read(addr); - //sram_bulk_read_next(); + byte = sram_bulk_read(); + sram_bulk_read_next(); printf(" %02x", byte); } - //sram_bulk_read_end(); + printf("\n"); + sram_bulk_read_end(); } diff --git a/avr/usbload/main.c b/avr/usbload/main.c index cfd86d5..d4436c4 100644 --- a/avr/usbload/main.c +++ b/avr/usbload/main.c @@ -12,12 +12,13 @@ #include "uart.h" #include "sram.h" #include "debug.h" +#include "dump.h" #include "crc.h" #include "usb_bulk.h" extern FILE uart_stdout; -uint8_t debug_level = ( DEBUG | DEBUG_USB | DEBUG_USB_TRANS | DEBUG_SRAM); +uint8_t debug_level = ( DEBUG | DEBUG_USB); uint8_t read_buffer[TRANSFER_BUFFER_SIZE]; uint32_t req_addr = 0; @@ -53,7 +54,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) req_bank_size = 1 << rq->wValue.word; sync_errors = 0; crc = 0; - debug(DEBUG_USB,"USB_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size); + debug(DEBUG_USB,"USB_UPLOAD_INIT: bank_size=0x%04x\n", req_bank_size); /* * ------------------------------------------------------------------------- @@ -292,7 +293,7 @@ int main(void) system_init(); printf("Sytem Init\n"); - + avr_bus_active(); usbInit(); printf("USB Init\n"); @@ -320,9 +321,14 @@ int main(void) usbDeviceDisconnect(); printf("USB disconnect\n"); - crc_check_bulk_memory(0x000000,0x8000); + crc_check_bulk_memory(0x000000, 0x80000); + +#if 0 + dump_memory(0x0000,0x0080); + printf("crc=0x%x\n",crc_check_bulk_memory(0x000000, 0x80)); +#endif - dump_memory(0x00,0x80); + dump_memory(0x7f00,0x8000); printf("Disable snes WR\n"); snes_wr_disable(); diff --git a/avr/usbload/sram.c b/avr/usbload/sram.c index 1603ab7..13e2ec2 100644 --- a/avr/usbload/sram.c +++ b/avr/usbload/sram.c @@ -131,7 +131,7 @@ inline uint8_t sram_bulk_read(void) void sram_bulk_read_end(void) { - debug(DEBUG_SRAM,"sram_bulk_read_end:"); + debug(DEBUG_SRAM,"sram_bulk_read_end:\n"); AVR_RD_PORT |= (1 << AVR_RD_PIN); AVR_CS_PORT |= (1 << AVR_CS_PIN); diff --git a/avr/usbload/usbconfig.h b/avr/usbload/usbconfig.h index 85d1934..1afdae5 100644 --- a/avr/usbload/usbconfig.h +++ b/avr/usbload/usbconfig.h @@ -141,7 +141,7 @@ section at the end of this file). * of the macros usbDisableAllRequests() and usbEnableAllRequests() in * usbdrv.h. */ -#define USB_CFG_LONG_TRANSFERS 1 +#define USB_CFG_LONG_TRANSFERS 0 /* Define this to 1 if you want to send/receive blocks of more than 254 bytes * in a single control-in or control-out transfer. Note that the capability * for long transfers increases the driver size.