o make rom uploader
This commit is contained in:
parent
9a959e46a4
commit
56ac6b73a4
@ -55,13 +55,9 @@ DirList list;
|
|||||||
unsigned short e;
|
unsigned short e;
|
||||||
unsigned char buf[513];
|
unsigned char buf[513];
|
||||||
|
|
||||||
void cleanup_name(filename,sfn){
|
void cleanup_name(uint8_t * filename,uint8_t *sfn){
|
||||||
|
|
||||||
while(*filename != '\0'){
|
while(*filename != '\0');
|
||||||
if(*filename=='.' && !dot){
|
|
||||||
dot=1;
|
|
||||||
c=8;
|
|
||||||
}else{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -176,7 +172,7 @@ int main(void)
|
|||||||
file_normalToFatName("sprite .smc",fatfilename);
|
file_normalToFatName("sprite .smc",fatfilename);
|
||||||
rprintf("Fatfilename: '%s'\n",fatfilename);
|
rprintf("Fatfilename: '%s'\n",fatfilename);
|
||||||
dump_filename(fatfilename);
|
dump_filename(fatfilename);
|
||||||
//dump_filename(rom_filename);
|
dump_filename(rom_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
ledToggle();
|
ledToggle();
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
# app defs
|
# app defs
|
||||||
EXE = custom_client
|
|
||||||
ifndef LIBUSB
|
ifndef LIBUSB
|
||||||
LIBUSB = "/opt/local/"
|
LIBUSB = "/opt/local/"
|
||||||
endif
|
endif
|
||||||
@ -8,12 +7,16 @@ endif
|
|||||||
CFLAGS = -W -Wall -g -I$(LIBUSB)/include
|
CFLAGS = -W -Wall -g -I$(LIBUSB)/include
|
||||||
LIBS = -L$(LIBUSB)/lib -lusb
|
LIBS = -L$(LIBUSB)/lib -lusb
|
||||||
|
|
||||||
all: $(EXE)
|
all: custom_client uploader
|
||||||
|
|
||||||
$(EXE): main.o
|
custom_client: custom_client.o
|
||||||
$(CC) -o $(EXE) $< $(LIBS)
|
$(CC) -o $@ $< $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
uploader: uploader.o
|
||||||
|
$(CC) -o $@ $< $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(EXE) main.o
|
$(RM) custom_client uploader *.o
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
|
||||||
@ -39,8 +40,8 @@ typedef unsigned int U32;
|
|||||||
typedef unsigned char U8;
|
typedef unsigned char U8;
|
||||||
|
|
||||||
#define MAX_TIME 3000
|
#define MAX_TIME 3000
|
||||||
|
#define BLOCKSIZE 8192
|
||||||
static unsigned char abData[16384];
|
static unsigned char abData[BLOCKSIZE];
|
||||||
|
|
||||||
// USB device specific definitions
|
// USB device specific definitions
|
||||||
#define VENDOR_ID 0xFFFF
|
#define VENDOR_ID 0xFFFF
|
||||||
@ -89,6 +90,14 @@ static int stoptimer(void)
|
|||||||
return 1000 * (now.time - start.time) + now.millitm - start.millitm;
|
return 1000 * (now.time - start.time) + now.millitm - start.millitm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_filesize(FILE *input)
|
||||||
|
{
|
||||||
|
int s;
|
||||||
|
fseek(input, 0, SEEK_END);
|
||||||
|
s = ftell(input);
|
||||||
|
fseek(input, 0, SEEK_SET);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -121,45 +130,19 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "usb_claim_interface failed %d\n", i);
|
fprintf(stderr, "usb_claim_interface failed %d\n", i);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
FILE * file;
|
||||||
|
file = fopen( argv[1] ,"r");
|
||||||
// read some data
|
if (file == NULL)
|
||||||
for (j = 6; j < 15; j++) {
|
{
|
||||||
dwBlockSize = (1 << j);
|
fprintf(stderr, "cannt open file %s\n",argv[1]);
|
||||||
fprintf(stderr, "Testing blocksize %5d\n", dwBlockSize);
|
return -1;
|
||||||
|
}
|
||||||
fprintf(stderr, "* read :");
|
MemCmd.dwLength = get_filesize(file);
|
||||||
// send a vendor request for a read
|
|
||||||
MemCmd.dwAddress = 0;
|
MemCmd.dwAddress = 0;
|
||||||
MemCmd.dwLength = 1024 * 1024;
|
dwBlockSize = BLOCKSIZE;
|
||||||
i = usb_control_msg(hdl, BM_REQUEST_TYPE, 0x01, 0, 0, (char *)&MemCmd, sizeof(MemCmd), 1000);
|
fprintf(stderr, "open file %s (%i bytes)\n",argv[1],MemCmd.dwLength);
|
||||||
if (i < 0) {
|
|
||||||
fprintf(stderr, "usb_control_msg failed %d\n", i);
|
|
||||||
}
|
|
||||||
dwBytes = 0;
|
|
||||||
starttimer();
|
|
||||||
while (MemCmd.dwLength > 0) {
|
|
||||||
dwChunk = MIN(dwBlockSize, MemCmd.dwLength);
|
|
||||||
i = usb_bulk_read(hdl, 0x82, (char *)abData, dwBlockSize, 2000);
|
|
||||||
if (i < 0) {
|
|
||||||
fprintf(stderr, "usb_bulk_read failed %d\n", i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
MemCmd.dwLength -= dwChunk;
|
|
||||||
dwBytes += dwBlockSize;
|
|
||||||
if (stoptimer() > MAX_TIME) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iTimer = stoptimer();
|
|
||||||
fprintf(stderr, " %7d bytes in %d ms = %d kB/s\n", dwBytes, iTimer, dwBytes / iTimer);
|
|
||||||
// stdout
|
|
||||||
printf("%d,%d,%d,", dwBlockSize, dwBytes, iTimer);
|
|
||||||
|
|
||||||
fprintf(stderr, "* write:");
|
fprintf(stderr, "* write:");
|
||||||
// send a vendor request for a write
|
// send a vendor request for a write
|
||||||
MemCmd.dwAddress = 0;
|
|
||||||
MemCmd.dwLength = 1024 * 1024;
|
|
||||||
i = usb_control_msg(hdl, BM_REQUEST_TYPE, 0x02, 0, 0, (char *)&MemCmd, sizeof(MemCmd), 1000);
|
i = usb_control_msg(hdl, BM_REQUEST_TYPE, 0x02, 0, 0, (char *)&MemCmd, sizeof(MemCmd), 1000);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
fprintf(stderr, "usb_control_msg failed %d\n", i);
|
fprintf(stderr, "usb_control_msg failed %d\n", i);
|
||||||
@ -167,6 +150,7 @@ int main(int argc, char *argv[])
|
|||||||
dwBytes = 0;
|
dwBytes = 0;
|
||||||
starttimer();
|
starttimer();
|
||||||
while (MemCmd.dwLength > 0) {
|
while (MemCmd.dwLength > 0) {
|
||||||
|
fread(abData,dwBlockSize, 1, file);
|
||||||
dwChunk = MIN(dwBlockSize, MemCmd.dwLength);
|
dwChunk = MIN(dwBlockSize, MemCmd.dwLength);
|
||||||
i = usb_bulk_write(hdl, 0x05, (char *)abData, dwBlockSize, 2000);
|
i = usb_bulk_write(hdl, 0x05, (char *)abData, dwBlockSize, 2000);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
@ -175,6 +159,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
MemCmd.dwLength -= dwChunk;
|
MemCmd.dwLength -= dwChunk;
|
||||||
dwBytes += dwBlockSize;
|
dwBytes += dwBlockSize;
|
||||||
|
iTimer = stoptimer();
|
||||||
|
|
||||||
if (stoptimer() > MAX_TIME) {
|
if (stoptimer() > MAX_TIME) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -182,9 +168,8 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, " %7d bytes in %d ms = %d kB/s\n", dwBytes, iTimer, dwBytes / iTimer);
|
fprintf(stderr, " %7d bytes in %d ms = %d kB/s\n", dwBytes, iTimer, dwBytes / iTimer);
|
||||||
// stdout
|
// stdout
|
||||||
printf("%d,%d,%d\n", dwBlockSize, dwBytes, iTimer);
|
printf("%d,%d,%d\n", dwBlockSize, dwBytes, iTimer);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
usb_release_interface(hdl, 0);
|
usb_release_interface(hdl, 0);
|
||||||
usb_close(hdl);
|
usb_close(hdl);
|
||||||
|
|
||||||
@ -3,5 +3,6 @@ wait_halt
|
|||||||
sleep 10
|
sleep 10
|
||||||
poll
|
poll
|
||||||
flash erase_sector 0 0 14
|
flash erase_sector 0 0 14
|
||||||
flash write_bank 0 /Users/david/Devel/arch/arm/code/lpcusb/examples/custom.bin 0
|
flash write_bank 0 /Users/david/Devel/arch/arm/code/snesram/poc/lpc2148_usb/target/custom/custom.bin 0
|
||||||
|
|
||||||
reset run
|
reset run
|
||||||
|
|||||||
@ -165,6 +165,7 @@ static void _HandleBulkOut(U8 bEP, U8 bEPStatus)
|
|||||||
|
|
||||||
MemoryCmd.dwAddress += iChunk;
|
MemoryCmd.dwAddress += iChunk;
|
||||||
MemoryCmd.dwLength -= iChunk;
|
MemoryCmd.dwLength -= iChunk;
|
||||||
|
DBG("_HandleBulkOut addr=%X, len=%d\n",MemoryCmd.dwAddress,MemoryCmd.dwLength);
|
||||||
|
|
||||||
if (MemoryCmd.dwLength == 0) {
|
if (MemoryCmd.dwLength == 0) {
|
||||||
DBG("_HandleBulkOut done\n");
|
DBG("_HandleBulkOut done\n");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user