summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorcpldcpu <cpldcpu@gmail.com>2013-11-25 00:13:28 +0100
committercpldcpu <cpldcpu@gmail.com>2013-11-25 00:13:28 +0100
commitb54e55361cec1cc59d5175460800ad531ca017df (patch)
tree69ad21eef93edc83f64e072b0e8ea16ffebfefb1 /firmware
parentec82f5513ae13c94fc2421c310ffb99c96ad9561 (diff)
downloadmicronucleus-b54e55361cec1cc59d5175460800ad531ca017df.tar.gz
micronucleus-b54e55361cec1cc59d5175460800ad531ca017df.tar.bz2
micronucleus-b54e55361cec1cc59d5175460800ad531ca017df.zip
clean up, added LED, NO USB exit delay
Work towards v1.10 - Clean up bootloaderconfig.h - Included option for LED - Included second timout if no USB connected
Diffstat (limited to 'firmware')
-rw-r--r--firmware/Makefile2
-rw-r--r--firmware/bootloaderconfig.h105
-rw-r--r--firmware/main.c66
-rw-r--r--firmware/releases/Micronucleus-testing-11222013-LEDonPB1.hex127
-rw-r--r--firmware/releases/micronucleus-1.09rc1.hex (renamed from firmware/releases/micronucleus-testing-11132013.hex)112
-rw-r--r--firmware/releases/micronucleus-1.09rc1_LEDonPB1.hex128
-rw-r--r--firmware/usbconfig.h10
7 files changed, 294 insertions, 256 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
index b2177a6..8213461 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -189,7 +189,7 @@ read_fuses:
$(UISP) --rd_fuses
clean:
- rm -f main.hex main.bin main.c.lst main.map *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s libs-device/osccalASM.o
+ rm -f main.hex main.bin main.c.lst main.map *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s libs-device/osccalASM.o *.lss
# file targets:
main.bin: $(OBJECTS)
diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h
index 641a9e0..7471d63 100644
--- a/firmware/bootloaderconfig.h
+++ b/firmware/bootloaderconfig.h
@@ -133,6 +133,7 @@ these macros are defined, the boot loader uses them.
* programmer closes the connection to the device. Costs ~36 bytes.
* Required for TINY85MODE
*/
+
//#define HAVE_CHIP_ERASE 0
/* If this macro is defined to 1, the boot loader implements the Chip Erase
* ISP command. Otherwise pages are erased on demand before they are written.
@@ -169,13 +170,8 @@ these macros are defined, the boot loader uses them.
* bootLoaderCondition() for efficiency.
*/
-
#define JUMPER_BIT 0 /* jumper is connected to this bit in port B, active low */
-#ifndef MCUCSR /* compatibility between ATMega8 and ATMega88 */
-# define MCUCSR MCUSR
-#endif
-
/* tiny85 Architecture Specifics */
#ifndef __AVR_ATtiny85__
# error "uBoot is only designed for attiny85"
@@ -205,26 +201,13 @@ these macros are defined, the boot loader uses them.
#define USB_INTR_PENDING_BIT PCIF
#define USB_INTR_VECTOR PCINT0_vect
-
-/* max 6200ms to not overflow idlePolls variable */
-#define AUTO_EXIT_MS 6000
-//#define AUTO_EXIT_CONDITION() (idlePolls > (AUTO_EXIT_MS * 10UL))
-
+
// uncomment for chips with clkdiv8 enabled in fuses
//#define LOW_POWER_MODE 1
-// restore cpu speed calibration back to 8/16mhz instead of 8.25/16.5mhz
-// #define RESTORE_OSCCAL
+
// set clock prescaler to a value before running user program
//#define SET_CLOCK_PRESCALER _BV(CLKPS0) /* divide by 2 for 8mhz */
-// Specific configuration for the Nanite
-// Nanite has both LED and tactile button connected to control pin.
-// LED will turn on when output=low and act as external pull up otherwise
-// button shorts to GND
-
-//#define NANITE
-#define NANITE_CTRLPIN PB5
-
#ifdef BUILD_JUMPER_MODE
#define START_JUMPER_PIN 5
@@ -243,12 +226,6 @@ these macros are defined, the boot loader uses them.
PORTB = 0;
}
#endif /* __ASSEMBLER__ */
-
-#elif defined NANITE
- #define bootLoaderInit()
- #define bootLoaderExit()
- #define bootLoaderCondition() (++idlePolls < (AUTO_EXIT_MS * 10UL))
- #define bootLoaderStartCondition() (!(PINB & _BV(NANITE_CTRLPIN)))
#else
#define bootLoaderInit()
@@ -289,20 +266,74 @@ these macros are defined, the boot loader uses them.
#ifndef __ASSEMBLER__ /* assembler cannot parse function definitions */
-//static inline void bootLoaderInit(void) {
-// // DeuxVis pin-5 pullup
-// DDRB |= _BV(DEUXVIS_JUMPER_PIN); // is an input
-// PORTB |= _BV(DEUXVIS_JUMPER_PIN); // has pullup enabled
-// _delay_ms(10);
-//}
-//static inline void bootLoaderExit(void) {
- // DeuxVis pin-5 pullup
-// PORTB = 0;
-// DDRB = 0;
-//}
+/*
+ * Define bootloader timeout value.
+ *
+ * These will only be used if is bootLoaderCondition() evaluates idlePolls below!
+ *
+ * AUTO_EXIT_NO_USB_MS The bootloader will exit after this delay if no USB is connected.
+ * Set to 0 to disable
+ * Adds ~6 bytes.
+ * (This will wait for an USB SE0 reset from the host)
+ * AUTO_EXIT_MS The bootloader will exit after this delay if no USB communication
+ * from the host tool was received.
+ *
+ * All values are approx. in milliseconds
+ */
+
+#define AUTO_EXIT_NO_USB_MS 500
+#define AUTO_EXIT_MS 6000
+
+ /*
+ * Defines the setting of the RC-oscillator calibration after quitting the bootloader. (OSCCAL)
+ *
+ * OSCCAL_RESTORE Set this to '1' to revert to factory calibration, which is 16.0 MHZ +/-10%
+ * Adds ~14 bytes.
+ *
+ * OSCCAL_16.5MHz Set this to '1' to use the same calibration as during program upload.
+ * This value is 16.5Mhz +/-1% as calibrated from the USB timing. Please note
+ * that only true if the ambient temperature does not change.
+ * This is the default behaviour of the Digispark.
+ * Adds ~38 bytes.
+ *
+ * If both options are selected, OSCCAL_RESTORE takes precedence.
+ *
+ * If no option is selected, OSCCAL will be left untouched and stay at either 16.0Mhz or 16.5Mhz depending
+ * on whether the bootloader was activated. This will take the least memory. You can use this if your program
+ * comes with its own OSCCAL calibration or an external clock source is used.
+ */
+
+ #define OSCCAL_RESTORE 0
+ #define OSCCAL_16_5MHz 1
+
+/*
+ * Defines handling of an indicator LED while the bootloader is active.
+ *
+ * LED_PRESENT Set this this to '1' to active all LED related code. If this is 0, all other
+ * defines are ignored.
+ * Adds 18 bytes depending on implementation.
+ *
+ * LED_DDR,LED_PORT,LED_PIN Where is you LED connected?
+ *
+ * LED_INIT Called once after bootloader entry
+ * LED_EXIT Called once during bootloader exit
+ * LED_MACRO Called in the main loop with the idle counter as parameter.
+ * Use to define pattern.
+ */
+
+#define LED_PRESENT 0
+
+#define LED_DDR DDRB
+#define LED_PORT PORTB
+#define LED_PIN PB1
+
+#define LED_INIT LED_PORT &=~_BV(LED_PIN);
+#define LED_EXIT LED_DDR &=~_BV(LED_PIN);
+#define LED_MACRO(x) if ( x & 0xd ) {LED_DDR&=~_BV(LED_PIN);} else {LED_DDR|=_BV(LED_PIN);}
#endif /* __ASSEMBLER__ */
+
/* ------------------------------------------------------------------------- */
#endif /* __bootloader_h_included__ */
diff --git a/firmware/main.c b/firmware/main.c
index b3ecf0d..2d6036f 100644
--- a/firmware/main.c
+++ b/firmware/main.c
@@ -18,7 +18,6 @@
// Use the old delay routines without NOP padding. This saves memory.
#define __DELAY_BACKWARD_COMPATIBLE__
-
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
@@ -55,11 +54,6 @@ static void leaveBootloader() __attribute__((__noreturn__));
# define bootLoaderCondition() BOOTLOADER_CONDITION
#endif
-/* device compatibility: */
-#ifndef GICR /* ATMega*8 don't have GICR, use MCUCR instead */
-# define GICR MCUCR
-#endif
-
/* ------------------------------------------------------------------------ */
#define addr_t uint
@@ -104,10 +98,11 @@ uint16_t idlePolls = 0; // how long have we been idle?
static uint16_t vectorTemp[2]; // remember data to create tinyVector table before BOOTLOADER_ADDRESS
static addr_t currentAddress; // current progmem address, used for erasing and writing
-#ifdef RESTORE_OSCCAL
+#if OSCCAL_RESTORE
static uint8_t osccal_default; // due to compiler insanity, having this as global actually saves memory
#endif
+
/* ------------------------------------------------------------------------ */
static inline void eraseApplication(void);
static void writeFlashPage(void);
@@ -184,13 +179,12 @@ static void writeWordToPageBuffer(uint16_t data) {
data = vectorTemp[0] + ((FLASHEND + 1) - BOOTLOADER_ADDRESS)/2 + 2 + RESET_VECTOR_OFFSET;
} else if (currentAddress == BOOTLOADER_ADDRESS - TINYVECTOR_USBPLUS_OFFSET) {
data = vectorTemp[1] + ((FLASHEND + 1) - BOOTLOADER_ADDRESS)/2 + 1 + USBPLUS_VECTOR_OFFSET;
-#ifndef RESTORE_OSCCAL
+#if (!OSCCAL_RESTORE) && OSCCAL_16_5MHz
} else if (currentAddress == BOOTLOADER_ADDRESS - TINYVECTOR_OSCCAL_OFFSET) {
data = OSCCAL;
#endif
}
-
-
+
// clear page buffer as a precaution before filling the buffer on the first page
// in case the bootloader somehow ran after user program and there was something
// in the page buffer already
@@ -243,7 +237,7 @@ static void fillFlashWithVectors(void) {
static uchar usbFunctionSetup(uchar data[8]) {
usbRequest_t *rq = (void *)data;
idlePolls = 0; // reset idle polls when we get usb traffic
-
+
static uchar replyBuffer[4] = {
(((uint)PROGMEM_SIZE) >> 8) & 0xff,
((uint)PROGMEM_SIZE) & 0xff,
@@ -334,7 +328,7 @@ static inline void initForUsbConnectivity(void) {
usbInit();
/* enforce USB re-enumerate: */
usbDeviceDisconnect(); /* do this while interrupts are disabled */
- _delay_ms(500);
+ _delay_ms(300); // reduced to 300ms from 500ms to allow faster resetting when no usb connected
usbDeviceConnect();
sei();
}
@@ -374,7 +368,6 @@ static inline void tiny85FlashWrites(void) {
static inline void leaveBootloader(void) {
_delay_ms(10); // removing delay causes USB errors
- //DBG1(0x01, 0, 0);
bootLoaderExit();
cli();
usbDeviceDisconnect(); /* Disconnect micronucleus */
@@ -386,7 +379,7 @@ static inline void leaveBootloader(void) {
*(uint8_t*)(RAMEND) = 0x00; // A single write is sufficient to invalidate magic word
// *(uint8_t*)(RAMEND-1) = 0x00;
-#ifndef RESTORE_OSCCAL
+#if (!OSCCAL_RESTORE) && OSCCAL_16_5MHz
// adjust clock to previous calibration value, so user program always starts with same calibration
// as when it was uploaded originally
// TODO: Test this and find out, do we need the +1 offset?
@@ -402,19 +395,22 @@ static inline void leaveBootloader(void) {
int main(void) {
/* initialize */
- #ifdef RESTORE_OSCCAL
+ #if OSCCAL_RESTORE
osccal_default = OSCCAL;
#endif
#if (!SET_CLOCK_PRESCALER) && LOW_POWER_MODE
uint8_t prescaler_default = CLKPR;
#endif
-
-
- MCUSR=0; /* clean wdt reset bit if reset occured due to wdt */
+
+ // MCUSR=0; /* clean wdt reset bit if reset occured due to wdt */
wdt_disable(); /* main app may have enabled watchdog */
tiny85FlashInit();
bootLoaderInit();
-
+
+# if AUTO_EXIT_NO_USB_MS
+ ((uint8_t*)&idlePolls)[1]=((AUTO_EXIT_MS-AUTO_EXIT_NO_USB_MS) * 10UL)>>8; // write only high byte to save 6 bytes
+# endif
+
if (bootLoaderStartCondition()) {
#if LOW_POWER_MODE
// turn off clock prescalling - chip must run at full speed for usb
@@ -423,12 +419,12 @@ int main(void) {
CLKPR = 0;
#endif
- #ifdef NANITE
- PORTB &=~_BV(NANITE_CTRLPIN);
- #endif
+# if LED_PRESENT
+ LED_PORT &=~_BV(LED_PIN);
+# endif
+
initForUsbConnectivity();
-
do {
usbPoll();
@@ -440,19 +436,18 @@ int main(void) {
if (isEvent(EVENT_ERASE_APPLICATION)) eraseApplication();
if (isEvent(EVENT_WRITE_PAGE)) tiny85FlashWrites();
- #ifdef NANITE
- DDRB |= _BV(NANITE_CTRLPIN);
- if (((unsigned char*)&idlePolls)[1]&0xd) DDRB &=~_BV(NANITE_CTRLPIN);
- #endif
-
# if BOOTLOADER_CAN_EXIT
if (isEvent(EVENT_EXECUTE)) { // when host requests device run uploaded program
break;
}
# endif
-
+
clearEvents();
-
+
+# if LED_PRESENT
+ LED_MACRO( ((uint8_t*)&idlePolls)[1] )
+# endif
+
} while(bootLoaderCondition()); /* main event loop runs so long as bootLoaderCondition remains truthy */
}
@@ -466,13 +461,16 @@ int main(void) {
CLKPR = prescaler_default;
#endif
#endif
-
- #ifdef RESTORE_OSCCAL
-
+# if LED_PRESENT
+ LED_DDR &=~_BV(LED_PIN);
+# endif
+
+# if OSCCAL_RESTORE
OSCCAL=osccal_default;
asm volatile("nop"); // NOP to avoid CPU hickup during osccillator stabilization
- #endif
+# endif
+
leaveBootloader();
}
diff --git a/firmware/releases/Micronucleus-testing-11222013-LEDonPB1.hex b/firmware/releases/Micronucleus-testing-11222013-LEDonPB1.hex
deleted file mode 100644
index 2e6825e..0000000
--- a/firmware/releases/Micronucleus-testing-11222013-LEDonPB1.hex
+++ /dev/null
@@ -1,127 +0,0 @@
-:1018400022C040C059C03EC03DC03CC03BC03AC0B1
-:1018500039C038C037C036C035C034C033C00902C3
-:1018600012000101008032090400000000000000A5
-:1018700012011001FF000008D016530706010000F6
-:1018800000010403090411241FBECFE5D2E0DEBF2E
-:10189000CDBF00EB0F9307E00F9310E0A0E6B0E0A0
-:1018A000EAEFFFE102C005900D92A636B107D9F725
-:1018B00020E0A6E6B0E001C01D92AB39B207E1F727
-:1018C000F0D199C3BDCFA82FB92F80E090E041E0BF
-:1018D00050EA609530E009C02D9182279795879551
-:1018E00010F084279527305EC8F36F5FA8F3089542
-:1018F000EADF8D939D930895CF93CFB7CF93C09197
-:101900005F02C03B21F4C0915E02C73021F0CF914D
-:10191000CFBFCF9194CFCC27C395B39BE9F7B39BAF
-:101920000BC0B39B09C0B39B07C0B39B05C0B39B5F
-:1019300003C0B39B01C0D3C00F92DF93C0917E0060
-:10194000DD27CB57DF4F012EB39B03C0DF910F90F4
-:10195000E6CF2F930F931F934F932FEF4F6F06B345
-:1019600003FB20F95F933F9350E03BE065C016B363
-:101970000126502953FDC89556B3012703FB25F9CD
-:101980002F7306B3B1F05027102713FB26F906B2C8
-:101990002230F0F000C016B3012703FB27F901261F
-:1019A000502906B22430E8F54F77206816B30000BE
-:1019B000F6CF50274F7D206206B2102F000000C0E6
-:1019C00006B300265029102713FB26F906B2E2CFF2
-:1019D0004F7B06B3206400C0DACF0126502918716E
-:1019E00006B269F14E7F2160012F16B328C0002690
-:1019F00050294D7F06B22260102F29C001265029A0
-:101A00004B7F06B22460012F2DC016B3012650294A
-:101A1000477F2860000006B22EC04F7E06B32061CB
-:101A200030C0422706B3499300265029102706B23A
-:101A30004FEF13FB20F9297F16B379F2187159F192
-:101A40000126502906B2012703FB21F9237F06B3A3
-:101A500071F2002650293150D0F006B2102713FB46
-:101A600022F9277E16B351F201265029012703FBE4
-:101A700006B223F92F7C49F2000006B3102713FBAE
-:101A800024F90026502906B22F7939F270CF10E2DE
-:101A90001ABF002717C03B503195C31BD04010E23E
-:101AA0001ABF0881033CF9F00B34E9F020917C0067
-:101AB0001981110F1213EDCF093651F10D3211F0CA
-:101AC000013E39F7009383003F915F914F911F9141
-:101AD0000F912F91DF910F90CAB7C5FD1DCFCF9108
-:101AE000CFBFCF91189520918300222369F31091E5
-:101AF0008100112321F5343022F1309381002093AD
-:101B00007D0010917E003BE0311B30937E0019C0B8
-:101B10000091810001309CF40AE53091600034FDB1
-:101B200011C000936000C1E7D0E010C0052710E0AD
-:101B300000C021C0052710E0C89508BB14C03AE5D5
-:101B400001C032ED032EC0E0D0E032E017B31861DF
-:101B5000C39A08B317BB58E120E84FEF20FF0527D1
-:101B600008BB279517951C3F28F700004552B0F792
-:101B700020FF0527279508BB17951C3FB8F629912C
-:101B80003A9561F7077E10918200110F08BBC25091
-:101B9000D04011F010937C0010E21ABF086017B318
-:101BA000177E402F477E54E05A95F1F708BB17BBCC
-:101BB00048BB8ACFF8942FEFB0E8A0E44AE0B1BF69
-:101BC000000081EE9CE0B399FECFB39BFECF01975E
-:101BD000B399FDCF97FF03C0BA1B819501C0BA0F1F
-:101BE000A69529F4281710F031B7282FA1E041500D
-:101BF00031F731BF0000789408958FB7F894E091E1
-:101C00006900F0916A00329795E090935700E8954B
-:101C10008FBF08952091690030916A002115310528
-:101C200089F12430310591F12C3348E1340739F43E
-:101C300080916B0090916C008E519C4F10C02E33A0
-:101C400048E1340739F480916D0090916E008D5118
-:101C50009C4F05C02A33384111F481B790E02FB76B
-:101C6000F894E0916900F0916A0031E00C01309342
-:101C70005700E89511242FBF3296F0936A00E09345
-:101C80006900089581E180935700E8958FE19CEC0D
-:101C9000E6CF8FEF9FEFBEDF809169008F73C9F7AA
-:101CA000ACCF14BE88E10FB6F89481BD11BC0FBE55
-:101CB000E1E0F0E0E491EF3F09F4EBDF10926A001D
-:101CC00010926900C198AC9A8BB780628BBFBB9AA7
-:101CD00088E893E1ECE9F1E03197F1F70197D1F76A
-:101CE000BB98789400918100035007FDCFC080918C
-:101CF0007E00CCE0D0E0C81BD109CB57DF4F8091EC
-:101D00007D008D3209F090C0083009F0BDC083EC31
-:101D1000809371008AE58093600010926F002881A3
-:101D2000922F90768981992329F110926700109261
-:101D30006600811108C082E690E090938000809355
-:101D40007F0014E067C0813051F48C819D819093B5
-:101D50006A008093690027FD58C01FEF57C090911B
-:101D60006800823011F4916001C094609093680023
-:101D700010E050C09A8110927A00811106C0109232
-:101D80007B008AE790E012E03BC0853019F4909325
-:101D900082002CC0863009F58B81813019F480E7F0
-:101DA00098E104C0823041F48EE598E19093800080
-:101DB00080937F0012E10DC0833051F4911108C06F
-:101DC00082E898E19093800080937F0014E001C046
-:101DD00010E080E480936F001DC0883059F0893096
-:101DE00019F49093840002C08A3039F08AE790E0B9
-:101DF00010E006C084E890E002C08AE790E011E0BD
-:101E00009093800080937F0005C01E8180E88093BE
-:101E10006F0007C08F81811104C08E81811708F483
-:101E2000182F1093610030C080916F0087FF2CC085
-:101E30008091690090916A00009739F488819981B6
-:101E400090936C0080936B0012C08430910539F43C
-:101E50008881998190936E0080936D0008C08034D2
-:101E6000984128F0809169008F7339F00DC08991F5
-:101E70009991D0DE0250E1F6F5CF80916800826042
-:101E80008093680010926100109281008091600040
-:101E900084FF43C0809161008F3F09F43EC0082F4A
-:101EA000893008F008E0801B809361008091710008
-:101EB00098E8892780937100002319F1E0917F0051
-:101EC000F091800080916F0086FF0BC0A2E7B0E028
-:101ED00084918D93319682E790E0800F8A13F8CF3A
-:101EE0000CC0CF01A2E7B0E0FC012191CF012D93FE
-:101EF00022E730E0200F2A13F7CFF0938000E09321
-:101F00007F00602F82E790E0F3DC0C5F0C3019F06B
-:101F10008FEF809361000093600084E196B3987125
-:101F200031F48150D9F71092820010927C0001E0C8
-:101F3000811100E080917000801729F0011101C02B
-:101F400039DE009370008CE991E00197F1F7809100
-:101F5000680080FF11C0F894E0E4F8E1E054F10972
-:101F600083E080935700E8953097C1F710926A009C
-:101F7000109269008EDE78948091680081FF0BC01A
-:101F80008AE390E20197F1F7809169008F7311F075
-:101F900080DE01C032DEB99A809167008D7009F051
-:101FA000B9988091680082FF12C082E291EA01979D
-:101FB000F1F7F894BB9A1BBE15BA10925F02EAE3E0
-:101FC000F8E1E4918E2F81508E3F88F012C010927C
-:101FD0006800809166009091670001969093670079
-:101FE0008093660080369A4E08F47CCEDECFE1BF47
-:0A1FF000000024CC0FCFF894FFCFBF
-:061FFA005AFF183A4008EE
-:0400000300001840A1
-:00000001FF
diff --git a/firmware/releases/micronucleus-testing-11132013.hex b/firmware/releases/micronucleus-1.09rc1.hex
index ac00f02..88cfcd4 100644
--- a/firmware/releases/micronucleus-testing-11132013.hex
+++ b/firmware/releases/micronucleus-1.09rc1.hex
@@ -4,9 +4,9 @@
:1018700012011001FF000008D016530706010000F6
:1018800000010403090411241FBECFE5D2E0DEBF2E
:10189000CDBF00EB0F9307E00F9310E0A0E6B0E0A0
-:1018A000E8EEFFE102C005900D92A636B107D9F728
+:1018A000E0EFFFE102C005900D92A636B107D9F72F
:1018B00020E0A6E6B0E001C01D92AB39B207E1F727
-:1018C000F0D190C3BDCFA82FB92F80E090E041E0C8
+:1018C000F0D194C3BDCFA82FB92F80E090E041E0C4
:1018D00050EA609530E009C02D9182279795879551
:1018E00010F084279527305EC8F36F5FA8F3089542
:1018F000EADF8D939D930895CF93CFB7CF93C09197
@@ -68,59 +68,59 @@
:101C70005700E89511242FBF3296F0936A00E09345
:101C80006900089581E180935700E8958FE19CEC0D
:101C9000E6CF8FEF9FEFBEDF809169008F73C9F7AA
-:101CA000ACCF14BE88E10FB6F89481BD11BC0FBE55
-:101CB000E1E0F0E0E491EF3F09F4EBDF10926A001D
-:101CC00010926900AC9A8BB780628BBFBB9A88E890
-:101CD00093E1ECE9F1E03197F1F70197D1F7BB9887
-:101CE000789400918100035007FDCFC080917E0061
-:101CF000CCE0D0E0C81BD109CB57DF4F80917D00ED
-:101D00008D3209F090C0083009F0BDC083EC80939B
-:101D100071008AE58093600010926F002881922FF5
-:101D200090768981992329F11092670010926600BC
-:101D3000811108C082E690E09093800080937F003C
-:101D400014E067C0813051F48C819D8190936A00CA
-:101D50008093690027FD58C01FEF57C0909168001D
-:101D6000823011F4916001C094609093680010E09B
-:101D700050C09A8110927A00811106C010927B00A7
-:101D80008AE790E012E03BC0853019F4909382001E
-:101D90002CC0863009F58B81813019F480E798E1F9
-:101DA00004C0823041F48EE598E1909380008093E6
-:101DB0007F0012E10DC0833051F4911108C082E818
-:101DC00098E19093800080937F0014E001C010E0C0
-:101DD00080E480936F001DC0883059F0893019F479
-:101DE0009093840002C08A3039F08AE790E010E0D6
-:101DF00006C084E890E002C08AE790E011E090938A
-:101E0000800080937F0005C01E8180E880936F0072
-:101E100007C08F81811104C08E81811708F4182FAB
-:101E20001093610030C080916F0087FF2CC08091BB
-:101E3000690090916A00009739F4888199819093A4
-:101E40006C0080936B0012C08430910539F4888156
-:101E5000998190936E0080936D0008C08034984102
-:101E600028F0809169008F7339F00DC089919991A4
-:101E7000D1DE0250E1F6F5CF809168008260809358
-:101E8000680010926100109281008091600084FFD0
-:101E900043C0809161008F3F09F43EC0082F893014
-:101EA00008F008E0801B809361008091710098E841
-:101EB000892780937100002319F1E0917F00F09150
-:101EC000800080916F0086FF0BC0A2E7B0E0849194
-:101ED0008D93319682E790E0800F8A13F8CF0CC083
-:101EE000CF01A2E7B0E0FC012191CF012D9322E7C1
-:101EF00030E0200F2A13F7CFF0938000E0937F00AB
-:101F0000602F82E790E0F4DC0C5F0C3019F08FEF6B
-:101F1000809361000093600084E196B3987131F47E
-:101F20008150D9F71092820010927C0001E081115B
-:101F300000E080917000801729F0011101C03ADEA5
-:101F4000009370008CE991E00197F1F780916800AF
-:101F500080FF11C0F894E0E4F8E1E054F10983E077
-:101F600080935700E8953097C1F710926A0010925D
-:101F700069008FDE78940091680001FF0BC08AE34E
-:101F800090E20197F1F7809169008F7311F081DE83
-:101F900001C033DE02FF12C082E291EA0197F1F73D
-:101FA000F894BB9A1BBE15BA10925F02EAE3F8E1FF
-:101FB000E4918E2F81508E3F88F012C010926800FD
-:101FC00080916600909167000196909367008093DE
-:101FD000660080369A4E08F484CEDECFE1BF000062
-:081FE0002DCC17CFF894FFCFC0
-:061FE8005AFF183A400800
+:101CA000ACCF88E10FB6F89481BD11BC0FBEE1E066
+:101CB000F0E0E491EF3F09F4ECDF10926A0010923B
+:101CC000690086ED80936700AC9A8BB780628BBF0A
+:101CD000BB9A88EB9BE0ECE9F1E03197F1F70197D3
+:101CE000D1F7BB98789400918100035007FDCFC0D5
+:101CF00080917E00CCE0D0E0C81BD109CB57DF4FEC
+:101D000080917D008D3209F090C0083009F0BDC08F
+:101D100083EC809371008AE58093600010926F00DD
+:101D20002881922F90768981992329F1109267005A
+:101D300010926600811108C082E690E090938000C6
+:101D400080937F0014E067C0813051F48C819D81C5
+:101D500090936A008093690027FD58C01FEF57C019
+:101D600090916800823011F4916001C0946090936A
+:101D7000680010E050C09A8110927A00811106C06C
+:101D800010927B008AE790E012E03BC0853019F4A6
+:101D9000909382002CC0863009F58B81813019F434
+:101DA00080E798E104C0823041F48EE598E1909399
+:101DB000800080937F0012E10DC0833051F49111B7
+:101DC00008C082E898E19093800080937F0014E03F
+:101DD00001C010E080E480936F001DC0883059F08E
+:101DE000893019F49093840002C08A3039F08AE770
+:101DF00090E010E006C084E890E002C08AE790E03E
+:101E000011E09093800080937F0005C01E8180E8E0
+:101E100080936F0007C08F81811104C08E8181176C
+:101E200008F4182F1093610030C080916F0087FF75
+:101E30002CC08091690090916A00009739F48881E4
+:101E4000998190936C0080936B0012C0843091054F
+:101E500039F48881998190936E0080936D0008C059
+:101E60008034984128F0809169008F7339F00DC05B
+:101E700089919991CFDE0250E1F6F5CF809168000B
+:101E800082608093680010926100109281008091BE
+:101E9000600084FF43C0809161008F3F09F43EC021
+:101EA000082F893008F008E0801B80936100809142
+:101EB000710098E8892780937100002319F1E0915F
+:101EC0007F00F091800080916F0086FF0BC0A2E739
+:101ED000B0E084918D93319682E790E0800F8A1371
+:101EE000F8CF0CC0CF01A2E7B0E0FC012191CF01F7
+:101EF0002D9322E730E0200F2A13F7CFF0938000D4
+:101F0000E0937F00602F82E790E0F2DC0C5F0C3002
+:101F100019F08FEF809361000093600084E196B325
+:101F2000987131F48150D9F71092820010927C00A0
+:101F300001E0811100E080917000801739F00111FB
+:101F400003C01092670036DE009370008CE991E0C8
+:101F50000197F1F78091680080FF11C0F894E0E4E8
+:101F6000F8E1E054F10983E080935700E895309759
+:101F7000C1F710926A00109269008BDE789400918C
+:101F8000680001FF0BC08AE390E20197F1F78091AE
+:101F900069008F7311F07DDE01C02FDE02FF12C0D9
+:101FA00082E291EA0197F1F7F894BB9A1BBE15BA49
+:101FB00010925F02EAE3F8E1E4918E2F81508E3FA8
+:101FC00088F012C0109268008091660090916700BE
+:101FD0000196909367008093660080369A4E08F4CD
+:101FE00082CEDECFE1BF000029CC15CFF894FFCF21
+:061FF0005AFF183A4008F8
:0400000300001840A1
:00000001FF
diff --git a/firmware/releases/micronucleus-1.09rc1_LEDonPB1.hex b/firmware/releases/micronucleus-1.09rc1_LEDonPB1.hex
new file mode 100644
index 0000000..4eb1b61
--- /dev/null
+++ b/firmware/releases/micronucleus-1.09rc1_LEDonPB1.hex
@@ -0,0 +1,128 @@
+:1018000022C040C059C03EC03DC03CC03BC03AC0F1
+:1018100039C038C037C036C035C034C033C0090203
+:1018200012000101008032090400000000000000E5
+:1018300012011001FF000008D01653070601000036
+:1018400000010403090411241FBECFE5D2E0DEBF6E
+:10185000CDBF00EB0F9307E00F9310E0A0E6B0E0E0
+:10186000E2ECFFE102C005900D92A636B107D9F770
+:1018700020E0A6E6B0E001C01D92AB39B207E1F767
+:10188000F0D19DC3BDCFA82FB92F80E090E041E0FB
+:1018900050EA609530E009C02D9182279795879591
+:1018A00010F084279527305EC8F36F5FA8F3089582
+:1018B000EADF8D939D930895CF93CFB7CF93C091D7
+:1018C0005F02C03B21F4C0915E02C73021F0CF918E
+:1018D000CFBFCF9194CFCC27C395B39BE9F7B39BF0
+:1018E0000BC0B39B09C0B39B07C0B39B05C0B39BA0
+:1018F00003C0B39B01C0D3C00F92DF93C0917E00A1
+:10190000DD27CB57DF4F012EB39B03C0DF910F9034
+:10191000E6CF2F930F931F934F932FEF4F6F06B385
+:1019200003FB20F95F933F9350E03BE065C016B3A3
+:101930000126502953FDC89556B3012703FB25F90D
+:101940002F7306B3B1F05027102713FB26F906B208
+:101950002230F0F000C016B3012703FB27F901265F
+:10196000502906B22430E8F54F77206816B30000FE
+:10197000F6CF50274F7D206206B2102F000000C026
+:1019800006B300265029102713FB26F906B2E2CF32
+:101990004F7B06B3206400C0DACF012650291871AE
+:1019A00006B269F14E7F2160012F16B328C00026D0
+:1019B00050294D7F06B22260102F29C001265029E0
+:1019C0004B7F06B22460012F2DC016B3012650298B
+:1019D000477F2860000006B22EC04F7E06B320610C
+:1019E00030C0422706B3499300265029102706B27B
+:1019F0004FEF13FB20F9297F16B379F2187159F1D3
+:101A00000126502906B2012703FB21F9237F06B3E3
+:101A100071F2002650293150D0F006B2102713FB86
+:101A200022F9277E16B351F201265029012703FB24
+:101A300006B223F92F7C49F2000006B3102713FBEE
+:101A400024F90026502906B22F7939F270CF10E21E
+:101A50001ABF002717C03B503195C31BD04010E27E
+:101A60001ABF0881033CF9F00B34E9F020917C00A7
+:101A70001981110F1213EDCF093651F10D3211F00A
+:101A8000013E39F7009383003F915F914F911F9181
+:101A90000F912F91DF910F90CAB7C5FD1DCFCF9148
+:101AA000CFBFCF91189520918300222369F3109125
+:101AB0008100112321F5343022F1309381002093ED
+:101AC0007D0010917E003BE0311B30937E0019C0F9
+:101AD0000091810001309CF40AE53091600034FDF2
+:101AE00011C000936000C1E7D0E010C0052710E0EE
+:101AF00000C021C0052710E0C89508BB14C03AE516
+:101B000001C032ED032EC0E0D0E032E017B318611F
+:101B1000C39A08B317BB58E120E84FEF20FF052711
+:101B200008BB279517951C3F28F700004552B0F7D2
+:101B300020FF0527279508BB17951C3FB8F629916C
+:101B40003A9561F7077E10918200110F08BBC250D1
+:101B5000D04011F010937C0010E21ABF086017B358
+:101B6000177E402F477E54E05A95F1F708BB17BB0C
+:101B700048BB8ACFF8942FEFB0E8A0E44AE0B1BFA9
+:101B8000000081EE9CE0B399FECFB39BFECF01979E
+:101B9000B399FDCF97FF03C0BA1B819501C0BA0F5F
+:101BA000A69529F4281710F031B7282FA1E041504D
+:101BB00031F731BF0000789408958FB7F894E09121
+:101BC0006900F0916A00329795E090935700E8958C
+:101BD0008FBF08952091690030916A002115310569
+:101BE00089F12430310591F12C3F47E1340739F474
+:101BF00080916B0090916C008E5F9B4F10C02E3FC8
+:101C000047E1340739F480916D0090916E008D5F4B
+:101C10009B4F05C02A3F374111F481B790E02FB7A1
+:101C2000F894E0916900F0916A0031E00C01309382
+:101C30005700E89511242FBF3296F0936A00E09385
+:101C40006900089581E180935700E8958FEF9BEC40
+:101C5000E6CF8FEF9FEFBEDF809169008F73C9F7EA
+:101C6000ACCF88E10FB6F89481BD11BC0FBEE1E0A6
+:101C7000F0E0E491EF3F09F4ECDF10926A0010927B
+:101C8000690086ED80936700C198AC9A8BB780623B
+:101C90008BBFBB9A88EB9BE0ECE9F1E03197F1F761
+:101CA0000197D1F7BB98789400918100035007FD0C
+:101CB000CFC080917E00CCE0D0E0C81BD109CB57CB
+:101CC000DF4F80917D008D3209F090C0083009F01F
+:101CD000BDC083EC809371008AE580936000109210
+:101CE0006F002881922F90768981992329F1109293
+:101CF000670010926600811108C082E690E0909320
+:101D0000800080937F0014E067C0813051F48C81A3
+:101D10009D8190936A008093690027FD58C01FEF52
+:101D200057C090916800823011F4916001C09460B6
+:101D30009093680010E050C09A8110927A0081114F
+:101D400006C010927B008AE790E012E03BC085302D
+:101D500019F4909382002CC0863009F58B81813074
+:101D600019F480E398E104C0823041F48EE198E1F7
+:101D70009093800080937F0012E10DC0833051F476
+:101D8000911108C082E498E19093800080937F00D5
+:101D900014E001C010E080E480936F001DC0883023
+:101DA00059F0893019F49093840002C08A3039F0D8
+:101DB0008AE790E010E006C084E890E002C08AE77D
+:101DC00090E011E09093800080937F0005C01E8119
+:101DD00080E880936F0007C08F81811104C08E81DD
+:101DE000811708F4182F1093610030C080916F00A4
+:101DF00087FF2CC08091690090916A00009739F4A8
+:101E00008881998190936C0080936B0012C084301C
+:101E1000910539F48881998190936E0080936D00CB
+:101E200008C08115984128F0809169008F7339F0BE
+:101E30000DC089919991CEDE0250E1F6F5CF8091E7
+:101E400068008260809368001092610010928100A7
+:101E50008091600084FF43C0809161008F3F09F44E
+:101E60003EC0082F893008F008E0801B8093610095
+:101E70008091710098E8892780937100002319F1FF
+:101E8000E0917F00F091800080916F0086FF0BC091
+:101E9000A2E7B0E084918D93319682E790E0800FC5
+:101EA0008A13F8CF0CC0CF01A2E7B0E0FC0121916A
+:101EB000CF012D9322E730E0200F2A13F7CFF093C4
+:101EC0008000E0937F00602F82E790E0F1DC0C5F00
+:101ED0000C3019F08FEF809361000093600084E173
+:101EE00096B3987131F48150D9F710928200109214
+:101EF0007C0001E0811100E080917000801739F0D2
+:101F0000011103C01092670035DE009370008CE968
+:101F100091E00197F1F78091680080FF11C0F8947B
+:101F2000E0E0F8E1E054F10983E080935700E895A0
+:101F30003097C1F710926A00109269008ADE789497
+:101F40000091680001FF0BC08AE390E20197F1F76E
+:101F5000809169008F7311F07CDE01C02EDE02FFDC
+:101F600013C0B99882E291EA0197F1F7F894BB9A0D
+:101F70001BBE15BA10925F02EAEFF7E1E4918E2FD3
+:101F800081508E3FC0F019C01092680080916700A8
+:101F90008D7011F0B99801C0B99A80916600909146
+:101FA00067000196909367008093660080369A4E92
+:101FB00008F47ACED6CFE1BF000020CC0DCFF89444
+:021FC000FFCF51
+:061FC2005AFF17FA400867
+:0400000300001800E1
+:00000001FF
diff --git a/firmware/usbconfig.h b/firmware/usbconfig.h
index bba210d..560c34d 100644
--- a/firmware/usbconfig.h
+++ b/firmware/usbconfig.h
@@ -159,8 +159,16 @@
*/
//#if USB_CFG_CLOCK_KHZ==16500
+//#include "osccal.h"
+
+#ifndef __ASSEMBLER__
+ void calibrateOscillatorASM(void);
+ extern uint16_t idlePolls;
+# define USB_RESET_HOOK(resetStarts) if(!resetStarts){ ((uint8_t*)&idlePolls)[1]= 0;calibrateOscillatorASM();}
+
+# define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
+#endif
-#include "osccal.h"
/* define this macro to 1 if you want the function usbMeasureFrameLength()
* compiled in. This function can be used to calibrate the AVR's RC oscillator.