Group hardware files for Arduino 1.x.x into hardware folder
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -0,0 +1,130 @@
 | 
			
		||||
:020000021000EC
 | 
			
		||||
:10F000000C9446F80C9465F80C9465F80C9465F82B
 | 
			
		||||
:10F010000C9465F80C9465F80C9465F80C9465F8FC
 | 
			
		||||
:10F020000C9465F80C9465F80C9465F80C9465F8EC
 | 
			
		||||
:10F030000C9465F80C9465F80C9465F80C9465F8DC
 | 
			
		||||
:10F040000C9465F80C9465F80C9465F80C9465F8CC
 | 
			
		||||
:10F050000C9465F80C9465F80C9465F80C9465F8BC
 | 
			
		||||
:10F060000C9465F80C9465F80C9465F80C9465F8AC
 | 
			
		||||
:10F070000C9465F80C9465F80C9465F80C9465F89C
 | 
			
		||||
:10F080000C9465F80C9465F80C9465F811241FBE77
 | 
			
		||||
:10F09000CFEFD0E4DEBFCDBF11E0A0E0B1E0E8EDFE
 | 
			
		||||
:10F0A000F7EF01E00BBF02C007900D92A230B1074D
 | 
			
		||||
:10F0B000D9F712E0A2E0B1E001C01D92AD30B10776
 | 
			
		||||
:10F0C000E1F70E947EF90C94EAFB0C9400F8909111
 | 
			
		||||
:10F0D0000201913019F0923041F008959091C000F2
 | 
			
		||||
:10F0E00095FFFCCF8093C60008959091C80095FFCE
 | 
			
		||||
:10F0F000FCCF8093CE0008951F93982F95959595FA
 | 
			
		||||
:10F1000095959595905D182F1F701A304CF4105DF1
 | 
			
		||||
:10F11000892F0E9467F8812F0E9467F81F91089538
 | 
			
		||||
:10F12000195A892F0E9467F8812F0E9467F81F9152
 | 
			
		||||
:10F130000895EF92FF920F931F9380910201813007
 | 
			
		||||
:10F1400069F1823031F080E01F910F91FF90EF90D4
 | 
			
		||||
:10F150000895EE24FF2487018091C80087FD17C021
 | 
			
		||||
:10F160000894E11CF11C011D111D81E4E81682E4E4
 | 
			
		||||
:10F17000F8068FE0080780E0180770F3E0910401BB
 | 
			
		||||
:10F18000F091050109958091C80087FFE9CF809132
 | 
			
		||||
:10F19000CE001F910F91FF90EF900895EE24FF2471
 | 
			
		||||
:10F1A00087018091C00087FD17C00894E11CF11C05
 | 
			
		||||
:10F1B000011D111D81E4E81682E4F8068FE00807BE
 | 
			
		||||
:10F1C00080E0180770F3E0910401F09105010995C2
 | 
			
		||||
:10F1D0008091C00087FFE9CF8091C6001F910F91F9
 | 
			
		||||
:10F1E000FF90EF9008951F930E9499F8182F0E94A6
 | 
			
		||||
:10F1F00067F8113634F410330CF01053812F1F913F
 | 
			
		||||
:10F2000008951755812F1F9108951F930E94F3F8B9
 | 
			
		||||
:10F21000182F0E94F3F81295107F810F1F91089507
 | 
			
		||||
:10F2200020910201882339F0213031F0223061F041
 | 
			
		||||
:10F2300081508823C9F708959091C00097FFFCCFB3
 | 
			
		||||
:10F240009091C6008150F5CF9091C80097FFFCCFF8
 | 
			
		||||
:10F250009091CE008150EDCF1F93182F0E9499F806
 | 
			
		||||
:10F26000803281F0809103018F5F809303018530AC
 | 
			
		||||
:10F2700011F01F910895E0910401F09105010995A5
 | 
			
		||||
:10F280001F91089584E10E9467F8812F0E9467F81A
 | 
			
		||||
:10F2900080E10E9467F8EDCF0E9499F8803271F00A
 | 
			
		||||
:10F2A000809103018F5F80930301853009F00895F9
 | 
			
		||||
:10F2B000E0910401F09105010995089584E10E940F
 | 
			
		||||
:10F2C00067F880E10E9467F8089515C0289A2FEF2B
 | 
			
		||||
:10F2D00031EE44E0215030404040E1F700C00000F2
 | 
			
		||||
:10F2E00028982FEF31EE44E0215030404040E1F7C4
 | 
			
		||||
:10F2F00000C000008150882349F70895EF92FF92E3
 | 
			
		||||
:10F300000F931F93CF93DF93000081E0809302015E
 | 
			
		||||
:10F3100080E18093C4001092C5001092C00086E086
 | 
			
		||||
:10F320008093C20088E18093C100209A81E00E940E
 | 
			
		||||
:10F3300065F90E9499F88033B1F18133B9F18034D5
 | 
			
		||||
:10F3400009F454C0813409F45AC0823409F469C004
 | 
			
		||||
:10F35000853409F46CC0803531F1823521F1813575
 | 
			
		||||
:10F3600011F1853509F469C0863509F471C0843618
 | 
			
		||||
:10F3700009F47AC0843709F4E1C0853709F43FC144
 | 
			
		||||
:10F38000863709F44AC0809103018F5F809303019F
 | 
			
		||||
:10F39000853079F6E0910401F091050109950E940C
 | 
			
		||||
:10F3A00099F8803351F60E944CF9C3CF0E9499F826
 | 
			
		||||
:10F3B000803249F784E10E9467F881E40E9467F88F
 | 
			
		||||
:10F3C00086E50E9467F882E50E9467F880E20E9465
 | 
			
		||||
:10F3D00067F889E40E9467F883E50E9467F880E592
 | 
			
		||||
:10F3E0000E9467F880E10E9467F8A3CF0E9499F815
 | 
			
		||||
:10F3F0008638C8F20E9499F80E944CF99ACF0E9470
 | 
			
		||||
:10F4000099F8803809F414C1813809F415C182389B
 | 
			
		||||
:10F4100009F416C1883909F407C180E00E942CF96B
 | 
			
		||||
:10F4200088CF84E10E9410F90E944CF982CF85E0D8
 | 
			
		||||
:10F430000E9410F90E944CF97CCF0E9499F88093A9
 | 
			
		||||
:10F4400006010E9499F8809307010E944CF971CF40
 | 
			
		||||
:10F450000E9499F8803309F405C183E00E9410F9F5
 | 
			
		||||
:10F4600080E00E942CF965CF0E9499F880930902F0
 | 
			
		||||
:10F470000E9499F88093080280910C028E7F8093FD
 | 
			
		||||
:10F480000C020E9499F8853409F4FDC080910802AD
 | 
			
		||||
:10F49000909109020097A1F068E0E62E61E0F62E57
 | 
			
		||||
:10F4A00000E010E00E9499F8F70181937F010F5F5F
 | 
			
		||||
:10F4B0001F4F80910802909109020817190790F3D5
 | 
			
		||||
:10F4C0000E9499F8803209F05ECF80910C0280FF93
 | 
			
		||||
:10F4D000ECC08091060190910701880F991F9093CD
 | 
			
		||||
:10F4E000070180930601209108023091090221153D
 | 
			
		||||
:10F4F0003105E9F048E0E42E41E0F42E00E010E0B0
 | 
			
		||||
:10F50000F70161917F010E94DCFB809106019091DF
 | 
			
		||||
:10F510000701019690930701809306010F5F1F4F2B
 | 
			
		||||
:10F5200020910802309109020217130748F384E181
 | 
			
		||||
:10F530000E9467F880E10E9467F8FBCE0E9499F86C
 | 
			
		||||
:10F54000809309020E9499F8809308028091060135
 | 
			
		||||
:10F550009091070197FDA3C020910C022D7F20936D
 | 
			
		||||
:10F560000C02880F991F90930701809306010E9457
 | 
			
		||||
:10F5700099F8853409F48DC080910C028E7F8093B8
 | 
			
		||||
:10F580000C020E9499F8803209F0D3CE84E10E94E7
 | 
			
		||||
:10F5900067F88091080290910902009709F440C031
 | 
			
		||||
:10F5A00000E010E0809106019091070116C0FC0177
 | 
			
		||||
:10F5B00084910E9467F8809106019091070101965D
 | 
			
		||||
:10F5C00090930701809306010F5F1F4F209108025F
 | 
			
		||||
:10F5D000309109020217130718F520910C0220FD43
 | 
			
		||||
:10F5E00033C021FFE4CFA0E0B0E080509040AF4FA7
 | 
			
		||||
:10F5F000BF4FABBFFC0187910E9467F8DCCF0E9430
 | 
			
		||||
:10F6000099F8803209F0BFCE84E10E9467F88EE15C
 | 
			
		||||
:10F610000E9467F887E90E9467F885E00E9467F812
 | 
			
		||||
:10F6200080E10E9467F885CE83E00E942CF981CEAC
 | 
			
		||||
:10F6300082E00E942CF97DCE81E00E942CF979CEE7
 | 
			
		||||
:10F6400080E10E942CF975CE0E94D4FB0E9467F8DD
 | 
			
		||||
:10F650008091060190910701019690930701809394
 | 
			
		||||
:10F660000601B2CF0E9499F80E9499F8082F0E94D3
 | 
			
		||||
:10F6700099F8002309F48BC0013009F48CC085E0AF
 | 
			
		||||
:10F680000E942CF956CE80910C02816080930C026E
 | 
			
		||||
:10F69000FDCE80910C02816080930C0272CF20918C
 | 
			
		||||
:10F6A0000C02226020930C025CCF8091070187FD41
 | 
			
		||||
:10F6B00076C010920B0280E08BBF80910601909182
 | 
			
		||||
:10F6C0000701880F991F909307018093060180918D
 | 
			
		||||
:10F6D000080280FF09C080910802909109020196FA
 | 
			
		||||
:10F6E0009093090280930802F894F999FECF1127AC
 | 
			
		||||
:10F6F000E0910601F0910701C8E0D1E08091080295
 | 
			
		||||
:10F7000090910902103091F400915700017001307E
 | 
			
		||||
:10F71000D9F303E000935700E8950091570001707A
 | 
			
		||||
:10F720000130D9F301E100935700E8950990199051
 | 
			
		||||
:10F730000091570001700130D9F301E000935700A8
 | 
			
		||||
:10F74000E8951395103898F0112700915700017033
 | 
			
		||||
:10F750000130D9F305E000935700E8950091570078
 | 
			
		||||
:10F7600001700130D9F301E100935700E89532961A
 | 
			
		||||
:10F77000029709F0C7CF103011F00296E5CF11249F
 | 
			
		||||
:10F7800084E10E9467F880E10E9467F8D2CD8EE1A3
 | 
			
		||||
:10F790000E942CF9CECD87E90E942CF9CACDF1E068
 | 
			
		||||
:10F7A000F0930B0281E088CFF999FECF92BD81BD25
 | 
			
		||||
:10F7B000F89A992780B50895262FF999FECF1FBA98
 | 
			
		||||
:10F7C00092BD81BD20BD0FB6F894FA9AF99A0FBE8A
 | 
			
		||||
:08F7D00001960895F894FFCFA3
 | 
			
		||||
:02F7D8008000AF
 | 
			
		||||
:040000031000F000F9
 | 
			
		||||
:00000001FF
 | 
			
		||||
@@ -0,0 +1,130 @@
 | 
			
		||||
:020000021000EC
 | 
			
		||||
:10F000000C9446F80C9465F80C9465F80C9465F82B
 | 
			
		||||
:10F010000C9465F80C9465F80C9465F80C9465F8FC
 | 
			
		||||
:10F020000C9465F80C9465F80C9465F80C9465F8EC
 | 
			
		||||
:10F030000C9465F80C9465F80C9465F80C9465F8DC
 | 
			
		||||
:10F040000C9465F80C9465F80C9465F80C9465F8CC
 | 
			
		||||
:10F050000C9465F80C9465F80C9465F80C9465F8BC
 | 
			
		||||
:10F060000C9465F80C9465F80C9465F80C9465F8AC
 | 
			
		||||
:10F070000C9465F80C9465F80C9465F80C9465F89C
 | 
			
		||||
:10F080000C9465F80C9465F80C9465F811241FBE77
 | 
			
		||||
:10F09000CFEFD0E4DEBFCDBF11E0A0E0B1E0E8EDFE
 | 
			
		||||
:10F0A000F7EF01E00BBF02C007900D92A230B1074D
 | 
			
		||||
:10F0B000D9F712E0A2E0B1E001C01D92AD30B10776
 | 
			
		||||
:10F0C000E1F70E947EF90C94EAFB0C9400F8909111
 | 
			
		||||
:10F0D0000201913019F0923041F008959091C000F2
 | 
			
		||||
:10F0E00095FFFCCF8093C60008959091C80095FFCE
 | 
			
		||||
:10F0F000FCCF8093CE0008951F93982F95959595FA
 | 
			
		||||
:10F1000095959595905D182F1F701A304CF4105DF1
 | 
			
		||||
