summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/Roadmap.txt10
-rw-r--r--firmware/bootloaderconfig.h2
-rw-r--r--firmware/main.c37
3 files changed, 24 insertions, 25 deletions
diff --git a/firmware/Roadmap.txt b/firmware/Roadmap.txt
index 564cf12..1612fcd 100644
--- a/firmware/Roadmap.txt
+++ b/firmware/Roadmap.txt
@@ -3,10 +3,11 @@ Development Roadmap
1.x Improvements (No protocol change, micronucleus host tool stays the same)
Changes to client firmware:
- - Only time out bootloader if program is loaded
- - CRC check
- - Move clean boot page to initialization
- - Integrate blarrgg global optimizations
+ - Only time out bootloader if program is loaded - done
+ - Move clean boot page to initialization - done
+ - Integrate blargg optimizations
+ * turned "event"-variable into register to save memory
+ * moved flash buffer clean to hardware initialization function
2.x Improvements (New Protocol, new command line tool)
@@ -22,6 +23,7 @@ Changes to protocol/command line tool
- Move writing of tiny vector table to host tool. Reset vector patching stays on client
-> no risk of bricking device, since bootloader will remain active
- erase command
+ - CRC check
\ No newline at end of file
diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h
index e1b2a4c..53c650f 100644
--- a/firmware/bootloaderconfig.h
+++ b/firmware/bootloaderconfig.h
@@ -282,7 +282,7 @@ these macros are defined, the boot loader uses them.
*/
#define AUTO_EXIT_NO_USB_MS 0
-#define AUTO_EXIT_MS 6000
+#define AUTO_EXIT_MS 5000
/*
* Defines the setting of the RC-oscillator calibration after quitting the bootloader. (OSCCAL)
diff --git a/firmware/main.c b/firmware/main.c
index 401aaa8..3fca133 100644
--- a/firmware/main.c
+++ b/firmware/main.c
@@ -25,7 +25,6 @@
#include <avr/boot.h>
#include <util/delay.h>
-
#include "bootloaderconfig.h"
#include "usbdrv/usbdrv.c"
@@ -49,7 +48,7 @@
// events system schedules functions to run in the main loop
// static uint8_t events = 0; // bitmap of events to run
-register uint8_t events asm( "r1" ); // register saves many bytes
+register uint8_t events asm( "r3" ); // register saves many bytes
#define EVENT_ERASE_APPLICATION 1
#define EVENT_WRITE_PAGE 2
@@ -156,7 +155,6 @@ static void writeWordToPageBuffer(uint16_t data) {
previous_sreg=SREG;
cli(); // ensure interrupts are disabled
-
boot_page_fill(currentAddress, data);
// increment progmem address by one word
@@ -260,7 +258,7 @@ static void initHardware (void)
// reset system to a normal state and launch user program
static void leaveBootloader(void) __attribute__((__noreturn__));
static inline void leaveBootloader(void) {
- _delay_ms(10); // removing delay causes USB errors
+ _delay_ms(10); // removing delay causes USB errors
bootLoaderExit();
cli();
@@ -308,28 +306,27 @@ int main(void) {
LED_INIT();
# endif
do {
+ clearEvents();
usbPoll();
_delay_us(100);
-
- // these next two freeze the chip for ~ 4.5ms, breaking usb protocol
- // and usually both of these will activate in the same loop, so host
- // needs to wait > 9ms before next usb request
- if (isEvent(EVENT_ERASE_APPLICATION)) eraseApplication();
- if (isEvent(EVENT_WRITE_PAGE)) {
- _delay_us(2000); // Wait for USB traffic to finish before halting CPU with write-
- writeFlashPage();
- }
-
-# if BOOTLOADER_CAN_EXIT
- if (isEvent(EVENT_EXECUTE)) break; // when host requests device run uploaded program
-# endif
- clearEvents();
+
+ // these next two freeze the chip for ~ 4.5ms, breaking usb protocol
+ // and usually both of these will activate in the same loop, so host
+ // needs to wait > 9ms before next usb request
+ if (isEvent(EVENT_ERASE_APPLICATION)) eraseApplication();
+ if (isEvent(EVENT_WRITE_PAGE)) {
+ _delay_us(2000); // Wait for USB traffic to finish before halting CPU with write-
+ writeFlashPage();
+ }
# if LED_PRESENT
LED_MACRO( ((uint8_t*)&idlePolls)[1] )
# endif
-
- } while(bootLoaderCondition()); /* main event loop runs so long as bootLoaderCondition remains truthy */
+
+ // Only try to execute program if reset vector is set - bootloader will not time out with erased memory
+ if (!bootLoaderCondition()&&(pgm_read_byte(BOOTLOADER_ADDRESS - TINYVECTOR_RESET_OFFSET)!=0xff)) fireEvent(EVENT_EXECUTE);
+
+ } while(!isEvent(EVENT_EXECUTE)); /* main event loop runs as long as program is not executed */
}
// set clock prescaler to desired clock speed (changing from clkdiv8, or no division, depending on fuses)