diff options
| author | cpldcpu <cpldcpu@gmail.com> | 2015-10-09 20:02:29 +0200 | 
|---|---|---|
| committer | cpldcpu <cpldcpu@gmail.com> | 2015-10-09 20:02:36 +0200 | 
| commit | a84f9b262f0b9218356f261277f19208eea60904 (patch) | |
| tree | 866e52bfb87dc686df9601ad4f02ffc4243d40a7 | |
| parent | 00e6063013c31a0da59092e50cf94624bafc0f04 (diff) | |
| download | micronucleus-a84f9b262f0b9218356f261277f19208eea60904.tar.gz micronucleus-a84f9b262f0b9218356f261277f19208eea60904.tar.bz2 micronucleus-a84f9b262f0b9218356f261277f19208eea60904.zip | |
firmware: ATiny45 build
| -rw-r--r-- | firmware/configuration/t45_default/Makefile.inc | 60 | ||||
| -rw-r--r-- | firmware/configuration/t45_default/bootloaderconfig.h | 259 | ||||
| -rw-r--r-- | firmware/makerelease.bat | 3 | ||||
| -rw-r--r-- | firmware/releases/t45_default.hex | 102 | 
4 files changed, 424 insertions, 0 deletions
| diff --git a/firmware/configuration/t45_default/Makefile.inc b/firmware/configuration/t45_default/Makefile.inc new file mode 100644 index 0000000..87c22a6 --- /dev/null +++ b/firmware/configuration/t45_default/Makefile.inc @@ -0,0 +1,60 @@ +# Name: Makefile +# Project: Micronucleus +# License: GNU GPL v2 (see License.txt) + +# Controller type: ATtiny 45 - 16.5 MHz +# Configuration:   Default +# Last Change:     Oct 9,2015 +  +  +F_CPU = 16500000 +DEVICE = attiny45 + +# hexadecimal address for bootloader section to begin. To calculate the best value: +# - make clean; make main.hex; ### output will list data: 2124 (or something like that) +# - 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 = 980 + +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 + +#--------------------------------------------------------------------- +# ATtiny85 +#--------------------------------------------------------------------- +# Fuse extended byte: +# 0xFE = - - - -   - 1 1 0 +#                        ^ +#                        | +#                        +---- SELFPRGEN (enable self programming flash) +# +# Fuse high byte: +# 0xdd = 1 1 0 1   1 1 0 1 +#        ^ ^ ^ ^   ^ \-+-/  +#        | | | |   |   +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V) +#        | | | |   +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved) +#        | | | +-------------- WDTON (watchdog timer always on -> disable) +#        | | +---------------- SPIEN (enable serial programming -> enabled) +#        | +------------------ DWEN (debug wire enable) +#        +-------------------- RSTDISBL (disable external reset -> enabled) +# +# Fuse high byte ("no reset": external reset disabled, can't program through SPI anymore) +# 0x5d = 0 1 0 1   1 1 0 1 +#        ^ ^ ^ ^   ^ \-+-/  +#        | | | |   |   +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V) +#        | | | |   +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved) +#        | | | +-------------- WDTON (watchdog timer always on -> disable) +#        | | +---------------- SPIEN (enable serial programming -> enabled) +#        | +------------------ DWEN (debug wire enable) +#        +-------------------- RSTDISBL (disable external reset -> disabled!) +# +# Fuse low byte: +# 0xe1 = 1 1 1 0   0 0 0 1 +#        ^ ^ \+/   \--+--/ +#        | |  |       +------- CKSEL 3..0 (clock selection -> HF PLL) +#        | |  +--------------- SUT 1..0 (BOD enabled, fast rising power) +#        | +------------------ CKOUT (clock output on CKOUT pin -> disabled) +#        +-------------------- CKDIV8 (divide clock by 8 -> don't divide) + +############################################################################### diff --git a/firmware/configuration/t45_default/bootloaderconfig.h b/firmware/configuration/t45_default/bootloaderconfig.h new file mode 100644 index 0000000..ecd6261 --- /dev/null +++ b/firmware/configuration/t45_default/bootloaderconfig.h @@ -0,0 +1,259 @@ +/* Name: bootloaderconfig.h + * Micronucleus configuration file.  + * This file (together with some settings in Makefile.inc) configures the boot loader + * according to the hardware. + *  + * Controller type: ATtiny 45 - 16.5 MHz + * Configuration:   Default configuration + *       USB D- :   PB3 + *       USB D+ :   PB4 + *       Entry  :   Always + *       LED    :   None + *       OSCCAL :   Stays at 16 MHz + * Note: Uses 16.5 MHz V-USB implementation with PLL + * Last Change:     Mar 16,2014 + * + * License: GNU GPL v2 (see License.txt + */ +#ifndef __bootloaderconfig_h_included__ +#define __bootloaderconfig_h_included__ + +/* ------------------------------------------------------------------------- */ +/*                       Hardware configuration.                             */ +/*      Change this according to your CPU and USB configuration              */ +/* ------------------------------------------------------------------------- */ + +#define USB_CFG_IOPORTNAME      B +  /* This is the port where the USB bus is connected. When you configure it to +   * "B", the registers PORTB, PINB and DDRB will be used. +   */ + +#define USB_CFG_DMINUS_BIT      3 +/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. + * This may be any bit in the port. + */ +#define USB_CFG_DPLUS_BIT       4 +/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. + * This may be any bit in the port, but must be configured as a pin change interrupt. + */ + +#define USB_CFG_CLOCK_KHZ       (F_CPU/1000) +/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, + * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code + * require no crystal, they tolerate +/- 1% deviation from the nominal + * frequency. All other rates require a precision of 2000 ppm and thus a + * crystal! + * Since F_CPU should be defined to your actual clock rate anyway, you should + * not need to modify this setting. + */ + +/* ------------- Set up interrupt configuration (CPU specific) --------------   */ +/* The register names change quite a bit in the ATtiny family. Pay attention    */ +/* to the manual. Note that the interrupt flag system is still used even though */ +/* interrupts are disabled. So this has to be configured correctly.             */ + + +// setup interrupt for Pin Change for D+ +#define USB_INTR_CFG            PCMSK +#define USB_INTR_CFG_SET        (1 << USB_CFG_DPLUS_BIT) +#define USB_INTR_CFG_CLR        0 +#define USB_INTR_ENABLE         GIMSK +#define USB_INTR_ENABLE_BIT     PCIE +#define USB_INTR_PENDING        GIFR +#define USB_INTR_PENDING_BIT    PCIF +#define USB_INTR_VECTOR         PCINT0_vect + +/* ------------------------------------------------------------------------- */ +/*       Configuration relevant to the CPU the bootloader is running on      */ +/* ------------------------------------------------------------------------- */ + +// how many milliseconds should host wait till it sends another erase or write? +// needs to be above 4.5 (and a whole integer) as avr freezes for 4.5ms +#define MICRONUCLEUS_WRITE_SLEEP 5 + + +/* ---------------------- feature / code size options ---------------------- */ +/*               Configure the behavior of the bootloader here               */ +/* ------------------------------------------------------------------------- */ + +/* + *  Define Bootloader entry condition + *  + *  If the entry condition is not met, the bootloader will not be activated and the user program + *  is executed directly after a reset. If no user program has been loaded, the bootloader + *  is always active. + *  + *  ENTRY_ALWAYS        Always activate the bootloader after reset. Requires the least + *                      amount of code. + * + *  ENTRY_WATCHDOG      Activate the bootloader after a watchdog reset. This can be used + *                      to enter the bootloader from the user program. + *                      Adds 22 bytes. + * + *  ENTRY_EXT_RESET     Activate the bootloader after an external reset was issued by  + *                      pulling the reset pin low. It may be necessary to add an external + *                      pull-up resistor to the reset pin if this entry method appears to + *                      behave unreliably. + *                      Adds 22 bytes. + * + *  ENTRY_JUMPER        Activate the bootloader when a specific pin is pulled low by an  + *                      external jumper.  + *                      Adds 34 bytes. + * + *       JUMPER_PIN     Pin the jumper is connected to. (e.g. PB0) + *       JUMPER_PORT    Port out register for the jumper (e.g. PORTB)   + *       JUMPER_DDR     Port data direction register for the jumper (e.g. DDRB)   + *       JUMPER_INP     Port inout register for the jumper (e.g. PINB)   + *  + */ + +#define ENTRYMODE ENTRY_ALWAYS + +#define JUMPER_PIN    PB0 +#define JUMPER_PORT   PORTB  +#define JUMPER_DDR    DDRB  +#define JUMPER_INP    PINB  +  +/* +  Internal implementation, don't change this unless you want to add an entrymode. +*/  +  +#define ENTRY_ALWAYS    1 +#define ENTRY_WATCHDOG  2 +#define ENTRY_EXT_RESET 3 +#define ENTRY_JUMPER    4 + +#if ENTRYMODE==ENTRY_ALWAYS +  #define bootLoaderInit() +  #define bootLoaderExit() +  #define bootLoaderStartCondition() 1 +#elif ENTRYMODE==ENTRY_WATCHDOG +  #define bootLoaderInit() +  #define bootLoaderExit() +  #define bootLoaderStartCondition() (MCUSR&_BV(WDRF)) +#elif ENTRYMODE==ENTRY_EXT_RESET +  #define bootLoaderInit() +  #define bootLoaderExit() +  #define bootLoaderStartCondition() (MCUSR&_BV(EXTRF)) +#elif ENTRYMODE==ENTRY_JUMPER +  // Enable pull up on jumper pin and delay to stabilize input     +  #define bootLoaderInit()   {JUMPER_DDR&=~_BV(JUMPER_PIN);JUMPER_PORT|=_BV(JUMPER_PIN);_delay_ms(1);} +  #define bootLoaderExit()   {JUMPER_PORT&=~_BV(JUMPER_PIN);} +  #define bootLoaderStartCondition() (!(JUMPER_INP&_BV(JUMPER_PIN))) +#else +   #error "No entry mode defined" +#endif + +/* + * Define bootloader timeout value.  + *  + *  The bootloader will only time out if a user program was loaded. + *  + *  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. + *                             Set to 0 to disable + *   + *  All values are approx. in milliseconds + */ + +#define AUTO_EXIT_NO_USB_MS    0 +#define AUTO_EXIT_MS           6000 + + /* + *  Defines the setting of the RC-oscillator calibration after quitting the bootloader. (OSCCAL) + *  + *  OSCCAL_RESTORE_DEFAULT    Set this to '1' to revert to OSCCAL factore calibration after bootlaoder exit. + *                            This is 8 MHz +/-2% on most devices or 16 MHz on the ATtiny 85 with activated PLL. + *                            Adds ~14 bytes. + * + *  OSCCAL_SAVE_CALIB         Set this to '1' to save the OSCCAL calibration during program upload. + *                            This value will be reloaded after reset and will also be used for the user + *                            program unless "OSCCAL_RESTORE_DEFAULT" is active. This allows calibrate the internal + *                            RC oscillator to the F_CPU target frequency +/-1% from the USB timing. Please note + *                            that only true if the ambient temperature does not change. + *                            Adds ~38 bytes. + * + *  OSCCAL_HAVE_XTAL          Set this to '1' if you have an external crystal oscillator. In this case no attempt + *                            will be made to calibrate the oscillator. You should deactivate both options above + *                            if you use this to avoid redundant code. + * + *  If both options are selected, OSCCAL_RESTORE_DEFAULT takes precedence. + * + *  If no option is selected, OSCCAL will be left untouched and stays at either factory calibration or F_CPU 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_DEFAULT 0 +#define OSCCAL_SAVE_CALIB 1 +#define OSCCAL_HAVE_XTAL 0 +   +/*   + *  Defines handling of an indicator LED while the bootloader is active.   + *  + *  LED_MODE                  Define behavior of attached LED or suppress LED code. + * + *          NONE              Do not generate LED code (gains 18 bytes). + *          ACTIVE_HIGH       LED is on when output pin is high. This will toggle bettwen 1 and 0. + *          ACTIVE_LOW        LED is on when output pin is low.  This will toggle between Z and 0. + * + *  LED_DDR,LED_PORT,LED_PIN  Where is your LED connected? + * + */  + +#define LED_MODE    NONE + +#define LED_DDR     DDRB +#define LED_PORT    PORTB +#define LED_PIN     PB1 + +/* + *  This is the implementation of the LED code. Change the configuration above unless you want to  + *  change the led behavior + * + *  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 NONE        0 +#define ACTIVE_HIGH 1 +#define ACTIVE_LOW  2 + +#if LED_MODE==ACTIVE_HIGH +  #define LED_INIT(x)   LED_DDR   = _BV(LED_PIN);  +  #define LED_EXIT(x)   {LED_DDR  &=~_BV(LED_PIN);LED_PORT  &=~_BV(LED_PIN);} +  #define LED_MACRO(x)  if ( x & 0x4c ) {LED_PORT&=~_BV(LED_PIN);} else {LED_PORT|=_BV(LED_PIN);} +#elif LED_MODE==ACTIVE_LOW +  #define LED_INIT(x)   LED_PORT &=~_BV(LED_PIN);    +  #define LED_EXIT(x)   LED_DDR  &=~_BV(LED_PIN); +  #define LED_MACRO(x)  if ( x & 0x4c ) {LED_DDR&=~_BV(LED_PIN);} else {LED_DDR|=_BV(LED_PIN);}   +#elif LED_MODE==NONE +  #define LED_INIT(x) +  #define LED_EXIT(x) +  #define LED_MACRO(x) +#endif + +/* --------------------------------------------------------------------------- */ +/* Micronucleus internal configuration. Do not change anything below this line */ +/* --------------------------------------------------------------------------- */ + +// Microcontroller vectortable entries in the flash +#define RESET_VECTOR_OFFSET         0 + +// number of bytes before the boot loader vectors to store the tiny application vector table +#define TINYVECTOR_RESET_OFFSET     4 +#define TINYVECTOR_OSCCAL_OFFSET    6 + +/* ------------------------------------------------------------------------ */ +// postscript are the few bytes at the end of programmable memory which store tinyVectors +#define POSTSCRIPT_SIZE 6 +#define PROGMEM_SIZE (BOOTLOADER_ADDRESS - POSTSCRIPT_SIZE) /* max size of user program */ + +#endif /* __bootloader_h_included__ */ diff --git a/firmware/makerelease.bat b/firmware/makerelease.bat index 908d40c..0f57e48 100644 --- a/firmware/makerelease.bat +++ b/firmware/makerelease.bat @@ -5,6 +5,9 @@ make clean  make CONFIG=t85_default  cp main.hex releases/t85_default.hex  make clean +make CONFIG=t45_default +cp main.hex releases/t45_default.hex +make clean  make CONFIG=t85_aggressive  cp main.hex releases/t85_aggressive.hex  make clean diff --git a/firmware/releases/t45_default.hex b/firmware/releases/t45_default.hex new file mode 100644 index 0000000..d24cfb4 --- /dev/null +++ b/firmware/releases/t45_default.hex @@ -0,0 +1,102 @@ +:1009800017C0097A40059206090212000101008091 +:100990003209040000000000000012011001FF00F5 +:1009A0000008D016530702020000000104030904E6 +:1009B00011241FBECFE5D1E0CDBFDEBF20E0A0E611 +:1009C000B0E001C01D92AC38B207E1F7BFC1A82F5B +:1009D000B92F80E090E041E050EA609530E009C036 +:1009E0002D9182279795879510F084279527305E63 +:1009F000C8F36F5FA8F30895EADF8D939D93089580 +:100A0000CF93CFB7CF93C395B39BE9F7B39B0BC0FD +:100A1000B39B09C0B39B07C0B39B05C0B39B03C086 +:100A2000B39B01C0D9C00F92DF93C0916E00DD2748 +:100A3000CA58DF4F012EB39B03C0DF910F90E6CF62 +:100A40002F930F931F934F932FEF4F6F06B303FB1B +:100A500020F95F933F9350E03BE065C016B3012659 +:100A6000502953FDC89556B3012703FB25F92F7371 +:100A700006B3B1F05027102713FB26F906B2223037 +:100A8000F0F000C016B3012703FB27F90126502917 +:100A900006B22430E8F54F77206816B30000F6CF91 +:100AA00050274F7D206206B2102F000000C006B311 +:100AB00000265029102713FB26F906B2E2CF4F7B00 +:100AC00006B3206400C0DACF01265029187106B29F +:100AD00069F14E7F2160012F16B328C000265029EE +:100AE0004D7F06B22260102F29C0012650294B7F6E +:100AF00006B22460012F2DC016B301265029477F6E +:100B00002860000006B22EC04F7E06B3206130C0C0 +:100B1000422706B3499300265029102706B24FEF0B +:100B200013FB20F9297F16B379F2187159F10126C8 +:100B3000502906B2012703FB21F9237F06B371F286 +:100B4000002650293150D0F006B2102713FB22F9AD +:100B5000277E16B351F201265029012703FB06B266 +:100B600023F92F7C49F2000006B3102713FB24F968 +:100B70000026502906B22F7939F270CF10E21ABF41 +:100B800000271DC03B503195C31BD04010E21ABF57 +:100B90000881033C29F10B3419F120916C00198173 +:100BA000110F1213EDCF093651F10D3211F0013E44 +:100BB00039F7CAE01AB715FD02C0CA95D9F70093F4 +:100BC00074003F915F914F911F910F912F91DF9191 +:100BD0000F90CAB7C5FD17CFCF91CFBFCF91089562 +:100BE00020917400222369F3109172001123F1F413 +:100BF0003430F2F03093720020936D0019C00091F0 +:100C0000720001309CF40AE530916F0034FD11C090 +:100C100000936F00C1E6D0E010C0052710E000C0CF +:100C200021C0052710E0C89508BB14C03AE501C0F3 +:100C300032ED032EC0E0D0E032E017B31861C39A62 +:100C400008B317BB58E120E84FEF20FF052708BB8A +:100C5000279517951C3F28F700004552B0F720FF55 +:100C60000527279508BB17951C3FB8F629913A959B +:100C700061F7077E10917300110F08BBC250D0407E +:100C800011F010936C0010E21ABF086017B3177EC2 +:100C9000402F477E54E05A95F1F708BB17BB48BB7D +:100CA00090CF2FEFB0E8A0E04AE0B1BF000081EEA6 +:100CB0009CE0B399FECFB39BFECF0197B399FDCFD4 +:100CC00097FF03C0BA1B819501C0BA0FA69539F4EE +:100CD000A0E428F4281710F031B7282FA1E04150E4 +:100CE00021F731BF00000895F201309741F02AE763 +:100CF000421629E0520629F481B790E002C08FEB3A +:100D000094EC21E00C0120935700E8951124CF01C9 +:100D100002962C01089514BE88E181BD87E081BD53 +:100D2000BB9A2FE28BE19FE0215080409040E1F799 +:100D300000C00000BB988AE580936F008FEF80931E +:100D40006000AC9A8BB780628BBF0895EAE7F9E048 +:100D5000E491EF3F11F0E1BF0000DDDF712C312C99 +:100D6000412C512C14E6CCE7D5E186B3887109F00B +:100D700014E6115029F41092730010926C0091DF68 +:100D80000AB605FE05C03CDE80E28ABF712C03C0B6 +:100D90002197209751F7A89522E032120CC0E0E885 +:100DA000F9E0E054F10983E080935700E89530972B +:100DB000C1F7412C512C832D803459F4F201329724 +:100DC000E03889E0F80750F485E080935700E89513 +:100DD00005C0843019F4CD2B11F4E9C0312C809179 +:100DE0007200835087FD98C090916D009D3209F08C +:100DF00091C0883009F08EC083EC809361008AE551 +:100E000080936F009091770090768091780099237D +:100E100061F1811108C082E899E09093710080939C +:100E2000700026E06CC0813059F44114510409F47B +:100E30004CC080917B00807C482E50907C0045C047 +:100E4000833081F48091790090917A004DDF809118 +:100E50007B0090917C0048DF842D8F73B1F580E496 +:100E6000382E33C08F73382E30C090917900109295 +:100E70006A00811106C010926B008AE690E022E0C1 +:100E80003AC0853019F49093730027C08630F9F486 +:100E900080917A00813019F48AE999E004C08230A7 +:100EA00041F488E899E0909371008093700022E10A +:100EB00026C0833051F4911108C08CEA99E09093D8 +:100EC00071008093700024E01AC020E018C08830C0 +:100ED00079F0893031F4909375008AE690E020E053 +:100EE0000AC021E08A3009F020E08AE690E003C0E1 +:100EF00085E790E021E090937100809370008091ED +:100F00007E00811105C080917D00821708F4282F92 +:100F1000209360001092720080916F0084FF31C0B6 +:100F2000809160008F3F69F1C82F893008F0C8E0D8 +:100F30008C1B809360008091610098E889278093E2 +:100F40006100CC2391F0E0917000F091710082E695 +:100F500090E0DC0124912D9331962C2F280F2A1339 +:100F6000F9CFF0937100E09370006C2F82E690E06F +:100F700043DDCC5FCC3019F08FEF80936000C093DD +:100F80006F00C30101963C01803B944029F4EDE7DA +:100F9000F9E0E491EF3F59F40AB605FEE3CE8DE1A6 +:100FA000B39B8DE18150E1F780E28ABFDBCEB3DEF7 +:080FB0001BBE15BAE3CCFFCF14 +:040000030000098070 +:00000001FF | 
