From aca630da48ef090c2a68cb6adfe906e6e036e05e Mon Sep 17 00:00:00 2001 From: Stephan Baerwolf Date: Sun, 5 May 2013 22:05:22 +0200 Subject: [PATCH] further optimize codesize Signed-off-by: Stephan Baerwolf --- firmware/Makefile | 2 +- firmware/main.c | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/firmware/Makefile b/firmware/Makefile index 04bec88..df886aa 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -19,7 +19,7 @@ include ../Makefile.inc # Remove the -fno-* options when you use gcc 3, it does not understand them CFLAGS = -Wall -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DF_CPU=$(F_CPU) $(DEFINES) -LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) +LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -Wl,--defsym=nullVector=0 OBJECTS = usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o diff --git a/firmware/main.c b/firmware/main.c index b8e17a0..2639644 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -220,25 +220,21 @@ void __func_clearram(void) { } #endif -#if (!USE_EXCESSIVE_ASSEMBLER) || (!(defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__))) static void (*nullVector)(void) __attribute__((__noreturn__)); -#endif -static void __attribute__((__noreturn__)) leaveBootloader() -{ +static void __attribute__((naked)) __attribute__((__noreturn__)) leaveBootloader(void); +static void leaveBootloader(void) { #if (USE_EXCESSIVE_ASSEMBLER) && (defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)) asm volatile ( "cli\n\t" - "clr r30\n\t" "sbi %[usbddr], %[usbminus]\n\t" "cbi %[port], %[bit]\n\t" - "out %[usbintrenab], r30\n\t" - "out %[usbintrcfg], r30\n\t" + "out %[usbintrenab], __zero_reg__\n\t" + "out %[usbintrcfg], __zero_reg__\n\t" "ldi r31, %[ivce]\n\t" "out %[mygicr], r31\n\t" - "out %[mygicr], r30\n\t" - "clr r31\n\t" - "icall\n\t" + "out %[mygicr], __zero_reg__\n\t" + "rjmp nullVector\n\t" : : [port] "I" (_SFR_IO_ADDR(PIN_PORT(JUMPER_PORT))), [bit] "I" (PIN(JUMPER_PORT, JUMPER_BIT)), -- 2.11.0