:10F11000892F0E9467F8812F0E9467F81F91089538
 | 
			
		||||
:10F12000195A892F0E9467F8812F0E9467F81F9152
 | 
			
		||||
:10F130000895EF92FF920F931F9380910201813007
 | 
			
		||||
:10F1400069F1823031F080E01F910F91FF90EF90D4
 | 
			
		||||
:10F150000895EE24FF2487018091C80087FD17C021
 | 
			
		||||
:10F160000894E11CF11C011D111D81E2E81681EAE1
 | 
			
		||||
:10F17000F80687E0080780E0180770F3E0910401C3
 | 
			
		||||
:10F18000F091050109958091C80087FFE9CF809132
 | 
			
		||||
:10F19000CE001F910F91FF90EF900895EE24FF2471
 | 
			
		||||
:10F1A00087018091C00087FD17C00894E11CF11C05
 | 
			
		||||
:10F1B000011D111D81E2E81681EAF80687E00807C3
 | 
			
		||||
:10F1C00080E0180770F3E0910401F09105010995C2
 | 
			
		||||
:10F1D0008091C00087FFE9CF8091C6001F910F91F9
 | 
			
		||||
:10F1E000FF90EF9008951F930E9499F8182F0E94A6
 | 
			
		||||
:10F1F00067F8113634F410330CF01053812F1F913F
 | 
			
		||||
:10F2000008951755812F1F9108951F930E94F3F8B9
 | 
			
		||||
:10F21000182F0E94F3F81295107F810F1F91089507
 | 
			
		||||
:10F2200020910201882339F0213031F0223061F041
 | 
			
		||||
:10F2300081508823C9F708959091C00097FFFCCFB3
 | 
			
		||||
:10F240009091C6008150F5CF9091C80097FFFCCFF8
 | 
			
		||||
:10F250009091CE008150EDCF1F93182F0E9499F806
 | 
			
		||||
:10F26000803281F0809103018F5F809303018530AC
 | 
			
		||||
:10F2700011F01F910895E0910401F09105010995A5
 | 
			
		||||
:10F280001F91089584E10E9467F8812F0E9467F81A
 | 
			
		||||
:10F2900080E10E9467F8EDCF0E9499F8803271F00A
 | 
			
		||||
:10F2A000809103018F5F80930301853009F00895F9
 | 
			
		||||
:10F2B000E0910401F09105010995089584E10E940F
 | 
			
		||||
:10F2C00067F880E10E9467F8089515C0289A2FEF2B
 | 
			
		||||
:10F2D00030E742E0215030404040E1F700C00000FC
 | 
			
		||||
:10F2E00028982FEF30E742E0215030404040E1F7CE
 | 
			
		||||
:10F2F00000C000008150882349F70895EF92FF92E3
 | 
			
		||||
:10F300000F931F93CF93DF93000081E0809302015E
 | 
			
		||||
:10F3100089E18093C4001092C5001092C00086E07D
 | 
			
		||||
:10F320008093C20088E18093C100209A81E00E940E
 | 
			
		||||
:10F3300065F90E9499F88033B1F18133B9F18034D5
 | 
			
		||||
:10F3400009F454C0813409F45AC0823409F469C004
 | 
			
		||||
:10F35000853409F46CC0803531F1823521F1813575
 | 
			
		||||
:10F3600011F1853509F469C0863509F471C0843618
 | 
			
		||||
:10F3700009F47AC0843709F4E1C0853709F43FC144
 | 
			
		||||
:10F38000863709F44AC0809103018F5F809303019F
 | 
			
		||||
:10F39000853079F6E0910401F091050109950E940C
 | 
			
		||||
:10F3A00099F8803351F60E944CF9C3CF0E9499F826
 | 
			
		||||
:10F3B000803249F784E10E9467F881E40E9467F88F
 | 
			
		||||
:10F3C00086E50E9467F882E50E9467F880E20E9465
 | 
			
		||||
:10F3D00067F889E40E9467F883E50E9467F880E592
 | 
			
		||||
:10F3E0000E9467F880E10E9467F8A3CF0E9499F815
 | 
			
		||||
:10F3F0008638C8F20E9499F80E944CF99ACF0E9470
 | 
			
		||||
:10F4000099F8803809F414C1813809F415C182389B
 | 
			
		||||
:10F4100009F416C1883909F407C180E00E942CF96B
 | 
			
		||||
:10F4200088CF84E10E9410F90E944CF982CF85E0D8
 | 
			
		||||
:10F430000E9410F90E944CF97CCF0E9499F88093A9
 | 
			
		||||
:10F4400006010E9499F8809307010E944CF971CF40
 | 
			
		||||
:10F450000E9499F8803309F405C183E00E9410F9F5
 | 
			
		||||
:10F4600080E00E942CF965CF0E9499F880930902F0
 | 
			
		||||
:10F470000E9499F88093080280910C028E7F8093FD
 | 
			
		||||
:10F480000C020E9499F8853409F4FDC080910802AD
 | 
			
		||||
:10F49000909109020097A1F068E0E62E61E0F62E57
 | 
			
		||||
:10F4A00000E010E00E9499F8F70181937F010F5F5F
 | 
			
		||||
:10F4B0001F4F80910802909109020817190790F3D5
 | 
			
		||||
:10F4C0000E9499F8803209F05ECF80910C0280FF93
 | 
			
		||||
:10F4D000ECC08091060190910701880F991F9093CD
 | 
			
		||||
:10F4E000070180930601209108023091090221153D
 | 
			
		||||
:10F4F0003105E9F048E0E42E41E0F42E00E010E0B0
 | 
			
		||||
:10F50000F70161917F010E94DCFB809106019091DF
 | 
			
		||||
:10F510000701019690930701809306010F5F1F4F2B
 | 
			
		||||
:10F5200020910802309109020217130748F384E181
 | 
			
		||||
:10F530000E9467F880E10E9467F8FBCE0E9499F86C
 | 
			
		||||
:10F54000809309020E9499F8809308028091060135
 | 
			
		||||
:10F550009091070197FDA3C020910C022D7F20936D
 | 
			
		||||
:10F560000C02880F991F90930701809306010E9457
 | 
			
		||||
:10F5700099F8853409F48DC080910C028E7F8093B8
 | 
			
		||||
:10F580000C020E9499F8803209F0D3CE84E10E94E7
 | 
			
		||||
:10F5900067F88091080290910902009709F440C031
 | 
			
		||||
:10F5A00000E010E0809106019091070116C0FC0177
 | 
			
		||||
:10F5B00084910E9467F8809106019091070101965D
 | 
			
		||||
:10F5C00090930701809306010F5F1F4F209108025F
 | 
			
		||||
:10F5D000309109020217130718F520910C0220FD43
 | 
			
		||||
:10F5E00033C021FFE4CFA0E0B0E080509040AF4FA7
 | 
			
		||||
:10F5F000BF4FABBFFC0187910E9467F8DCCF0E9430
 | 
			
		||||
:10F6000099F8803209F0BFCE84E10E9467F88EE15C
 | 
			
		||||
:10F610000E9467F887E90E9467F885E00E9467F812
 | 
			
		||||
:10F6200080E10E9467F885CE83E00E942CF981CEAC
 | 
			
		||||
:10F6300082E00E942CF97DCE81E00E942CF979CEE7
 | 
			
		||||
:10F6400080E10E942CF975CE0E94D4FB0E9467F8DD
 | 
			
		||||
:10F650008091060190910701019690930701809394
 | 
			
		||||
:10F660000601B2CF0E9499F80E9499F8082F0E94D3
 | 
			
		||||
:10F6700099F8002309F48BC0013009F48CC085E0AF
 | 
			
		||||
:10F680000E942CF956CE80910C02816080930C026E
 | 
			
		||||
:10F69000FDCE80910C02816080930C0272CF20918C
 | 
			
		||||
:10F6A0000C02226020930C025CCF8091070187FD41
 | 
			
		||||
:10F6B00076C010920B0280E08BBF80910601909182
 | 
			
		||||
:10F6C0000701880F991F909307018093060180918D
 | 
			
		||||
:10F6D000080280FF09C080910802909109020196FA
 | 
			
		||||
:10F6E0009093090280930802F894F999FECF1127AC
 | 
			
		||||
:10F6F000E0910601F0910701C8E0D1E08091080295
 | 
			
		||||
:10F7000090910902103091F400915700017001307E
 | 
			
		||||
:10F71000D9F303E000935700E8950091570001707A
 | 
			
		||||
:10F720000130D9F301E100935700E8950990199051
 | 
			
		||||
:10F730000091570001700130D9F301E000935700A8
 | 
			
		||||
:10F74000E8951395103898F0112700915700017033
 | 
			
		||||
:10F750000130D9F305E000935700E8950091570078
 | 
			
		||||
:10F7600001700130D9F301E100935700E89532961A
 | 
			
		||||
:10F77000029709F0C7CF103011F00296E5CF11249F
 | 
			
		||||
:10F7800084E10E9467F880E10E9467F8D2CD8EE1A3
 | 
			
		||||
:10F790000E942CF9CECD87E90E942CF9CACDF1E068
 | 
			
		||||
:10F7A000F0930B0281E088CFF999FECF92BD81BD25
 | 
			
		||||
:10F7B000F89A992780B50895262FF999FECF1FBA98
 | 
			
		||||
:10F7C00092BD81BD20BD0FB6F894FA9AF99A0FBE8A
 | 
			
		||||
:08F7D00001960895F894FFCFA3
 | 
			
		||||
:02F7D8008000AF
 | 
			
		||||
:040000031000F000F9
 | 
			
		||||
:00000001FF
 | 
			
		||||
@@ -0,0 +1,126 @@
 | 
			
		||||
:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
 | 
			
		||||
:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
 | 
			
		||||
:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
 | 
			
		||||
:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
 | 
			
		||||
:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
 | 
			
		||||
:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
 | 
			
		||||
:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
 | 
			
		||||
:10F870000C945B7C0C945B7C0C945B7C11241FBE11
 | 
			
		||||
:10F88000CFEFD0E1DEBFCDBF11E0A0E0B1E0EAEA0A
 | 
			
		||||
:10F89000FFEF02C005900D92A230B107D9F712E038
 | 
			
		||||
:10F8A000A2E0B1E001C01D92AD30B107E1F70E94C6
 | 
			
		||||
:10F8B000747D0C94D37F0C94007C90910201913064
 | 
			
		||||
:10F8C00019F0923041F008959091C00095FFFCCF5F
 | 
			
		||||
:10F8D0008093C60008959091C80095FFFCCF809357
 | 
			
		||||
:10F8E000CE0008951F93982F95959595959595958C
 | 
			
		||||
:10F8F000905D182F1F701A304CF4105D892F0E94F4
 | 
			
		||||
:10F900005D7C812F0E945D7C1F910895195A892F7B
 | 
			
		||||
:10F910000E945D7C812F0E945D7C1F910895EF9273
 | 
			
		||||
:10F92000FF920F931F9380910201813069F1823021
 | 
			
		||||
:10F9300031F080E01F910F91FF90EF900895EE2439
 | 
			
		||||
:10F94000FF2487018091C80087FD17C00894E11C3F
 | 
			
		||||
:10F95000F11C011D111D81E4E81682E4F8068FE018
 | 
			
		||||
:10F96000080780E0180770F3E0910401F0910501A9
 | 
			
		||||
:10F9700009958091C80087FFE9CF8091CE001F9143
 | 
			
		||||
:10F980000F91FF90EF900895EE24FF24870180915E
 | 
			
		||||
:10F99000C00087FD17C00894E11CF11C011D111D5A
 | 
			
		||||
:10F9A00081E4E81682E4F8068FE0080780E0180793
 | 
			
		||||
:10F9B00070F3E0910401F091050109958091C00078
 | 
			
		||||
:10F9C00087FFE9CF8091C6001F910F91FF90EF90C4
 | 
			
		||||
:10F9D00008951F930E948F7C182F0E945D7C113622
 | 
			
		||||
:10F9E00034F410330CF01053812F1F9108951755E4
 | 
			
		||||
:10F9F000812F1F9108951F930E94E97C182F0E9468
 | 
			
		||||
:10FA0000E97C1295107F810F1F91089520910201CA
 | 
			
		||||
:10FA1000882339F0213031F0223061F08150882381
 | 
			
		||||
:10FA2000C9F708959091C00097FFFCCF9091C60050
 | 
			
		||||
:10FA30008150F5CF9091C80097FFFCCF9091CE00F8
 | 
			
		||||
:10FA40008150EDCF1F93182F0E948F7C803281F060
 | 
			
		||||
:10FA5000809103018F5F80930301853011F01F9126
 | 
			
		||||
:10FA60000895E0910401F091050109951F91089511
 | 
			
		||||
:10FA700084E10E945D7C812F0E945D7C80E10E9478
 | 
			
		||||
:10FA80005D7CEDCF0E948F7C803271F0809103010C
 | 
			
		||||
:10FA90008F5F80930301853009F00895E0910401A0
 | 
			
		||||
