X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/blobdiff_plain/c2df4584d6bc82ef8c793eaaffc0acead7f8410c..da254736cb7aaf5f1bc5fe79b1816e13f71ee264:/firmware/bootloaderconfig.h?ds=sidebyside diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h index c9676a6..af67d6e 100644 --- a/firmware/bootloaderconfig.h +++ b/firmware/bootloaderconfig.h @@ -12,6 +12,7 @@ #ifndef __bootloaderconfig_h_included__ #define __bootloaderconfig_h_included__ +#include /* General Description: @@ -143,35 +144,106 @@ these macros are defined, the boot loader usees them. * feature. */ -#define HAVE_EEPROM_PAGED_ACCESS 1 +#define HAVE_SPMINTEREFACE_NORETMAGIC 1 +/* + * If sth. went wrong within "bootloader__do_spm" and this macro is ACTIVATED, + * then "bootloader__do_spm" will not return the call and loop infinity instead. + * + * This feature prevents old updaters to do sth. undefined on wrong magic. + */ + +/* all boards should use a magic to make it safe to confuse updatefiles :-) */ +#define HAVE_SPMINTEREFACE_MAGICVALUE 0 +/* If this feature is enabled (value != 0), the configured 32bit value is + * used as a magic value within spminterface. "bootloader__do_spm" will check + * additional four (4) registers for this value and only proceed, if they contain + * the right value. With this feature you can identify your board and avoid + * updating the wrong bootloader to the wrong board! + * + * Not all values are possible - "SPMINTEREFACE_MAGICVALUE" must be very sparse! + * To avoid collisions, magic-values will be organized centrally by Stephan + * Following values are definitly blocked or reserved and must not be used: + * 0x00000000, 0x12345678, + * 0x00a500a5, 0x00a5a500, 0xa50000a5, 0xa500a500, + * 0x005a005a, 0x005a5a00, 0x5a00005a, 0x5a005a00, + * 0x5aa55aa5, 0x5aa5a55a, 0xa55a5aa5, 0xa55aa55a, + * 0x5a5a5a5a, 0xa5a5a5a5, + * 0xffa5ffa5, 0xffa5a5ff, 0xa5ffffa5, 0xa5ffa5ff, + * 0xff5aff5a, 0xff5a5aff, 0x5affff5a, 0x5aff5aff, + * 0x00ff00ff, 0x00ffff00, 0xff0000ff, 0xff00ff00, + * 0xffffffff + * + * To request your own magic, please send at least following information + * about yourself and your board together within an informal request to: + * stephan@matrixstorm.com / matrixstorm@gmx.de / stephan.baerwolf@tu-ilmenau.de + * - your name + * - your e-mail + * - your project (maybe an url?) + * - your type of MCU used + * --> your used "BOOTLOADER_ADDRESS" (since same magics can be reused for different "BOOTLOADER_ADDRESS") + * + * There may be no garanty for it, but Stephan will then send you an + * response with a "SPMINTEREFACE_MAGICVALUE" just for your board/project... + * WITH REQUESTING A MAGIC YOU AGREE TO PUBLISHED YOUR DATA SEND WITHIN THE REQUEST + */ + +#ifndef CONFIG_NO__EEPROM_PAGED_ACCESS +# define HAVE_EEPROM_PAGED_ACCESS 1 +#else +# define HAVE_EEPROM_PAGED_ACCESS 0 +#endif /* If HAVE_EEPROM_PAGED_ACCESS is defined to 1, page mode access to EEPROM is * compiled in. Whether page mode or byte mode access is used by AVRDUDE * depends on the target device. Page mode is only used if the device supports * it, e.g. for the ATMega88, 168 etc. You can save quite a bit of memory by * disabling page mode EEPROM access. Costs ~ 138 bytes. */ -#define HAVE_EEPROM_BYTE_ACCESS 1 + +#ifndef CONFIG_NO__EEPROM_BYTE_ACCESS +# define HAVE_EEPROM_BYTE_ACCESS 1 +#else +# define HAVE_EEPROM_BYTE_ACCESS 0 +#endif /* If HAVE_EEPROM_BYTE_ACCESS is defined to 1, byte mode access to EEPROM is * compiled in. Byte mode is only used if the device (as identified by its * signature) does not support page mode for EEPROM. It is required for * accessing the EEPROM on the ATMega8. Costs ~54 bytes. */ + #ifndef CONFIG_NO__BOOTLOADER_CAN_EXIT - #define BOOTLOADER_CAN_EXIT 1 +# define BOOTLOADER_CAN_EXIT 1 #else - #define BOOTLOADER_CAN_EXIT 0 +# define BOOTLOADER_CAN_EXIT 0 #endif /* If this macro is defined to 1, the boot loader will exit shortly after the * programmer closes the connection to the device. Costs extra bytes. */ -#define HAVE_CHIP_ERASE 0 + +#ifndef CONFIG_NO__CHIP_ERASE +# define HAVE_CHIP_ERASE 1 +#else +# define HAVE_CHIP_ERASE 0 +#endif /* 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. */ +#ifndef CONFIG_NO__ONDEMAND_PAGEERASE +# define HAVE_ONDEMAND_PAGEERASE 1 +#else +# define HAVE_ONDEMAND_PAGEERASE 0 +#endif +/* Even if "HAVE_CHIP_ERASE" is avtivated - enabling the "HAVE_ONDEMAND_PAGEERASE"- + * feature the bootloader will erase pages on demand short before writing new data + * to it. + * If pages are not erase before reprogram (for example because user call avrdude -D) + * then data may become inconsistent since writing only allow to unset bits in the flash. + * This feature may prevent this... + */ + #ifndef CONFIG_NO__NEED_WATCHDOG - #define NEED_WATCHDOG 1 +# define NEED_WATCHDOG 1 #else - #define NEED_WATCHDOG 0 +# define NEED_WATCHDOG 0 #endif /* ATTANTION: This macro MUST BE 1, if the MCU has reset enabled watchdog (WDTON is 0). * If this macro is defined to 1, the bootloader implements an additional "wdt_disable()" @@ -179,10 +251,11 @@ these macros are defined, the boot loader usees them. * If the used MCU is fused not to enable watchdog after reset (WDTON is 1 - safty level 1) * then "NEED_WATCHDOG" may be deactivated in order to save some memory. */ + #ifndef CONFIG_NO__PRECISESLEEP - #define HAVE_UNPRECISEWAIT 0 +# define HAVE_UNPRECISEWAIT 0 #else - #define HAVE_UNPRECISEWAIT 1 +# define HAVE_UNPRECISEWAIT 1 #endif /* This macro enables hand-optimized assembler code * instead to use _sleep_ms for delaying USB enumeration. @@ -190,6 +263,31 @@ these macros are defined, the boot loader usees them. * the optimized assembler code does not need to be precise. * Therefore it is very small, which saves some PROGMEM bytes! */ + +#ifndef CONFIG_NO__FLASH_BYTE_READACCESS +# define HAVE_FLASH_BYTE_READACCESS 1 +#else +# define HAVE_FLASH_BYTE_READACCESS 0 +#endif +/* If HAVE_FLASH_BYTE_READACCESS is defined to 1, byte mode access to FLASH is + * compiled in. Byte mode sometimes might be used by some programming softwares + * (avrdude in terminal mode). Without this feature the device would return "0" + * instead the right content of the flash memory. + */ + +#ifdef CONFIG_USE__EXCESSIVE_ASSEMBLER +# define USE_EXCESSIVE_ASSEMBLER 1 +#else +# define USE_EXCESSIVE_ASSEMBLER 0 +#endif +/* This macro enables large codeareas of hand-optimized assembler code. + * WARNING: + * It will only work properly on devices with <64k of flash memory and SRAM. + * Some configuration macros (when changed) may not be applied correctly + * (since their behaviour is raced within asm)! + * Nevertheless this feature saves lots of memory. + */ + //#define SIGNATURE_BYTES 0x1e, 0x93, 0x07, 0 /* ATMega8 */ /* This macro defines the signature bytes returned by the emulated USBasp to * the programmer software. They should match the actual device at least in @@ -214,6 +312,10 @@ these macros are defined, the boot loader usees them. # define MCUCSR MCUSR #endif +/* WARNING: + * following commands and macros may not be evaluated properly when 'USE_EXCESSIVE_ASSEMBLER" + */ + static inline void bootLoaderInit(void) { PIN_DDR(JUMPER_PORT) = 0; @@ -226,12 +328,10 @@ static inline void bootLoaderInit(void) MCUCSR = 0; /* clear all reset flags for next time */ } -#if BOOTLOADER_CAN_EXIT static inline void bootLoaderExit(void) { PIN_PORT(JUMPER_PORT) = 0; /* undo bootLoaderInit() changes */ } -#endif #define bootLoaderCondition() ((PIN_PIN(JUMPER_PORT) & (1 << PIN(JUMPER_PORT, JUMPER_BIT))) == 0)