Compare commits
26 Commits
Author | SHA1 | Date |
---|---|---|
Olaf Rempel | 1509afc016 | |
Olaf Rempel | 751dfff780 | |
Olaf Rempel | 7c18de72f8 | |
Olaf Rempel | 2c2646b64f | |
Olaf Rempel | 5cc82b476b | |
Olaf Rempel | 31b7584b2f | |
Olaf Rempel | dcee58ebd2 | |
Olaf Rempel | 0cbb5686dc | |
Olaf Rempel | 93453d0aaa | |
Olaf Rempel | d1f7b638d1 | |
Olaf Rempel | f302c14c93 | |
Olaf Rempel | 9d7073387a | |
Olaf Rempel | 2dca010c7d | |
Olaf Rempel | 11b8928759 | |
Olaf Rempel | 70d5a20eb3 | |
Olaf Rempel | b253baf838 | |
Olaf Rempel | b29674a1f2 | |
Olaf Rempel | 570d07d3a0 | |
Olaf Rempel | c897637dc2 | |
Olaf Rempel | cb5d02f4ba | |
Olaf Rempel | 51182dbccb | |
Olaf Rempel | ba471f01de | |
Olaf Rempel | 919606b3ab | |
Olaf Rempel | 722e6d5d68 | |
Olaf Rempel | f2c227f428 | |
Olaf Rempel | f32c7e3131 |
|
@ -0,0 +1 @@
|
|||
<Project name="avrprog_boot"><File path="chipdef.h"></File><File path="main.c"></File><File path="makefile"></File><File path="mega128.h"></File><File path="mega128can.h"></File><File path="mega16.h"></File><File path="mega169.h"></File><File path="mega32.h"></File><File path="mega8.h"></File><File path="readme.txt"></File><File path="ldscripts_no_vector\avr5.x"></File><File path="main.lss"></File><File path="main.map"></File><File path="ldscripts_no_vector\avr4.x"></File><File path="mega162.h"></File><File path="mega644.h"></File><File path="mega644p.h"></File><File path="megaxx4p.h"></File><File path="mega324p.h"></File></Project>
|
|
@ -0,0 +1 @@
|
|||
<pd><ViewState><e p="avrprog_boot" x="true"></e></ViewState></pd>
|
|
@ -1,81 +0,0 @@
|
|||
:103800000C942A1C0C94451C0C94451C0C94451CCF
|
||||
:103810000C94451C0C94451C0C94451C0C94451CA4
|
||||
:103820000C94451C0C94451C0C94451C0C94451C94
|
||||
:103830000C94451C0C94451C0C94451C0C94451C84
|
||||
:103840000C94451C0C94451C0C94451C0C94451C74
|
||||
:103850000C94451C11241FBECFE5D4E0DEBFCDBFC4
|
||||
:1038600010E0A0E6B0E0E6EEFCE302C005900D92A9
|
||||
:10387000A036B107D9F710E0A0E6B0E001C01D9274
|
||||
:10388000A33EB107E1F70C945D1C0C94001C81E48D
|
||||
:103890000E94401E86E50E94401E82E50E94401E56
|
||||
:1038A00082E40E94401E8FE40E94401E8FE40E942A
|
||||
:1038B000401E84E50E94401E0895CFE5D4E0DEBF9F
|
||||
:1038C000CDBFC0E0D0E001E005BF82E085BF60E091
|
||||
:1038D0008BE090E00E94361E8FEF8BBBCF9B07C022
|
||||
:1038E0001BBA81E085BF15BEFE0109950FC00E947D
|
||||
:1038F000551E8B3141F40E94551E8335E1F70E941D
|
||||
:10390000471C00E003C08FE30E94401E002331F7F4
|
||||
:103910000E94551E682F813611F489E5C3C0813499
|
||||
:10392000A9F40E94551E99279093E1008093E0002E
|
||||
:10393000182F00270E94551E9927082B192B000FBE
|
||||
:10394000111F1093E1000093E00052C0823641F451
|
||||
:1039500089E50E94401E80E00E94401E80E8A2C0CF
|
||||
:10396000823489F40E94551E9927182F00270E943F
|
||||
:10397000551E9927082B192B0E94551E682FC80128
|
||||
:103980000E94551D8FC0873689F40E94551E9927C5
|
||||
:10399000182F00270E94551E9927082B192B0E94CB
|
||||
:1039A000551E682FC8010E94F41DB2CF853611F54F
|
||||
:1039B0008091E2008537C1F41092E1001092E0009E
|
||||
:1039C00020E030E083E0F90180935700E89507B6E6
|
||||
:1039D00000FCFDCF20583F4F88E32030380790F39C
|
||||
:1039E0003093E1002093E00081E180935700E89557
|
||||
:1039F0008DE058C0853451F488E190E028E00FB69E
|
||||
:103A0000F894A89581BD0FBE21BDF2CF803581F31A
|
||||
:103A10008C3471F3803711F483E544C0863421F48B
|
||||
:103A200069E080E090E005C0823731F469E081E030
|
||||
:103A300090E00E94691E36C08E3421F469E083E074
|
||||
:103A400090E0F7CF813569F1843729F485E70E944A
|
||||
:103A5000401E80E027C08857823018F40E94551E0F
|
||||
:103A6000C7CF643529F40E94551E8093E200C0CF71
|
||||
:103A7000633519F40E94471C4BCF663529F480E367
|
||||
:103A80000E94401E84E30EC0633741F483E00E942D
|
||||
:103A9000401E84E90E94401E8EE104C06B3109F48F
|
||||
:103AA00037CF8FE30E94401E33CFDF92EF92FF9219
|
||||
:103AB0000F931F93CF93DF938C01D62E60E070E0BD
|
||||
:103AC000EB01C05ADF4F7B010894E11CF11C601729
|
||||
:103AD000710718F40E94551E01C08FEF8883B7014B
|
||||
:103AE0006038710568F360E070E0C091E000D0914B
|
||||
:103AF000E1008CB399279C012270307081FDF9CFD1
|
||||
:103B00008091E200853709F066C0FFB6F89486E43C
|
||||
:103B1000D81609F03EC04091E0005091E100DB0171
|
||||
:103B2000A05ABF4F8D91282F33278D919927982F19
|
||||
:103B30008827282B392B6E5F7F4F81E00901FA011E
|
||||
:103B400080935700E89511244E5F5F4F025010405C
|
||||
:103B500049F75093E1004093E000C07885E0FE0112
|
||||
:103B600080935700E89507B600FCFDCF81E1809374
|
||||
:103B70005700E8958091E0009091E1009C01207849
|
||||
:103B80008217930731F020583F4F3093E100209384
|
||||
:103B9000E00085E4D816D9F4FB01E05AFF4F80918C
|
||||
:103BA000E0008EBB8091E0009091E100292F332747
|
||||
:103BB0002FBB01969093E1008093E00081918DBB33
|
||||
:103BC000E29AE19AE199FECF0150104041F7FFBE21
|
||||
:103BD0008DE090E001C0C901DF91CF911F910F915D
|
||||
:103BE000FF90EF90DF900895FF920F931F93CF9374
|
||||
:103BF000DF93EC01FFB6F894E199FECF6534B1F4A0
|
||||
:103C00008091E0008EBB8091E0009091E100292F2F
|
||||
:103C100033272FBB01969093E1008093E000E09A58
|
||||
:103C20008DB30E94401E219759F719C060E0809122
|
||||
:103C3000E0009091E1000E94691E8C010E94401EEC
|
||||
:103C4000812F99270E94401E8091E0009091E10011
|
||||
:103C500002969093E1008093E000229739F7FFBE2F
|
||||
:103C6000DF91CF911F910F91FF9008959C01832FB9
|
||||
:103C7000992780BD29B988E18AB986E880BD089571
|
||||
:103C800020E030E08CB90FB607FE0BC05E990BC088
|
||||
:103C90002F5F3F4F5E9907C087E220313807C4F39A
|
||||
:103CA00002C05E9BFECF5E9A089580E090E00FB662
|
||||
:103CB00007FE0AC05F990AC001965F9907C027E214
|
||||
:103CC00080319207CCF302C05F9BFECF8CB1992765
|
||||
:103CD0000895FC0160FD60935700C895802DE39521
|
||||
:063CE000C895902D089527
|
||||
:0400000300003800C1
|
||||
:00000001FF
|
|
@ -1,77 +0,0 @@
|
|||
:103800000C942A1C0C94451C0C94451C0C94451CCF
|
||||
:103810000C94451C0C94451C0C94451C0C94451CA4
|
||||
:103820000C94451C0C94451C0C94451C0C94451C94
|
||||
:103830000C94451C0C94451C0C94451C0C94451C84
|
||||
:103840000C94451C0C94451C0C94451C0C94451C74
|
||||
:103850000C94451C11241FBECFE5D4E0DEBFCDBFC4
|
||||
:1038600010E0A0E6B0E0EAEAFCE302C005900D92A9
|
||||
:10387000A036B107D9F710E0A0E6B0E001C01D9274
|
||||
:10388000A33EB107E1F70C945D1C0C94001C81E48D
|
||||
:103890000E94221E86E50E94221E82E50E94221EB0
|
||||
:1038A00082E40E94221E8FE40E94221E8FE40E9466
|
||||
:1038B000221E84E50E94221E0895CFE5D4E0DEBFDB
|
||||
:1038C000CDBF81E085BF82E085BF60E087E190E009
|
||||
:1038D0000E94181E0E94371E682F813611F489E558
|
||||
:1038E000C3C08134A9F40E94371E99279093E10048
|
||||
:1038F0008093E000182F00270E94371E9927082B7D
|
||||
:10390000192B000F111F1093E1000093E00052C02B
|
||||
:10391000823641F489E50E94221E80E00E94221E28
|
||||
:1039200080E8A2C0823489F40E94371E9927182F9C
|
||||
:1039300000270E94371E9927082B192B0E94371E3B
|
||||
:10394000682FC8010E94371D8FC0873689F40E94F6
|
||||
:10395000371E9927182F00270E94371E9927082BFA
|
||||
:10396000192B0E94371E682FC8010E94D61DB2CFA6
|
||||
:10397000853611F58091E2008537C1F41092E1009F
|
||||
:103980001092E00020E030E083E0F90180935700DE
|
||||
:10399000E89507B600FCFDCF20583F4F88E3203064
|
||||
:1039A000380790F33093E1002093E00081E18093A9
|
||||
:1039B0005700E8958DE058C0853451F488E190E0D7
|
||||
:1039C00028E00FB6F894A89581BD0FBE21BDF2CFB7
|
||||
:1039D000803581F38C3471F3803711F483E544C072
|
||||
:1039E000863421F469E080E090E005C0823731F44C
|
||||
:1039F00069E081E090E00E944B1E36C08E3421F4D5
|
||||
:103A000069E083E090E0F7CF813569F1843729F4EC
|
||||
:103A100085E70E94221E80E027C08857823018F474
|
||||
:103A20000E94371EC7CF643529F40E94371E809349
|
||||
:103A3000E200C0CF633519F40E94471C4BCF6635B6
|
||||
:103A400029F480E30E94221E84E30EC0633741F410
|
||||
:103A500083E00E94221E84E90E94221E8EE104C09F
|
||||
:103A60006B3109F437CF8FE30E94221E33CFDF92F0
|
||||
:103A7000EF92FF920F931F93CF93DF938C01D62E7B
|
||||
:103A800060E070E0EB01C05ADF4F7B010894E11C5D
|
||||
:103A9000F11C6017710718F40E94371E01C08FEFE8
|
||||
:103AA0008883B7016038710568F360E070E0C09109
|
||||
:103AB000E000D091E1008CB399279C012270307016
|
||||
:103AC00081FDF9CF8091E200853709F066C0FFB62D
|
||||
:103AD000F89486E4D81609F03EC04091E000509179
|
||||
:103AE000E100DB01A05ABF4F8D91282F33278D9124
|
||||
:103AF0009927982F8827282B392B6E5F7F4F81E0DD
|
||||
:103B00000901FA0180935700E89511244E5F5F4F39
|
||||
:103B10000250104049F75093E1004093E000C07814
|
||||
:103B200085E0FE0180935700E89507B600FCFDCFC5
|
||||
:103B300081E180935700E8958091E0009091E10049
|
||||
:103B40009C0120788217930731F020583F4F309323
|
||||
:103B5000E1002093E00085E4D816D9F4FB01E05A97
|
||||
:103B6000FF4F8091E0008EBB8091E0009091E100DA
|
||||
:103B7000292F33272FBB01969093E1008093E0001B
|
||||
:103B800081918DBBE29AE19AE199FECF01501040FC
|
||||
:103B900041F7FFBE8DE090E001C0C901DF91CF91F8
|
||||
:103BA0001F910F91FF90EF90DF900895FF920F9378
|
||||
:103BB0001F93CF93DF93EC01FFB6F894E199FECF0A
|
||||
:103BC0006534B1F48091E0008EBB8091E00090916B
|
||||
:103BD000E100292F33272FBB01969093E1008093BA
|
||||
:103BE000E000E09A8DB30E94221E219759F719C078
|
||||
:103BF00060E08091E0009091E1000E944B1E8C01FA
|
||||
:103C00000E94221E812F99270E94221E8091E0008F
|
||||
:103C10009091E10002969093E1008093E00022975A
|
||||
:103C200039F7FFBEDF91CF911F910F91FF9008955B
|
||||
:103C30009C01832F992780BD29B988E18AB986E83C
|
||||
:103C400080BD089520E030E08CB90FB607FE0BC0B0
|
||||
:103C50005E990BC02F5F3F4F5E9907C087E220310E
|
||||
:103C60003807C4F302C05E9BFECF5E9A089580E0E1
|
||||
:103C700090E00FB607FE0AC05F990AC001965F99EF
|
||||
:103C800007C027E280319207CCF302C05F9BFECFD2
|
||||
:103C90008CB199270895FC0160FD60935700C89589
|
||||
:0A3CA000802DE395C895902D08953E
|
||||
:0400000300003800C1
|
||||
:00000001FF
|
193
chipdef.h
193
chipdef.h
|
@ -1,134 +1,59 @@
|
|||
|
||||
#ifndef CHIPDEF_H
|
||||
#define CHIPDEF_H
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
// TODO: make use of RAMEND in the avr-libc io-files and
|
||||
// avoid a lot of by-device definitions here
|
||||
|
||||
#if defined(__AVR_ATmega169__)
|
||||
#define sig_byte3 0x1E
|
||||
#define sig_byte2 0x94
|
||||
#define sig_byte1 0x05
|
||||
|
||||
#define devtype 0x79 // Mega 169 device code
|
||||
|
||||
// #define PAGESIZE 128 // 2*64 Words = Size in Bytes
|
||||
|
||||
#ifdef _B128
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*128 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B256
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*256 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B512
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*512 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B1024
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*1024 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B2048
|
||||
#error "_B2048 not suppoted on this device"
|
||||
#endif
|
||||
|
||||
#elif defined(__AVR_ATmega16__)
|
||||
|
||||
#define sig_byte3 0x1E
|
||||
#define sig_byte2 0x94
|
||||
#define sig_byte1 0x03
|
||||
|
||||
#define devtype 0x75 // Mega16 device code
|
||||
|
||||
// #define PAGESIZE 128 // Size in Bytes
|
||||
|
||||
#ifdef _B128
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*128 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B256
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*256 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B512
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*512 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B1024
|
||||
#define APP_PAGES ((2*8192 / SPM_PAGESIZE)- (2*1024 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B2048
|
||||
#error "_B2048 not suppoted on this device"
|
||||
#endif
|
||||
|
||||
#elif defined(__AVR_ATmega8__)
|
||||
|
||||
#define sig_byte3 0x1E
|
||||
#define sig_byte2 0x93
|
||||
#define sig_byte1 0x07
|
||||
|
||||
#define devtype 0x77 // Mega8 boot device code
|
||||
|
||||
// #define PAGESIZE 64 // Size in Bytes
|
||||
|
||||
#ifdef _B128
|
||||
#define APP_PAGES ((2*4096 / SPM_PAGESIZE)- (2*128 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B256
|
||||
#define APP_PAGES ((2*4096 / SPM_PAGESIZE)- (2*256 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B512
|
||||
#define APP_PAGES ((2*4096 / SPM_PAGESIZE)- (2*512 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B1024
|
||||
#define APP_PAGES ((2*4096 / SPM_PAGESIZE)- (2*1024 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B2048
|
||||
#error "_B2048 not suppoted on this device"
|
||||
#endif
|
||||
|
||||
#elif defined(__AVR_ATmega32__)
|
||||
|
||||
#define sig_byte3 0x1E
|
||||
#define sig_byte2 0x95
|
||||
#define sig_byte1 0x02
|
||||
|
||||
#define devtype 0x73 // Mega32 device code
|
||||
|
||||
// #define PAGESIZE 128 // Size in Bytes
|
||||
|
||||
#ifdef _B128
|
||||
#define APP_PAGES ((2*16384 / SPM_PAGESIZE)- (2*128 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B256
|
||||
#define APP_PAGES ((2*16384 / SPM_PAGESIZE)- (2*256 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B512
|
||||
#define APP_PAGES ((2*16384 / SPM_PAGESIZE)- (2*512 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B1024
|
||||
#define APP_PAGES ((2*16384 / SPM_PAGESIZE)- (2*1024 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
#ifdef _B2048
|
||||
#define APP_PAGES ((2*16384 / SPM_PAGESIZE)- (2*2048 / SPM_PAGESIZE ))
|
||||
#define APP_END APP_PAGES * SPM_PAGESIZE
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "no definition for MCU available in chipdef.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef CHIPDEF_H
|
||||
#define CHIPDEF_H
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#if defined (SPMCSR)
|
||||
#define SPM_REG SPMCSR
|
||||
#elif defined (SPMCR)
|
||||
#define SPM_REG SPMCR
|
||||
#else
|
||||
#error "AVR processor does not provide bootloader support!"
|
||||
#endif
|
||||
|
||||
#define APP_END (FLASHEND - (BOOTSIZE * 2))
|
||||
|
||||
#if (SPM_PAGESIZE > UINT8_MAX)
|
||||
typedef uint16_t pagebuf_t;
|
||||
#else
|
||||
typedef uint8_t pagebuf_t;
|
||||
#endif
|
||||
|
||||
#if defined(__AVR_ATmega169__)
|
||||
#include "mega169.h"
|
||||
|
||||
#elif defined(__AVR_ATmega16__)
|
||||
#include "mega16.h"
|
||||
|
||||
#elif defined(__AVR_ATmega162__)
|
||||
#include "mega162.h"
|
||||
|
||||
#elif defined(__AVR_ATmega8__)
|
||||
#include "mega8.h"
|
||||
|
||||
#elif defined(__AVR_ATmega32__)
|
||||
#include "mega32.h"
|
||||
|
||||
#elif defined(__AVR_ATmega324P__)
|
||||
#include "mega324p.h"
|
||||
|
||||
#elif defined(__AVR_ATmega64__)
|
||||
#include "mega64.h"
|
||||
|
||||
#elif defined(__AVR_ATmega644__)
|
||||
#include "mega644.h"
|
||||
|
||||
#elif defined(__AVR_ATmega644P__)
|
||||
#include "mega644p.h"
|
||||
|
||||
#elif defined(__AVR_ATmega128__)
|
||||
#include "mega128.h"
|
||||
|
||||
#elif defined(__AVR_AT90CAN128__)
|
||||
#include "mega128can.h"
|
||||
|
||||
#else
|
||||
#error "no definition for MCU available in chipdef.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
/* Default linker script, for normal executables */
|
||||
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
|
||||
OUTPUT_ARCH(avr:1)
|
||||
MEMORY
|
||||
{
|
||||
text (rx) : ORIGIN = 0, LENGTH = 8K
|
||||
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0
|
||||
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rel.init : { *(.rel.init) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rel.text :
|
||||
{
|
||||
*(.rel.text)
|
||||
*(.rel.text.*)
|
||||
*(.rel.gnu.linkonce.t*)
|
||||
}
|
||||
.rela.text :
|
||||
{
|
||||
*(.rela.text)
|
||||
*(.rela.text.*)
|
||||
*(.rela.gnu.linkonce.t*)
|
||||
}
|
||||
.rel.fini : { *(.rel.fini) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rel.rodata :
|
||||
{
|
||||
*(.rel.rodata)
|
||||
*(.rel.rodata.*)
|
||||
*(.rel.gnu.linkonce.r*)
|
||||
}
|
||||
.rela.rodata :
|
||||
{
|
||||
*(.rela.rodata)
|
||||
*(.rela.rodata.*)
|
||||
*(.rela.gnu.linkonce.r*)
|
||||
}
|
||||
.rel.data :
|
||||
{
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.gnu.linkonce.d*)
|
||||
}
|
||||
.rela.data :
|
||||
{
|
||||
*(.rela.data)
|
||||
*(.rela.data.*)
|
||||
*(.rela.gnu.linkonce.d*)
|
||||
}
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
/* Internal text space or external memory */
|
||||
/DISCARD/ : { *(.vectors); }
|
||||
.text :
|
||||
{
|
||||
/* *(.vectors) */
|
||||
__ctors_start = . ;
|
||||
*(.ctors)
|
||||
__ctors_end = . ;
|
||||
__dtors_start = . ;
|
||||
*(.dtors)
|
||||
__dtors_end = . ;
|
||||
*(.progmem.gcc*)
|
||||
*(.progmem*)
|
||||
. = ALIGN(2);
|
||||
*(.init0) /* Start here after reset. */
|
||||
*(.init1)
|
||||
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
|
||||
*(.init3)
|
||||
*(.init4) /* Initialize data and BSS. */
|
||||
*(.init5)
|
||||
*(.init6) /* C++ constructors. */
|
||||
*(.init7)
|
||||
*(.init8)
|
||||
*(.init9) /* Call main(). */
|
||||
*(.text)
|
||||
. = ALIGN(2);
|
||||
*(.text.*)
|
||||
. = ALIGN(2);
|
||||
*(.fini9) /* _exit() starts here. */
|
||||
*(.fini8)
|
||||
*(.fini7)
|
||||
*(.fini6) /* C++ destructors. */
|
||||
*(.fini5)
|
||||
*(.fini4)
|
||||
*(.fini3)
|
||||
*(.fini2)
|
||||
*(.fini1)
|
||||
*(.fini0) /* Infinite loop after program termination. */
|
||||
_etext = . ;
|
||||
} > text
|
||||
.data : AT (ADDR (.text) + SIZEOF (.text))
|
||||
{
|
||||
PROVIDE (__data_start = .) ;
|
||||
*(.data)
|
||||
*(.gnu.linkonce.d*)
|
||||
. = ALIGN(2);
|
||||
_edata = . ;
|
||||
PROVIDE (__data_end = .) ;
|
||||
} > data
|
||||
.bss SIZEOF(.data) + ADDR(.data) :
|
||||
{
|
||||
PROVIDE (__bss_start = .) ;
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
PROVIDE (__bss_end = .) ;
|
||||
} > data
|
||||
__data_load_start = LOADADDR(.data);
|
||||
__data_load_end = __data_load_start + SIZEOF(.data);
|
||||
/* Global data not cleared after reset. */
|
||||
.noinit SIZEOF(.bss) + ADDR(.bss) :
|
||||
{
|
||||
PROVIDE (__noinit_start = .) ;
|
||||
*(.noinit*)
|
||||
PROVIDE (__noinit_end = .) ;
|
||||
_end = . ;
|
||||
PROVIDE (__heap_start = .) ;
|
||||
} > data
|
||||
.eeprom :
|
||||
{
|
||||
*(.eeprom*)
|
||||
__eeprom_end = . ;
|
||||
} > eeprom
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/* Default linker script, for normal executables */
|
||||
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
|
||||
OUTPUT_ARCH(avr:2)
|
||||
MEMORY
|
||||
{
|
||||
text (rx) : ORIGIN = 0, LENGTH = 8K
|
||||
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
|
||||
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rel.init : { *(.rel.init) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rel.text :
|
||||
{
|
||||
*(.rel.text)
|
||||
*(.rel.text.*)
|
||||
*(.rel.gnu.linkonce.t*)
|
||||
}
|
||||
.rela.text :
|
||||
{
|
||||
*(.rela.text)
|
||||
*(.rela.text.*)
|
||||
*(.rela.gnu.linkonce.t*)
|
||||
}
|
||||
.rel.fini : { *(.rel.fini) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rel.rodata :
|
||||
{
|
||||
*(.rel.rodata)
|
||||
*(.rel.rodata.*)
|
||||
*(.rel.gnu.linkonce.r*)
|
||||
}
|
||||
.rela.rodata :
|
||||
{
|
||||
*(.rela.rodata)
|
||||
*(.rela.rodata.*)
|
||||
*(.rela.gnu.linkonce.r*)
|
||||
}
|
||||
.rel.data :
|
||||
{
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.gnu.linkonce.d*)
|
||||
}
|
||||
.rela.data :
|
||||
{
|
||||
*(.rela.data)
|
||||
*(.rela.data.*)
|
||||
*(.rela.gnu.linkonce.d*)
|
||||
}
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
/* Internal text space or external memory */
|
||||
/DISCARD/ : { *(.vectors); }
|
||||
.text :
|
||||
{
|
||||
/* *(.vectors) */
|
||||
__ctors_start = . ;
|
||||
*(.ctors)
|
||||
__ctors_end = . ;
|
||||
__dtors_start = . ;
|
||||
*(.dtors)
|
||||
__dtors_end = . ;
|
||||
*(.progmem.gcc*)
|
||||
*(.progmem*)
|
||||
. = ALIGN(2);
|
||||
*(.init0) /* Start here after reset. */
|
||||
*(.init1)
|
||||
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
|
||||
*(.init3)
|
||||
*(.init4) /* Initialize data and BSS. */
|
||||
*(.init5)
|
||||
*(.init6) /* C++ constructors. */
|
||||
*(.init7)
|
||||
*(.init8)
|
||||
*(.init9) /* Call main(). */
|
||||
*(.text)
|
||||
. = ALIGN(2);
|
||||
*(.text.*)
|
||||
. = ALIGN(2);
|
||||
*(.fini9) /* _exit() starts here. */
|
||||
*(.fini8)
|
||||
*(.fini7)
|
||||
*(.fini6) /* C++ destructors. */
|
||||
*(.fini5)
|
||||
*(.fini4)
|
||||
*(.fini3)
|
||||
*(.fini2)
|
||||
*(.fini1)
|
||||
*(.fini0) /* Infinite loop after program termination. */
|
||||
_etext = . ;
|
||||
} > text
|
||||
.data : AT (ADDR (.text) + SIZEOF (.text))
|
||||
{
|
||||
PROVIDE (__data_start = .) ;
|
||||
*(.data)
|
||||
*(.gnu.linkonce.d*)
|
||||
. = ALIGN(2);
|
||||
_edata = . ;
|
||||
PROVIDE (__data_end = .) ;
|
||||
} > data
|
||||
.bss SIZEOF(.data) + ADDR(.data) :
|
||||
{
|
||||
PROVIDE (__bss_start = .) ;
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
PROVIDE (__bss_end = .) ;
|
||||
} > data
|
||||
__data_load_start = LOADADDR(.data);
|
||||
__data_load_end = __data_load_start + SIZEOF(.data);
|
||||
/* Global data not cleared after reset. */
|
||||
.noinit SIZEOF(.bss) + ADDR(.bss) :
|
||||
{
|
||||
PROVIDE (__noinit_start = .) ;
|
||||
*(.noinit*)
|
||||
PROVIDE (__noinit_end = .) ;
|
||||
_end = . ;
|
||||
PROVIDE (__heap_start = .) ;
|
||||
} > data
|
||||
.eeprom :
|
||||
{
|
||||
*(.eeprom*)
|
||||
__eeprom_end = . ;
|
||||
} > eeprom
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/* Default linker script, for normal executables */
|
||||
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
|
||||
OUTPUT_ARCH(avr:3)
|
||||
MEMORY
|
||||
{
|
||||
text (rx) : ORIGIN = 0, LENGTH = 128K
|
||||
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
|
||||
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rel.init : { *(.rel.init) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rel.text :
|
||||
{
|
||||
*(.rel.text)
|
||||
*(.rel.text.*)
|
||||
*(.rel.gnu.linkonce.t*)
|
||||
}
|
||||
.rela.text :
|
||||
{
|
||||
*(.rela.text)
|
||||
*(.rela.text.*)
|
||||
*(.rela.gnu.linkonce.t*)
|
||||
}
|
||||
.rel.fini : { *(.rel.fini) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rel.rodata :
|
||||
{
|
||||
*(.rel.rodata)
|
||||
*(.rel.rodata.*)
|
||||
*(.rel.gnu.linkonce.r*)
|
||||
}
|
||||
.rela.rodata :
|
||||
{
|
||||
*(.rela.rodata)
|
||||
*(.rela.rodata.*)
|
||||
*(.rela.gnu.linkonce.r*)
|
||||
}
|
||||
.rel.data :
|
||||
{
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.gnu.linkonce.d*)
|
||||
}
|
||||
.rela.data :
|
||||
{
|
||||
*(.rela.data)
|
||||
*(.rela.data.*)
|
||||
*(.rela.gnu.linkonce.d*)
|
||||
}
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
/* Internal text space or external memory */
|
||||
/DISCARD/ : { *(.vectors); }
|
||||
.text :
|
||||
{
|
||||
/* *(.vectors) */
|
||||
__ctors_start = . ;
|
||||
*(.ctors)
|
||||
__ctors_end = . ;
|
||||
__dtors_start = . ;
|
||||
*(.dtors)
|
||||
__dtors_end = . ;
|
||||
*(.progmem.gcc*)
|
||||
*(.progmem*)
|
||||
. = ALIGN(2);
|
||||
*(.init0) /* Start here after reset. */
|
||||
*(.init1)
|
||||
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
|
||||
*(.init3)
|
||||
*(.init4) /* Initialize data and BSS. */
|
||||
*(.init5)
|
||||
*(.init6) /* C++ constructors. */
|
||||
*(.init7)
|
||||
*(.init8)
|
||||
*(.init9) /* Call main(). */
|
||||
*(.text)
|
||||
. = ALIGN(2);
|
||||
*(.text.*)
|
||||
. = ALIGN(2);
|
||||
*(.fini9) /* _exit() starts here. */
|
||||
*(.fini8)
|
||||
*(.fini7)
|
||||
*(.fini6) /* C++ destructors. */
|
||||
*(.fini5)
|
||||
*(.fini4)
|
||||
*(.fini3)
|
||||
*(.fini2)
|
||||
*(.fini1)
|
||||
*(.fini0) /* Infinite loop after program termination. */
|
||||
_etext = . ;
|
||||
} > text
|
||||
.data : AT (ADDR (.text) + SIZEOF (.text))
|
||||
{
|
||||
PROVIDE (__data_start = .) ;
|
||||
*(.data)
|
||||
*(.gnu.linkonce.d*)
|
||||
. = ALIGN(2);
|
||||
_edata = . ;
|
||||
PROVIDE (__data_end = .) ;
|
||||
} > data
|
||||
.bss SIZEOF(.data) + ADDR(.data) :
|
||||
{
|
||||
PROVIDE (__bss_start = .) ;
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
PROVIDE (__bss_end = .) ;
|
||||
} > data
|
||||
__data_load_start = LOADADDR(.data);
|
||||
__data_load_end = __data_load_start + SIZEOF(.data);
|
||||
/* Global data not cleared after reset. */
|
||||
.noinit SIZEOF(.bss) + ADDR(.bss) :
|
||||
{
|
||||
PROVIDE (__noinit_start = .) ;
|
||||
*(.noinit*)
|
||||
PROVIDE (__noinit_end = .) ;
|
||||
_end = . ;
|
||||
PROVIDE (__heap_start = .) ;
|
||||
} > data
|
||||
.eeprom :
|
||||
{
|
||||
*(.eeprom*)
|
||||
__eeprom_end = . ;
|
||||
} > eeprom
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/* MODIFIED LINKER SCRIPT - BOOTLOADER: without .vectors */
|
||||
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
|
||||
OUTPUT_ARCH(avr:4)
|
||||
MEMORY
|
||||
{
|
||||
text (rx) : ORIGIN = 0, LENGTH = 8K
|
||||
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
|
||||
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rel.init : { *(.rel.init) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rel.text :
|
||||
{
|
||||
*(.rel.text)
|
||||
*(.rel.text.*)
|
||||
*(.rel.gnu.linkonce.t*)
|
||||
}
|
||||
.rela.text :
|
||||
{
|
||||
*(.rela.text)
|
||||
*(.rela.text.*)
|
||||
*(.rela.gnu.linkonce.t*)
|
||||
}
|
||||
.rel.fini : { *(.rel.fini) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rel.rodata :
|
||||
{
|
||||
*(.rel.rodata)
|
||||
*(.rel.rodata.*)
|
||||
*(.rel.gnu.linkonce.r*)
|
||||
}
|
||||
.rela.rodata :
|
||||
{
|
||||
*(.rela.rodata)
|
||||
*(.rela.rodata.*)
|
||||
*(.rela.gnu.linkonce.r*)
|
||||
}
|
||||
.rel.data :
|
||||
{
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.gnu.linkonce.d*)
|
||||
}
|
||||
.rela.data :
|
||||
{
|
||||
*(.rela.data)
|
||||
*(.rela.data.*)
|
||||
*(.rela.gnu.linkonce.d*)
|
||||
}
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
/* Internal text space or external memory */
|
||||
/DISCARD/ : { *(.vectors); }
|
||||
.text :
|
||||
{
|
||||
/* *(.vectors) */
|
||||
__ctors_start = . ;
|
||||
*(.ctors)
|
||||
__ctors_end = . ;
|
||||
__dtors_start = . ;
|
||||
*(.dtors)
|
||||
__dtors_end = . ;
|
||||
*(.progmem.gcc*)
|
||||
*(.progmem*)
|
||||
. = ALIGN(2);
|
||||
*(.init0) /* Start here after reset. */
|
||||
*(.init1)
|
||||
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
|
||||
*(.init3)
|
||||
*(.init4) /* Initialize data and BSS. */
|
||||
*(.init5)
|
||||
*(.init6) /* C++ constructors. */
|
||||
*(.init7)
|
||||
*(.init8)
|
||||
*(.init9) /* Call main(). */
|
||||
*(.text)
|
||||
. = ALIGN(2);
|
||||
*(.text.*)
|
||||
. = ALIGN(2);
|
||||
*(.fini9) /* _exit() starts here. */
|
||||
*(.fini8)
|
||||
*(.fini7)
|
||||
*(.fini6) /* C++ destructors. */
|
||||
*(.fini5)
|
||||
*(.fini4)
|
||||
*(.fini3)
|
||||
*(.fini2)
|
||||
*(.fini1)
|
||||
*(.fini0) /* Infinite loop after program termination. */
|
||||
_etext = . ;
|
||||
} > text
|
||||
.data : AT (ADDR (.text) + SIZEOF (.text))
|
||||
{
|
||||
PROVIDE (__data_start = .) ;
|
||||
*(.data)
|
||||
*(.gnu.linkonce.d*)
|
||||
. = ALIGN(2);
|
||||
_edata = . ;
|
||||
PROVIDE (__data_end = .) ;
|
||||
} > data
|
||||
.bss SIZEOF(.data) + ADDR(.data) :
|
||||
{
|
||||
PROVIDE (__bss_start = .) ;
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
PROVIDE (__bss_end = .) ;
|
||||
} > data
|
||||
__data_load_start = LOADADDR(.data);
|
||||
__data_load_end = __data_load_start + SIZEOF(.data);
|
||||
/* Global data not cleared after reset. */
|
||||
.noinit SIZEOF(.bss) + ADDR(.bss) :
|
||||
{
|
||||
PROVIDE (__noinit_start = .) ;
|
||||
*(.noinit*)
|
||||
PROVIDE (__noinit_end = .) ;
|
||||
_end = . ;
|
||||
PROVIDE (__heap_start = .) ;
|
||||
} > data
|
||||
.eeprom :
|
||||
{
|
||||
*(.eeprom*)
|
||||
__eeprom_end = . ;
|
||||
} > eeprom
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
/* MODIFIED LINKER SCRIPT - BOOTLOADER: without .vectors */
|
||||
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
|
||||
OUTPUT_ARCH(avr:5)
|
||||
MEMORY
|
||||
{
|
||||
text (rx) : ORIGIN = 0, LENGTH = 128K
|
||||
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
|
||||
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rel.init : { *(.rel.init) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rel.text :
|
||||
{
|
||||
*(.rel.text)
|
||||
*(.rel.text.*)
|
||||
*(.rel.gnu.linkonce.t*)
|
||||
}
|
||||
.rela.text :
|
||||
{
|
||||
*(.rela.text)
|
||||
*(.rela.text.*)
|
||||
*(.rela.gnu.linkonce.t*)
|
||||
}
|
||||
.rel.fini : { *(.rel.fini) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rel.rodata :
|
||||
{
|
||||
*(.rel.rodata)
|
||||
*(.rel.rodata.*)
|
||||
*(.rel.gnu.linkonce.r*)
|
||||
}
|
||||
.rela.rodata :
|
||||
{
|
||||
*(.rela.rodata)
|
||||
*(.rela.rodata.*)
|
||||
*(.rela.gnu.linkonce.r*)
|
||||
}
|
||||
.rel.data :
|
||||
{
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.gnu.linkonce.d*)
|
||||
}
|
||||
.rela.data :
|
||||
{
|
||||
*(.rela.data)
|
||||
*(.rela.data.*)
|
||||
*(.rela.gnu.linkonce.d*)
|
||||
}
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
|
||||
/* Internal text space or external memory */
|
||||
|
||||
/* BOOTLOADER-MODIFICATION - not interrupt-vectors */
|
||||
/DISCARD/ : { *(.vectors) }
|
||||
.text :
|
||||
{
|
||||
/* *(.vectors) */ /* BOOTLOADER-MODIFICATION ! */
|
||||
__ctors_start = . ;
|
||||
*(.ctors)
|
||||
__ctors_end = . ;
|
||||
__dtors_start = . ;
|
||||
*(.dtors)
|
||||
__dtors_end = . ;
|
||||
*(.progmem.gcc*)
|
||||
*(.progmem*)
|
||||
. = ALIGN(2);
|
||||
*(.init0) /* Start here after reset. */
|
||||
*(.init1)
|
||||
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
|
||||
*(.init3)
|
||||
*(.init4) /* Initialize data and BSS. */
|
||||
*(.init5)
|
||||
*(.init6) /* C++ constructors. */
|
||||
*(.init7)
|
||||
*(.init8)
|
||||
*(.init9) /* Call main(). */
|
||||
*(.text)
|
||||
. = ALIGN(2);
|
||||
*(.text.*)
|
||||
. = ALIGN(2);
|
||||
*(.fini9) /* _exit() starts here. */
|
||||
*(.fini8)
|
||||
*(.fini7)
|
||||
*(.fini6) /* C++ destructors. */
|
||||
*(.fini5)
|
||||
*(.fini4)
|
||||
*(.fini3)
|
||||
*(.fini2)
|
||||
*(.fini1)
|
||||
*(.fini0) /* Infinite loop after program termination. */
|
||||
_etext = . ;
|
||||
} > text
|
||||
.data : AT (ADDR (.text) + SIZEOF (.text))
|
||||
{
|
||||
PROVIDE (__data_start = .) ;
|
||||
*(.data)
|
||||
*(.gnu.linkonce.d*)
|
||||
. = ALIGN(2);
|
||||
_edata = . ;
|
||||
PROVIDE (__data_end = .) ;
|
||||
} > data
|
||||
.bss SIZEOF(.data) + ADDR(.data) :
|
||||
{
|
||||
PROVIDE (__bss_start = .) ;
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
PROVIDE (__bss_end = .) ;
|
||||
} > data
|
||||
__data_load_start = LOADADDR(.data);
|
||||
__data_load_end = __data_load_start + SIZEOF(.data);
|
||||
/* Global data not cleared after reset. */
|
||||
.noinit SIZEOF(.bss) + ADDR(.bss) :
|
||||
{
|
||||
PROVIDE (__noinit_start = .) ;
|
||||
*(.noinit*)
|
||||
PROVIDE (__noinit_end = .) ;
|
||||
_end = . ;
|
||||
PROVIDE (__heap_start = .) ;
|
||||
} > data
|
||||
.eeprom :
|
||||
{
|
||||
*(.eeprom*)
|
||||
__eeprom_end = . ;
|
||||
} > eeprom
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
}
|
44
lowlevel.c
44
lowlevel.c
|
@ -1,44 +0,0 @@
|
|||
//
|
||||
// Low-level bootloader routines to replace "assembly.s90"
|
||||
// from the original ATMEL Butterfly bootloader code
|
||||
// which are not included in avr-libc's boot.h by the
|
||||
// time of writing this.
|
||||
//
|
||||
// 3/2004 Martin Thomas, Kaiserslautern, Germany
|
||||
//
|
||||
|
||||
#include "lowlevel.h"
|
||||
|
||||
unsigned int read_program_memory(unsigned int adr, unsigned char param)
|
||||
// to read lockbits give param=0x09, if param!=0 it is written to SPMCSR
|
||||
// this is a "translation" from the original code to gcc-inline-assembler
|
||||
{
|
||||
unsigned int retval;
|
||||
|
||||
asm volatile
|
||||
(
|
||||
"movw r30, %3\n\t"
|
||||
"sbrc %2,0x00\n\t"
|
||||
"sts %0, %2\n\t"
|
||||
#ifdef LARGE_MEMORY // If large memory (>64K) ELPM is needed to use RAMPZ
|
||||
"elpm\n\t" // read LSB
|
||||
#else
|
||||
"lpm\n\t" // R0 is now the LSB of the return value
|
||||
#endif
|
||||
"mov %A1,r0\n\t"
|
||||
"inc r30\n\t"
|
||||
#ifdef LARGE_MEMORY // If large memory (>64K) ELPM is needed to use RAMPZ
|
||||
"elpm\n\t" // read MSB
|
||||
#else
|
||||
"lpm\n\t" // R0 is now the MSB of the return value
|
||||
#endif
|
||||
"mov %B1,r0\n\t"
|
||||
: "=m" (SPM_REG),
|
||||
"=r" (retval)
|
||||
: "r" ((unsigned char)param),
|
||||
"r" ((unsigned short)adr)
|
||||
: "r30", "r31", "r0"
|
||||
);
|
||||
return retval;
|
||||
}
|
||||
|
18
lowlevel.h
18
lowlevel.h
|
@ -1,18 +0,0 @@
|
|||
#ifndef LOWLEVEL_H
|
||||
#define LOWLEVEL_H
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
/* Check for SPM Control Register in processor. */
|
||||
#if defined (SPMCSR)
|
||||
# define SPM_REG SPMCSR
|
||||
#elif defined (SPMCR)
|
||||
# define SPM_REG SPMCR
|
||||
#else
|
||||
# error AVR processor does not provide bootloader support!
|
||||
#endif
|
||||
|
||||
unsigned int read_program_memory (unsigned int,unsigned char);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef _MEGA128_H_
|
||||
#define _MEGA128_H_
|
||||
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x43
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x44
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x97
|
||||
#define SIG_BYTE3 0x02
|
||||
|
||||
#ifndef UART_USE_SECOND
|
||||
#define UART_BAUD_HIGH UBRR0H
|
||||
#define UART_BAUD_LOW UBRR0L
|
||||
#define UART_STATUS UCSR0A
|
||||
#define UART_TXREADY UDRE0
|
||||
#define UART_RXREADY RXC0
|
||||
#define UART_DOUBLE U2X0
|
||||
#define UART_CTRL UCSR0B
|
||||
#define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
|
||||
#define UART_CTRL2 UCSR0C
|
||||
#define UART_CTRL2_DATA ((1<<UCSZ01) | (1<<UCSZ00))
|
||||
#define UART_DATA UDR0
|
||||
#else
|
||||
#define UART_BAUD_HIGH UBRR1H
|
||||
#define UART_BAUD_LOW UBRR1L
|
||||
#define UART_STATUS UCSR1A
|
||||
#define UART_TXREADY UDRE1
|
||||
#define UART_RXREADY RXC1
|
||||
#define UART_DOUBLE U2X1
|
||||
#define UART_CTRL UCSR1B
|
||||
#define UART_CTRL_DATA ((1<<TXEN1) | (1<<RXEN1))
|
||||
#define UART_CTRL2 UCSR1C
|
||||
#define UART_CTRL2_DATA ((1<<UCSZ11) | (1<<UCSZ10))
|
||||
#define UART_DATA UDR1
|
||||
#endif
|
||||
|
||||
#endif // #ifndef _MEGA128_H_
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef _MEGA128CAN_H_
|
||||
#define _MEGA128CAN_H_
|
||||
|
||||
/* Dummy: use ATmega128 device-code for now,
|
||||
must be same as used in avrdude.conf */
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x43
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x44
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x97
|
||||
#define SIG_BYTE3 0x81
|
||||
|
||||
|
||||
#ifndef UART_USE_SECOND
|
||||
#define UART_BAUD_HIGH UBRR0H
|
||||
#define UART_BAUD_LOW UBRR0L
|
||||
#define UART_STATUS UCSR0A
|
||||
#define UART_TXREADY UDRE0
|
||||
#define UART_RXREADY RXC0
|
||||
#define UART_DOUBLE U2X0
|
||||
#define UART_CTRL UCSR0B
|
||||
#define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
|
||||
#define UART_CTRL2 UCSR0C
|
||||
#define UART_CTRL2_DATA ((1<<UCSZ01) | (1<<UCSZ00))
|
||||
#define UART_DATA UDR0
|
||||
#else
|
||||
#define UART_BAUD_HIGH UBRR1H
|
||||
#define UART_BAUD_LOW UBRR1L
|
||||
#define UART_STATUS UCSR1A
|
||||
#define UART_TXREADY UDRE1
|
||||
#define UART_RXREADY RXC1
|
||||
#define UART_DOUBLE U2X1
|
||||
#define UART_CTRL UCSR1B
|
||||
#define UART_CTRL_DATA ((1<<TXEN1) | (1<<RXEN1))
|
||||
#define UART_CTRL2 UCSR1C
|
||||
#define UART_CTRL2_DATA ((1<<UCSZ11) | (1<<UCSZ10))
|
||||
#define UART_DATA UDR1
|
||||
#endif
|
||||
|
||||
#endif // #ifndef _MEGA128CAN_H_
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef _MEGA16_H_
|
||||
#define _MEGA16_H_
|
||||
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x74
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x75
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x94
|
||||
#define SIG_BYTE3 0x03
|
||||
|
||||
#define UART_BAUD_HIGH UBRRH
|
||||
#define UART_BAUD_LOW UBRRL
|
||||
#define UART_STATUS UCSRA
|
||||
#define UART_TXREADY UDRE
|
||||
#define UART_RXREADY RXC
|
||||
#define UART_DOUBLE U2X
|
||||
#define UART_CTRL UCSRB
|
||||
#define UART_CTRL_DATA ((1<<TXEN) | (1<<RXEN))
|
||||
#define UART_CTRL2 UCSRC
|
||||
#define UART_CTRL2_DATA ((1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0))
|
||||
#define UART_DATA UDR
|
||||
|
||||
#endif // #ifndef _MEGA16_H_
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef _MEGA162_H_
|
||||
#define _MEGA162_H_
|
||||
|
||||
/* Part-Code ISP */
|
||||
// documented code (AVR109 AppNote) but not supported by AVRProg 1.40
|
||||
// #define DEVTYPE_ISP 0x62
|
||||
// fake ATmega16 instead:
|
||||
#define DEVTYPE_ISP 0x74
|
||||
/* Part-Code Boot */
|
||||
// documented code but not supported by AVRProg 1.40
|
||||
// #define DEVTYPE_BOOT 0x63
|
||||
// fake ATmega16:
|
||||
#define DEVTYPE_BOOT 0x75
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x94
|
||||
#define SIG_BYTE3 0x04
|
||||
|
||||
#ifndef UART_USE_SECOND
|
||||
#define UART_BAUD_HIGH UBRR0H
|
||||
#define UART_BAUD_LOW UBRR0L
|
||||
#define UART_STATUS UCSR0A
|
||||
#define UART_TXREADY UDRE0
|
||||
#define UART_RXREADY RXC0
|
||||
#define UART_DOUBLE U2X0
|
||||
#define UART_CTRL UCSR0B
|
||||
#define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
|
||||
#define UART_CTRL2 UCSR0C
|
||||
#define UART_CTRL2_DATA ((1<<URSEL0) | (1<<UCSZ01) | (1<<UCSZ00))
|
||||
#define UART_DATA UDR0
|
||||
#else
|
||||
#define UART_BAUD_HIGH UBRR1H
|
||||
#define UART_BAUD_LOW UBRR1L
|
||||
#define UART_STATUS UCSR1A
|
||||
#define UART_TXREADY UDRE1
|
||||
#define UART_RXREADY RXC1
|
||||
#define UART_DOUBLE U2X1
|
||||
#define UART_CTRL UCSR1B
|
||||
#define UART_CTRL_DATA ((1<<TXEN1) | (1<<RXEN1))
|
||||
#define UART_CTRL2 UCSR1C
|
||||
#define UART_CTRL2_DATA ( (1<<URSEL1) | (1<<UCSZ11) | (1<<UCSZ10))
|
||||
#define UART_DATA UDR1
|
||||
#endif
|
||||
|
||||
#endif // #ifndef _MEGA162_H_
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef _MEGA169_H_
|
||||
#define _MEGA169_H_
|
||||
|
||||
#define DEVTYPE_ISP 0x78
|
||||
#define DEVTYPE_BOOT 0x79
|
||||
|
||||
#define SIG_BYTE3 0x1E
|
||||
#define SIG_BYTE2 0x94
|
||||
#define SIG_BYTE1 0x05
|
||||
|
||||
#define UART_BAUD_HIGH UBRRH
|
||||
#define UART_BAUD_LOW UBRRL
|
||||
#define UART_STATUS UCSRA
|
||||
#define UART_TXREADY UDRE
|
||||
#define UART_RXREADY RXC
|
||||
#define UART_DOUBLE U2X
|
||||
#define UART_CTRL UCSRB
|
||||
#define UART_CTRL_DATA ((1<<TXEN) | (1<<RXEN))
|
||||
#define UART_CTRL2 UCSRC
|
||||
#define UART_CTRL2_DATA ((1<<UCSZ1) | (1<<UCSZ0))
|
||||
#define UART_DATA UDR
|
||||
|
||||
#endif // #ifndef _MEGA169_H_
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef _MEGA32_H_
|
||||
#define _MEGA32_H_
|
||||
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x72
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x73
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x95
|
||||
#define SIG_BYTE3 0x02
|
||||
|
||||
#define UART_BAUD_HIGH UBRRH
|
||||
#define UART_BAUD_LOW UBRRL
|
||||
#define UART_STATUS UCSRA
|
||||
#define UART_TXREADY UDRE
|
||||
#define UART_RXREADY RXC
|
||||
#define UART_DOUBLE U2X
|
||||
#define UART_CTRL UCSRB
|
||||
#define UART_CTRL_DATA ((1<<TXEN) | (1<<RXEN))
|
||||
#define UART_CTRL2 UCSRC
|
||||
#define UART_CTRL2_DATA ((1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0))
|
||||
#define UART_DATA UDR
|
||||
|
||||
#endif // #ifndef _MEGA32_H_
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _MEGA324P_H_
|
||||
#define _MEGA324P_H_
|
||||
|
||||
/* I (M. Thomas) could not find an official Boot-ID
|
||||
for the ATmega324P so pretend it's an ATmega32 */
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x72
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x73
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x95
|
||||
#define SIG_BYTE3 0x08
|
||||
|
||||
#include "megaxx4p.h"
|
||||
|
||||
#endif // #ifndef _MEGA324P_H_
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef _MEGA64_H_
|
||||
#define _MEGA64_H_
|
||||
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x45
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x46
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x96
|
||||
#define SIG_BYTE3 0x02
|
||||
|
||||
#ifndef UART_USE_SECOND
|
||||
#define UART_BAUD_HIGH UBRR0H
|
||||
#define UART_BAUD_LOW UBRR0L
|
||||
#define UART_STATUS UCSR0A
|
||||
#define UART_TXREADY UDRE0
|
||||
#define UART_RXREADY RXC0
|
||||
#define UART_DOUBLE U2X0
|
||||
#define UART_CTRL UCSR0B
|
||||
#define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
|
||||
#define UART_CTRL2 UCSR0C
|
||||
#define UART_CTRL2_DATA ((1<<UCSZ01) | (1<<UCSZ00))
|
||||
#define UART_DATA UDR0
|
||||
#else
|
||||
#define UART_BAUD_HIGH UBRR1H
|
||||
#define UART_BAUD_LOW UBRR1L
|
||||
#define UART_STATUS UCSR1A
|
||||
#define UART_TXREADY UDRE1
|
||||
#define UART_RXREADY RXC1
|
||||
#define UART_DOUBLE U2X1
|
||||
#define UART_CTRL UCSR1B
|
||||
#define UART_CTRL_DATA ((1<<TXEN1) | (1<<RXEN1))
|
||||
#define UART_CTRL2 UCSR1C
|
||||
#define UART_CTRL2_DATA ((1<<UCSZ11) | (1<<UCSZ10))
|
||||
#define UART_DATA UDR1
|
||||
#endif
|
||||
|
||||
#endif // #ifndef _MEGA64_H_
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef _MEGA644_H_
|
||||
#define _MEGA644_H_
|
||||
|
||||
/* I (M. Thomas) could not find an official Boot-ID
|
||||
for the ATmega644 so pretend it's an ATmega64 */
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x45
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x46
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x96
|
||||
#define SIG_BYTE3 0x09
|
||||
|
||||
#define UART_BAUD_HIGH UBRR0H
|
||||
#define UART_BAUD_LOW UBRR0L
|
||||
#define UART_STATUS UCSR0A
|
||||
#define UART_TXREADY UDRE0
|
||||
#define UART_RXREADY RXC0
|
||||
#define UART_DOUBLE U2X0
|
||||
#define UART_CTRL UCSR0B
|
||||
#define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
|
||||
#define UART_CTRL2 UCSR0C
|
||||
#define UART_CTRL2_DATA ( (1<<UCSZ01) | (1<<UCSZ00))
|
||||
#define UART_DATA UDR0
|
||||
|
||||
#define WDT_OFF_SPECIAL
|
||||
static inline void bootloader_wdt_off(void)
|
||||
{
|
||||
cli();
|
||||
wdt_reset();
|
||||
/* Clear WDRF in MCUSR */
|
||||
MCUSR &= ~(1<<WDRF);
|
||||
/* Write logical one to WDCE and WDE */
|
||||
/* Keep old prescaler setting to prevent unintentional time-out */
|
||||
WDTCSR |= (1<<WDCE) | (1<<WDE);
|
||||
/* Turn off WDT */
|
||||
WDTCSR = 0x00;
|
||||
}
|
||||
|
||||
|
||||
#endif // #ifndef _MEGA644_H_
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _MEGA644P_H_
|
||||
#define _MEGA644P_H_
|
||||
|
||||
/* I (M. Thomas) could not find an official Boot-ID
|
||||
for the ATmega644P so pretend it's an ATmega64 */
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x45
|
||||
/* Part-Code Boot */
|
||||
#define DEVTYPE_BOOT 0x46
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x96
|
||||
#define SIG_BYTE3 0x0A
|
||||
|
||||
#include "megaxx4p.h"
|
||||
|
||||
#endif // #ifndef _MEGA644P_H_
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef _MEGA8_H_
|
||||
#define _MEGA8_H_
|
||||
|
||||
/* Part-Code ISP */
|
||||
#define DEVTYPE_ISP 0x76
|
||||
/* Part-Code BOOT */
|
||||
#define DEVTYPE_BOOT 0x77
|
||||
|
||||
#define SIG_BYTE1 0x1E
|
||||
#define SIG_BYTE2 0x93
|
||||
#define SIG_BYTE3 0x07
|
||||
|
||||
#define UART_BAUD_HIGH UBRRH
|
||||
#define UART_BAUD_LOW UBRRL
|
||||
#define UART_STATUS UCSRA
|
||||
#define UART_TXREADY UDRE
|
||||
#define UART_RXREADY RXC
|
||||
#define UART_DOUBLE U2X
|
||||
#define UART_CTRL UCSRB
|
||||
#define UART_CTRL_DATA ((1<<TXEN) | (1<<RXEN))
|
||||
#define UART_CTRL2 UCSRC
|
||||
#define UART_CTRL2_DATA ((1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0))
|
||||
#define UART_DATA UDR
|
||||
|
||||
#endif // #ifndef _MEGA8_H_
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef _MEGAxx4_H_
|
||||
#define _MEGAxx4_H_
|
||||
|
||||
#ifndef UART_USE_SECOND
|
||||
/* UART 0 */
|
||||
#define UART_BAUD_HIGH UBRR0H
|
||||
#define UART_BAUD_LOW UBRR0L
|
||||
#define UART_STATUS UCSR0A
|
||||
#define UART_TXREADY UDRE0
|
||||
#define UART_RXREADY RXC0
|
||||
#define UART_DOUBLE U2X0
|
||||
#define UART_CTRL UCSR0B
|
||||
#define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
|
||||
#define UART_CTRL2 UCSR0C
|
||||
#define UART_CTRL2_DATA ( (1<<UCSZ01) | (1<<UCSZ00))
|
||||
#define UART_DATA UDR0
|
||||
#else
|
||||
/* UART 1 */
|
||||
#define UART_BAUD_HIGH UBRR1H
|
||||
#define UART_BAUD_LOW UBRR1L
|
||||
#define UART_STATUS UCSR1A
|
||||
#define UART_TXREADY UDRE1
|
||||
#define UART_RXREADY RXC1
|
||||
#define UART_DOUBLE U2X1
|
||||
#define UART_CTRL UCSR1B
|
||||
#define UART_CTRL_DATA ((1<<TXEN1) | (1<<RXEN1))
|
||||
#define UART_CTRL2 UCSR1C
|
||||
#define UART_CTRL2_DATA ( (1<<UCSZ11) | (1<<UCSZ10))
|
||||
#define UART_DATA UDR1
|
||||
#endif
|
||||
|
||||
#define WDT_OFF_SPECIAL
|
||||
|
||||
static inline void bootloader_wdt_off(void)
|
||||
{
|
||||
cli();
|
||||
wdt_reset();
|
||||
/* Clear WDRF in MCUSR */
|
||||
MCUSR &= ~(1<<WDRF);
|
||||
/* Write logical one to WDCE and WDE */
|
||||
/* Keep old prescaler setting to prevent unintentional time-out */
|
||||
WDTCSR |= (1<<WDCE) | (1<<WDE);
|
||||
/* Turn off WDT */
|
||||
WDTCSR = 0x00;
|
||||
}
|
||||
|
||||
#endif // #ifndef _MEGA644_H_
|
520
myboot.h
520
myboot.h
|
@ -1,520 +0,0 @@
|
|||
/* Copyright (c) 2002, 2003, 2004 Eric B. Weddington
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#ifndef _AVR_BOOT_H_
|
||||
#define _AVR_BOOT_H_ 1
|
||||
|
||||
/** \defgroup avr_boot Bootloader Support Utilities
|
||||
\code
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
\endcode
|
||||
|
||||
The macros in this module provide a C language interface to the
|
||||
bootloader support functionality of certain AVR processors. These
|
||||
macros are designed to work with all sizes of flash memory.
|
||||
|
||||
\note Not all AVR processors provide bootloader support. See your
|
||||
processor datasheet to see if it provides bootloader support.
|
||||
|
||||
\todo From email with Marek: On smaller devices (all except ATmega64/128),
|
||||
__SPM_REG is in the I/O space, accessible with the shorter "in" and "out"
|
||||
instructions - since the boot loader has a limited size, this could be an
|
||||
important optimization.
|
||||
|
||||
\par API Usage Example
|
||||
The following code shows typical usage of the boot API.
|
||||
|
||||
\code
|
||||
#include <inttypes.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
void boot_program_page (uint32_t page, uint8_t *buf)
|
||||
{
|
||||
uint16_t i;
|
||||
uint8_t sreg;
|
||||
|
||||
// Disable interrupts.
|
||||
|
||||
sreg = SREG;
|
||||
cli();
|
||||
|
||||
eeprom_busy_wait ();
|
||||
|
||||
boot_page_erase (page);
|
||||
boot_spm_busy_wait (); // Wait until the memory is erased.
|
||||
|
||||
for (i=0; i<SPM_PAGESIZE; i+=2)
|
||||
{
|
||||
// Set up little-endian word.
|
||||
|
||||
uint16_t w = *buf++;
|
||||
w += (*buf++) << 8;
|
||||
|
||||
boot_page_fill (page + i, w);
|
||||
}
|
||||
|
||||
boot_page_write (page); // Store buffer in flash page.
|
||||
boot_spm_busy_wait(); // Wait until the memory is written.
|
||||
|
||||
// Reenable RWW-section again. We need this if we want to jump back
|
||||
// to the application after bootloading.
|
||||
|
||||
boot_rww_enable ();
|
||||
|
||||
// Re-enable interrupts (if they were ever enabled).
|
||||
|
||||
SREG = sreg;
|
||||
}\endcode */
|
||||
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/io.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* Check for SPM Control Register in processor. */
|
||||
#if defined (SPMCSR)
|
||||
# define __SPM_REG SPMCSR
|
||||
#elif defined (SPMCR)
|
||||
# define __SPM_REG SPMCR
|
||||
#else
|
||||
# error AVR processor does not provide bootloader support!
|
||||
#endif
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def BOOTLOADER_SECTION
|
||||
|
||||
Used to declare a function or variable to be placed into a
|
||||
new section called .bootloader. This section and its contents
|
||||
can then be relocated to any address (such as the bootloader
|
||||
NRWW area) at link-time. */
|
||||
|
||||
#define BOOTLOADER_SECTION __attribute__ ((section (".bootloader")))
|
||||
|
||||
/* Create common bit definitions. */
|
||||
#ifdef ASB
|
||||
#define __COMMON_ASB ASB
|
||||
#else
|
||||
#define __COMMON_ASB RWWSB
|
||||
#endif
|
||||
|
||||
#ifdef ASRE
|
||||
#define __COMMON_ASRE ASRE
|
||||
#else
|
||||
#define __COMMON_ASRE RWWSRE
|
||||
#endif
|
||||
|
||||
/* Define the bit positions of the Boot Lock Bits. */
|
||||
|
||||
#define BLB12 5
|
||||
#define BLB11 4
|
||||
#define BLB02 3
|
||||
#define BLB01 2
|
||||
// mthomas:
|
||||
#define LB2 1
|
||||
#define LB1 0
|
||||
#define LOCK6 6
|
||||
#define LOCK7 7
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_spm_interrupt_enable()
|
||||
Enable the SPM interrupt. */
|
||||
|
||||
#define boot_spm_interrupt_enable() (__SPM_REG |= (uint8_t)_BV(SPMIE))
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_spm_interrupt_disable()
|
||||
Disable the SPM interrupt. */
|
||||
|
||||
#define boot_spm_interrupt_disable() (__SPM_REG &= (uint8_t)~_BV(SPMIE))
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_is_spm_interrupt()
|
||||
Check if the SPM interrupt is enabled. */
|
||||
|
||||
#define boot_is_spm_interrupt() (__SPM_REG & (uint8_t)_BV(SPMIE))
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_rww_busy()
|
||||
Check if the RWW section is busy. */
|
||||
|
||||
#define boot_rww_busy() (__SPM_REG & (uint8_t)_BV(__COMMON_ASB))
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_spm_busy()
|
||||
Check if the SPM instruction is busy. */
|
||||
|
||||
#define boot_spm_busy() (__SPM_REG & (uint8_t)_BV(SPMEN))
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_spm_busy_wait()
|
||||
Wait while the SPM instruction is busy. */
|
||||
|
||||
#define boot_spm_busy_wait() do{}while(boot_spm_busy())
|
||||
|
||||
#define __BOOT_PAGE_ERASE (_BV(SPMEN) | _BV(PGERS))
|
||||
#define __BOOT_PAGE_WRITE (_BV(SPMEN) | _BV(PGWRT))
|
||||
#define __BOOT_PAGE_FILL _BV(SPMEN)
|
||||
#define __BOOT_RWW_ENABLE (_BV(SPMEN) | _BV(__COMMON_ASRE))
|
||||
#define __BOOT_LOCK_BITS_SET (_BV(SPMEN) | _BV(BLBSET))
|
||||
|
||||
// mthomas - should be inverted
|
||||
// #define __BOOT_LOCK_BITS_MASK (_BV(BLB01) | _BV(BLB02) | _BV(BLB11) | _BV(BLB12))
|
||||
#define __BOOT_LOCK_BITS_MASK (_BV(LB1) | _BV(LB2) | _BV(LOCK6) | _BV(LOCK7))
|
||||
|
||||
#define __boot_page_fill_normal(address, data) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r0, %3\n\t" \
|
||||
"movw r30, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
"clr r1\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||
"r" ((uint16_t)address), \
|
||||
"r" ((uint16_t)data) \
|
||||
: "r0", "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_fill_alternate(address, data)\
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r0, %3\n\t" \
|
||||
"movw r30, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
".word 0xffff\n\t" \
|
||||
"nop\n\t" \
|
||||
"clr r1\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||
"r" ((uint16_t)address), \
|
||||
"r" ((uint16_t)data) \
|
||||
: "r0", "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_fill_extended(address, data) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r0, %4\n\t" \
|
||||
"movw r30, %A3\n\t" \
|
||||
"sts %1, %C3\n\t" \
|
||||
"sts %0, %2\n\t" \
|
||||
"spm\n\t" \
|
||||
"clr r1\n\t" \
|
||||
: "=m" (__SPM_REG), \
|
||||
"=m" (RAMPZ) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||
"r" ((uint32_t)address), \
|
||||
"r" ((uint16_t)data) \
|
||||
: "r0", "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_erase_normal(address) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r30, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||
"r" ((uint16_t)address) \
|
||||
: "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_erase_alternate(address) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r30, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
".word 0xffff\n\t" \
|
||||
"nop\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||
"r" ((uint16_t)address) \
|
||||
: "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_erase_extended(address) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r30, %A3\n\t" \
|
||||
"sts %1, %C3\n\t" \
|
||||
"sts %0, %2\n\t" \
|
||||
"spm\n\t" \
|
||||
: "=m" (__SPM_REG), \
|
||||
"=m" (RAMPZ) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||
"r" ((uint32_t)address) \
|
||||
: "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_write_normal(address) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r30, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||
"r" ((uint16_t)address) \
|
||||
: "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_write_alternate(address) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r30, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
".word 0xffff\n\t" \
|
||||
"nop\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||
"r" ((uint16_t)address) \
|
||||
: "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_page_write_extended(address) \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"movw r30, %A3\n\t" \
|
||||
"sts %1, %C3\n\t" \
|
||||
"sts %0, %2\n\t" \
|
||||
"spm\n\t" \
|
||||
: "=m" (__SPM_REG), \
|
||||
"=m" (RAMPZ) \
|
||||
: "r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||
"r" ((uint32_t)address) \
|
||||
: "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_rww_enable() \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_RWW_ENABLE) \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_rww_enable_alternate() \
|
||||
({ \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
".word 0xffff\n\t" \
|
||||
"nop\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_RWW_ENABLE) \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_lock_bits_set(lock_bits) \
|
||||
({ \
|
||||
uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"ldi r30, 1\n\t" \
|
||||
"ldi r31, 0\n\t" \
|
||||
"mov r0, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \
|
||||
"r" (value) \
|
||||
: "r0", "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
#define __boot_lock_bits_set_alternate(lock_bits) \
|
||||
({ \
|
||||
uint8_t value = (uint8_t)(lock_bits | __BOOT_LOCK_BITS_MASK); \
|
||||
__asm__ __volatile__ \
|
||||
( \
|
||||
"ldi r30, 1\n\t" \
|
||||
"ldi r31, 0\n\t" \
|
||||
"mov r0, %2\n\t" \
|
||||
"sts %0, %1\n\t" \
|
||||
"spm\n\t" \
|
||||
".word 0xffff\n\t" \
|
||||
"nop\n\t" \
|
||||
: "=m" (__SPM_REG) \
|
||||
: "r" ((uint8_t)__BOOT_LOCK_BITS_SET), \
|
||||
"r" (value) \
|
||||
: "r0", "r30", "r31" \
|
||||
); \
|
||||
})
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_page_fill(address, data)
|
||||
|
||||
Fill the bootloader temporary page buffer for flash
|
||||
address with data word.
|
||||
|
||||
\note The address is a byte address. The data is a word. The AVR
|
||||
writes data to the buffer a word at a time, but addresses the buffer
|
||||
per byte! So, increment your address by 2 between calls, and send 2
|
||||
data bytes in a word format! The LSB of the data is written to the lower
|
||||
address; the MSB of the data is written to the higher address.*/
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_page_erase(address)
|
||||
|
||||
Erase the flash page that contains address.
|
||||
|
||||
\note address is a byte address in flash, not a word address. */
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_page_write(address)
|
||||
|
||||
Write the bootloader temporary page buffer
|
||||
to flash page that contains address.
|
||||
|
||||
\note address is a byte address in flash, not a word address. */
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_rww_enable()
|
||||
|
||||
Enable the Read-While-Write memory section. */
|
||||
|
||||
/** \ingroup avr_boot
|
||||
\def boot_lock_bits_set(lock_bits)
|
||||
|
||||
Set the bootloader lock bits. */
|
||||
|
||||
/* Normal versions of the macros use 16-bit addresses.
|
||||
Extended versions of the macros use 32-bit addresses.
|
||||
Alternate versions of the macros use 16-bit addresses and require special
|
||||
instruction sequences after LPM.
|
||||
|
||||
FLASHEND is defined in the ioXXXX.h file.
|
||||
USHRT_MAX is defined in <limits.h>. */
|
||||
|
||||
#if defined(__AVR_ATmega161__) || defined(__AVR_ATmega163__) \
|
||||
|| defined(__AVR_ATmega323__)
|
||||
|
||||
/* Alternate: ATmega161/163/323 and 16 bit address */
|
||||
#define boot_page_fill(address, data) __boot_page_fill_alternate(address, data)
|
||||
#define boot_page_erase(address) __boot_page_erase_alternate(address)
|
||||
#define boot_page_write(address) __boot_page_write_alternate(address)
|
||||
#define boot_rww_enable() __boot_rww_enable_alternate()
|
||||
#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_alternate(lock_bits)
|
||||
|
||||
#elif (FLASHEND > USHRT_MAX) && !defined(__USING_MINT8)
|
||||
|
||||
/* Extended: >16 bit address */
|
||||
#define boot_page_fill(address, data) __boot_page_fill_extended(address, data)
|
||||
#define boot_page_erase(address) __boot_page_erase_extended(address)
|
||||
#define boot_page_write(address) __boot_page_write_extended(address)
|
||||
#define boot_rww_enable() __boot_rww_enable()
|
||||
#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set(lock_bits)
|
||||
|
||||
#else
|
||||
|
||||
/* Normal: 16 bit address */
|
||||
#define boot_page_fill(address, data) __boot_page_fill_normal(address, data)
|
||||
#define boot_page_erase(address) __boot_page_erase_normal(address)
|
||||
#define boot_page_write(address) __boot_page_write_normal(address)
|
||||
#define boot_rww_enable() __boot_rww_enable()
|
||||
#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set(lock_bits)
|
||||
|
||||
#endif
|
||||
|
||||
#define __boot_eeprom_spm_safe(func, address, data) \
|
||||
do { \
|
||||
boot_spm_busy_wait(); \
|
||||
eeprom_busy_wait(); \
|
||||
func (address, data); \
|
||||
} while (0)
|
||||
|
||||
/** \ingroup avr_boot
|
||||
|
||||
Same as boot_page_fill() except it waits for eeprom and spm operations to
|
||||
complete before filling the page. */
|
||||
|
||||
#define boot_page_fill_safe(address, data) \
|
||||
__boot_eeprom_spm_safe (boot_page_fill, address, data)
|
||||
|
||||
/** \ingroup avr_boot
|
||||
|
||||
Same as boot_page_erase() except it waits for eeprom and spm operations to
|
||||
complete before erasing the page. */
|
||||
|
||||
#define boot_page_erase_safe(address, data) \
|
||||
__boot_eeprom_spm_safe (boot_page_erase, address, data)
|
||||
|
||||
/** \ingroup avr_boot
|
||||
|
||||
Same as boot_page_write() except it waits for eeprom and spm operations to
|
||||
complete before writing the page. */
|
||||
|
||||
#define boot_page_write_safe(address, data) \
|
||||
__boot_eeprom_spm_safe (boot_page_wrte, address, data)
|
||||
|
||||
/** \ingroup avr_boot
|
||||
|
||||
Same as boot_rww_enable() except waits for eeprom and spm operations to
|
||||
complete before enabling the RWW mameory. */
|
||||
|
||||
#define boot_rww_enable_safe(address, data) \
|
||||
__boot_eeprom_spm_safe (boot_rww_enable, address, data)
|
||||
|
||||
/** \ingroup avr_boot
|
||||
|
||||
Same as boot_lock_bits_set() except waits for eeprom and spm operations to
|
||||
complete before setting the lock bits. */
|
||||
|
||||
#define boot_lock_bits_set_safe(address, data) \
|
||||
__boot_eeprom_spm_safe (boot_lock_bits_set, address, data)
|
||||
|
||||
#endif /* _AVR_BOOT_H_ */
|
243
readme.txt
243
readme.txt
|
@ -2,23 +2,154 @@
|
|||
======================================================
|
||||
|
||||
ATMEL AVR UART Bootloader for AVR-GCC/avr-libc
|
||||
based on the AVR Butterfly bootloader code
|
||||
|
||||
by Martin Thomas, Kaiserslautern, Germany
|
||||
mthomas@rhrk.uni-kl.de
|
||||
mthomas@rhrk.uni-kl.de
|
||||
eversmith@heizung-thomas.de
|
||||
http://www.siwawi.arubi.uni-kl.de/avr_projects
|
||||
|
||||
This is an adapted version which has been tested
|
||||
with the ATmega16 but should work with the ATmega8,
|
||||
ATmega169 and ATmega32. The bootloader uses block/
|
||||
page write for flash and is fast.
|
||||
** Addtional code and improvements contributed **
|
||||
** by Uwe Bonnes, Bjoern Riemer and Olaf Rempel. **
|
||||
|
||||
Eearly versions of this bootloader-code have been
|
||||
based on the AVR Butterfly bootloader-source REV02
|
||||
which has been available from atmel.com.
|
||||
|
||||
======================================================
|
||||
|
||||
|
||||
Programming-Software (on the "PC-Side"):
|
||||
|
||||
* AVRProg (included in AVRStudio) available at www.atmel.com.
|
||||
MS-Windows only. AVRProg can be used as stand-alone application.
|
||||
(avrprog.exe)
|
||||
|
||||
* avrdude available at http://savannah.nongnu.org/projects/avrdude/
|
||||
"Multiplattform"
|
||||
|
||||
* Installation instructions at the end of this file.
|
||||
|
||||
|
||||
3. Dec. 2008 - Version 0.85
|
||||
|
||||
* disable U2X before jump to app as suggested be Alexander Döller
|
||||
* moved UBRR-macros to main.c and changed them. Inspired by code from avr-libc setbaud.
|
||||
(macros which are commented out (//) are from Pavel Fertser)
|
||||
|
||||
6. Nov. 2008 - Version 0.84
|
||||
|
||||
* Added definitions for ATmega64 provided by Pavel Fertser - Thanks.
|
||||
|
||||
12. Apr. 2008 - Version 0.83
|
||||
|
||||
* Added definitions for ATmega644P and ATmega324P
|
||||
* Tested with ATmega324P, gcc 4.2.2, avr-libc 1.4.6
|
||||
* Added testapp to verify "exit bootloader" with
|
||||
watchdog (n.b.: watchdog-disable called early in testapp)
|
||||
|
||||
27. Jan. 2007 - Version 0.82
|
||||
|
||||
* Added definitions for ATmega644.
|
||||
* Using avr-lib's eeprom-functions (old "direct-access"-code
|
||||
has not been compatible with ATmega644).
|
||||
* Watchdog-disable at startup (configurable): avoids problems with
|
||||
repeated login to bootloader. Not needed if the bootloader is
|
||||
never re-entered again between an "exit programming" and
|
||||
a system-reset/power-toogle.
|
||||
* Additional watchdog disable-function for ATmega644.
|
||||
* Made watchdog-enable time at exit-programming a configuration-value
|
||||
(define).
|
||||
* Bootloader read-protection: if enabled the bootloader fakes
|
||||
an empty boot-section (configurable by define)
|
||||
Since more of the avr-libc functions's are used this version
|
||||
should be more portable for other AVRs but the size of the
|
||||
binary increases a little bit.
|
||||
Make sure to disable the watchdog early in the user-application
|
||||
esp. when using a "modern" AVR (i.e. ATmega48/88/168/644/324P/644P).
|
||||
|
||||
3. Dec. 2006 - Version 0.81
|
||||
|
||||
* Added definitions for ATmega162.
|
||||
* Fixed init for double-speed (bitmask). Thanks to Bernhard Roth
|
||||
|
||||
28. May 2006 - Version 0.8beta3
|
||||
|
||||
* Supports discarding of interrupt-vectors which saves some space
|
||||
if no interrupts are needed in the bootloader. Added option
|
||||
in makefile to enable this feature, modified LDFLAGS,
|
||||
additional code in main.c for a pseudo default_interrupt ISR.
|
||||
The modified linker-scripts have been contributed by
|
||||
Olaf Rempel (basicly just the .vector-section is not linked).
|
||||
* Reverted the order of signatur-byte-numbers in part-
|
||||
configurations to the usual order in the datasheet,
|
||||
also reverted in main.c for sending the signature.
|
||||
* Definitions for lock/fuse-readout.
|
||||
* Updated installation-instruction at the end of this file.
|
||||
* Added DEVTYPE_ISP/DEVTYPE_BOOT to part-configurations,
|
||||
added configuration-option for this in main.c.
|
||||
* A remark about the DEVTYPE: Usualy there are two
|
||||
Part-Codes/Device-Codes. One is for ISP: AVRProg shows
|
||||
the type of the AVR. The other code is for bootloading:
|
||||
AVRprog shows the type plus "BOOT". When a boot-device-code
|
||||
gets detected by AVRprog it "knows" how do handle the
|
||||
limited functionality of bootloaders. (When receiving the
|
||||
ISP-code AVRProg expects an AVR910-type programmer.)
|
||||
The offset between the codes is usualy 0x01 where the
|
||||
ISP-code is the smaller value, i.e. ATmega32 ISP-code
|
||||
is 0x72->"ATmega32" and boot-code is 0x73->"ATmega32 BOOT".
|
||||
When using avrdude the bootloader's device-code must match
|
||||
the device-code in the avrdude.conf. Check the avrdude-
|
||||
code to see if both codes (AVR910 and AVR109) are supported.
|
||||
-- I have got some e-mails from users which have been
|
||||
confused by this. Hopefully this explanation is good enough.
|
||||
* This bootloader lets the watchdog do a reset when the
|
||||
user selects "Exit programmer" (i.e. in AVRProg) after an
|
||||
update. Make sure to disable or reset the watchdog early in
|
||||
your application.
|
||||
|
||||
27. May 2006 - Version 0.8beta2
|
||||
|
||||
* More very well done improvements contributed by Olaf Rempel.
|
||||
* Olaf Rempel also modified the STARTUP_WAIT method.
|
||||
|
||||
21. May 2006 - Version 0.8beta
|
||||
|
||||
* Version contributed by Olaf Rempel. He has done a lot of modifications.
|
||||
-> "cleaner code", smaller binaries.
|
||||
|
||||
09. Feb. 2006 - Version 0.75
|
||||
|
||||
* additional STARTUP_WAIT support contributed by Bjoern Riemer
|
||||
|
||||
18. Aug. 2005 - Version 0.74
|
||||
|
||||
* AT90CAN128 support contributed by Uwe Bonnes
|
||||
* Makefile modifications contributed by Uwe Bonnes
|
||||
|
||||
23. Feb. 2005 - Version 0.7
|
||||
|
||||
* (Version 0.6 has never been available on the web-page)
|
||||
* ATmega128 support
|
||||
* code cleanup
|
||||
* This version has been tested with ATmega8, ATmega32 and
|
||||
ATmega128
|
||||
|
||||
7. Apr. 2004 - Version 0.5
|
||||
|
||||
* added different startup-methods
|
||||
* compatible with ATmega8 now
|
||||
* included makefile adapted to ATmega8 now
|
||||
(ATmega16 options still available)
|
||||
* fixed jump to application which did not work
|
||||
reliably before
|
||||
* tested with ATmega8
|
||||
* minimal options and startup-code result in
|
||||
bootloader-size < 512 words
|
||||
|
||||
6. Apr. 2004 - Version 0.4
|
||||
|
||||
* Buffered read of chars from UART during programming
|
||||
since eeprom-write is too slow for unbuffered
|
||||
since eeprom-write is too slow for unbuffered
|
||||
operation. So EEPROM-upload does work now.
|
||||
* Added BOOTICE-mode to flash JTAGICE-compatible
|
||||
hardware (ATmega16@7,3Mhz) (if you know about BOOTICE,
|
||||
|
@ -29,12 +160,12 @@ out during the development of the STK-500-compatible
|
|||
bootloader. But setting lock-bits still does not
|
||||
work with this bootloader.
|
||||
* read of the low-fuse byte works (high byte still TODO)
|
||||
* read of the lock-byte works (wirte still TODO)
|
||||
* read of the lock-byte works (write still TODO)
|
||||
|
||||
27. Mar 2004 - Version 0.3
|
||||
|
||||
Felt that as much functions from avr-libc's boot.h
|
||||
as possible should be used without modifications.
|
||||
as possible should be used without modifications.
|
||||
Latest CVS-version of boot.h is included.
|
||||
Only the read-routine is still "self-made" based
|
||||
on ATMELs assembler-code.
|
||||
|
@ -42,7 +173,7 @@ EEPROM write on Mega16 does not work (and did not
|
|||
work with V0.2 too). May be caused by my old Mega16
|
||||
chip. Needs testing. Flash read/write and EEPROM
|
||||
read works. Still only tested with ATmega16.
|
||||
This version may not work with the ATmega169 any
|
||||
This version may not work with the ATmega169 any
|
||||
more.
|
||||
|
||||
24. Mar 2004 - Version 0.2
|
||||
|
@ -52,24 +183,24 @@ with the AVR-Butterfly there was a need to make
|
|||
some changes in the bootloader. The same problem
|
||||
again: no IAR compiler. The same way to solve the
|
||||
problem: a port of the code to avr-gcc/avr-libc.
|
||||
So this code is based on the ATMEL Butterfly
|
||||
So this code is based on the ATMEL Butterfly
|
||||
bootloader source code Rev 0.2 for IAR.
|
||||
|
||||
The bootloader-port for the Butterfly which mimics
|
||||
the complete functionality of the original
|
||||
the complete functionality of the original
|
||||
BF-bootloader is availabe at:
|
||||
www.siwawi.arubi.uni-kl.de/avr_projects
|
||||
|
||||
Atmel used a separate "lib" written in "pure"
|
||||
Atmel used a separate "lib" written in "pure"
|
||||
assembly to access the low-level functions
|
||||
for flash read/write. Well, so far I
|
||||
don't know how to use "mixed language sources"
|
||||
don't know how to use "mixed language sources"
|
||||
with the avr-gcc toolchain, so the low-level
|
||||
routines have been implemented as inline assembler.
|
||||
The avr-libc boot.h module written by Eric
|
||||
Weddington served as a template Three of the four
|
||||
low-level routines found in lowlevel.c come from
|
||||
boot.h with minimal changes. The read routine has
|
||||
Weddington served as a template Three of the four
|
||||
low-level routines found in lowlevel.c come from
|
||||
boot.h with minimal changes. The read routine has
|
||||
been developed based on the ATMEL assembler code.
|
||||
|
||||
Ignore the fuse and lock-bit readout. Read and Set is
|
||||
|
@ -78,71 +209,59 @@ not enabled (TODO).
|
|||
|
||||
--------------- Installation -----------------
|
||||
|
||||
- Change the MCU type in the makefile (so far
|
||||
ATmega16 has been tested, ATmega169, ATmega8
|
||||
and ATmega32 should be o.k. too.
|
||||
- Change the MCU type in the makefile.
|
||||
|
||||
- Change the boot(loader)-size in main.c, this
|
||||
bootloader is larger than 512 words (1024 bytes),
|
||||
so select at least _B1024!
|
||||
- Change the boot(loader)-size in Makefile. The needed
|
||||
space depends on the features selected in main.c
|
||||
|
||||
- Change the XTAL in main.c to the clock-frequency
|
||||
of your board (keep BAUDRATE at 19200). See
|
||||
the datasheet for frequencies with minimum
|
||||
error at 19200bps and select Crystal/Oscillator
|
||||
to get minimum errors.
|
||||
- Set baudrate in main.c, a doublespeed configuration-option
|
||||
is available too.
|
||||
|
||||
- Change the start-condition in main.c. Default
|
||||
is: enter bootloader if Pin A7 is connected to
|
||||
GND during reset/startup
|
||||
- Change the F_CPU in main.c to the clock-frequency
|
||||
of your board. See the datasheet for frequencies
|
||||
with minimum error at the selected baudrate.
|
||||
|
||||
- Edit the value MT_BOOTLOADER_ADDRESS in the
|
||||
makefile according to the selected bootloader
|
||||
size. Keep in mind that this value has to be
|
||||
given in bytes (not words) in the linker options.
|
||||
- Select the start-condition in main.c.
|
||||
|
||||
i.e. ATMega16, boot-size 1024 words, see
|
||||
datasheet and find "Boot Reset Adress" for
|
||||
"Boot Size" 1024 words is 1C00. 1C00 is given
|
||||
in words, so set MT_BOOTLOADER_ADDRESS to
|
||||
3800 (=2*1C00)
|
||||
- Please use at least avr-gcc 3.3.1/avr-libc 1.0
|
||||
or WINAVR Sept. 2003 or later to compile and link
|
||||
this bootloader.
|
||||
|
||||
- Please use at least avr-gcc 3.3.1/avr-libc 1.0
|
||||
or WINAVR Sept. 2003 or later to compile and link
|
||||
the bootloader.
|
||||
- Upload the hex-File to the AVR (STK500, STK200, SP12
|
||||
evertool, AVR910 etc.)
|
||||
|
||||
- upload the hex-File to the AVR (STK500, STK200, SP12
|
||||
etc.)
|
||||
- Program the "Boot Flash section size" (BOOTSZ fuses)
|
||||
according to the boot-size selected in the makefile
|
||||
i.e. BOOTSZ=00 for boot-size 1024 words (2048 bytes)
|
||||
on ATmega16
|
||||
|
||||
- program the "Boot Flash section size" (BOOTSZ fuses)
|
||||
according to the boot-size selected in main.c
|
||||
i.e. BOOTSZ=00 for boot-size 1024 words on ATmega16
|
||||
|
||||
- enable the BOOT Reset Vector (BOOTTRST=0)
|
||||
- enable the BOOT Reset Vector fuse (BOOTRST=0)
|
||||
|
||||
- Set the lock bits to protect the bootloader from
|
||||
SPM-writes (Boot Loader Protection Mode 2 in STK500-
|
||||
plugin)
|
||||
plugin) so that it can not overwrite itself.
|
||||
|
||||
- Connect the AVR UART Pins via level-shifter/inverter
|
||||
(i.e. MAX232) to you PCs Com-Port.
|
||||
(i.e. MAX232) to your PCs COM-Port.
|
||||
|
||||
- Reset the AVR while fullfilling the bootloader start-
|
||||
condition. Which means connect PA7 to GND in the default
|
||||
config during reste/power-cycle. Keep the connection
|
||||
or hold the key down until you see the AVRPROG dialog!
|
||||
condition. (Default: selected pin connected to GND).
|
||||
The condition must be "true" until you see the
|
||||
AVRPROG dialog or avrdude connects.
|
||||
|
||||
- Start AVRPROG (AVRStuido/Tools or stand-alone) -
|
||||
keep PA7 grounded!
|
||||
- Start AVRPROG (AVRStudio/Tools or stand-alone avrprog.exe)
|
||||
AVRDUDE is supported too, check it's manual
|
||||
for command-line options. Read the text above for
|
||||
information about Device-Types and AVRDUDE
|
||||
|
||||
- AVRPROG will detect the bootloader, you may release
|
||||
PA7 now
|
||||
- AVRPROG or AVRDUDE should detect the bootloader.
|
||||
|
||||
- see AVRStuido online-help for more information how
|
||||
- see AVRStudio's online-help for more information how
|
||||
to use AVRPROG
|
||||
|
||||
- make sure to EXIT from AVRPROG (button) to start
|
||||
your main-application (or toogle power/reset)
|
||||
your main-application or toogle power/reset.
|
||||
|
||||
good luck, feedback welcome.
|
||||
|
||||
Feedback welcome, Good luck.
|
||||
Martin
|
||||
|
|
|
@ -0,0 +1,619 @@
|
|||
# Hey Emacs, this is a -*- makefile -*-
|
||||
#----------------------------------------------------------------------------
|
||||
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
|
||||
#
|
||||
# Released to the Public Domain
|
||||
#
|
||||
# Additional material for this makefile was written by:
|
||||
# Peter Fleury
|
||||
# Tim Henigan
|
||||
# Colin O'Flynn
|
||||
# Reiner Patommel
|
||||
# Markus Pfaff
|
||||
# Sander Pool
|
||||
# Frederik Rouleau
|
||||
# Carlos Lamas
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device, using avrdude.
|
||||
# Please customize the avrdude settings below first!
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# MCU name
|
||||
MCU = atmega324p
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
# Typical values are:
|
||||
# F_CPU = 1000000
|
||||
# F_CPU = 1843200
|
||||
# F_CPU = 2000000
|
||||
# F_CPU = 3686400
|
||||
# F_CPU = 4000000
|
||||
# F_CPU = 7372800
|
||||
# F_CPU = 8000000
|
||||
# F_CPU = 11059200
|
||||
# F_CPU = 14745600
|
||||
# F_CPU = 16000000
|
||||
# F_CPU = 18432000
|
||||
# F_CPU = 20000000
|
||||
F_CPU = 3686400
|
||||
|
||||
|
||||
# Output format. (can be srec, ihex, binary)
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = testapp
|
||||
|
||||
|
||||
# Object files directory
|
||||
# To put object files in current directory, use a dot (.), do NOT make
|
||||
# this an empty or blank macro!
|
||||
OBJDIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = $(TARGET).c
|
||||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
# Make them always end in a capital .S. Files ending in a lowercase .s
|
||||
# will not be considered source files but generated files (assembler
|
||||
# output from the compiler), and will be deleted upon "make clean"!
|
||||
# Even though the DOS/Win* filesystem matches both .s and .S the same,
|
||||
# it will preserve the spelling of the filenames, and gcc itself does
|
||||
# care about how the name is spelled on its command-line.
|
||||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
||||
|
||||
# Debugging format.
|
||||
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
|
||||
# AVR Studio 4.10 requires dwarf-2.
|
||||
# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
|
||||
DEBUG = dwarf-2
|
||||
|
||||
|
||||
# List any extra directories to look for include files here.
|
||||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRAINCDIRS =
|
||||
|
||||
|
||||
# Compiler flag to set the C Standard level.
|
||||
# c89 = "ANSI" C
|
||||
# gnu89 = c89 plus GCC extensions
|
||||
# c99 = ISO C99 standard (not yet fully implemented)
|
||||
# gnu99 = c99 plus GCC extensions
|
||||
CSTANDARD = -std=gnu99
|
||||
|
||||
|
||||
# Place -D or -U options here for C sources
|
||||
CDEFS = -DF_CPU=$(F_CPU)UL
|
||||
|
||||
|
||||
# Place -D or -U options here for ASM sources
|
||||
ADEFS = -DF_CPU=$(F_CPU)
|
||||
|
||||
|
||||
# Place -D or -U options here for C++ sources
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL
|
||||
#CPPDEFS += -D__STDC_LIMIT_MACROS
|
||||
#CPPDEFS += -D__STDC_CONSTANT_MACROS
|
||||
|
||||
|
||||
|
||||
#---------------- Compiler Options C ----------------
|
||||
# -g*: generate debugging information
|
||||
# -O*: optimization level
|
||||
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||
# -Wall...: warning level
|
||||
# -Wa,...: tell GCC to pass this to the assembler.
|
||||
# -adhlns...: create assembler listing
|
||||
CFLAGS = -g$(DEBUG)
|
||||
CFLAGS += $(CDEFS)
|
||||
CFLAGS += -O$(OPT)
|
||||
CFLAGS += -funsigned-char
|
||||
CFLAGS += -funsigned-bitfields
|
||||
CFLAGS += -fpack-struct
|
||||
CFLAGS += -fshort-enums
|
||||
CFLAGS += -Wall
|
||||
CFLAGS += -Wstrict-prototypes
|
||||
#CFLAGS += -mshort-calls
|
||||
#CFLAGS += -fno-unit-at-a-time
|
||||
#CFLAGS += -Wundef
|
||||
#CFLAGS += -Wunreachable-code
|
||||
#CFLAGS += -Wsign-compare
|
||||
CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
|
||||
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||
CFLAGS += $(CSTANDARD)
|
||||
|
||||
|
||||
#---------------- Compiler Options C++ ----------------
|
||||
# -g*: generate debugging information
|
||||
# -O*: optimization level
|
||||
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||
# -Wall...: warning level
|
||||
# -Wa,...: tell GCC to pass this to the assembler.
|
||||
# -adhlns...: create assembler listing
|
||||
CPPFLAGS = -g$(DEBUG)
|
||||
CPPFLAGS += $(CPPDEFS)
|
||||
CPPFLAGS += -O$(OPT)
|
||||
CPPFLAGS += -funsigned-char
|
||||
CPPFLAGS += -funsigned-bitfields
|
||||
CPPFLAGS += -fpack-struct
|
||||
CPPFLAGS += -fshort-enums
|
||||
CPPFLAGS += -fno-exceptions
|
||||
CPPFLAGS += -Wall
|
||||
CFLAGS += -Wundef
|
||||
#CPPFLAGS += -mshort-calls
|
||||
#CPPFLAGS += -fno-unit-at-a-time
|
||||
#CPPFLAGS += -Wstrict-prototypes
|
||||
#CPPFLAGS += -Wunreachable-code
|
||||
#CPPFLAGS += -Wsign-compare
|
||||
CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
|
||||
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||
#CPPFLAGS += $(CSTANDARD)
|
||||
|
||||
|
||||
#---------------- Assembler Options ----------------
|
||||
# -Wa,...: tell GCC to pass this to the assembler.
|
||||
# -adhlns: create listing
|
||||
# -gstabs: have the assembler create line number information; note that
|
||||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
||||
#---------------- Library Options ----------------
|
||||
# Minimalistic printf version
|
||||
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||
|
||||
# Floating point printf version (requires MATH_LIB = -lm below)
|
||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
||||
# Minimalistic scanf version
|
||||
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||
|
||||
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
|
||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
||||
MATH_LIB = -lm
|
||||
|
||||
|
||||
# List any extra directories to look for libraries here.
|
||||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
#---------------- External Memory Options ----------------
|
||||
|
||||
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
|
||||
# used for variables (.data/.bss) and heap (malloc()).
|
||||
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
|
||||
|
||||
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
|
||||
# only used for heap (malloc()).
|
||||
#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
|
||||
|
||||
EXTMEMOPTS =
|
||||
|
||||
|
||||
|
||||
#---------------- Linker Options ----------------
|
||||
# -Wl,...: tell GCC to pass this to linker.
|
||||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
||||
#LDFLAGS += -T linker_script.x
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options (avrdude) ----------------
|
||||
|
||||
# Programming hardware: alf avr910 avrisp bascom bsd
|
||||
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
|
||||
#
|
||||
# Type: avrdude -c ?
|
||||
# to get a full listing.
|
||||
#
|
||||
AVRDUDE_PROGRAMMER = stk500
|
||||
|
||||
# com1 = serial port. Use lpt1 to connect to parallel port.
|
||||
AVRDUDE_PORT = com1 # programmer connected to serial device
|
||||
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||
|
||||
|
||||
# Uncomment the following if you want avrdude's erase cycle counter.
|
||||
# Note that this counter needs to be initialized first using -Yn,
|
||||
# see avrdude manual.
|
||||
#AVRDUDE_ERASE_COUNTER = -y
|
||||
|
||||
# Uncomment the following if you do /not/ wish a verification to be
|
||||
# performed after programming the device.
|
||||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
||||
|
||||
|
||||
|
||||
#---------------- Debugging Options ----------------
|
||||
|
||||
# For simulavr only - target MCU frequency.
|
||||
DEBUG_MFREQ = $(F_CPU)
|
||||
|
||||
# Set the DEBUG_UI to either gdb or insight.
|
||||
# DEBUG_UI = gdb
|
||||
DEBUG_UI = insight
|
||||
|
||||
# Set the debugging back-end to either avarice, simulavr.
|
||||
DEBUG_BACKEND = avarice
|
||||
#DEBUG_BACKEND = simulavr
|
||||
|
||||
# GDB Init Filename.
|
||||
GDBINIT_FILE = __avr_gdbinit
|
||||
|
||||
# When using avarice settings for the JTAG
|
||||
JTAG_DEV = /dev/com1
|
||||
|
||||
# Debugging port used to communicate between GDB / avarice / simulavr.
|
||||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
||||
|
||||
#============================================================================
|
||||
|
||||
|
||||
# Define programs and commands.
|
||||
SHELL = sh
|
||||
CC = avr-gcc
|
||||
OBJCOPY = avr-objcopy
|
||||
OBJDUMP = avr-objdump
|
||||
SIZE = avr-size
|
||||
AR = avr-ar rcs
|
||||
NM = avr-nm
|
||||
AVRDUDE = avrdude
|
||||
REMOVE = rm -f
|
||||
REMOVEDIR = rm -rf
|
||||
COPY = cp
|
||||
WINSHELL = cmd
|
||||
|
||||
|
||||
# Define Messages
|
||||
# English
|
||||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
MSG_FLASH = Creating load file for Flash:
|
||||
MSG_EEPROM = Creating load file for EEPROM:
|
||||
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
||||
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
||||
MSG_LINKING = Linking:
|
||||
MSG_COMPILING = Compiling C:
|
||||
MSG_COMPILING_CPP = Compiling C++:
|
||||
MSG_ASSEMBLING = Assembling:
|
||||
MSG_CLEANING = Cleaning project:
|
||||
MSG_CREATING_LIBRARY = Creating library:
|
||||
|
||||
|
||||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
|
||||
|
||||
|
||||
# Combine all necessary flags and optional flags.
|
||||
# Add target processor to flags.
|
||||
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
||||
ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Default target.
|
||||
all: begin gccversion sizebefore build sizeafter end
|
||||
|
||||
# Change the build target to build a HEX file or a library.
|
||||
build: elf hex eep lss sym
|
||||
#build: lib
|
||||
|
||||
|
||||
elf: $(TARGET).elf
|
||||
hex: $(TARGET).hex
|
||||
eep: $(TARGET).eep
|
||||
lss: $(TARGET).lss
|
||||
sym: $(TARGET).sym
|
||||
LIBNAME=lib$(TARGET).a
|
||||
lib: $(LIBNAME)
|
||||
|
||||
|
||||
|
||||
# Eye candy.
|
||||
# AVR Studio 3.x does not check make's exit code but relies on
|
||||
# the following magic strings to be generated by the compile job.
|
||||
begin:
|
||||
@echo
|
||||
@echo $(MSG_BEGIN)
|
||||
|
||||
end:
|
||||
@echo $(MSG_END)
|
||||
@echo
|
||||
|
||||
|
||||
# Display size of file.
|
||||
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||
ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
|
||||
|
||||
sizebefore:
|
||||
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
|
||||
2>/dev/null; echo; fi
|
||||
|
||||
sizeafter:
|
||||
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
|
||||
2>/dev/null; echo; fi
|
||||
|
||||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
@echo end >> $(GDBINIT_FILE)
|
||||
@echo file $(TARGET).elf >> $(GDBINIT_FILE)
|
||||
@echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
|
||||
ifeq ($(DEBUG_BACKEND),simulavr)
|
||||
@echo load >> $(GDBINIT_FILE)
|
||||
endif
|
||||
@echo break main >> $(GDBINIT_FILE)
|
||||
|
||||
debug: gdb-config $(TARGET).elf
|
||||
ifeq ($(DEBUG_BACKEND), avarice)
|
||||
@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
|
||||
@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
|
||||
$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
|
||||
@$(WINSHELL) /c pause
|
||||
|
||||
else
|
||||
@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
|
||||
$(DEBUG_MFREQ) --port $(DEBUG_PORT)
|
||||
endif
|
||||
@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
|
||||
|
||||
|
||||
|
||||
|
||||
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
||||
COFFCONVERT = $(OBJCOPY) --debugging
|
||||
COFFCONVERT += --change-section-address .data-0x800000
|
||||
COFFCONVERT += --change-section-address .bss-0x800000
|
||||
COFFCONVERT += --change-section-address .noinit-0x800000
|
||||
COFFCONVERT += --change-section-address .eeprom-0x810000
|
||||
|
||||
|
||||
|
||||
coff: $(TARGET).elf
|
||||
@echo
|
||||
@echo $(MSG_COFF) $(TARGET).cof
|
||||
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
|
||||
|
||||
|
||||
extcoff: $(TARGET).elf
|
||||
@echo
|
||||
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
|
||||
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
|
||||
|
||||
|
||||
|
||||
# Create final output files (.hex, .eep) from ELF output file.
|
||||
%.hex: %.elf
|
||||
@echo
|
||||
@echo $(MSG_FLASH) $@
|
||||
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
|
||||
%.eep: %.elf
|
||||
@echo
|
||||
@echo $(MSG_EEPROM) $@
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
|
||||
|
||||
# Create extended listing file from ELF output file.
|
||||
%.lss: %.elf
|
||||
@echo
|
||||
@echo $(MSG_EXTENDED_LISTING) $@
|
||||
$(OBJDUMP) -h -S $< > $@
|
||||
|
||||
# Create a symbol table from ELF output file.
|
||||
%.sym: %.elf
|
||||
@echo
|
||||
@echo $(MSG_SYMBOL_TABLE) $@
|
||||
$(NM) -n $< > $@
|
||||
|
||||
|
||||
|
||||
# Create library from object files.
|
||||
.SECONDARY : $(TARGET).a
|
||||
.PRECIOUS : $(OBJ)
|
||||
%.a: $(OBJ)
|
||||
@echo
|
||||
@echo $(MSG_CREATING_LIBRARY) $@
|
||||
$(AR) $@ $(OBJ)
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
.SECONDARY : $(TARGET).elf
|
||||
.PRECIOUS : $(OBJ)
|
||||
%.elf: $(OBJ)
|
||||
@echo
|
||||
@echo $(MSG_LINKING) $@
|
||||
$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
%.s : %.c
|
||||
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C++ source files.
|
||||
%.s : %.cpp
|
||||
$(CC) -S $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Assemble: create object files from assembler source files.
|
||||
$(OBJDIR)/%.o : %.S
|
||||
@echo
|
||||
@echo $(MSG_ASSEMBLING) $<
|
||||
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
clean: begin clean_list end
|
||||
|
||||
clean_list :
|
||||
@echo
|
||||
@echo $(MSG_CLEANING)
|
||||
$(REMOVE) $(TARGET).hex
|
||||
$(REMOVE) $(TARGET).eep
|
||||
$(REMOVE) $(TARGET).cof
|
||||
$(REMOVE) $(TARGET).elf
|
||||
$(REMOVE) $(TARGET).map
|
||||
$(REMOVE) $(TARGET).sym
|
||||
$(REMOVE) $(TARGET).lss
|
||||
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
|
||||
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
|
||||
$(REMOVE) $(SRC:.c=.s)
|
||||
$(REMOVE) $(SRC:.c=.d)
|
||||
$(REMOVE) $(SRC:.c=.i)
|
||||
$(REMOVEDIR) .dep
|
||||
|
||||
|
||||
# Create object files directory
|
||||
$(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||
|
||||
|
||||
# Include the dependency files.
|
||||
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||
|
||||
|
||||
# Listing of phony targets.
|
||||
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||
build elf hex eep lss sym coff extcoff \
|
||||
clean clean_list program debug gdb-config
|
|
@ -0,0 +1,62 @@
|
|||
// Martin Thomas 4/2008
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#define LED_PORT PORTB
|
||||
#define LED_DDR DDRB
|
||||
#define LED_BIT PB2
|
||||
|
||||
#define BT_PORT PORTC
|
||||
#define BT_DDR DDRC
|
||||
#define BT_PIN PINC
|
||||
#define BT_BIT PC7
|
||||
|
||||
static inline void my_wdt_off(void)
|
||||
{
|
||||
cli();
|
||||
wdt_reset();
|
||||
/* Clear WDRF in MCUSR */
|
||||
MCUSR &= ~(1<<WDRF);
|
||||
/* Write logical one to WDCE and WDE */
|
||||
/* Keep old prescaler setting to prevent unintentional time-out */
|
||||
WDTCSR |= (1<<WDCE) | (1<<WDE);
|
||||
/* Turn off WDT */
|
||||
WDTCSR = 0x00;
|
||||
}
|
||||
|
||||
static void my_delay( void )
|
||||
{
|
||||
int i;
|
||||
for ( i=0; i<500; i++ ) {
|
||||
_delay_ms(1);
|
||||
}
|
||||
}
|
||||
|
||||
int main( void )
|
||||
{
|
||||
my_wdt_off();
|
||||
|
||||
LED_PORT |= ( 1<<LED_BIT );
|
||||
LED_DDR |= ( 1<<LED_BIT );
|
||||
|
||||
BT_DDR &= ~( 1<<BT_BIT );
|
||||
BT_PORT |= ( 1<<BT_BIT );
|
||||
|
||||
while ( 1 ) {
|
||||
LED_PORT &= ~( 1<<LED_BIT );
|
||||
my_delay();
|
||||
LED_PORT |= ( 1<<LED_BIT );
|
||||
my_delay();
|
||||
|
||||
if ( !( BT_PIN & ( 1<<BT_BIT ) ) ) {
|
||||
/* start bootloader */
|
||||
wdt_enable( WDTO_250MS );
|
||||
while (1) { ; }
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
:103800000C942A1C0C94451C0C94451C0C94451CCF
|
||||
:103810000C94451C0C94451C0C94451C0C94451CA4
|
||||
:103820000C94451C0C94451C0C94451C0C94451C94
|
||||
:103830000C94451C0C94451C0C94451C0C94451C84
|
||||
:103840000C94451C0C94451C0C94451C0C94451C74
|
||||
:103850000C94451C11241FBECFE5D4E0DEBFCDBFC4
|
||||
:1038600010E0A0E6B0E0EEE2FFE302C005900D92AA
|
||||
:10387000A036B107D9F710E0A0E6B0E001C01D9274
|
||||
:10388000A53EB107E1F70C94871D0C94001C8F9A9C
|
||||
:1038900084E083BD89E185BD089581E40E94E21E34
|
||||
:1038A00086E50E94E21E82E50E94E21E82E40E94FA
|
||||
:1038B000E21E8FE40E94E21E8FE40E94E21E84E575
|
||||
:1038C0000E94E21E08958F929F92AF92BF92CF9274
|
||||
:1038D000DF92EF92FF920F931F93CF93DF936C01D0
|
||||
:1038E000962EEE24FF2487010E591F4FE7012196E3
|
||||
:1038F000EC14FD0418F40E94E61E01C08FEFF801DD
|
||||
:1039000080837E01C038D10570F3EE24FF248091BE
|
||||
:10391000E400853721F08B3311F0C7018CC0A090F3
|
||||
:10392000E200B090E300E199FECF8FB6F89426E470
|
||||
:10393000921609F07DC08091E40087010E591F4F57
|
||||
:10394000E7012196EEEFFFEFCE0EDF1E8537F1F493
|
||||
:10395000F8018081282F3327FE01EE59FF4F808127
|
||||
:103960009927982F8827282B392B7E010894E11C52
|
||||
:10397000F11C41E08091E2009091E3000901FC011B
|
||||
:1039800040935700E8951124029628C080E40E94D5
|
||||
:103990004B1F8091E3000E944B1F8091E2000E9428
|
||||
:1039A0004B1FF80180810E944B1F88E40E944B1F2F
|
||||
:1039B0008091E3000E944B1F8091E2000E944B1F08
|
||||
:1039C0007E010894E11CF11CCE59DF4F88810E94D2
|
||||
:1039D0004B1F8091E2009091E30001969093E300E9
|
||||
:1039E0008093E200C114D10409F0A5CF8091E400D6
|
||||
:1039F000853769F485E0F50180935700E89507B6AF
|
||||
:103A000000FCFDCF81E180935700E89511C08CE464
|
||||
:103A10000E944B1F8B2D99270E944B1F8A2D0E94BD
|
||||
:103A20004B1F80E00E944B1F88E893E10E94F51E27
|
||||
:103A30008FBE8DE090E0DF91CF911F910F91FF90AD
|
||||
:103A4000EF90DF90CF90BF90AF909F908F900895B0
|
||||
:103A5000FF920F931F93CF93DF93EC01FFB6F8947F
|
||||
:103A6000E199FECF8091E4008537E9F4653409F4EB
|
||||
:103A700047C060E08091E2009091E3000E94EB1E5D
|
||||
:103A80008C010E94E21E812F99270E94E21E8091E4
|
||||
:103A9000E2009091E30002969093E3008093E200AD
|
||||
:103AA000229739F72DC08B3359F580E20E944B1FC6
|
||||
:103AB0008091E3000E944B1F8091E2000E944B1F07
|
||||
:103AC0008FEF0E944B1F0E94E21E88E20E944B1F54
|
||||
:103AD0008091E3000E944B1F8091E2000E944B1FE7
|
||||
:103AE0008FEF0E944B1F0E94E21E8091E200909196
|
||||
:103AF000E30001969093E3008093E2002297A9F6F9
|
||||
:103B0000FFBEDF91CF911F910F91FF900895CFE5F8
|
||||
:103B1000D4E0DEBFCDBFF89401E005BF82E085BFF1
|
||||
:103B2000A698AE9A60E087E190E00E94D81E9E9B26
|
||||
:103B300008C0AE9805BF15BEE0916000F09161002D
|
||||
:103B40000995BB9AC39A0E94401F0E94471C0E947D
|
||||
:103B5000E61E813611F489E528C18134F9F40E940A
|
||||
:103B6000E61E99279093E3008093E200182F002728
|
||||
:103B70000E94E61E282F3327202B312B3093E300A1
|
||||
:103B80002093E2008091E400853709F083C0220F82
|
||||
:103B9000331F3093E3002093E2007CC0823689F427
|
||||
:103BA00089E50E94E21E8091E400853729F480E0D7
|
||||
:103BB0000E94E21E80E8F9C080E00E94E21E80E4DC
|
||||
:103BC000F4C0823489F40E94E61E9927182F00273A
|
||||
:103BD0000E94E61E9927082B192B0E94E61E682FCB
|
||||
:103BE000C8010E94631CE1C0873689F40E94E61E6A
|
||||
:103BF0009927182F00270E94E61E9927082B192BBA
|
||||
:103C00000E94E61E682FC8010E94281DA0CF85369D
|
||||
:103C1000B1F58091E4008537F9F41092E300109239
|
||||
:103C2000E20043E020E030E0F90140935700E895DE
|
||||
:103C300007B600FCFDCFC90180589F4F9C0158E397
|
||||
:103C40008030950788F39093E3008093E20081E150
|
||||
:103C500080935700E8951EC08B33E1F48CEA0E94F4
|
||||
:103C60004B1F80E80E944B1F80E00E944B1F80E0AA
|
||||
:103C70000E944B1F8CE893E20E94F51E0BC0853416
|
||||
:103C800059F488E190E028E00FB6F894A89581BD3A
|
||||
:103C90000FBE21BD8DE089C0803539F48091E400EC
|
||||
:103CA0008B33C1F70E94511FF5CF8C3439F48091CA
|
||||
:103CB000E4008B3379F70E946D1FECCF803711F44D
|
||||
:103CC00083E573C0823711F48FEF6FC08E3459F4DF
|
||||
:103CD0008091E400853711F488E967C08B3309F0DF
|
||||
:103CE00036CF8EED62C08C3619F40E94E61ED2CF1C
|
||||
:103CF000843741F485E70E94E21E8BE30E94E21EB6
|
||||
:103D000080E053C0883731F40E94E61E823031F4DF
|
||||
:103D1000C398C0CF893721F40E94E61EC39ABACF58
|
||||
:103D2000843529F40E94E61E8093E400B3CF8335E6
|
||||
:103D300019F40E944D1C0BCF863529F480E30E94B4
|
||||
:103D4000E21E87E332C0833711F58091E4008537A6
|
||||
:103D500041F483E00E94E21E84E90E94E21E8EE1AB
|
||||
:103D600024C08B3309F0F3CE03E0015080E30E94BE
|
||||
:103D70004B1F80E00E944B1F802F0E944B1F8FEF34
|
||||
:103D80000E944B1F0E94E21E002379F7E0CE8D3483
|
||||
:103D900041F488B398E0892788BB84E70E94E21E3B
|
||||
:103DA00079CF8B3109F4D3CE8FE30E94E21ECFCEC0
|
||||
:103DB0009C01832F992780BD29B988E18AB986E8BB
|
||||
:103DC00080BD08955D9BFECF8CB908955F9BFECFAB
|
||||
:103DD0008CB199270895FC0160FD60935700C89548
|
||||
:103DE000802DE395C895902D0895CF93DF93CDB79F
|
||||
:103DF000DEB722970FB6F894DEBF0FBECDBF039695
|
||||
:103E000065E070E00E94831F9B0144275527DA017B
|
||||
:103E1000C90163E0880F991FAA1FBB1F6A95D1F7DC
|
||||
:103E2000821B930BA40BB50B9C0119821A8289810A
|
||||
:103E30009A818217930750F489819A810196898328
|
||||
:103E40009A8389819A8182179307B0F322960FB6DD
|
||||
:103E5000F894DEBF0FBECDBFDF91CF910895D89803
|
||||
:103E600088E092E50E94F51E0895D89A88E092E5D0
|
||||
:103E70000E94F51E08950E94351F0E942F1F08956D
|
||||
:103E8000C79A87B3806B87BBD09ABE9883E58DB9FC
|
||||
:103E90000E94351F08958FB9779BFECF8FB1992768
|
||||
:103EA0000895CF93C7980E943B1FC0E08CEA0E9400
|
||||
:103EB0004B1F83E50E944B1F8FEF0E944B1F8335E2
|
||||
:103EC00011F4C1E402C00E943B1F80E00E944B1F1E
|
||||
:103ED000CF5FC03458F3CF9108950E943B1F0E94DA
|
||||
:103EE000351F08950E94511F8CEA0E944B1F80E8E5
|
||||
:103EF0000E944B1F80E00E944B1F80E00E944B1FDE
|
||||
:103F00000E946D1F0895AA1BBB1B51E107C0AA1F89
|
||||
:103F1000BB1FA617B70710F0A61BB70B881F991F6A
|
||||
:0E3F20005A95A9F780959095BC01CD010895A2
|
||||
:0400000300003800C1
|
||||
:00000001FF
|
|
@ -0,0 +1,20 @@
|
|||
@echo off
|
||||
rem Use avrdude as programming-software with the AVRProg compatible bootloader
|
||||
rem Martin Thomas, 2006
|
||||
|
||||
rem Verfiy that the bootloader is configured with #define DEVTYPE DEVTYPE_ISP
|
||||
rem since it seems that avrdude does not work with "Boot" device-types and needs
|
||||
rem ISP device-types (at least in version 5.1 as in WinAVR 4/06)
|
||||
|
||||
set HEXFILE=cansniffer.hex
|
||||
set PROGRAMMER=avr109
|
||||
set PORT=com2
|
||||
set BAUD=19200
|
||||
set PART=atmega32
|
||||
|
||||
rem * disable safemode - bootloader can not "restore" fuses anyway
|
||||
set DIS_SAVE=-u
|
||||
|
||||
avrdude %DIS_SAVE% -p %PART% -P %PORT% -c %PROGRAMMER% -b %BAUD% -v -U flash:w:%HEXFILE%
|
||||
|
||||
rem pause
|
151
uart.c
151
uart.c
|
@ -1,151 +0,0 @@
|
|||
|
||||
#include <avr/io.h>
|
||||
|
||||
/* most of the definitions borrowed from Peter Fleury's UART-Library
|
||||
extende for control-register C and ATmega169 */
|
||||
|
||||
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) \
|
||||
|| defined(__AVR_ATmega323__)
|
||||
/* ATMega with one USART */
|
||||
#define ATMEGA_USART
|
||||
#define UART0_UBRR_HIGH UBRRH
|
||||
#define UART0_UBRR_LOW UBRRL
|
||||
#define UART0_RECEIVE_INTERRUPT SIG_UART_RECV
|
||||
#define UART0_TRANSMIT_INTERRUPT SIG_UART_DATA
|
||||
#define UART0_STATUS UCSRA
|
||||
#define UART0_CONTROL UCSRB
|
||||
#define UART0_DATA UDR
|
||||
#define UART0_UDRIE UDRIE
|
||||
#elif defined(__AVR_ATmega162__)
|
||||
/* ATMega with two USART */
|
||||
#define ATMEGA_USART0
|
||||
#define ATMEGA_USART1
|
||||
#define UART0_UBRR_HIGH UBRR0H
|
||||
#define UART0_UBRR_LOW UBRR0L
|
||||
#define UART1_UBRR_HIGH UBRR1H
|
||||
#define UART1_UBRR_LOW UBRR1L
|
||||
#define UART0_RECEIVE_INTERRUPT SIG_USART0_RECV
|
||||
#define UART1_RECEIVE_INTERRUPT SIG_USART1_RECV
|
||||
#define UART0_TRANSMIT_INTERRUPT SIG_USART0_DATA
|
||||
#define UART1_TRANSMIT_INTERRUPT SIG_USART1_DATA
|
||||
#define UART0_STATUS UCSR0A
|
||||
#define UART0_CONTROL UCSR0B
|
||||
#define UART0_CONTROL2 UCSR0C
|
||||
#define UART0_DATA UDR0
|
||||
#define UART0_UDRIE UDRIE0
|
||||
#define UART1_STATUS UCSR1A
|
||||
#define UART1_CONTROL UCSR1B
|
||||
#define UART1_CONTROL2 UCSR1C
|
||||
#define UART1_DATA UDR1
|
||||
#define UART1_UDRIE UDRIE1
|
||||
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||
/* ATMega with two USART */
|
||||
#define ATMEGA_USART0
|
||||
#define ATMEGA_USART1
|
||||
#define UART0_UBRR_HIGH UBRR0H
|
||||
#define UART0_UBRR_LOW UBRR0L
|
||||
#define UART1_UBRR_HIGH UBRR1H
|
||||
#define UART1_UBRR_LOW UBRR1L
|
||||
#define UART0_RECEIVE_INTERRUPT SIG_UART0_RECV
|
||||
#define UART1_RECEIVE_INTERRUPT SIG_UART1_RECV
|
||||
#define UART0_TRANSMIT_INTERRUPT SIG_UART0_DATA
|
||||
#define UART1_TRANSMIT_INTERRUPT SIG_UART1_DATA
|
||||
#define UART0_STATUS UCSR0A
|
||||
#define UART0_CONTROL UCSR0B
|
||||
#define UART0_CONTROL2 UCSR0C
|
||||
#define UART0_DATA UDR0
|
||||
#define UART0_UDRIE UDRIE0
|
||||
#define UART1_STATUS UCSR1A
|
||||
#define UART1_CONTROL UCSR1B
|
||||
#define UART1_CONTROL2 UCSR1C
|
||||
#define UART1_DATA UDR1
|
||||
#define UART1_UDRIE UDRIE1
|
||||
#elif defined(__AVR_ATmega169__)
|
||||
#define ATMEGA_USART
|
||||
#define UART0_UBRR_HIGH UBRR0H
|
||||
#define UART0_UBRR_LOW UBRR0L
|
||||
// TODO #define UART0_RECEIVE_INTERRUPT SIG_UART_RECV
|
||||
// TODO #define UART0_TRANSMIT_INTERRUPT SIG_UART_DATA
|
||||
#define UART0_STATUS UCSR0A
|
||||
#define UART0_CONTROL UCSR0B
|
||||
#define UART0_CONTROL2 UCSR0C
|
||||
#define UART0_DATA UDR0
|
||||
#define UART0_DOUBLEAVAIL
|
||||
// TODO #define UART0_UDRIE UDRIE
|
||||
#else
|
||||
#error "Processor type not supported in uart.c !"
|
||||
#endif
|
||||
|
||||
void USART_Init(unsigned int baudrate, unsigned char doublespeed)
|
||||
{
|
||||
// Set baud rate
|
||||
UART0_UBRR_HIGH = (unsigned char)(baudrate>>8);
|
||||
UART0_UBRR_LOW = (unsigned char)baudrate;
|
||||
|
||||
// Enable 2x speed - TODO adopt to all uCs
|
||||
#ifdef UART0_DOUBLEAVAIL
|
||||
if (doublespeed) UCSR0A = (1<<U2X0);
|
||||
#endif
|
||||
|
||||
#if defined (ATMEGA_USART)
|
||||
/* Enable USART receiver and transmitter and disable interrupts */
|
||||
UART0_CONTROL = (1<<RXEN)|(1<<TXEN)|(0<<RXCIE)|(0<<UDRIE);
|
||||
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||
#ifdef URSEL
|
||||
UCSRC = (1<<URSEL)|(3<<UCSZ0);
|
||||
#else
|
||||
UCSRC = (3<<UCSZ0);
|
||||
#endif
|
||||
|
||||
#elif defined (ATMEGA_USART0 )
|
||||
/* Enable USART receiver and transmitter and disable interrupts */
|
||||
UART0_CONTROL = (1<<RXEN0)|(1<<TXEN0)|(0<<RXCIE0)|(0<<UDRIE0);
|
||||
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||
#ifdef URSEL0
|
||||
UCSR0C = (1<<URSEL0)|(3<<UCSZ00);
|
||||
#else
|
||||
UCSR0C = (3<<UCSZ00);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void sendchar(char data)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
UART0_DATA = data;
|
||||
|
||||
if(SREG & 0x80)
|
||||
{
|
||||
while ( !(UART0_STATUS&0x40) && (i<10000) )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
while( !(UART0_STATUS&0x40) );
|
||||
|
||||
UART0_STATUS=UART0_STATUS|0x40; //delete TXCflag
|
||||
}
|
||||
|
||||
|
||||
char recchar(void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if(SREG & 0x80)
|
||||
{
|
||||
// while (!(UART0_STATUS & (1<<RXC0)) && (i<10000))
|
||||
while (!(UART0_STATUS & 0x80) && (i<10000))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
// while(!(UART0_STATUS & (1<<RXC0)));
|
||||
while(!(UART0_STATUS & 0x80));
|
||||
|
||||
return UART0_DATA ;
|
||||
}
|
Loading…
Reference in New Issue