:10FAA000F09105010995089584E10E945D7C80E153
 | 
			
		||||
:10FAB0000E945D7C089515C0289A2FEF31EE44E036
 | 
			
		||||
:10FAC000215030404040E1F700C0000028982FEF5F
 | 
			
		||||
:10FAD00031EE44E0215030404040E1F700C00000EA
 | 
			
		||||
:10FAE0008150882349F70895EF92FF920F931F9357
 | 
			
		||||
:10FAF000CF93DF93000081E08093020180E1809347
 | 
			
		||||
:10FB0000C4001092C5001092C00086E08093C2002D
 | 
			
		||||
:10FB100088E18093C100209A81E00E945B7D0E9471
 | 
			
		||||
:10FB20008F7C8033B1F18133B9F1803409F454C052
 | 
			
		||||
:10FB3000813409F45AC0823409F469C0853409F467
 | 
			
		||||
:10FB40006CC0803531F1823521F1813511F1853577
 | 
			
		||||
:10FB500009F469C0863509F471C0843609F47AC0A5
 | 
			
		||||
:10FB6000843709F4E1C0853709F439C1863709F4CF
 | 
			
		||||
:10FB70004AC0809103018F5F80930301853079F63D
 | 
			
		||||
:10FB8000E0910401F091050109950E948F7C80337A
 | 
			
		||||
:10FB900051F60E94427DC3CF0E948F7C803249F78C
 | 
			
		||||
:10FBA00084E10E945D7C81E40E945D7C86E50E9488
 | 
			
		||||
:10FBB0005D7C82E50E945D7C80E20E945D7C89E440
 | 
			
		||||
:10FBC0000E945D7C83E50E945D7C80E50E945D7CF7
 | 
			
		||||
:10FBD00080E10E945D7CA3CF0E948F7C8638C8F2B2
 | 
			
		||||
:10FBE0000E948F7C0E94427D9ACF0E948F7C803839
 | 
			
		||||
:10FBF00009F40EC1813809F40FC1823809F410C12B
 | 
			
		||||
:10FC0000883909F401C180E00E94227D88CF84E117
 | 
			
		||||
:10FC10000E94067D0E94427D82CF85E00E94067D83
 | 
			
		||||
:10FC20000E94427D7CCF0E948F7C809306010E94BF
 | 
			
		||||
:10FC30008F7C809307010E94427D71CF0E948F7C50
 | 
			
		||||
:10FC4000803309F4F1C083E00E94067D80E00E94C9
 | 
			
		||||
:10FC5000227D65CF0E948F7C809309020E948F7C59
 | 
			
		||||
:10FC60008093080280910C028E7F80930C020E9488
 | 
			
		||||
:10FC70008F7C853409F4E9C08091080290910902D3
 | 
			
		||||
:10FC80000097A1F068E0E62E61E0F62E00E010E0BB
 | 
			
		||||
:10FC90000E948F7CF70181937F010F5F1F4F80913E
 | 
			
		||||
:10FCA0000802909109020817190790F30E948F7CAF
 | 
			
		||||
:10FCB000803209F05ECF80910C0280FFE5C0809118
 | 
			
		||||
:10FCC000060190910701880F991F90930701809377
 | 
			
		||||
:10FCD0000601209108023091090221153105E9F051
 | 
			
		||||
:10FCE00048E0E42E41E0F42E00E010E0F7016191DD
 | 
			
		||||
:10FCF0007F010E94C57F80910601909107010196C6
 | 
			
		||||
:10FD000090930701809306010F5F1F4F2091080217
 | 
			
		||||
:10FD1000309109020217130748F384E10E945D7CC9
 | 
			
		||||
:10FD200080E10E945D7CFBCE0E948F7C8093090263
 | 
			
		||||
:10FD30000E948F7C809308028091060190910701B8
 | 
			
		||||
:10FD400097FD9CC020910C022D7F20930C02880F00
 | 
			
		||||
:10FD5000991F90930701809306010E948F7C853440
 | 
			
		||||
:10FD600009F486C080910C028E7F80930C020E9461
 | 
			
		||||
:10FD70008F7C803209F0D3CE84E10E945D7C20919B
 | 
			
		||||
:10FD800008023091090221153105D1F100E010E09F
 | 
			
		||||
:10FD900080910601909107010CC041FF5CC0019663
 | 
			
		||||
:10FDA00090930701809306010F5F1F4F02171307FF
 | 
			
		||||
:10FDB00038F540910C0240FFF0CF0E94BD7F0E94B9
 | 
			
		||||
:10FDC0005D7C809106019091070101969093070157
 | 
			
		||||
:10FDD000809306012091080230910902E5CF0E942C
 | 
			
		||||
:10FDE0008F7C803209F0C5CE84E10E945D7C8EE17B
 | 
			
		||||
:10FDF0000E945D7C86E90E945D7C8AE00E945D7CB9
 | 
			
		||||
:10FE000080E10E945D7C8BCE83E00E94227D87CEC4
 | 
			
		||||
:10FE100082E00E94227D83CE81E00E94227D7FCEFF
 | 
			
		||||
:10FE200080E10E94227D7BCE0E948F7C0E948F7C8D
 | 
			
		||||
:10FE3000082F0E948F7C002309F497C0013009F439
 | 
			
		||||
:10FE400098C08AE00E94227D6ACE80910C02816077
 | 
			
		||||
:10FE500080930C0211CFFC0184910E945D7C209163
 | 
			
		||||
:10FE6000080230910902809106019091070197CF15
 | 
			
		||||
:10FE700080910C02816080930C0279CF20910C025A
 | 
			
		||||
:10FE8000226020930C0263CF80910701880F880BBA
 | 
			
		||||
:10FE9000817080930B028091060190910701880F79
 | 
			
		||||
:10FEA000991F90930701809306018091080280FFBB
 | 
			
		||||
:10FEB00009C080910802909109020196909309026D
 | 
			
		||||
:10FEC00080930802F894F999FECF1127E09106017A
 | 
			
		||||
:10FED000F0910701C8E0D1E08091080290910902F9
 | 
			
		||||
:10FEE000103091F40091570001700130D9F303E014
 | 
			
		||||
:10FEF00000935700E8950091570001700130D9F345
 | 
			
		||||
:10FF000001E100935700E89509901990009157007E
 | 
			
		||||
:10FF100001700130D9F301E000935700E895139583
 | 
			
		||||
:10FF2000103898F011270091570001700130D9F373
 | 
			
		||||
:10FF300005E000935700E8950091570001700130EB
 | 
			
		||||
:10FF4000D9F301E100935700E8953296029709F042
 | 
			
		||||
:10FF5000C7CF103011F00296E5CF112484E10E9442
 | 
			
		||||
:10FF60005D7C80E10E945D7CDACD8EE10E94227D85
 | 
			
		||||
:10FF7000D6CD86E90E94227DD2CDF999FECF92BDE1
 | 
			
		||||
:10FF800081BDF89A992780B50895262FF999FECF5B
 | 
			
		||||
:10FF90001FBA92BD81BD20BD0FB6F894FA9AF99AA6
 | 
			
		||||
:0AFFA0000FBE01960895F894FFCFFC
 | 
			
		||||
:02FFAA008000D5
 | 
			
		||||
:040000030000F80001
 | 
			
		||||
:00000001FF
 | 
			
		||||
@@ -0,0 +1,254 @@
 | 
			
		||||
# Makefile for ATmegaBOOT
 | 
			
		||||
# E.Lins, 18.7.2005
 | 
			
		||||
# $Id$
 | 
			
		||||
#
 | 
			
		||||
# Instructions
 | 
			
		||||
#
 | 
			
		||||
# To make bootloader .hex file:
 | 
			
		||||
# make diecimila
 | 
			
		||||
# make lilypad
 | 
			
		||||
# make ng
 | 
			
		||||
# etc...
 | 
			
		||||
#
 | 
			
		||||
# To burn bootloader .hex file:
 | 
			
		||||
# make diecimila_isp
 | 
			
		||||
# make lilypad_isp
 | 
			
		||||
# make ng_isp
 | 
			
		||||
# etc...
 | 
			
		||||
 | 
			
		||||
# program name should not be changed...
 | 
			
		||||
PROGRAM    = ATmegaBOOT_168
 | 
			
		||||
 | 
			
		||||
# enter the parameters for the avrdude isp tool
 | 
			
		||||
ISPTOOL	   = stk500v2
 | 
			
		||||
ISPPORT	   = usb
 | 
			
		||||
ISPSPEED   = -b 115200
 | 
			
		||||
 | 
			
		||||
MCU_TARGET = atmega168
 | 
			
		||||
LDSECTION  = --section-start=.text=0x3800
 | 
			
		||||
 | 
			
		||||
# the efuse should really be 0xf8; since, however, only the lower
 | 
			
		||||
# three bits of that byte are used on the atmega168, avrdude gets
 | 
			
		||||
# confused if you specify 1's for the higher bits, see:
 | 
			
		||||
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
 | 
			
		||||
#
 | 
			
		||||
# similarly, the lock bits should be 0xff instead of 0x3f (to
 | 
			
		||||
# unlock the bootloader section) and 0xcf instead of 0x0f (to
 | 
			
		||||
# lock it), but since the high two bits of the lock byte are
 | 
			
		||||
# unused, avrdude would get confused.
 | 
			
		||||
 | 
			
		||||
ISPFUSES    = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
 | 
			
		||||
-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
 | 
			
		||||
ISPFLASH    = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
 | 
			
		||||
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
 | 
			
		||||
 | 
			
		||||
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
 | 
			
		||||
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
 | 
			
		||||
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
 | 
			
		||||
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
OBJ        = $(PROGRAM).o
 | 
			
		||||
OPTIMIZE   = -O2
 | 
			
		||||
 | 
			
		||||
DEFS       = 
 | 
			
		||||
LIBS       =
 | 
			
		||||
 | 
			
		||||
CC         = avr-gcc
 | 
			
		||||
 | 
			
		||||
# Override is only needed by avr-lib build system.
 | 
			
		||||
 | 
			
		||||
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
 | 
			
		||||
override LDFLAGS       = -Wl,$(LDSECTION)
 | 
			
		||||
#override LDFLAGS       = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
 | 
			
		||||
 | 
			
		||||
OBJCOPY        = avr-objcopy
 | 
			
		||||
OBJDUMP        = avr-objdump
 | 
			
		||||
 | 
			
		||||
all:
 | 
			
		||||
 | 
			
		||||
lilypad: TARGET = lilypad
 | 
			
		||||
lilypad: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
 | 
			
		||||
lilypad: AVR_FREQ = 8000000L
 | 
			
		||||
lilypad: $(PROGRAM)_lilypad.hex
 | 
			
		||||
 | 
			
		||||
lilypad_isp: lilypad
 | 
			
		||||
lilypad_isp: TARGET = lilypad
 | 
			
		||||
lilypad_isp: HFUSE = DD
 | 
			
		||||
lilypad_isp: LFUSE = E2
 | 
			
		||||
lilypad_isp: EFUSE = 00
 | 
			
		||||
lilypad_isp: isp
 | 
			
		||||
 | 
			
		||||
lilypad_resonator: TARGET = lilypad_resonator
 | 
			
		||||
lilypad_resonator: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=3'
 | 
			
		||||
lilypad_resonator: AVR_FREQ = 8000000L
 | 
			
		||||
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
 | 
			
		||||
 | 
			
		||||
lilypad_resonator_isp: lilypad_resonator
 | 
			
		||||
lilypad_resonator_isp: TARGET = lilypad_resonator
 | 
			
		||||
lilypad_resonator_isp: HFUSE = DD
 | 
			
		||||
lilypad_resonator_isp: LFUSE = C6
 | 
			
		||||
lilypad_resonator_isp: EFUSE = 00
 | 
			
		||||
lilypad_resonator_isp: isp
 | 
			
		||||
 | 
			
		||||
pro8: TARGET = pro_8MHz
 | 
			
		||||
pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
 | 
			
		||||
pro8: AVR_FREQ = 8000000L
 | 
			
		||||
pro8: $(PROGRAM)_pro_8MHz.hex
 | 
			
		||||
 | 
			
		||||
pro8_isp: pro8
 | 
			
		||||
pro8_isp: TARGET = pro_8MHz
 | 
			
		||||
pro8_isp: HFUSE = DD
 | 
			
		||||
pro8_isp: LFUSE = C6
 | 
			
		||||
pro8_isp: EFUSE = 00
 | 
			
		||||
pro8_isp: isp
 | 
			
		||||
 | 
			
		||||
pro16: TARGET = pro_16MHz
 | 
			
		||||
pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
 | 
			
		||||
pro16: AVR_FREQ = 16000000L
 | 
			
		||||
pro16: $(PROGRAM)_pro_16MHz.hex
 | 
			
		||||
 | 
			
		||||
pro16_isp: pro16
 | 
			
		||||
pro16_isp: TARGET = pro_16MHz
 | 
			
		||||
pro16_isp: HFUSE = DD
 | 
			
		||||
