summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/Makefile3
-rw-r--r--firmware/configuration/t85_aggressive/Makefile.inc12
-rw-r--r--firmware/configuration/t85_default/Makefile.inc2
-rw-r--r--firmware/crt1.S3
-rw-r--r--firmware/main.c12
-rw-r--r--firmware/osccalASM.S6
6 files changed, 28 insertions, 10 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
index 9bf5570..4574e0f 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -18,6 +18,7 @@ CONFIG ?= t85_default
# make flash # to load the boot loader into flash
# make disablereset # use external reset line for IO (CAUTION: this is not easy to enable again, see README)
+CFLAGS =
CONFIGPATH = configuration/$(CONFIG)
include $(CONFIGPATH)/Makefile.inc
@@ -29,7 +30,7 @@ AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
CC = avr-gcc
# Options:
-CFLAGS = -I. -g2 -Os # -Wall
+CFLAGS += -I. -g2 -Os # -Wall
CFLAGS += -I$(CONFIGPATH) -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -DBOOTLOADER_ADDRESS=0x$(BOOTLOADER_ADDRESS)
CFLAGS += -nostartfiles -ffunction-sections -fdata-sections -fpack-struct -fno-inline-small-functions -fno-move-loop-invariants -fno-tree-scev-cprop
diff --git a/firmware/configuration/t85_aggressive/Makefile.inc b/firmware/configuration/t85_aggressive/Makefile.inc
index 7ac110d..4675ae9 100644
--- a/firmware/configuration/t85_aggressive/Makefile.inc
+++ b/firmware/configuration/t85_aggressive/Makefile.inc
@@ -4,8 +4,16 @@
# Controller type: ATtiny 85
# Configuration: Size optimized. Uses 16 MHz V-USB implementation, which may be instable with some computers
-# Last Change: Mar 16,2014
-
+# Last Change: Jan 11,2015
+
+# Enable unsafe optimizions. This will disable several safety features in microncleus to save around 40 more bytes
+#
+# Disabled features:
+# * Stack pointer and SREG initialization in CRT
+# * Client side reset vector patching
+# * USB collision detection. Micronucleus will not work reliability with hubs if this is disabled.
+
+CFLAGS += -DENABLE_UNSAFE_OPTIMIZATIONS
F_CPU = 16000000
DEVICE = attiny85
diff --git a/firmware/configuration/t85_default/Makefile.inc b/firmware/configuration/t85_default/Makefile.inc
index 53a4682..ee7252d 100644
--- a/firmware/configuration/t85_default/Makefile.inc
+++ b/firmware/configuration/t85_default/Makefile.inc
@@ -15,7 +15,7 @@ DEVICE = attiny85
# - for the size of your device (8kb = 1024 * 8 = 8192) subtract above value 2124... = 6068
# - How many pages in is that? 6068 / 64 (tiny85 page size in bytes) = 94.8125
# - round that down to 94 - our new bootloader address is 94 * 64 = 6016, in hex = 1780
-BOOTLOADER_ADDRESS = 19C0
+BOOTLOADER_ADDRESS = 1980
FUSEOPT = -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m
FUSEOPT_DISABLERESET = -U lfuse:w:0xe1:m -U efuse:w:0xfe:m -U hfuse:w:0x5d:m
diff --git a/firmware/crt1.S b/firmware/crt1.S
index b018ff1..1f68351 100644
--- a/firmware/crt1.S
+++ b/firmware/crt1.S
@@ -95,11 +95,14 @@ __init:
.section .init2,"ax",@progbits
clr R1
+
+#ifndef ENABLE_UNSAFE_OPTIMIZATIONS
out 0x3f,r1
ldi r28,lo8(__stack)
ldi r29,hi8(__stack)
out 0x3d, r28
out 0x3e, r29
+#endif
.section .init9,"ax",@progbits
; rcall main
; XJMP __vectors-2
diff --git a/firmware/main.c b/firmware/main.c
index 194156c..0cd0d26 100644
--- a/firmware/main.c
+++ b/firmware/main.c
@@ -131,19 +131,21 @@ static inline void writeFlashPage(void) {
// the device can not be bricked. Saving user-reset-vector is done in the host
// tool, starting with firmware V2
static void writeWordToPageBuffer(uint16_t data) {
-
-#if BOOTLOADER_ADDRESS < 8192
+
+#ifndef ENABLE_UNSAFE_OPTIMIZATIONS
+ #if BOOTLOADER_ADDRESS < 8192
// rjmp
if (currentAddress.w == RESET_VECTOR_OFFSET * 2) {
data = 0xC000 + (BOOTLOADER_ADDRESS/2) - 1;
}
-#else
+ #else
// far jmp
if (currentAddress.w == RESET_VECTOR_OFFSET * 2) {
data = 0x940c;
} else if (currentAddress.w == (RESET_VECTOR_OFFSET +1 ) * 2) {
data = (BOOTLOADER_ADDRESS/2);
}
+ #endif
#endif
#if OSCCAL_SAVE_CALIB
@@ -177,7 +179,7 @@ static uint8_t usbFunctionSetup(uint8_t data[8]) {
command=cmd_write_page; // ask runloop to write our page
} else {
// Handle cmd_erase_application and cmd_exit
- command=rq->bRequest&0x3f;
+ command=rq->bRequest&0x3f;
}
return 0;
}
@@ -278,7 +280,7 @@ int main(void) {
}
} while(--fastctr);
-
+
wdr();
// commands are only evaluated after next USB transmission or after 5 ms passed
diff --git a/firmware/osccalASM.S b/firmware/osccalASM.S
index fa26dc4..57730bf 100644
--- a/firmware/osccalASM.S
+++ b/firmware/osccalASM.S
@@ -147,6 +147,9 @@ usbCOWaitLoop:
sbic USBIN, USBMINUS ;[2]
rjmp usbCOWaitLoop ;[3]
+ ; This section of code deals with traffic from other USB devices on the same hub.
+ ; If this code is excluded, micronucleus may only work when it is connected to a dedicated USB port
+#ifndef ENABLE_UNSAFE_OPTIMIZATIONS
sbis USBIN, USBPLUS ; ignore frame if data is present
rjmp usbCOnotdata
@@ -161,7 +164,8 @@ usbCOWaitNoData2:
sbis USBIN, USBMINUS ; wait for D- go to high
rjmp usbCOWaitNoData2
rjmp usbCOLoopNoCal
-
+#endif
+
usbCOnotdata:
sbrs cnt16H, 7 ;delay overflow?
rjmp usbCOclocktoolow