X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/blobdiff_plain/27f21b1464a7743393bb1ea88f70d687155bbe4b..8a827b1fd2ddcca5d27e2a03fe80d8c2e706515e:/firmware/main.c diff --git a/firmware/main.c b/firmware/main.c index bd36e06..e40c0b5 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -3,11 +3,10 @@ * Author: Christian Starkjohann * Author: Stephan Baerwolf * Creation Date: 2007-12-08 - * Modification Date: 2012-11-10 + * Modification Date: 2013-03-31 * Tabsize: 4 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt) - * This Revision: $Id: main.c 786 2010-05-30 20:41:40Z cs $ */ #include "spminterface.h" /* must be included as first! */ @@ -260,7 +259,16 @@ asm volatile ( USB_INTR_CFG = 0; /* also reset config bits */ GICR = (1 << IVCE); /* enable change of interrupt vectors */ GICR = (0 << IVSEL); /* move interrupts to application flash section */ - + +/* + * There seems to be another funny compiler Bug. + * When gcc is using "eicall" opcode it forgets to modify EIND. + * On devices with large flash memory there are some target address bits + * missing. In this case some zero bits... + */ +#if (defined(EIND) && ((FLASHEND)>131071)) + EIND=0; +#endif /* We must go through a global function pointer variable instead of writing * ((void (*)(void))0)(); * because the compiler optimizes a constant 0 to "rcall 0" which is not @@ -369,7 +377,7 @@ usbRequest_t *rq = (void *)data; uchar len = 0; static uchar replyBuffer[4]; - usbMsgPtr = replyBuffer; + usbMsgPtr = (usbMsgPtr_t)replyBuffer; if(rq->bRequest == USBASP_FUNC_TRANSMIT){ /* emulate parts of ISP protocol */ replyBuffer[3] = usbFunctionSetup_USBASP_FUNC_TRANSMIT(rq); len = 4;