pro16_isp: LFUSE = C6
 | 
			
		||||
pro16_isp: EFUSE = 00
 | 
			
		||||
pro16_isp: isp
 | 
			
		||||
 | 
			
		||||
pro20: TARGET = pro_20mhz
 | 
			
		||||
pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
 | 
			
		||||
pro20: AVR_FREQ = 20000000L
 | 
			
		||||
pro20: $(PROGRAM)_pro_20mhz.hex
 | 
			
		||||
 | 
			
		||||
pro20_isp: pro20
 | 
			
		||||
pro20_isp: TARGET = pro_20mhz
 | 
			
		||||
pro20_isp: HFUSE = DD
 | 
			
		||||
pro20_isp: LFUSE = C6
 | 
			
		||||
pro20_isp: EFUSE = 00
 | 
			
		||||
pro20_isp: isp
 | 
			
		||||
 | 
			
		||||
diecimila: TARGET = diecimila
 | 
			
		||||
diecimila: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1'
 | 
			
		||||
diecimila: AVR_FREQ = 16000000L 
 | 
			
		||||
diecimila: $(PROGRAM)_diecimila.hex
 | 
			
		||||
 | 
			
		||||
diecimila_isp: diecimila
 | 
			
		||||
diecimila_isp: TARGET = diecimila
 | 
			
		||||
diecimila_isp: HFUSE = DD
 | 
			
		||||
diecimila_isp: LFUSE = FF
 | 
			
		||||
diecimila_isp: EFUSE = 00
 | 
			
		||||
diecimila_isp: isp
 | 
			
		||||
 | 
			
		||||
ng: TARGET = ng
 | 
			
		||||
ng: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
 | 
			
		||||
ng: AVR_FREQ = 16000000L
 | 
			
		||||
ng: $(PROGRAM)_ng.hex
 | 
			
		||||
 | 
			
		||||
ng_isp: ng
 | 
			
		||||
ng_isp: TARGET = ng
 | 
			
		||||
ng_isp: HFUSE = DD
 | 
			
		||||
ng_isp: LFUSE = FF
 | 
			
		||||
ng_isp: EFUSE = 00
 | 
			
		||||
ng_isp: isp
 | 
			
		||||
 | 
			
		||||
atmega328: TARGET = atmega328
 | 
			
		||||
atmega328: MCU_TARGET = atmega328p
 | 
			
		||||
atmega328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600
 | 
			
		||||
atmega328: AVR_FREQ = 16000000L 
 | 
			
		||||
atmega328: LDSECTION  = --section-start=.text=0x7800
 | 
			
		||||
atmega328: $(PROGRAM)_atmega328.hex
 | 
			
		||||
 | 
			
		||||
atmega328_isp: atmega328
 | 
			
		||||
atmega328_isp: TARGET = atmega328
 | 
			
		||||
atmega328_isp: MCU_TARGET = atmega328p
 | 
			
		||||
atmega328_isp: HFUSE = DA
 | 
			
		||||
atmega328_isp: LFUSE = FF
 | 
			
		||||
atmega328_isp: EFUSE = 05
 | 
			
		||||
atmega328_isp: isp
 | 
			
		||||
 | 
			
		||||
atmega328_pro8: TARGET = atmega328_pro_8MHz
 | 
			
		||||
atmega328_pro8: MCU_TARGET = atmega328p
 | 
			
		||||
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
 | 
			
		||||
atmega328_pro8: AVR_FREQ = 8000000L 
 | 
			
		||||
atmega328_pro8: LDSECTION  = --section-start=.text=0x7800
 | 
			
		||||
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
 | 
			
		||||
 | 
			
		||||
atmega328_pro8_isp: atmega328_pro8
 | 
			
		||||
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
 | 
			
		||||
atmega328_pro8_isp: MCU_TARGET = atmega328p
 | 
			
		||||
atmega328_pro8_isp: HFUSE = DA
 | 
			
		||||
atmega328_pro8_isp: LFUSE = FF
 | 
			
		||||
atmega328_pro8_isp: EFUSE = 05
 | 
			
		||||
atmega328_pro8_isp: isp
 | 
			
		||||
 | 
			
		||||
mega: TARGET = atmega1280
 | 
			
		||||
mega: MCU_TARGET = atmega1280
 | 
			
		||||
mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600
 | 
			
		||||
mega: AVR_FREQ = 16000000L 
 | 
			
		||||
mega: LDSECTION  = --section-start=.text=0x1F000
 | 
			
		||||
mega: $(PROGRAM)_atmega1280.hex
 | 
			
		||||
 | 
			
		||||
mega_isp: mega
 | 
			
		||||
mega_isp: TARGET = atmega1280
 | 
			
		||||
mega_isp: MCU_TARGET = atmega1280
 | 
			
		||||
mega_isp: HFUSE = DA
 | 
			
		||||
mega_isp: LFUSE = FF
 | 
			
		||||
mega_isp: EFUSE = F5
 | 
			
		||||
mega_isp: isp
 | 
			
		||||
 | 
			
		||||
atmega1284p: TARGET = atmega1284p
 | 
			
		||||
atmega1284p: MCU_TARGET = atmega1284p
 | 
			
		||||
atmega1284p: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=57600'
 | 
			
		||||
atmega1284p: AVR_FREQ = 16000000L 
 | 
			
		||||
atmega1284p: LDSECTION  = --section-start=.text=0x1F000
 | 
			
		||||
atmega1284p: $(PROGRAM)_atmega1284p.hex
 | 
			
		||||
 | 
			
		||||
atmega1284p_8m: TARGET = atmega1284p
 | 
			
		||||
atmega1284p_8m: MCU_TARGET = atmega1284p
 | 
			
		||||
atmega1284p_8m: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=19200'
 | 
			
		||||
atmega1284p_8m: AVR_FREQ = 8000000L
 | 
			
		||||
atmega1284p_8m: LDSECTION  = --section-start=.text=0x1F000
 | 
			
		||||
atmega1284p_8m: $(PROGRAM)_atmega1284p_8m.hex
 | 
			
		||||
 | 
			
		||||
atmega644p: TARGET = atmega644p
 | 
			
		||||
atmega644p: MCU_TARGET = atmega644p
 | 
			
		||||
atmega644p: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=57600'
 | 
			
		||||
atmega644p: AVR_FREQ = 16000000L
 | 
			
		||||
atmega644p: LDSECTION  = --section-start=.text=0xF800
 | 
			
		||||
atmega644p: $(PROGRAM)_atmega644p.hex
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
atmega1284p_isp: atmega1284p
 | 
			
		||||
atmega1284p_isp: TARGET = atmega1284p
 | 
			
		||||
atmega1284p_isp: MCU_TARGET = atmega1284p
 | 
			
		||||
atmega1284p_isp: HFUSE = DC
 | 
			
		||||
atmega1284p_isp: LFUSE = FF
 | 
			
		||||
atmega1284p_isp: EFUSE = FD
 | 
			
		||||
atmega1284p_isp: isp
 | 
			
		||||
 | 
			
		||||
isp: $(TARGET)
 | 
			
		||||
	$(ISPFUSES)
 | 
			
		||||
	$(ISPFLASH)
 | 
			
		||||
 | 
			
		||||
isp-stk500: $(PROGRAM)_$(TARGET).hex
 | 
			
		||||
	$(STK500-1)
 | 
			
		||||
	$(STK500-2)
 | 
			
		||||
 | 
			
		||||
%.elf: $(OBJ)
 | 
			
		||||
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
 | 
			
		||||
 | 
			
		||||
%.lst: %.elf
 | 
			
		||||
	$(OBJDUMP) -h -S $< > $@
 | 
			
		||||
 | 
			
		||||
%.hex: %.elf
 | 
			
		||||
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
 | 
			
		||||
 | 
			
		||||
%.srec: %.elf
 | 
			
		||||
	$(OBJCOPY) -j .text -j .data -O srec $< $@
 | 
			
		||||
 | 
			
		||||
%.bin: %.elf
 | 
			
		||||
	$(OBJCOPY) -j .text -j .data -O binary $< $@
 | 
			
		||||
	
 | 
			
		||||
@@ -0,0 +1,717 @@
 | 
			
		||||
/**********************************************************/
 | 
			
		||||
/* Serial Bootloader for Atmel megaAVR Controllers        */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* tested with ATmega644 and ATmega644P                   */
 | 
			
		||||
/* should work with other mega's, see code for details    */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* ATmegaBOOT.c                                           */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* 20090131: Added 324P support from Alex Leone           */
 | 
			
		||||
/*           Marius Kintel                                */
 | 
			
		||||
/* 20080915: applied ADABoot mods for Sanguino 644P       */
 | 
			
		||||
/*           Brian Riley                                  */
 | 
			
		||||
/* 20080711: hacked for Sanguino by Zach Smith            */
 | 
			
		||||
/*           and Justin Day                               */
 | 
			
		||||
/* 20070626: hacked for Arduino Diecimila (which auto-    */
 | 
			
		||||
/*           resets when a USB connection is made to it)  */
 | 
			
		||||
/*           by D. Mellis                                 */
 | 
			
		||||
/* 20060802: hacked for Arduino by D. Cuartielles         */
 | 
			
		||||
/*           based on a previous hack by D. Mellis        */
 | 
			
		||||
/*           and D. Cuartielles                           */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Monitor and debug functions were added to the original */
 | 
			
		||||
/* code by Dr. Erik Lins, chip45.com. (See below)         */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Thanks to Karl Pitrich for fixing a bootloader pin     */
 | 
			
		||||
/* problem and more informative LED blinking!             */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* For the latest version see:                            */
 | 
			
		||||
/* http://www.chip45.com/                                 */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* ------------------------------------------------------ */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* based on stk500boot.c                                  */
 | 
			
		||||
/* Copyright (c) 2003, Jason P. Kyle                      */
 | 
			
		||||
/* All rights reserved.                                   */
 | 
			
		||||
/* see avr1.org for original file and information         */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* This program is free software; you can redistribute it */
 | 
			
		||||
/* and/or modify it under the terms of the GNU General    */
 | 
			
		||||
/* Public License as published by the Free Software       */
 | 
			
		||||
/* Foundation; either version 2 of the License, or        */
 | 
			
		||||
/* (at your option) any later version.                    */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* This program is distributed in the hope that it will   */
 | 
			
		||||
/* be useful, but WITHOUT ANY WARRANTY; without even the  */
 | 
			
		||||
/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */
 | 
			
		||||
/* PARTICULAR PURPOSE.  See the GNU General Public        */
 | 
			
		||||
/* License for more details.                              */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* You should have received a copy of the GNU General     */
 | 
			
		||||
/* Public License along with this program; if not, write  */
 | 
			
		||||
/* to the Free Software Foundation, Inc.,                 */
 | 
			
		||||
/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Licence can be viewed at                               */
 | 
			
		||||
/* http://www.fsf.org/licenses/gpl.txt                    */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
 | 
			
		||||
/* m8515,m8535. ATmega161 has a very small boot block so  */
 | 
			
		||||
/* isn't supported.                                       */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Tested with m168                                       */
 | 
			
		||||
/**********************************************************/
 | 
			
		||||
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* some includes */
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <avr/pgmspace.h>
 | 
			
		||||
#include <avr/interrupt.h>
 | 
			
		||||
#include <avr/wdt.h>
 | 
			
		||||
#include <avr/boot.h>
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
    #define NUM_LED_FLASHES 3
 | 
			
		||||
    #define ADABOOT_VER	1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
 | 
			
		||||
#define MAX_ERROR_COUNT 5
 | 
			
		||||
 | 
			
		||||
/* set the UART baud rate */
 | 
			
		||||
/* 20080711: hack by Zach Hoeken */
 | 
			
		||||
#define BAUD_RATE   38400
 | 
			
		||||
 | 
			
		||||
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
 | 
			
		||||
/* never allow AVR Studio to do an update !!!! */
 | 
			
		||||
#define HW_VER	 0x02
 | 
			
		||||
#define SW_MAJOR 0x01
 | 
			
		||||
#define SW_MINOR 0x10
 | 
			
		||||
 | 
			
		||||
/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
 | 
			
		||||
/* if monitor functions are included, LED goes on after monitor was entered */
 | 
			
		||||
#define LED_DDR  DDRB
 | 
			
		||||
#define LED_PORT PORTB
 | 
			
		||||
#define LED_PIN  PINB
 | 
			
		||||
#define LED      PINB0
 | 
			
		||||
 | 
			
		||||
/* define various device id's */
 | 
			
		||||
/* manufacturer byte is always the same */
 | 
			
		||||
#define SIG1	0x1E	// Yep, Atmel is the only manufacturer of AVR micros.  Single source :(
 | 
			
		||||
#if defined(__AVR_ATmega1284P__)
 | 
			
		||||
#define SIG2	0x97
 | 
			
		||||
#define SIG3	0x05
 | 
			
		||||
#elif defined(__AVR_ATmega644P__)
 | 
			
		||||
#define SIG2	0x96
 | 
			
		||||
