From a52fb298607dfbd78b83e3d0787fdf5d508332d9 Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Wed, 26 Oct 2011 12:53:57 -0400 Subject: working (?!?!?!) bootloader. doesn't yet restart chip after upload completes. --- bootloaders/nuevo_diskloader/src/DiskLoader.cpp | 32 ++++++++++++++----------- bootloaders/nuevo_diskloader/src/USBCore.cpp | 6 ++++- 2 files changed, 23 insertions(+), 15 deletions(-) (limited to 'bootloaders/nuevo_diskloader/src') diff --git a/bootloaders/nuevo_diskloader/src/DiskLoader.cpp b/bootloaders/nuevo_diskloader/src/DiskLoader.cpp index f611e17..a7ccde6 100644 --- a/bootloaders/nuevo_diskloader/src/DiskLoader.cpp +++ b/bootloaders/nuevo_diskloader/src/DiskLoader.cpp @@ -24,11 +24,12 @@ void entrypoint(void) u8 _flashbuf[128]; u8 _inSync; u8 _ok; +u16 do_reset = 0; volatile u16 _timeout; void Program(u8 ep, u16 page, u8 count) { - u8 write = page < 28*1024; // Don't write over firmware please + u8 write = page < 28*1024; // Don't write over bootloader please if (write) boot_page_erase(page); @@ -94,18 +95,18 @@ const u8 _consts[] = 0x00, // }; -int getch(void) -{ - u16 timeout; - u8 c; - for (timeout = 0; timeout; timeout--) - { - c = USB_Recv(CDC_RX); - if (c != -1) - return c; - } - return -1; -} +//int getch(void) +//{ +// u16 timeout; +// u8 c; +// for (timeout = 0; timeout; timeout--) +// { +// c = USB_Recv(CDC_RX); +// if (c != -1) +// return c; +// } +// return -1; +//} int main(void) __attribute__ ((naked)); @@ -245,8 +246,11 @@ int main() // Send ok USB_Send(CDC_TX|TRANSFER_RELEASE, &_ok, 1); - if ('Q' == cmd) + if ('Q' == cmd) + { + do_reset = 500; break; + } } } } diff --git a/bootloaders/nuevo_diskloader/src/USBCore.cpp b/bootloaders/nuevo_diskloader/src/USBCore.cpp index fffe6f7..453c2ff 100644 --- a/bootloaders/nuevo_diskloader/src/USBCore.cpp +++ b/bootloaders/nuevo_diskloader/src/USBCore.cpp @@ -219,7 +219,8 @@ u8 USB_Available(u8 ep) void USB_Recv_block(u8 ep, u8* dst, int len) { - SetEP(ep); +// SetEP(ep & 7); + LockEP lock(ep); while (len--) { while (!ReadWriteAllowed()) @@ -314,6 +315,9 @@ int USB_Send(u8 ep, const void* d, int len) ReleaseTX(); } } + if (ep & TRANSFER_RELEASE) + ReleaseTX(); + TX_LED_ON(); TxLEDPulse = TX_RX_LED_PULSE_MS; return r; -- cgit v1.2.3-18-g5258