#define SIG3	0x0A
 | 
			
		||||
#elif defined(__AVR_ATmega644__)
 | 
			
		||||
#define SIG2	0x96
 | 
			
		||||
#define SIG3	0x09
 | 
			
		||||
#elif defined(__AVR_ATmega324P__)
 | 
			
		||||
#define SIG2	0x95
 | 
			
		||||
#define SIG3	0x08
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define PAGE_SIZE		0x080U   //128 words
 | 
			
		||||
#define PAGE_SIZE_BYTES	0x100U   //256 bytes
 | 
			
		||||
 | 
			
		||||
/* function prototypes */
 | 
			
		||||
void putch(char);
 | 
			
		||||
char getch(void);
 | 
			
		||||
void getNch(uint8_t);
 | 
			
		||||
void byte_response(uint8_t);
 | 
			
		||||
void nothing_response(void);
 | 
			
		||||
char gethex(void);
 | 
			
		||||
void puthex(char);
 | 
			
		||||
void flash_led(uint8_t);
 | 
			
		||||
 | 
			
		||||
/* some variables */
 | 
			
		||||
union address_union
 | 
			
		||||
{
 | 
			
		||||
    uint16_t word;
 | 
			
		||||
    uint8_t  byte[2];
 | 
			
		||||
} address;
 | 
			
		||||
 | 
			
		||||
union length_union
 | 
			
		||||
{
 | 
			
		||||
    uint16_t word;
 | 
			
		||||
    uint8_t  byte[2];
 | 
			
		||||
} length;
 | 
			
		||||
 | 
			
		||||
struct flags_struct
 | 
			
		||||
{
 | 
			
		||||
    unsigned eeprom : 1;
 | 
			
		||||
    unsigned rampz  : 1;
 | 
			
		||||
} flags;
 | 
			
		||||
 | 
			
		||||
uint8_t buff[256];
 | 
			
		||||
 | 
			
		||||
uint8_t error_count = 0;
 | 
			
		||||
uint8_t sreg;
 | 
			
		||||
 | 
			
		||||
void (*app_start)(void) = 0x0000;
 | 
			
		||||
 | 
			
		||||
/* main program starts here */
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t ch,ch2;
 | 
			
		||||
    uint16_t w;
 | 
			
		||||
	uint16_t i;
 | 
			
		||||
	
 | 
			
		||||
    asm volatile("nop\n\t");
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT		// BBR/LF 10/8/2007 & 9/13/2008
 | 
			
		||||
    ch = MCUSR;
 | 
			
		||||
    MCUSR = 0;
 | 
			
		||||
 | 
			
		||||
    WDTCSR |= _BV(WDCE) | _BV(WDE);
 | 
			
		||||
    WDTCSR = 0;
 | 
			
		||||
 | 
			
		||||
    // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
 | 
			
		||||
    if (! (ch &  _BV(EXTRF))) // if it's a not an external reset...
 | 
			
		||||
      app_start();  // skip bootloader
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	//initialize our serial port.
 | 
			
		||||
    UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
 | 
			
		||||
    UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
 | 
			
		||||
    UCSR0B = (1<<RXEN0) | (1<<TXEN0);
 | 
			
		||||
    UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
 | 
			
		||||
 | 
			
		||||
    /* Enable internal pull-up resistor on pin D0 (RX), in order
 | 
			
		||||
    to supress line noise that prevents the bootloader from
 | 
			
		||||
    timing out (DAM: 20070509) */
 | 
			
		||||
    DDRD &= ~_BV(PIND0);
 | 
			
		||||
    PORTD |= _BV(PIND0);
 | 
			
		||||
 | 
			
		||||
    /* set LED pin as output */
 | 
			
		||||
    LED_DDR |= _BV(LED);
 | 
			
		||||
 | 
			
		||||
	    /* flash onboard LED to signal entering of bootloader                   */
 | 
			
		||||
	    /* ADABOOT will do two series of flashes. first 4 - signifying ADABOOT  */
 | 
			
		||||
	    /* then a pause and another flash series signifying ADABOOT sub-version */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	flash_led(NUM_LED_FLASHES);
 | 
			
		||||
 | 
			
		||||
	#ifdef	ADABOOT
 | 
			
		||||
		flash_led(ADABOOT_VER);		// BBR 9/13/2008
 | 
			
		||||
	#endif 
 | 
			
		||||
 | 
			
		||||
    /* forever loop */
 | 
			
		||||
    for (;;)
 | 
			
		||||
	{
 | 
			
		||||
		/* get character from UART */
 | 
			
		||||
		ch = getch();
 | 
			
		||||
 | 
			
		||||
		/* A bunch of if...else if... gives smaller code than switch...case ! */
 | 
			
		||||
 | 
			
		||||
		/* Hello is anyone home ? */ 
 | 
			
		||||
		if(ch=='0')
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Request programmer ID */
 | 
			
		||||
		/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry  */
 | 
			
		||||
		/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares.  */
 | 
			
		||||
		else if(ch=='1')
 | 
			
		||||
		{
 | 
			
		||||
		    if (getch() == ' ')
 | 
			
		||||
			{
 | 
			
		||||
				putch(0x14);
 | 
			
		||||
				putch('A');
 | 
			
		||||
				putch('V');
 | 
			
		||||
				putch('R');
 | 
			
		||||
				putch(' ');
 | 
			
		||||
				putch('I');
 | 
			
		||||
				putch('S');
 | 
			
		||||
				putch('P');
 | 
			
		||||
				putch(0x10);
 | 
			
		||||
		    }
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
				    app_start();
 | 
			
		||||
		    }
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* AVR ISP/STK500 board commands  DON'T CARE so default nothing_response */
 | 
			
		||||
		else if(ch=='@')
 | 
			
		||||
		{
 | 
			
		||||
		    ch2 = getch();
 | 
			
		||||
		    if (ch2 > 0x85)
 | 
			
		||||
				getch();
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* AVR ISP/STK500 board requests */
 | 
			
		||||
		else if(ch=='A')
 | 
			
		||||
		{
 | 
			
		||||
		    ch2 = getch();
 | 
			
		||||
		    if(ch2 == 0x80)
 | 
			
		||||
				byte_response(HW_VER);		// Hardware version
 | 
			
		||||
		    else if(ch2==0x81)
 | 
			
		||||
				byte_response(SW_MAJOR);	// Software major version
 | 
			
		||||
		    else if(ch2==0x82)
 | 
			
		||||
				byte_response(SW_MINOR);	// Software minor version
 | 
			
		||||
		    else if(ch2==0x98)
 | 
			
		||||
				byte_response(0x03);		// Unknown but seems to be required by avr studio 3.56
 | 
			
		||||
		    else
 | 
			
		||||
				byte_response(0x00);		// Covers various unnecessary responses we don't care about
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Device Parameters  DON'T CARE, DEVICE IS FIXED  */
 | 
			
		||||
		else if(ch=='B')
 | 
			
		||||
		{
 | 
			
		||||
		    getNch(20);
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Parallel programming stuff  DON'T CARE  */
 | 
			
		||||
		else if(ch=='E')
 | 
			
		||||
		{
 | 
			
		||||
		    getNch(5);
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Enter programming mode  */
 | 
			
		||||
		else if(ch=='P')
 | 
			
		||||
		{
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Leave programming mode  */
 | 
			
		||||
		else if(ch=='Q')
 | 
			
		||||
		{
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
#ifdef ADABOOT		
 | 
			
		||||
			// autoreset via watchdog (sneaky!) BBR/LF 9/13/2008
 | 
			
		||||
	  		WDTCSR = _BV(WDE);
 | 
			
		||||
	  		while (1); // 16 ms
 | 
			
		||||
#endif		
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Erase device, don't care as we will erase one page at a time anyway.  */
 | 
			
		||||
		else if(ch=='R')
 | 
			
		||||
		{
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Set address, little endian. EEPROM in bytes, FLASH in words  */
 | 
			
		||||
		/* Perhaps extra address bytes may be added in future to support > 128kB FLASH.  */
 | 
			
		||||
		/* This might explain why little endian was used here, big endian used everywhere else.  */
 | 
			
		||||
		else if(ch=='U')
 | 
			
		||||
		{
 | 
			
		||||
		    address.byte[0] = getch();
 | 
			
		||||
		    address.byte[1] = getch();
 | 
			
		||||
		    nothing_response();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Universal SPI programming command, disabled.  Would be used for fuses and lock bits.  */
 | 
			
		||||
		else if(ch=='V')
 | 
			
		||||
		{
 | 
			
		||||
		    getNch(4);
 | 
			
		||||
		    byte_response(0x00);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Write memory, length is big endian and is in bytes  */
 | 
			
		||||
		else if(ch=='d')
 | 
			
		||||
		{
 | 
			
		||||
		    length.byte[1] = getch();
 | 
			
		||||
		    length.byte[0] = getch();
 | 
			
		||||
	
 | 
			
		||||
		    flags.eeprom = 0;
 | 
			
		||||
		    if (getch() == 'E')
 | 
			
		||||
				flags.eeprom = 1;
 | 
			
		||||
 | 
			
		||||
			for (i=0; i<PAGE_SIZE; i++)
 | 
			
		||||
				buff[i] = 0;
 | 
			
		||||
		
 | 
			
		||||
		    for (w = 0; w < length.word; w++)
 | 
			
		||||
			{
 | 
			
		||||
				// Store data in buffer, can't keep up with serial data stream whilst programming pages
 | 
			
		||||
				buff[w] = getch();
 | 
			
		||||
		    }
 | 
			
		||||
	
 | 
			
		||||
		    if (getch() == ' ')
 | 
			
		||||
			{
 | 
			
		||||
				if (flags.eeprom)
 | 
			
		||||
				{		                
 | 
			
		||||
					//Write to EEPROM one byte at a time
 | 
			
		||||
				    for(w=0;w<length.word;w++)
 | 
			
		||||
					{
 | 
			
		||||
						while(EECR & (1<<EEPE));
 | 
			
		||||
					
 | 
			
		||||
						EEAR = (uint16_t)(void *)address.word;
 | 
			
		||||
						EEDR = buff[w];
 | 
			
		||||
						EECR |= (1<<EEMPE);
 | 
			
		||||
						EECR |= (1<<EEPE);
 | 
			
		||||
 | 
			
		||||
						address.word++;
 | 
			
		||||
				    }			
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					//address * 2 -> byte location
 | 
			
		||||
				    address.word = address.word << 1;
 | 
			
		||||
			    
 | 
			
		||||
					//Even up an odd number of bytes
 | 
			
		||||
					if ((length.byte[0] & 0x01))
 | 
			
		||||
						length.word++;
 | 
			
		||||
				
 | 
			
		||||
					// HACKME: EEPE used to be EEWE
 | 
			
		||||
				    //Wait for previous EEPROM writes to complete
 | 
			
		||||
					//while(bit_is_set(EECR,EEPE));
 | 
			
		||||
					while(EECR & (1<<EEPE));
 | 
			
		||||
				
 | 
			
		||||
				    asm volatile(
 | 
			
		||||
						 "clr	r17		\n\t"	//page_word_count
 | 
			
		||||
						 "lds	r30,address	\n\t"	//Address of FLASH location (in bytes)
 | 
			
		||||
						 "lds	r31,address+1	\n\t"
 | 
			
		||||
						 "ldi	r28,lo8(buff)	\n\t"	//Start of buffer array in RAM
 | 
			
		||||
						 "ldi	r29,hi8(buff)	\n\t"
 | 
			
		||||
						 "lds	r24,length	\n\t"	//Length of data to be written (in bytes)
 | 
			
		||||
						 "lds	r25,length+1	\n\t"
 | 
			
		||||
						 "length_loop:		\n\t"	//Main loop, repeat for number of words in block							 							 
 | 
			
		||||
						 "cpi	r17,0x00	\n\t"	//If page_word_count=0 then erase page
 | 
			
		||||
						 "brne	no_page_erase	\n\t"						 
 | 
			
		||||
						 "wait_spm1:		\n\t"
 | 
			
		||||
						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
 | 
			
		||||
						 "andi	r16,1           \n\t"
 | 
			
		||||
						 "cpi	r16,1           \n\t"
 | 
			
		||||
						 "breq	wait_spm1       \n\t"
 | 
			
		||||
						 "ldi	r16,0x03	\n\t"	//Erase page pointed to by Z
 | 
			
		||||
						 "sts	%0,r16		\n\t"
 | 
			
		||||
						 "spm			\n\t"							 
 | 
			
		||||
						 "wait_spm2:		\n\t"
 | 
			
		||||
						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
 | 
			
		||||
						 "andi	r16,1           \n\t"
 | 
			
		||||
						 "cpi	r16,1           \n\t"
 | 
			
		||||
						 "breq	wait_spm2       \n\t"									 
 | 
			
		||||
 | 
			
		||||
						 "ldi	r16,0x11	\n\t"	//Re-enable RWW section
 | 
			
		||||
						 "sts	%0,r16		\n\t"						 			 
 | 
			
		||||
						 "spm			\n\t"
 | 
			
		||||
						 "no_page_erase:		\n\t"							 
 | 
			
		||||
						 "ld	r0,Y+		\n\t"	//Write 2 bytes into page buffer
 | 
			
		||||
						 "ld	r1,Y+		\n\t"							 
 | 
			
		||||
							 
 | 
			
		||||
						 "wait_spm3:		\n\t"
 | 
			
		||||
						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
 | 
			
		||||
						 "andi	r16,1           \n\t"
 | 
			
		||||
						 "cpi	r16,1           \n\t"
 | 
			
		||||
						 "breq	wait_spm3       \n\t"
 | 
			
		||||
						 "ldi	r16,0x01	\n\t"	//Load r0,r1 into FLASH page buffer
 | 
			
		||||
						 "sts	%0,r16		\n\t"
 | 
			
		||||
						 "spm			\n\t"
 | 
			
		||||
							 
 | 
			
		||||
						 "inc	r17		\n\t"	//page_word_count++
 | 
			
		||||
						 "cpi r17,%1	        \n\t"
 | 
			
		||||
						 "brlo	same_page	\n\t"	//Still same page in FLASH
 | 
			
		||||
						 "write_page:		\n\t"
 | 
			
		||||
						 "clr	r17		\n\t"	//New page, write current one first
 | 
			
		||||
						 "wait_spm4:		\n\t"
 | 
			
		||||
						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
 | 
			
		||||
						 "andi	r16,1           \n\t"
 | 
			
		||||
						 "cpi	r16,1           \n\t"
 | 
			
		||||
						 "breq	wait_spm4       \n\t"						 							 
 | 
			
		||||
						 "ldi	r16,0x05	\n\t"	//Write page pointed to by Z
 | 
			
		||||
						 "sts	%0,r16		\n\t"
 | 
			
		||||
						 "spm			\n\t"
 | 
			
		||||
						 "wait_spm5:		\n\t"
 | 
			
		||||
						 "lds	r16,%0		\n\t"	//Wait for previous spm to complete
 | 
			
		||||
						 "andi	r16,1           \n\t"
 | 
			
		||||
						 "cpi	r16,1           \n\t"
 | 
			
		||||
						 "breq	wait_spm5       \n\t"									 
 | 
			
		||||
						 "ldi	r16,0x11	\n\t"	//Re-enable RWW section
 | 
			
		||||
						 "sts	%0,r16		\n\t"						 			 
 | 
			
		||||
						 "spm			\n\t"					 		 
 | 
			
		||||
						 "same_page:		\n\t"							 
 | 
			
		||||
						 "adiw	r30,2		\n\t"	//Next word in FLASH
 | 
			
		||||
						 "sbiw	r24,2		\n\t"	//length-2
 | 
			
		||||
						 "breq	final_write	\n\t"	//Finished
 | 
			
		||||
						 "rjmp	length_loop	\n\t"
 | 
			
		||||
						 "final_write:		\n\t"
 | 
			
		||||
						 "cpi	r17,0		\n\t"
 | 
			
		||||
						 "breq	block_done	\n\t"
 | 
			
		||||
						 "adiw	r24,2		\n\t"	//length+2, fool above check on length after short page write
 | 
			
		||||
						 "rjmp	write_page	\n\t"
 | 
			
		||||
						 "block_done:		\n\t"
 | 
			
		||||
						 "clr	__zero_reg__	\n\t"	//restore zero register
 | 
			
		||||
						 : "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
 | 
			
		||||
 | 
			
		||||
						 );
 | 
			
		||||
				}
 | 
			
		||||
				putch(0x14);
 | 
			
		||||
				putch(0x10);
 | 
			
		||||
		    }
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
				    app_start();
 | 
			
		||||
		    }		
 | 
			
		||||
		}
 | 
			
		||||
    
 | 
			
		||||
		/* Read memory block mode, length is big endian.  */
 | 
			
		||||
		else if(ch=='t')
 | 
			
		||||
		{
 | 
			
		||||
			length.byte[1] = getch();
 | 
			
		||||
			length.byte[0] = getch();
 | 
			
		||||
 | 
			
		||||
			if (getch() == 'E')
 | 
			
		||||
				flags.eeprom = 1;
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				flags.eeprom = 0;
 | 
			
		||||
				address.word = address.word << 1;	        // address * 2 -> byte location
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Command terminator
 | 
			
		||||
			if (getch() == ' ')
 | 
			
		||||
			{
 | 
			
		||||
				putch(0x14);
 | 
			
		||||
				for (w=0; w<length.word; w++)
 | 
			
		||||
				{
 | 
			
		||||
					// Can handle odd and even lengths okay
 | 
			
		||||
				    if (flags.eeprom) 
 | 
			
		||||
					{
 | 
			
		||||
						// Byte access EEPROM read
 | 
			
		||||
						while(EECR & (1<<EEPE));
 | 
			
		||||
						EEAR = (uint16_t)(void *)address.word;
 | 
			
		||||
						EECR |= (1<<EERE);
 | 
			
		||||
						putch(EEDR);
 | 
			
		||||
 | 
			
		||||
						address.word++;
 | 
			
		||||
				    }
 | 
			
		||||
				    else
 | 
			
		||||
					{
 | 
			
		||||
						if (!flags.rampz)
 | 
			
		||||
							putch(pgm_read_byte_near(address.word));
 | 
			
		||||
 | 
			
		||||
						address.word++;
 | 
			
		||||
				    }
 | 
			
		||||
				}
 | 
			
		||||
				putch(0x10);
 | 
			
		||||
		    }
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Get device signature bytes  */
 | 
			
		||||
		else if(ch=='u')
 | 
			
		||||
		{
 | 
			
		||||
			if (getch() == ' ')
 | 
			
		||||
			{
 | 
			
		||||
				putch(0x14);
 | 
			
		||||
				putch(SIG1);
 | 
			
		||||
				putch(SIG2);
 | 
			
		||||
				putch(SIG3);
 | 
			
		||||
				putch(0x10);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
					app_start();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Read oscillator calibration byte */
 | 
			
		||||
		else if(ch=='v')
 | 
			
		||||
			byte_response(0x00);
 | 
			
		||||
 | 
			
		||||
		else if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
		    app_start();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
    /* end of forever loop */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
char gethex(void)
 | 
			
		||||
{
 | 
			
		||||
    char ah,al;
 | 
			
		||||
 | 
			
		||||
    ah = getch();
 | 
			
		||||
	putch(ah);
 | 
			
		||||
    al = getch();
 | 
			
		||||
	putch(al);
 | 
			
		||||
    
 | 
			
		||||
	if(ah >= 'a')
 | 
			
		||||
		ah = ah - 'a' + 0x0a;
 | 
			
		||||
	else if(ah >= '0')
 | 
			
		||||
		ah -= '0';
 | 
			
		||||
    if(al >= 'a')
 | 
			
		||||
		al = al - 'a' + 0x0a;
 | 
			
		||||
	else if(al >= '0')
 | 
			
		||||
		al -= '0';
 | 
			
		||||
 | 
			
		||||
    return (ah << 4) + al;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void puthex(char ch)
 | 
			
		||||
{
 | 
			
		||||
    char ah,al;
 | 
			
		||||
 | 
			
		||||
    ah = (ch & 0xf0) >> 4;
 | 
			
		||||
	if(ah >= 0x0a)
 | 
			
		||||
		ah = ah - 0x0a + 'a';
 | 
			
		||||
	else
 | 
			
		||||
		ah += '0';
 | 
			
		||||
 | 
			
		||||
    al = (ch & 0x0f);
 | 
			
		||||
	if(al >= 0x0a)
 | 
			
		||||
		al = al - 0x0a + 'a';
 | 
			
		||||
	else
 | 
			
		||||
		al += '0';
 | 
			
		||||
 | 
			
		||||
    putch(ah);
 | 
			
		||||
    putch(al);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void putch(char ch)
 | 
			
		||||
{
 | 
			
		||||
    while (!(UCSR0A & _BV(UDRE0)));
 | 
			
		||||
    UDR0 = ch;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
char getch(void)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t count = 0;
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
	LED_PORT &= ~_BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    while(!(UCSR0A & _BV(RXC0)))
 | 
			
		||||
	{
 | 
			
		||||
    	/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/               
 | 
			
		||||
    	/* HACKME:: here is a good place to count times*/
 | 
			
		||||
    	count++;
 | 
			
		||||
    	if (count > MAX_TIME_COUNT)
 | 
			
		||||
    		app_start();
 | 
			
		||||
     }
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
	LED_PORT |= _BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    return UDR0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void getNch(uint8_t count)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t i;
 | 
			
		||||
    for(i=0;i<count;i++)
 | 
			
		||||
	{
 | 
			
		||||
		while(!(UCSR0A & _BV(RXC0)));
 | 
			
		||||
		UDR0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void byte_response(uint8_t val)
 | 
			
		||||
{
 | 
			
		||||
    if (getch() == ' ')
 | 
			
		||||
	{
 | 
			
		||||
		putch(0x14);
 | 
			
		||||
		putch(val);
 | 
			
		||||
		putch(0x10);
 | 
			
		||||
    }
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
		    app_start();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void nothing_response(void)
 | 
			
		||||
{
 | 
			
		||||
    if (getch() == ' ')
 | 
			
		||||
	{
 | 
			
		||||
		putch(0x14);
 | 
			
		||||
		putch(0x10);
 | 
			
		||||
    }
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
		    app_start();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
 | 
			
		||||
void flash_led(uint8_t count)
 | 
			
		||||
{
 | 
			
		||||
    /* flash onboard LED count times to signal entering of bootloader */
 | 
			
		||||
	/* l needs to be volatile or the delay loops below might get      */
 | 
			
		||||
	/* optimized away if compiling with optimizations (DAM).          */
 | 
			
		||||
	
 | 
			
		||||
    volatile uint32_t l;
 | 
			
		||||
 | 
			
		||||
    if (count == 0) {
 | 
			
		||||
      count = ADABOOT;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
	int8_t i;
 | 
			
		||||
    for (i = 0; i < count; ++i) {
 | 
			
		||||
		LED_PORT |= _BV(LED);					// LED on
 | 
			
		||||
		for(l = 0; l < (F_CPU / 1000); ++l);		// delay NGvalue was 1000 for both loops - BBR
 | 
			
		||||
		LED_PORT &= ~_BV(LED);					// LED off
 | 
			
		||||
		for(l = 0; l < (F_CPU / 250); ++l);		// delay asymmteric for ADA BOOT BBR 
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for(l = 0; l < (F_CPU / 100); ++l);		    // pause ADA BOOT BBR 
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
void flash_led(uint8_t count)
 | 
			
		||||
{
 | 
			
		||||
    /* flash onboard LED three times to signal entering of bootloader */
 | 
			
		||||
	/* l needs to be volatile or the delay loops below might get
 | 
			
		||||
	optimized away if compiling with optimizations (DAM). */
 | 
			
		||||
    volatile uint32_t l;
 | 
			
		||||
 | 
			
		||||
    if (count == 0) {
 | 
			
		||||
      count = 3;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
	int8_t i;
 | 
			
		||||
    for (i = 0; i < count; ++i) {
 | 
			
		||||
		LED_PORT |= _BV(LED);
 | 
			
		||||
		for(l = 0; l < (F_CPU / 1000); ++l);
 | 
			
		||||
		LED_PORT &= ~_BV(LED);
 | 
			
		||||
		for(l = 0; l < (F_CPU / 1000); ++l); 
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* end of file ATmegaBOOT.c */
 | 
			
		||||
@@ -0,0 +1,388 @@
 | 
			
		||||
/**********************************************************/
 | 
			
		||||
/* Serial Bootloader for Atmel megaAVR Controllers        */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* tested with ATmega644 and ATmega644P                   */
 | 
			
		||||
/* should work with other mega's, see code for details    */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* ATmegaBOOT.c                                           */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* 20090131: Added 324P support from Alex Leone           */
 | 
			
		||||
/*           Marius Kintel                                */
 | 
			
		||||
/* 20080915: applied ADABoot mods for Sanguino 644P       */
 | 
			
		||||
/*           Brian Riley                                  */
 | 
			
		||||
/* 20080711: hacked for Sanguino by Zach Smith            */
 | 
			
		||||
/*           and Justin Day                               */
 | 
			
		||||
/* 20070626: hacked for Arduino Diecimila (which auto-    */
 | 
			
		||||
/*           resets when a USB connection is made to it)  */
 | 
			
		||||
/*           by D. Mellis                                 */
 | 
			
		||||
/* 20060802: hacked for Arduino by D. Cuartielles         */
 | 
			
		||||
/*           based on a previous hack by D. Mellis        */
 | 
			
		||||
/*           and D. Cuartielles                           */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Monitor and debug functions were added to the original */
 | 
			
		||||
/* code by Dr. Erik Lins, chip45.com. (See below)         */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Thanks to Karl Pitrich for fixing a bootloader pin     */
 | 
			
		||||
/* problem and more informative LED blinking!             */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* For the latest version see:                            */
 | 
			
		||||
/* http://www.chip45.com/                                 */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* ------------------------------------------------------ */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* based on stk500boot.c                                  */
 | 
			
		||||
/* Copyright (c) 2003, Jason P. Kyle                      */
 | 
			
		||||
/* All rights reserved.                                   */
 | 
			
		||||
/* see avr1.org for original file and information         */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* This program is free software; you can redistribute it */
 | 
			
		||||
/* and/or modify it under the terms of the GNU General    */
 | 
			
		||||
/* Public License as published by the Free Software       */
 | 
			
		||||
/* Foundation; either version 2 of the License, or        */
 | 
			
		||||
/* (at your option) any later version.                    */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* This program is distributed in the hope that it will   */
 | 
			
		||||
/* be useful, but WITHOUT ANY WARRANTY; without even the  */
 | 
			
		||||
/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */
 | 
			
		||||
/* PARTICULAR PURPOSE.  See the GNU General Public        */
 | 
			
		||||
/* License for more details.                              */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* You should have received a copy of the GNU General     */
 | 
			
		||||
/* Public License along with this program; if not, write  */
 | 
			
		||||
/* to the Free Software Foundation, Inc.,                 */
 | 
			
		||||
/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Licence can be viewed at                               */
 | 
			
		||||
/* http://www.fsf.org/licenses/gpl.txt                    */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
 | 
			
		||||
/* m8515,m8535. ATmega161 has a very small boot block so  */
 | 
			
		||||
/* isn't supported.                                       */
 | 
			
		||||
/*                                                        */
 | 
			
		||||
/* Tested with m168                                       */
 | 
			
		||||
/**********************************************************/
 | 
			
		||||
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* some includes */
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <avr/pgmspace.h>
 | 
			
		||||
#include <avr/interrupt.h>
 | 
			
		||||
#include <avr/wdt.h>
 | 
			
		||||
#include <avr/boot.h>
 | 
			
		||||
#include <util/delay.h>
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
    #define NUM_LED_FLASHES 3
 | 
			
		||||
    #define ADABOOT_VER	1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
 | 
			
		||||
#define MAX_ERROR_COUNT 5
 | 
			
		||||
 | 
			
		||||
/* set the UART baud rate */
 | 
			
		||||
/* 20080711: hack by Zach Hoeken */
 | 
			
		||||
#define BAUD_RATE   38400
 | 
			
		||||
 | 
			
		||||
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
 | 
			
		||||
/* never allow AVR Studio to do an update !!!! */
 | 
			
		||||
#define HW_VER	 0x02
 | 
			
		||||
#define SW_MAJOR 0x01
 | 
			
		||||
#define SW_MINOR 0x10
 | 
			
		||||
 | 
			
		||||
/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
 | 
			
		||||
/* if monitor functions are included, LED goes on after monitor was entered */
 | 
			
		||||
#define LED_DDR  DDRB
 | 
			
		||||
#define LED_PORT PORTB
 | 
			
		||||
#define LED_PIN  PINB
 | 
			
		||||
#define LED      PINB0
 | 
			
		||||
 | 
			
		||||
/* define various device id's */
 | 
			
		||||
/* manufacturer byte is always the same */
 | 
			
		||||
#define SIG1	0x1E	// Yep, Atmel is the only manufacturer of AVR micros.  Single source :(
 | 
			
		||||
#if defined(__AVR_ATmega1284P__)
 | 
			
		||||
#define SIG2	0x97
 | 
			
		||||
#define SIG3	0x05
 | 
			
		||||
#elif defined(__AVR_ATmega644P__)
 | 
			
		||||
#define SIG2	0x96
 | 
			
		||||
#define SIG3	0x0A
 | 
			
		||||
#elif defined(__AVR_ATmega644__)
 | 
			
		||||
#define SIG2	0x96
 | 
			
		||||
#define SIG3	0x09
 | 
			
		||||
#elif defined(__AVR_ATmega324P__)
 | 
			
		||||
#define SIG2	0x95
 | 
			
		||||
#define SIG3	0x08
 | 
			
		||||
#endif
 | 
			
		||||
#define PAGE_SIZE		0x080U   //128 words
 | 
			
		||||
#define PAGE_SIZE_BYTES	0x100U   //256 bytes
 | 
			
		||||
 | 
			
		||||
/* function prototypes */
 | 
			
		||||
void putch(char);
 | 
			
		||||
char getch(void);
 | 
			
		||||
void getNch(uint8_t);
 | 
			
		||||
void byte_response(uint8_t);
 | 
			
		||||
void nothing_response(void);
 | 
			
		||||
char gethex(void);
 | 
			
		||||
void puthex(char);
 | 
			
		||||
void flash_led(uint8_t);
 | 
			
		||||
 | 
			
		||||
/* some variables */
 | 
			
		||||
union address_union
 | 
			
		||||
{
 | 
			
		||||
    uint16_t word;
 | 
			
		||||
    uint8_t  byte[2];
 | 
			
		||||
} address;
 | 
			
		||||
 | 
			
		||||
union length_union
 | 
			
		||||
{
 | 
			
		||||
    uint16_t word;
 | 
			
		||||
    uint8_t  byte[2];
 | 
			
		||||
} length;
 | 
			
		||||
 | 
			
		||||
struct flags_struct
 | 
			
		||||
{
 | 
			
		||||
    unsigned eeprom : 1;
 | 
			
		||||
    unsigned rampz  : 1;
 | 
			
		||||
} flags;
 | 
			
		||||
 | 
			
		||||
uint8_t buff[256];
 | 
			
		||||
 | 
			
		||||
uint8_t error_count = 0;
 | 
			
		||||
uint8_t sreg;
 | 
			
		||||
 | 
			
		||||
void (*app_start)(void) = 0x0000;
 | 
			
		||||
 | 
			
		||||
/* main program starts here */
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t ch,ch2;
 | 
			
		||||
    uint16_t w;
 | 
			
		||||
	uint16_t i;
 | 
			
		||||
	
 | 
			
		||||
    asm volatile("nop\n\t");
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT		// BBR/LF 10/8/2007 & 9/13/2008
 | 
			
		||||
    ch = MCUSR;
 | 
			
		||||
    MCUSR = 0;
 | 
			
		||||
 | 
			
		||||
    WDTCSR |= _BV(WDCE) | _BV(WDE);
 | 
			
		||||
    WDTCSR = 0;
 | 
			
		||||
 | 
			
		||||
    // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
 | 
			
		||||
    if (! (ch &  _BV(EXTRF))) // if it's a not an external reset...
 | 
			
		||||
      app_start();  // skip bootloader
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	//initialize our serial port.
 | 
			
		||||
    UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
 | 
			
		||||
    UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
 | 
			
		||||
    UCSR0B = (1<<RXEN0) | (1<<TXEN0);
 | 
			
		||||
    UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
 | 
			
		||||
 | 
			
		||||
    /* Enable internal pull-up resistor on pin D0 (RX), in order
 | 
			
		||||
    to supress line noise that prevents the bootloader from
 | 
			
		||||
    timing out (DAM: 20070509) */
 | 
			
		||||
    DDRD &= ~_BV(PIND0);
 | 
			
		||||
    PORTD |= _BV(PIND0);
 | 
			
		||||
 | 
			
		||||
    /* set LED pin as output */
 | 
			
		||||
    LED_DDR |= _BV(LED);
 | 
			
		||||
 | 
			
		||||
	    /* flash onboard LED to signal entering of bootloader                   */
 | 
			
		||||
	    /* ADABOOT will do two series of flashes. first 4 - signifying ADABOOT  */
 | 
			
		||||
	    /* then a pause and another flash series signifying ADABOOT sub-version */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	flash_led(NUM_LED_FLASHES);
 | 
			
		||||
 | 
			
		||||
	#ifdef	ADABOOT
 | 
			
		||||
		flash_led(ADABOOT_VER);		// BBR 9/13/2008
 | 
			
		||||
	#endif 
 | 
			
		||||
 | 
			
		||||
    /* forever loop */
 | 
			
		||||
    for (;;)
 | 
			
		||||
	{
 | 
			
		||||
          putch('\r');
 | 
			
		||||
          _delay_ms(500);
 | 
			
		||||
        }
 | 
			
		||||
    /* end of forever loop */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
char gethex(void)
 | 
			
		||||
{
 | 
			
		||||
    char ah,al;
 | 
			
		||||
 | 
			
		||||
    ah = getch();
 | 
			
		||||
	putch(ah);
 | 
			
		||||
    al = getch();
 | 
			
		||||
	putch(al);
 | 
			
		||||
    
 | 
			
		||||
	if(ah >= 'a')
 | 
			
		||||
		ah = ah - 'a' + 0x0a;
 | 
			
		||||
	else if(ah >= '0')
 | 
			
		||||
		ah -= '0';
 | 
			
		||||
    if(al >= 'a')
 | 
			
		||||
		al = al - 'a' + 0x0a;
 | 
			
		||||
	else if(al >= '0')
 | 
			
		||||
		al -= '0';
 | 
			
		||||
 | 
			
		||||
    return (ah << 4) + al;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void puthex(char ch)
 | 
			
		||||
{
 | 
			
		||||
    char ah,al;
 | 
			
		||||
 | 
			
		||||
    ah = (ch & 0xf0) >> 4;
 | 
			
		||||
	if(ah >= 0x0a)
 | 
			
		||||
		ah = ah - 0x0a + 'a';
 | 
			
		||||
	else
 | 
			
		||||
		ah += '0';
 | 
			
		||||
 | 
			
		||||
    al = (ch & 0x0f);
 | 
			
		||||
	if(al >= 0x0a)
 | 
			
		||||
		al = al - 0x0a + 'a';
 | 
			
		||||
	else
 | 
			
		||||
		al += '0';
 | 
			
		||||
 | 
			
		||||
    putch(ah);
 | 
			
		||||
    putch(al);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void putch(char ch)
 | 
			
		||||
{
 | 
			
		||||
    while (!(UCSR0A & _BV(UDRE0)));
 | 
			
		||||
    UDR0 = ch;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
char getch(void)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t count = 0;
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
	LED_PORT &= ~_BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    while(!(UCSR0A & _BV(RXC0)))
 | 
			
		||||
	{
 | 
			
		||||
    	/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/               
 | 
			
		||||
    	/* HACKME:: here is a good place to count times*/
 | 
			
		||||
    	count++;
 | 
			
		||||
    	if (count > MAX_TIME_COUNT)
 | 
			
		||||
    		app_start();
 | 
			
		||||
     }
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
	LED_PORT |= _BV(LED);          // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    return UDR0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void getNch(uint8_t count)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t i;
 | 
			
		||||
    for(i=0;i<count;i++)
 | 
			
		||||
	{
 | 
			
		||||
		while(!(UCSR0A & _BV(RXC0)));
 | 
			
		||||
		UDR0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void byte_response(uint8_t val)
 | 
			
		||||
{
 | 
			
		||||
    if (getch() == ' ')
 | 
			
		||||
	{
 | 
			
		||||
		putch(0x14);
 | 
			
		||||
		putch(val);
 | 
			
		||||
		putch(0x10);
 | 
			
		||||
    }
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
		    app_start();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void nothing_response(void)
 | 
			
		||||
{
 | 
			
		||||
    if (getch() == ' ')
 | 
			
		||||
	{
 | 
			
		||||
		putch(0x14);
 | 
			
		||||
		putch(0x10);
 | 
			
		||||
    }
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (++error_count == MAX_ERROR_COUNT)
 | 
			
		||||
		    app_start();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef ADABOOT
 | 
			
		||||
 | 
			
		||||
void flash_led(uint8_t count)
 | 
			
		||||
{
 | 
			
		||||
    /* flash onboard LED count times to signal entering of bootloader */
 | 
			
		||||
	/* l needs to be volatile or the delay loops below might get      */
 | 
			
		||||
	/* optimized away if compiling with optimizations (DAM).          */
 | 
			
		||||
	
 | 
			
		||||
    volatile uint32_t l;
 | 
			
		||||
 | 
			
		||||
    if (count == 0) {
 | 
			
		||||
      count = ADABOOT;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
	int8_t i;
 | 
			
		||||
    for (i = 0; i < count; ++i) {
 | 
			
		||||
		LED_PORT |= _BV(LED);					// LED on
 | 
			
		||||
		for(l = 0; l < (F_CPU / 1000); ++l);		// delay NGvalue was 1000 for both loops - BBR
 | 
			
		||||
		LED_PORT &= ~_BV(LED);					// LED off
 | 
			
		||||
		for(l = 0; l < (F_CPU / 250); ++l);		// delay asymmteric for ADA BOOT BBR 
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for(l = 0; l < (F_CPU / 100); ++l);		    // pause ADA BOOT BBR 
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
void flash_led(uint8_t count)
 | 
			
		||||
{
 | 
			
		||||
    /* flash onboard LED three times to signal entering of bootloader */
 | 
			
		||||
	/* l needs to be volatile or the delay loops below might get
 | 
			
		||||
	optimized away if compiling with optimizations (DAM). */
 | 
			
		||||
    volatile uint32_t l;
 | 
			
		||||
 | 
			
		||||
    if (count == 0) {
 | 
			
		||||
      count = 3;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
	int8_t i;
 | 
			
		||||
    for (i = 0; i < count; ++i) {
 | 
			
		||||
		LED_PORT |= _BV(LED);
 | 
			
		||||
		for(l = 0; l < (F_CPU / 1000); ++l);
 | 
			
		||||
		LED_PORT &= ~_BV(LED);
 | 
			
		||||
		for(l = 0; l < (F_CPU / 1000); ++l); 
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* end of file ATmegaBOOT.c */
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							@@ -0,0 +1,110 @@
 | 
			
		||||
:020000021000EC
 | 
			
		||||
:10F000000C943EF80C9450F80C9450F80C9450F872
 | 
			
		||||
:10F010000C9450F80C9450F80C9450F80C9450F850
 | 
			
		||||
:10F020000C9450F80C9450F80C9450F80C9450F840
 | 
			
		||||
:10F030000C9450F80C9450F80C9450F80C9450F830
 | 
			
		||||
:10F040000C9450F80C9450F80C9450F80C9450F820
 | 
			
		||||
:10F050000C9450F80C9450F80C9450F80C9450F810
 | 
			
		||||
:10F060000C9450F80C9450F80C9450F80C9450F800
 | 
			
		||||
:10F070000C9450F80C9450F80C9450F811241FBEC6
 | 
			
		||||
:10F08000CFEFD0E1DEBFCDBF12E0A0E0B1E001C024
 | 
			
		||||
:10F090001D92A930B107E1F70E9471F90C944FFB62
 | 
			
		||||
:10F0A0000C9400F89091C00095FFFCCF8093C600AF
 | 
			
		||||
:10F0B00008951F93282F332727FD3095207F307028
 | 
			
		||||
:10F0C00094E0359527959A95E1F72A3014F0295A5E
 | 
			
		||||
:10F0D00001C0205D182F1F701A3014F0195A01C09A
 | 
			
		||||
:10F0E000105D822F0E9452F8812F0E9452F81F91CA
 | 
			
		||||
:10F0F0000895EF92FF920F931F932898EE24FF2418
 | 
			
		||||
:10F10000870113C00894E11CF11C011D111D81E051
 | 
			
		||||
:10F11000E81689E0F8068DE3080780E0180728F074
 | 
			
		||||
:10F12000E0910101F091020109958091C00087FFF3
 | 
			
		||||
:10F13000E9CF289A8091C6001F910F91FF90EF9020
 | 
			
		||||
:10F1400008950F931F930E9479F8082F0E9452F898
 | 
			
		||||
:10F150000E9479F8182F0E9452F8013614F00755D2
 | 
			
		||||
:10F1600003C000330CF00053113614F0175503C0E0
 | 
			
		||||
:10F1700010330CF01053802F8295807F810F1F91E8
 | 
			
		||||
:10F180000F91089590E007C02091C00027FFFCCFA9
 | 
			
		||||
:10F190002091C6009F5F9817B8F308951F93182F0A
 | 
			
		||||
:10F1A0000E9479F8803251F484E10E9452F8812F54
 | 
			
		||||
:10F1B0000E9452F880E10E9452F80CC08091000138
 | 
			
		||||
:10F1C0008F5F80930001853029F4E0910101F09177
 | 
			
		||||
:10F1D000020109951F9108950E9479F8803239F44F
 | 
			
		||||
:10F1E00084E10E9452F880E10E9452F808958091D3
 | 
			
		||||
:10F1F00000018F5F80930001853029F4E0910101C7
 | 
			
		||||
:10F20000F091020109950895DF93CF9300D000D0CB
 | 
			
		||||
:10F21000CDB7DEB7882309F481E090E03DC0289A9D
 | 
			
		||||
:10F2200019821A821B821C820CC029813A814B816F
 | 
			
		||||
:10F230005C812F5F3F4F4F4F5F4F29833A834B8352
 | 
			
		||||
:10F240005C8329813A814B815C8120386EE33607EB
 | 
			
		||||
:10F2500060E0460760E0560740F3289819821A825A
 | 
			
		||||
:10F260001B821C820CC029813A814B815C812F5FFB
 | 
			
		||||
:10F270003F4F4F4F5F4F29833A834B835C832981F4
 | 
			
		||||
:10F280003A814B815C8120306AEF360760E04607A7
 | 
			
		||||
:10F2900060E0560740F39F5F981709F619821A82BB
 | 
			
		||||
:10F2A0001B821C820BC089819A81AB81BC81019633
 | 
			
		||||
:10F2B000A11DB11D89839A83AB83BC8389819A8107
 | 
			
		||||
:10F2C000AB81BC81803021E7920722E0A20720E0D9
 | 
			
		||||
:10F2D000B20748F30F900F900F900F90CF91DF91EE
 | 
			
		||||
:10F2E0000895CF92DF92EF92FF920F931F93CF93E7
 | 
			
		||||
:10F2F000DF93000094B714BE809160008861809312
 | 
			
		||||
:10F3000060001092600091FD05C0E0910101F09154
 | 
			
		||||
:10F310000201099589E18093C4001092C50088E13B
 | 
			
		||||
:10F320008093C10086E08093C2005098589A209A3A
 | 
			
		||||
:10F3300083E00E9404F981E00E9404F90E9479F8B8
 | 
			
		||||
:10F34000803309F441C08133E1F40E9479F88032BE
 | 
			
		||||
:10F3500009F097C184E10E9452F881E40E9452F8BA
 | 
			
		||||
:10F3600086E50E9452F882E50E9452F880E20E94EF
 | 
			
		||||
:10F3700052F889E40E9452F883E50E9452F880E531
 | 
			
		||||
:10F380000BC1803439F40E9479F88638E8F00E9485
 | 
			
		||||
:10F3900079F81AC0813499F40E9479F8803811F410
 | 
			
		||||
:10F3A00082E06CC1813811F481E068C1823811F4C7
 | 
			
		||||
:10F3B00080E164C1883909F060C183E05FC18234B3
 | 
			
		||||
:10F3C00031F484E10E94C2F80E94ECF8B7CF853492
 | 
			
		||||
:10F3D00011F485E0F7CF8035B9F3813531F40E941F
 | 
			
		||||
:10F3E000ECF888E080936000FFCF823569F38535C3
 | 
			
		||||
:10F3F00049F40E9479F8809303010E9479F8809380
 | 
			
		||||
:10F400000401E2CF863521F484E00E94C2F835C1C0
 | 
			
		||||
:10F41000843609F0C7C00E9479F8809306020E94E2
 | 
			
		||||
:10F4200079F880930502809108028E7F809308020C
 | 
			
		||||
:10F430000E9479F8853429F48091080281608093D4
 | 
			
		||||
:10F44000080205E011E0F801119281E0E538F807C3
 | 
			
		||||
:10F45000D9F745E0C42E41E0D42EEE24FF2408C0A5
 | 
			
		||||
:10F460000E9479F8F60181936F010894E11CF11C68
 | 
			
		||||
:10F470008091050290910602E816F90688F30E9431
 | 
			
		||||
:10F4800079F8803209F0FDC08091080280FD17C034
 | 
			
		||||
:10F4900020C0F999FECF209103013091040132BDC3
 | 
			
		||||
:10F4A00021BDF80141918F0140BDFA9AF99A2F5F71
 | 
			
		||||
:10F4B0003F4F3093040120930301019602C080E086
 | 
			
		||||
:10F4C00090E020910502309106028217930708F31D
 | 
			
		||||
:10F4D00062C08091030190910401880F991F90935D
 | 
			
		||||
:10F4E0000401809303018091050280FF09C080918F
 | 
			
		||||
:10F4F0000502909106020196909306028093050200
 | 
			
		||||
:10F50000F999FECF1127E0910301F0910401C5E0C4
 | 
			
		||||
:10F51000D1E08091050290910602103091F40091A3
 | 
			
		||||
:10F52000570001700130D9F303E000935700E895CC
 | 
			
		||||
:10F530000091570001700130D9F301E100935700A9
 | 
			
		||||
:10F54000E895099019900091570001700130D9F3A6
 | 
			
		||||
:10F5500001E000935700E8951395103898F01127B3
 | 
			
		||||
:10F560000091570001700130D9F305E00093570076
 | 
			
		||||
:10F57000E8950091570001700130D9F301E1009343
 | 
			
		||||
:10F580005700E8953296029709F0C7CF103011F076
 | 
			
		||||
:10F590000296E5CF112484E10E9452F880E10E9496
 | 
			
		||||
:10F5A00052F8CCCE843709F055C00E9479F8809388
 | 
			
		||||
:10F5B00006020E9479F8809305020E9479F89091E2
 | 
			
		||||
:10F5C0000802853421F49160909308020DC09E7F5B
 | 
			
		||||
:10F5D000909308028091030190910401880F991F74
 | 
			
		||||
:10F5E00090930401809303010E9479F8803209F01E
 | 
			
		||||
:10F5F000A5CE84E10E9452F800E010E023C0809183
 | 
			
		||||
:10F60000080280FF0BC0F999FECF80910301909111
 | 
			
		||||
:10F61000040192BD81BDF89A80B507C081FD07C085
 | 
			
		||||
:10F62000E0910301F091040184910E9452F88091CD
 | 
			
		||||
:10F6300003019091040101969093040180930301CA
 | 
			
		||||
:10F640000F5F1F4F8091050290910602081719075E
 | 
			
		||||
:10F65000B0F2A4CF853779F40E9479F8803289F42A
 | 
			
		||||
:10F6600084E10E9452F88EE10E9452F886E90E94DD
 | 
			
		||||
:10F6700052F88AE091CF863721F480E00E94CEF8DC
 | 
			
		||||
:10F680005DCE809100018F5F80930001853009F08D
 | 
			
		||||
:10F6900055CEE0910101F091020109954FCEF89409
 | 
			
		||||
:02F6A000FFCF9A
 | 
			
		||||
:040000031000F000F9
 | 
			
		||||
:00000001FF
 | 
			
		||||
@@ -0,0 +1,56 @@
 | 
			
		||||
#Makefile for ATmegaBOOT
 | 
			
		||||
# E.Lins, 18.7.2005
 | 
			
		||||
# $Id$
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# program name should not be changed...
 | 
			
		||||
PROGRAM    = ATmegaBOOT_644P
 | 
			
		||||
 | 
			
		||||
# enter the target CPU frequency
 | 
			
		||||
AVR_FREQ   = 16000000L
 | 
			
		||||
 | 
			
		||||
MCU_TARGET = atmega644p
 | 
			
		||||
LDSECTION  = --section-start=.text=0x1F000
 | 
			
		||||
 | 
			
		||||
OBJ        = $(PROGRAM).o
 | 
			
		||||
OPTIMIZE   = -Os
 | 
			
		||||
 | 
			
		||||
DEFS       = 
 | 
			
		||||
LIBS       = 
 | 
			
		||||
 | 
			
		||||
CC         = avr-gcc
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Override is only needed by avr-lib build system.
 | 
			
		||||
 | 
			
		||||
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
 | 
			
		||||
override LDFLAGS       = -Wl,$(LDSECTION)
 | 
			
		||||
#override LDFLAGS       = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
 | 
			
		||||
 | 
			
		||||
OBJCOPY        = avr-objcopy
 | 
			
		||||
OBJDUMP        = avr-objdump
 | 
			
		||||
 | 
			
		||||
all: CFLAGS += '-DMAX_TIME_COUNT=8000000L>>1' -DADABOOT
 | 
			
		||||
all: $(PROGRAM).hex
 | 
			
		||||
 | 
			
		||||
$(PROGRAM).hex: $(PROGRAM).elf
 | 
			
		||||
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
 | 
			
		||||
	
 | 
			
		||||
$(PROGRAM).elf: $(OBJ)
 | 
			
		||||
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
 | 
			
		||||
	
 | 
			
		||||
$(OBJ): ATmegaBOOT.c
 | 
			
		||||
	avr-gcc $(CFLAGS) $(LDFLAGS) -c -g -Os -Wall -mmcu=$(MCU_TARGET) ATmegaBOOT.c -o $(PROGRAM).o
 | 
			
		||||
 | 
			
		||||
%.lst: %.elf
 | 
			
		||||
	$(OBJDUMP) -h -S $< > $@
 | 
			
		||||
 | 
			
		||||
%.srec: %.elf
 | 
			
		||||
	$(OBJCOPY) -j .text -j .data -O srec $< $@
 | 
			
		||||
 | 
			
		||||
%.bin: %.elf
 | 
			
		||||
	$(OBJCOPY) -j .text -j .data -O binary $< $@
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
 | 
			
		||||
	
 | 
			
		||||
@@ -0,0 +1,3 @@
 | 
			
		||||
Note: This bootloader support ATmega644, ATmega644P and ATmega324P.
 | 
			
		||||
To build, set PROGRAM and MCU_TARGET in the Makefile according to your target device.
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user