Compare commits
868 Commits
LUFA-11100
...
LUFA-13090
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56c6b594ac | ||
|
|
3f99d419aa | ||
|
|
25b0f55d99 | ||
|
|
ff8e86ba73 | ||
|
|
4f90aeddda | ||
|
|
de366fdbe1 | ||
|
|
82e606eb3b | ||
|
|
e24ab1600f | ||
|
|
c02a2c5257 | ||
|
|
fd524b0e00 | ||
|
|
23910fa09e | ||
|
|
7c57ad3858 | ||
|
|
5fde9e0f0d | ||
|
|
ea58513558 | ||
|
|
a4a6958524 | ||
|
|
5558b2f221 | ||
|
|
6dd0447c12 | ||
|
|
d557744503 | ||
|
|
a8a2fe3a23 | ||
|
|
a403b12b8d | ||
|
|
50e8fc615d | ||
|
|
2d21e36dd9 | ||
|
|
15828b1d5f | ||
|
|
b4af3f1fc9 | ||
|
|
fc61e88a8d | ||
|
|
a899ee0cf4 | ||
|
|
7cd9e0dbc4 | ||
|
|
37ba9ec326 | ||
|
|
e0ab5c5a5a | ||
|
|
368c9af784 | ||
|
|
9fc655f438 | ||
|
|
ebc0d8bc94 | ||
|
|
6e79c3ecaf | ||
|
|
873d288f31 | ||
|
|
8d1376bbe9 | ||
|
|
e9bf4bc84e | ||
|
|
ddf10cb162 | ||
|
|
7b75209b58 | ||
|
|
b1b109487e | ||
|
|
8cfa2e8023 | ||
|
|
f0c72df674 | ||
|
|
8bcc38aa32 | ||
|
|
fb9aa5aa81 | ||
|
|
c6e1bf87b5 | ||
|
|
9737a23271 | ||
|
|
ed922ff422 | ||
|
|
4a4b9d3051 | ||
|
|
7362abcd8a | ||
|
|
1d49fc7dd8 | ||
|
|
1509af922b | ||
|
|
f7b9ebea02 | ||
|
|
6d58628e85 | ||
|
|
1eae43da0c | ||
|
|
4175fe03ee | ||
|
|
24ff863f02 | ||
|
|
c2e7e5783b | ||
|
|
7941245122 | ||
|
|
16037433a2 | ||
|
|
94b43e2f9d | ||
|
|
3ef45fae56 | ||
|
|
0d2b3185ea | ||
|
|
195af9e530 | ||
|
|
1a62519c74 | ||
|
|
085f4d38e8 | ||
|
|
ac36abd9f0 | ||
|
|
f5882b875e | ||
|
|
902d3d9bff | ||
|
|
b5285c1411 | ||
|
|
969120070c | ||
|
|
c07d670b6c | ||
|
|
f835323682 | ||
|
|
b37bde5675 | ||
|
|
10448970e5 | ||
|
|
fdf50e9411 | ||
|
|
e51c0c84d6 | ||
|
|
151a1c5888 | ||
|
|
329629a316 | ||
|
|
65a8d68c57 | ||
|
|
139fabb6cd | ||
|
|
758ddfcc68 | ||
|
|
2bb012d4cb | ||
|
|
654baf7d60 | ||
|
|
8474262728 | ||
|
|
51bfd9c95c | ||
|
|
be5f06d9d3 | ||
|
|
44ecc034c1 | ||
|
|
91eb7c34c7 | ||
|
|
fbc57f965e | ||
|
|
773b6ae979 | ||
|
|
3a06ef99e6 | ||
|
|
7af4d949e2 | ||
|
|
06df6a3ea8 | ||
|
|
2338189c8d | ||
|
|
f6d0cdb817 | ||
|
|
9891bf7cc3 | ||
|
|
db528b6778 | ||
|
|
85a0e75c60 | ||
|
|
c8f2269804 | ||
|
|
e342ba8f64 | ||
|
|
0ad234c194 | ||
|
|
3d0e6d055b | ||
|
|
0d80075387 | ||
|
|
4a7405b2cf | ||
|
|
a3784c5944 | ||
|
|
983a2ed87a | ||
|
|
4bfd45b484 | ||
|
|
61d1be0cb2 | ||
|
|
1352ebe568 | ||
|
|
5a3baec455 | ||
|
|
707934d9cb | ||
|
|
6dde585475 | ||
|
|
214d5b39fc | ||
|
|
0223c3668c | ||
|
|
39603f05b2 | ||
|
|
46bb98d9dc | ||
|
|
f9a919aa77 | ||
|
|
bf6cc44ab1 | ||
|
|
b7455af965 | ||
|
|
9b2ff1d8e8 | ||
|
|
eef7286283 | ||
|
|
3bf3e53367 | ||
|
|
7b5b8f199f | ||
|
|
961da384f9 | ||
|
|
95ba6527a5 | ||
|
|
b68a71af38 | ||
|
|
9ccf3eafad | ||
|
|
7f5445c8c6 | ||
|
|
7464e40a4b | ||
|
|
fd5e98d380 | ||
|
|
db929fd4c8 | ||
|
|
fdc7c8abce | ||
|
|
1949b98e6c | ||
|
|
16e8fe9878 | ||
|
|
5e55be1004 | ||
|
|
70dd6bc526 | ||
|
|
a24e1cc7d7 | ||
|
|
3908d2e608 | ||
|
|
15fb6351e5 | ||
|
|
c757acf1f7 | ||
|
|
41810f6e9e | ||
|
|
d3cee5160b | ||
|
|
5cfa1c37c6 | ||
|
|
1840e1bbae | ||
|
|
29bfe7a09c | ||
|
|
9543276111 | ||
|
|
5dba028aa5 | ||
|
|
cf8ec8967e | ||
|
|
f515e8412f | ||
|
|
cc44591b58 | ||
|
|
344cd1a2e8 | ||
|
|
1d5b268fd9 | ||
|
|
c1ffcd8681 | ||
|
|
8232721102 | ||
|
|
2fe1d7d170 | ||
|
|
083b5cb143 | ||
|
|
3c5acb4d2c | ||
|
|
9136fe2132 | ||
|
|
d540e52505 | ||
|
|
dd723813d9 | ||
|
|
2cd3f843e2 | ||
|
|
38fa1d5c83 | ||
|
|
5a802b18df | ||
|
|
fff68762e9 | ||
|
|
e5c65f6e25 | ||
|
|
eefbf632d6 | ||
|
|
7ef41e3c1e | ||
|
|
196f4868b9 | ||
|
|
0672e4ac6c | ||
|
|
5555a43625 | ||
|
|
25224aae7e | ||
|
|
f2d7f6f674 | ||
|
|
f3a8263842 | ||
|
|
b6a38164bd | ||
|
|
70c59a7e42 | ||
|
|
188dea87e3 | ||
|
|
334f70aa80 | ||
|
|
d5e84db5ab | ||
|
|
c10935c80b | ||
|
|
91946e6d62 | ||
|
|
197e2ed985 | ||
|
|
b7f9beefd8 | ||
|
|
ebd059d0eb | ||
|
|
c2f9eba33f | ||
|
|
6ea66a7770 | ||
|
|
7c3867da33 | ||
|
|
7dc77a6abc | ||
|
|
dd08100a7d | ||
|
|
9aabce09f1 | ||
|
|
ace61d757e | ||
|
|
09ae9ad004 | ||
|
|
e40f0eb289 | ||
|
|
646e63b089 | ||
|
|
7dc5295103 | ||
|
|
dc389f1c72 | ||
|
|
85343a436d | ||
|
|
7251da6581 | ||
|
|
829ecefe41 | ||
|
|
b956fedeeb | ||
|
|
ddd6632295 | ||
|
|
907cb2459c | ||
|
|
83d5c4729e | ||
|
|
148b434228 | ||
|
|
d18f12bf42 | ||
|
|
8cd249c342 | ||
|
|
4ba4097716 | ||
|
|
f2e974954b | ||
|
|
3bc066cd69 | ||
|
|
169f21fbb1 | ||
|
|
654217548b | ||
|
|
31d3984d8d | ||
|
|
141f24b4a1 | ||
|
|
54e46d7818 | ||
|
|
04feb435ed | ||
|
|
9d988fdc22 | ||
|
|
199cf8f183 | ||
|
|
6e8642185a | ||
|
|
b2e49663f6 | ||
|
|
262b7d7b7b | ||
|
|
03cdb09071 | ||
|
|
88bcc6fde5 | ||
|
|
1703283893 | ||
|
|
be33d3a515 | ||
|
|
f8a1dc7424 | ||
|
|
f429975e01 | ||
|
|
dd1e18b264 | ||
|
|
6dd4d0a9f1 | ||
|
|
d1155a9a27 | ||
|
|
1575ca57bb | ||
|
|
e635872612 | ||
|
|
cb4e4a711e | ||
|
|
9e8bf8c0cf | ||
|
|
cc8b12f1cb | ||
|
|
61d396b555 | ||
|
|
68c317c4e9 | ||
|
|
de9d05f32a | ||
|
|
0b1f33e2a2 | ||
|
|
ef7b6a274c | ||
|
|
32fcf1ec53 | ||
|
|
3f52d6ee06 | ||
|
|
dddb709c43 | ||
|
|
df9b04c87f | ||
|
|
6c9632ae38 | ||
|
|
d5cff25cd1 | ||
|
|
e62e50c663 | ||
|
|
d5d83b8e8f | ||
|
|
726b325c73 | ||
|
|
bb8754e2b8 | ||
|
|
63e1fc6e6c | ||
|
|
d5d9ff73e5 | ||
|
|
0f0f9638a3 | ||
|
|
f00754ed97 | ||
|
|
6da1677bc3 | ||
|
|
7f5dab4f26 | ||
|
|
f0c7a11670 | ||
|
|
4753528b9e | ||
|
|
64f17a679f | ||
|
|
57071dea22 | ||
|
|
7d4062fa54 | ||
|
|
2e7fc37ad2 | ||
|
|
d999ca8f30 | ||
|
|
0c40ef8897 | ||
|
|
041bdf8954 | ||
|
|
63e80bea08 | ||
|
|
8a43da6b37 | ||
|
|
d88c6edea4 | ||
|
|
d8b81e76f6 | ||
|
|
71e28def27 | ||
|
|
3383487deb | ||
|
|
6019754b7a | ||
|
|
39ffce948a | ||
|
|
280fc85d1b | ||
|
|
fa2a8fca69 | ||
|
|
95fd3bf0fe | ||
|
|
cfa48f5987 | ||
|
|
2b4658de2c | ||
|
|
8703edc724 | ||
|
|
6c531a10c0 | ||
|
|
4bd36a9775 | ||
|
|
300a05d6c6 | ||
|
|
7ce76f2d81 | ||
|
|
3d2c39d267 | ||
|
|
5b089fbbf3 | ||
|
|
8d22cedfc4 | ||
|
|
da42e8840d | ||
|
|
fb18c315d0 | ||
|
|
f8f8ac0b1a | ||
|
|
2cd4c5aaa1 | ||
|
|
0e64a9d0c2 | ||
|
|
3929cae00e | ||
|
|
a05dd56239 | ||
|
|
bc8e686e51 | ||
|
|
22b04429e6 | ||
|
|
5937a134ab | ||
|
|
0878957241 | ||
|
|
2413d114b7 | ||
|
|
3059a33db2 | ||
|
|
b8d07ffb24 | ||
|
|
180180e234 | ||
|
|
5fea1abd22 | ||
|
|
2709627970 | ||
|
|
af241316de | ||
|
|
730db924c9 | ||
|
|
f51c87b916 | ||
|
|
7eaf3d18d2 | ||
|
|
397d77cb44 | ||
|
|
f2c2415480 | ||
|
|
184efdaba6 | ||
|
|
c791413fbc | ||
|
|
33bc48fa46 | ||
|
|
ed372b031c | ||
|
|
cff8a751bb | ||
|
|
cae97e1ac3 | ||
|
|
5cdc29616c | ||
|
|
bdd74a5ed9 | ||
|
|
5b5957f9ea | ||
|
|
bbffe94a9d | ||
|
|
eac6205747 | ||
|
|
77af37a587 | ||
|
|
0254a7e980 | ||
|
|
132de6ed22 | ||
|
|
8e11439f91 | ||
|
|
482cb097e8 | ||
|
|
841bb33e36 | ||
|
|
48e87c8e8f | ||
|
|
30545fdec7 | ||
|
|
3edd686a05 | ||
|
|
09b2254b33 | ||
|
|
fc876438f6 | ||
|
|
c50072c3c4 | ||
|
|
1da700e4fb | ||
|
|
ab8ae60058 | ||
|
|
26015d432d | ||
|
|
9603de1398 | ||
|
|
f644ffe873 | ||
|
|
fbab860902 | ||
|
|
78e6e4f4c2 | ||
|
|
56f03a793c | ||
|
|
5386a5a7ff | ||
|
|
340b2dc0bc | ||
|
|
4167f3aa6b | ||
|
|
5724b28151 | ||
|
|
a016942a3e | ||
|
|
bd2f3c0250 | ||
|
|
de0df8b162 | ||
|
|
13dd494cfe | ||
|
|
1ab7e11ddb | ||
|
|
2608fd1dd4 | ||
|
|
7d037c7db8 | ||
|
|
04d13d264c | ||
|
|
aa61ee1c11 | ||
|
|
2957f2bc8c | ||
|
|
c786d8a0b7 | ||
|
|
9740d3a55f | ||
|
|
2b43a6d7df | ||
|
|
fe49fd51b2 | ||
|
|
1f33bc2fd3 | ||
|
|
72fc4a204d | ||
|
|
826a77e90c | ||
|
|
9a04475c23 | ||
|
|
eee252603b | ||
|
|
4641acc691 | ||
|
|
4cd80263ff | ||
|
|
217f1eebc1 | ||
|
|
e471f7c78d | ||
|
|
9da01ee78b | ||
|
|
97046965ee | ||
|
|
f3049d958e | ||
|
|
7fd2349e1a | ||
|
|
e1803e3adb | ||
|
|
5f6235b195 | ||
|
|
7d259eac4c | ||
|
|
11fa17a7db | ||
|
|
1eefbf9041 | ||
|
|
92ee5ad826 | ||
|
|
a032d77d0e | ||
|
|
e186907e39 | ||
|
|
3e1f3869c1 | ||
|
|
fc2cbe0700 | ||
|
|
c8f7cf7621 | ||
|
|
45a56b4df7 | ||
|
|
5f1428bb50 | ||
|
|
df14c97519 | ||
|
|
c93259fbdb | ||
|
|
cd40797a4d | ||
|
|
6936fcbd60 | ||
|
|
ce5f5bd1c3 | ||
|
|
5f614861a6 | ||
|
|
7a51e97c3b | ||
|
|
0284385b4e | ||
|
|
7aa8dc1de0 | ||
|
|
1adf8174cf | ||
|
|
b01ebe2d37 | ||
|
|
b5d9239111 | ||
|
|
80dc196031 | ||
|
|
b9f3ff39a4 | ||
|
|
c4aeb6d5ab | ||
|
|
376160e2c0 | ||
|
|
43658f336e | ||
|
|
4b194592aa | ||
|
|
44aea22949 | ||
|
|
e225de8a83 | ||
|
|
ff00644cb8 | ||
|
|
9eef78d21e | ||
|
|
603a7d86e9 | ||
|
|
302ec480cc | ||
|
|
a69a0cbeb8 | ||
|
|
1cb60c1214 | ||
|
|
8d8e5c06b9 | ||
|
|
7750783809 | ||
|
|
0598d622d8 | ||
|
|
7375c789e1 | ||
|
|
3e50a59486 | ||
|
|
84fadb255e | ||
|
|
1ba60b4a18 | ||
|
|
00ab25d321 | ||
|
|
1f1bd69b85 | ||
|
|
94f5f31f10 | ||
|
|
63fb35f319 | ||
|
|
e92a9845d3 | ||
|
|
40755d4fde | ||
|
|
6fb6c628fa | ||
|
|
f0e5425208 | ||
|
|
ffbb30e0f8 | ||
|
|
fa664f8b46 | ||
|
|
9c590e41d7 | ||
|
|
a5abb0eb3f | ||
|
|
f1a2bca684 | ||
|
|
a148d63e8b | ||
|
|
fb917b7016 | ||
|
|
85f4f2c2b1 | ||
|
|
af3c001cba | ||
|
|
e90eeb791d | ||
|
|
bcc45e24aa | ||
|
|
e5781d172e | ||
|
|
db3f8565b8 | ||
|
|
33f832b958 | ||
|
|
cf48972f5a | ||
|
|
a002487140 | ||
|
|
16cd7c6896 | ||
|
|
5a0bd85330 | ||
|
|
efa5d54093 | ||
|
|
9f0cd5ebb8 | ||
|
|
b8807e9928 | ||
|
|
61d52c9fff | ||
|
|
c90b9b507d | ||
|
|
bfee7f8c56 | ||
|
|
5b6bae3445 | ||
|
|
07f4f8e990 | ||
|
|
8820b1f6cc | ||
|
|
c0da7660fc | ||
|
|
badbca5791 | ||
|
|
8e1328dc6a | ||
|
|
5b8b5018f2 | ||
|
|
3ca025f214 | ||
|
|
3c1b28cf5f | ||
|
|
a57ed1abfb | ||
|
|
79122426c9 | ||
|
|
b7e3c86e4e | ||
|
|
d4980e58d4 | ||
|
|
1faa5ba70a | ||
|
|
a9b6852603 | ||
|
|
22eeb9b4e9 | ||
|
|
0da99447d3 | ||
|
|
e3578113c9 | ||
|
|
3bf7ce15d5 | ||
|
|
b2920402b4 | ||
|
|
7f29c468d7 | ||
|
|
fafb52118d | ||
|
|
73a87a8c7b | ||
|
|
5087e6c303 | ||
|
|
c4da1929cd | ||
|
|
56d368f2de | ||
|
|
10944d9ddf | ||
|
|
8881e5a52d | ||
|
|
f7ad67cf18 | ||
|
|
865529adea | ||
|
|
4b8a46193e | ||
|
|
34c1b49cd1 | ||
|
|
5d9403fde4 | ||
|
|
2e27cc2670 | ||
|
|
579fbb68fc | ||
|
|
6f90d45684 | ||
|
|
c9ba8f2a2c | ||
|
|
80fab49e1d | ||
|
|
aba33a0334 | ||
|
|
3f4efc6159 | ||
|
|
8b985b44b5 | ||
|
|
6655815b32 | ||
|
|
43e10d666b | ||
|
|
90b6bf9e25 | ||
|
|
e5cf169469 | ||
|
|
bf5b49ecf5 | ||
|
|
924edb2f9a | ||
|
|
ef06eefc8b | ||
|
|
393fc71d8e | ||
|
|
532b3a18f1 | ||
|
|
8ccc2b2272 | ||
|
|
cce71a74e7 | ||
|
|
1d2f231cc1 | ||
|
|
7e65340c31 | ||
|
|
6fa8da4e56 | ||
|
|
d8621ee8f4 | ||
|
|
7d83e10b7f | ||
|
|
c128d8783e | ||
|
|
751806458b | ||
|
|
4da2ba9f1c | ||
|
|
c4ebddd27a | ||
|
|
deb6fce7bc | ||
|
|
3d39cbe94b | ||
|
|
2351c46f0b | ||
|
|
e7e45baef1 | ||
|
|
c41bbf9fcc | ||
|
|
9ab445518a | ||
|
|
fe3a5c2462 | ||
|
|
49424ce6b1 | ||
|
|
fae71b5780 | ||
|
|
857641b98e | ||
|
|
44ff0af68c | ||
|
|
b9952f4809 | ||
|
|
678cb3c2bf | ||
|
|
21a6acff83 | ||
|
|
67a8f54a6e | ||
|
|
59056ce544 | ||
|
|
6dc85e4023 | ||
|
|
53be52922f | ||
|
|
3808f5c36d | ||
|
|
544027da18 | ||
|
|
61b5740a25 | ||
|
|
cd0bd7bf90 | ||
|
|
7abaafb3ca | ||
|
|
6e29655b54 | ||
|
|
082537f5bd | ||
|
|
940145ca6d | ||
|
|
0c012ede5f | ||
|
|
3f82cb8dc3 | ||
|
|
94a1b4da06 | ||
|
|
28a2739fa3 | ||
|
|
511348fb13 | ||
|
|
fab1678602 | ||
|
|
000c4c6c5c | ||
|
|
d887c0c73c | ||
|
|
49ca5c3c83 | ||
|
|
32f2d59bc0 | ||
|
|
7d9467e431 | ||
|
|
a57c4eabae | ||
|
|
4124534144 | ||
|
|
60a2147a51 | ||
|
|
c7344c22ac | ||
|
|
41b4c5b645 | ||
|
|
8f8f347891 | ||
|
|
316cae29b5 | ||
|
|
00aaf1cb41 | ||
|
|
5af18ba288 | ||
|
|
88425d7dab | ||
|
|
9f7f595382 | ||
|
|
fc0ff2f976 | ||
|
|
7197893006 | ||
|
|
d0737f6ad5 | ||
|
|
7655205aac | ||
|
|
450ff51b7e | ||
|
|
0d888458e1 | ||
|
|
85579e12e4 | ||
|
|
719a0e7f78 | ||
|
|
4913678695 | ||
|
|
5ce60f25e6 | ||
|
|
a9bb2d5488 | ||
|
|
6a3a5f40da | ||
|
|
ecdffe2e41 | ||
|
|
0b262c569f | ||
|
|
e24993c13a | ||
|
|
fcf0b8a5bb | ||
|
|
59ca4ec0ec | ||
|
|
7c75623e43 | ||
|
|
fc3768733e | ||
|
|
29874f6db7 | ||
|
|
276eb35d68 | ||
|
|
79ee9e755f | ||
|
|
924c0eb6ac | ||
|
|
8031d97a4f | ||
|
|
4453133d3c | ||
|
|
2b332d3231 | ||
|
|
26cc2e9fa8 | ||
|
|
56e792c95b | ||
|
|
e309f42af3 | ||
|
|
8f2e82bd61 | ||
|
|
851fcd0c2f | ||
|
|
d4684b29b9 | ||
|
|
2ff1370221 | ||
|
|
1e42f7bd46 | ||
|
|
0389288e27 | ||
|
|
b017b41e91 | ||
|
|
96462ac746 | ||
|
|
c3dd6ac781 | ||
|
|
7d65c54eef | ||
|
|
4a09e4b2ee | ||
|
|
b5e850ffd6 | ||
|
|
1fe8e29ab3 | ||
|
|
910fd08ea1 | ||
|
|
a9d8af99e4 | ||
|
|
18d91ece3b | ||
|
|
35564bb1a7 | ||
|
|
f235021abe | ||
|
|
5ec9d04bca | ||
|
|
55283475d3 | ||
|
|
aba30ac2a0 | ||
|
|
615d34f1b7 | ||
|
|
5f709e281e | ||
|
|
5833b27f80 | ||
|
|
32cfb8cf4f | ||
|
|
28967ef2e8 | ||
|
|
063474561d | ||
|
|
b181cf4fb8 | ||
|
|
d4f00fe7d5 | ||
|
|
82162c710c | ||
|
|
f2ae4dc255 | ||
|
|
c9b3468f1e | ||
|
|
c31fdbd03e | ||
|
|
8cfb3d9f09 | ||
|
|
cca24c8dc9 | ||
|
|
666088a388 | ||
|
|
cb9e7392c5 | ||
|
|
e9e6730d49 | ||
|
|
80e278acde | ||
|
|
ae6a514929 | ||
|
|
9a373c4094 | ||
|
|
7f4462267a | ||
|
|
11ed8be175 | ||
|
|
0a00ee4037 | ||
|
|
13085a3351 | ||
|
|
64d00efd91 | ||
|
|
a9f0369fac | ||
|
|
f9fb44b01c | ||
|
|
5cba3ce3a4 | ||
|
|
998009c490 | ||
|
|
380f014c4c | ||
|
|
96fd39eda8 | ||
|
|
40fd566dba | ||
|
|
70fd816b09 | ||
|
|
383eb6da84 | ||
|
|
a268a570b1 | ||
|
|
802910d49f | ||
|
|
3e7e02c6dd | ||
|
|
33d9a75b03 | ||
|
|
926a83bbc1 | ||
|
|
74fb2d895e | ||
|
|
b601043e17 | ||
|
|
359fbfe14d | ||
|
|
7a7ee6a908 | ||
|
|
e5a7fa201e | ||
|
|
f0af2e4a02 | ||
|
|
2afa026866 | ||
|
|
44f348e7ff | ||
|
|
9207e8b2fd | ||
|
|
395e4287a1 | ||
|
|
1007317c5f | ||
|
|
590d9b5ff8 | ||
|
|
430973263b | ||
|
|
0e434c8f8f | ||
|
|
2d98e5499b | ||
|
|
46d511c021 | ||
|
|
04740d680e | ||
|
|
cc959c945b | ||
|
|
69ecaae732 | ||
|
|
bd6123e2c1 | ||
|
|
e875d7cf9f | ||
|
|
5b5b73ce58 | ||
|
|
c7bfcf2cbb | ||
|
|
cfa399a533 | ||
|
|
c48da94605 | ||
|
|
1ab76048c9 | ||
|
|
b42642a5d6 | ||
|
|
56aed4b3e6 | ||
|
|
e39f3378a2 | ||
|
|
cf7859e2f2 | ||
|
|
ce3db96d9a | ||
|
|
3703d50580 | ||
|
|
02120ebc38 | ||
|
|
c0841d98c5 | ||
|
|
e7670d06e0 | ||
|
|
bd3f6794dd | ||
|
|
2e757d8c38 | ||
|
|
47f6a35013 | ||
|
|
e8570c4a37 | ||
|
|
a19dc3d20c | ||
|
|
9add0d100d | ||
|
|
d771099f62 | ||
|
|
3211b35a4c | ||
|
|
b2fe539d1c | ||
|
|
f11826fc47 | ||
|
|
a25a6dfd56 | ||
|
|
fde181a830 | ||
|
|
60d724e398 | ||
|
|
3008f8ce13 | ||
|
|
512b4d87cc | ||
|
|
f1bf7e1816 | ||
|
|
292df85620 | ||
|
|
b04de2f2f4 | ||
|
|
b9a486efe7 | ||
|
|
ae91ccc048 | ||
|
|
8f4f48d963 | ||
|
|
d4b45e8502 | ||
|
|
0fb92f0441 | ||
|
|
8b4fe84163 | ||
|
|
55b315b00f | ||
|
|
25ac76a251 | ||
|
|
89f16f5d7f | ||
|
|
1cc62c9282 | ||
|
|
bb055c24e3 | ||
|
|
b3aaffb792 | ||
|
|
7cac5e22d7 | ||
|
|
5e5b7cf2ca | ||
|
|
00b6b0140f | ||
|
|
0424bd4dbc | ||
|
|
bbf9d14bf9 | ||
|
|
a77c3edc37 | ||
|
|
e58915344d | ||
|
|
01d5af3d6c | ||
|
|
1971a415e5 | ||
|
|
f87aec2264 | ||
|
|
77adb2ba52 | ||
|
|
c0f763db04 | ||
|
|
d5291c2e10 | ||
|
|
3ea356a720 | ||
|
|
8de8d7ab5a | ||
|
|
663f9bd5f5 | ||
|
|
62c5a14fbb | ||
|
|
eb2431ecd8 | ||
|
|
915b4d2346 | ||
|
|
65019e4408 | ||
|
|
fa49bc152c | ||
|
|
ceed4e680f | ||
|
|
dba5004684 | ||
|
|
e3124bb90b | ||
|
|
0d4a9a895b | ||
|
|
17f104cbe8 | ||
|
|
6ee79029d5 | ||
|
|
5c3623a7c5 | ||
|
|
9ffeac6992 | ||
|
|
e408f92b26 | ||
|
|
eb1275890a | ||
|
|
7416ebd7c6 | ||
|
|
bb85d083a7 | ||
|
|
b762780343 | ||
|
|
f5c155cf05 | ||
|
|
8a9e30a0cb | ||
|
|
7cbea39c42 | ||
|
|
0456dfeb88 | ||
|
|
f70fd6d6ed | ||
|
|
6a9d1eab2d | ||
|
|
63a65a9598 | ||
|
|
e406140f11 | ||
|
|
5561524a8f | ||
|
|
1dcc1fe527 | ||
|
|
4068efbd18 | ||
|
|
6c738343ae | ||
|
|
9a6c6c786e | ||
|
|
84ff878fd7 | ||
|
|
50ff97f378 | ||
|
|
bbe7c77b91 | ||
|
|
0e4ece1d1d | ||
|
|
b7f4370c8e | ||
|
|
2f036ae2bf | ||
|
|
1132488e8f | ||
|
|
04b8360b15 | ||
|
|
9d2e7aeff4 | ||
|
|
7a8b038687 | ||
|
|
01a80df6c2 | ||
|
|
5051df08d7 | ||
|
|
09d2be0dc1 | ||
|
|
f45d60f768 | ||
|
|
82fdedc192 | ||
|
|
81bd8f2f83 | ||
|
|
2180f57d17 | ||
|
|
385ffb6de3 | ||
|
|
a2d18e46f8 | ||
|
|
7a1033025b | ||
|
|
c60897df39 | ||
|
|
18b82b3575 | ||
|
|
1482f77826 | ||
|
|
4d131de85b | ||
|
|
fdab3aef86 | ||
|
|
fe8326855a | ||
|
|
5a2d815722 | ||
|
|
da676f0f70 | ||
|
|
0e8e70153a | ||
|
|
a677254026 | ||
|
|
252bd7bb2c | ||
|
|
e55946f972 | ||
|
|
f1b6ddb710 | ||
|
|
2c806f6cee | ||
|
|
64e9361298 | ||
|
|
df33278d91 | ||
|
|
43a3350981 | ||
|
|
3dacb73af3 | ||
|
|
10a56f6105 | ||
|
|
8d2cb61a5b | ||
|
|
a436fbb612 | ||
|
|
fc4d3ab400 | ||
|
|
956f9e3709 | ||
|
|
401ff1cef1 | ||
|
|
9f99c7fa03 | ||
|
|
5563da6a62 | ||
|
|
a147cee95f | ||
|
|
dd312cead4 | ||
|
|
bc3db793e9 | ||
|
|
3038ea1c6e | ||
|
|
154d28e39f | ||
|
|
f201f6697b | ||
|
|
77f354609f | ||
|
|
676de74d9b | ||
|
|
84a739ae72 | ||
|
|
ec3e47a7d0 | ||
|
|
ecba8bcecf | ||
|
|
0c59d5993e | ||
|
|
798cc84ff5 | ||
|
|
259a3c9854 | ||
|
|
24ca2d49fe | ||
|
|
70f3d8e933 | ||
|
|
2b23318357 | ||
|
|
057972bd25 | ||
|
|
b0a258722d | ||
|
|
cdd4e11fa8 | ||
|
|
38d7cdf803 | ||
|
|
3b99abb5fc | ||
|
|
e915d968a5 | ||
|
|
7f8dbb4908 | ||
|
|
8b5aa61601 | ||
|
|
075538abb9 | ||
|
|
d619214854 | ||
|
|
08f448407b | ||
|
|
e9802253e2 | ||
|
|
4f223302b1 | ||
|
|
c704131be4 | ||
|
|
a81ccd83fd | ||
|
|
09577fe541 | ||
|
|
b711b7d6a4 | ||
|
|
eb2e883fd3 | ||
|
|
3e04487279 | ||
|
|
dc09ccab8b | ||
|
|
e30be658c9 | ||
|
|
46aea9d4ce | ||
|
|
b057041660 | ||
|
|
6564416479 | ||
|
|
8df0cf3241 | ||
|
|
2b54cd984d | ||
|
|
0ad6f1fb53 | ||
|
|
cb7f7a8241 | ||
|
|
139c1afeeb | ||
|
|
7992202603 | ||
|
|
00ad509061 | ||
|
|
0304916356 | ||
|
|
eb5b8a32e4 | ||
|
|
1e0c3bc69a | ||
|
|
fe87b8a225 | ||
|
|
72717825e5 | ||
|
|
b714ffbfa0 | ||
|
|
c739974292 | ||
|
|
ab43251bf9 | ||
|
|
028a3c4ab3 | ||
|
|
6519aaa571 | ||
|
|
f1543ae8ff | ||
|
|
bc14c1a7f6 | ||
|
|
e9029d49d5 | ||
|
|
3aa8a69246 | ||
|
|
738c9203fc | ||
|
|
c6d6bdae0a | ||
|
|
c15eaa5dae | ||
|
|
1a4a26271e |
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
*.o
|
||||
*.d
|
||||
*.elf
|
||||
*.hex
|
||||
*.eep
|
||||
*.sym
|
||||
*.bin
|
||||
*.lss
|
||||
*.map
|
||||
*.bak
|
||||
*.class
|
||||
LUFA/StudioIntegration/ProjectGenerator/*
|
||||
LUFA/StudioIntegration/DocBook/*
|
||||
75
Bootloaders/CDC/BootloaderAPI.c
Normal file
75
Bootloaders/CDC/BootloaderAPI.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
58
Bootloaders/CDC/BootloaderAPI.h
Normal file
58
Bootloaders/CDC/BootloaderAPI.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
91
Bootloaders/CDC/BootloaderAPITable.S
Normal file
91
Bootloaders/CDC/BootloaderAPITable.S
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
; Trampolines to actual API implementations if the target address is outside the
|
||||
; range of a rjmp instruction (can happen with large bootloader sections)
|
||||
.section .apitable_trampolines, "ax"
|
||||
.global BootloaderAPI_Trampolines
|
||||
BootloaderAPI_Trampolines:
|
||||
|
||||
BootloaderAPI_ErasePage_Trampoline:
|
||||
jmp BootloaderAPI_ErasePage
|
||||
BootloaderAPI_WritePage_Trampoline:
|
||||
jmp BootloaderAPI_WritePage
|
||||
BootloaderAPI_FillWord_Trampoline:
|
||||
jmp BootloaderAPI_FillWord
|
||||
BootloaderAPI_ReadSignature_Trampoline:
|
||||
jmp BootloaderAPI_ReadSignature
|
||||
BootloaderAPI_ReadFuse_Trampoline:
|
||||
jmp BootloaderAPI_ReadFuse
|
||||
BootloaderAPI_ReadLock_Trampoline:
|
||||
jmp BootloaderAPI_ReadLock
|
||||
BootloaderAPI_WriteLock_Trampoline:
|
||||
jmp BootloaderAPI_WriteLock
|
||||
BootloaderAPI_UNUSED1:
|
||||
ret
|
||||
BootloaderAPI_UNUSED2:
|
||||
ret
|
||||
BootloaderAPI_UNUSED3:
|
||||
ret
|
||||
BootloaderAPI_UNUSED4:
|
||||
ret
|
||||
BootloaderAPI_UNUSED5:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; API function jump table
|
||||
.section .apitable_jumptable, "ax"
|
||||
.global BootloaderAPI_JumpTable
|
||||
BootloaderAPI_JumpTable:
|
||||
|
||||
rjmp BootloaderAPI_ErasePage_Trampoline
|
||||
rjmp BootloaderAPI_WritePage_Trampoline
|
||||
rjmp BootloaderAPI_FillWord_Trampoline
|
||||
rjmp BootloaderAPI_ReadSignature_Trampoline
|
||||
rjmp BootloaderAPI_ReadFuse_Trampoline
|
||||
rjmp BootloaderAPI_ReadLock_Trampoline
|
||||
rjmp BootloaderAPI_WriteLock_Trampoline
|
||||
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
|
||||
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
|
||||
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
|
||||
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
|
||||
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
|
||||
|
||||
|
||||
|
||||
; Bootloader table signatures and information
|
||||
.section .apitable_signatures, "ax"
|
||||
.global BootloaderAPI_Signatures
|
||||
BootloaderAPI_Signatures:
|
||||
|
||||
.long BOOT_START_ADDR ; Start address of the bootloader
|
||||
.word 0xDF00 ; Signature for the CDC class bootloader
|
||||
.word 0xDCFB ; Signature for a LUFA class bootloader
|
||||
@@ -1 +0,0 @@
|
||||
<AVRStudio><MANAGEMENT><ProjectName>BootloaderCDC</ProjectName><Created>13-Jul-2010 14:41:25</Created><LastEdit>13-Jul-2010 14:42:12</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderCDC.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderCDC.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderCDC.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -56,6 +56,55 @@ static uint32_t CurrAddress;
|
||||
*/
|
||||
static bool RunBootloader = true;
|
||||
|
||||
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
|
||||
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
|
||||
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
|
||||
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
|
||||
*/
|
||||
uint16_t MagicBootKey ATTR_NO_INIT;
|
||||
|
||||
|
||||
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
|
||||
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
|
||||
* this will force the user application to start via a software jump.
|
||||
*/
|
||||
void Application_Jump_Check(void)
|
||||
{
|
||||
bool JumpToApplication = false;
|
||||
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
/* Disable JTAG debugging */
|
||||
JTAG_DISABLE();
|
||||
|
||||
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
|
||||
PORTF |= (1 << 4);
|
||||
Delay_MS(10);
|
||||
|
||||
/* If the TCK pin is not jumpered to ground, start the user application instead */
|
||||
JumpToApplication |= ((PINF & (1 << 4)) != 0);
|
||||
|
||||
/* Re-enable JTAG debugging */
|
||||
JTAG_ENABLE();
|
||||
#endif
|
||||
|
||||
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
||||
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||
JumpToApplication |= true;
|
||||
|
||||
/* If a request has been made to jump to the user application, honor it */
|
||||
if (JumpToApplication)
|
||||
{
|
||||
/* Turn off the watchdog */
|
||||
MCUSR &= ~(1<<WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Clear the boot key and jump to the user application */
|
||||
MagicBootKey = 0;
|
||||
|
||||
// cppcheck-suppress constStatement
|
||||
((void (*)(void))0x0000)();
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
|
||||
* runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start
|
||||
@@ -70,7 +119,7 @@ int main(void)
|
||||
LEDs_SetAllLEDs(LEDS_LED1);
|
||||
|
||||
/* Enable global interrupts so that the USB stack can function */
|
||||
sei();
|
||||
GlobalInterruptEnable();
|
||||
|
||||
while (RunBootloader)
|
||||
{
|
||||
@@ -81,6 +130,9 @@ int main(void)
|
||||
/* Disconnect from the host - USB interface will be reset later along with the AVR */
|
||||
USB_Detach();
|
||||
|
||||
/* Unlock the forced application start mode of the bootloader if it is restarted */
|
||||
MagicBootKey = MAGIC_BOOT_KEY;
|
||||
|
||||
/* Enable the watchdog and force a timeout to reset the AVR */
|
||||
wdt_enable(WDTO_250MS);
|
||||
|
||||
@@ -88,7 +140,7 @@ int main(void)
|
||||
}
|
||||
|
||||
/** Configures all hardware required for the bootloader. */
|
||||
void SetupHardware(void)
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
@@ -101,13 +153,13 @@ void SetupHardware(void)
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Initialize USB Subsystem */
|
||||
/* Initialize the USB and other board hardware drivers */
|
||||
USB_Init();
|
||||
LEDs_Init();
|
||||
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
|
||||
@@ -122,17 +174,12 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
/* Setup CDC Notification, Rx and Tx Endpoints */
|
||||
Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT,
|
||||
ENDPOINT_DIR_IN, CDC_NOTIFICATION_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT,
|
||||
CDC_NOTIFICATION_EPSIZE, 1);
|
||||
|
||||
Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK,
|
||||
ENDPOINT_DIR_IN, CDC_TXRX_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
Endpoint_ConfigureEndpoint(CDC_TX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
|
||||
|
||||
Endpoint_ConfigureEndpoint(CDC_RX_EPNUM, EP_TYPE_BULK,
|
||||
ENDPOINT_DIR_OUT, CDC_TXRX_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
Endpoint_ConfigureEndpoint(CDC_RX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
|
||||
@@ -176,6 +223,14 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
}
|
||||
|
||||
break;
|
||||
case CDC_REQ_SetControlLineState:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +245,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
uint16_t BlockSize;
|
||||
char MemoryType;
|
||||
|
||||
bool HighByte = false;
|
||||
uint8_t HighByte = 0;
|
||||
uint8_t LowByte = 0;
|
||||
|
||||
BlockSize = (FetchNextCommandByte() << 8);
|
||||
@@ -198,7 +253,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
|
||||
MemoryType = FetchNextCommandByte();
|
||||
|
||||
if ((MemoryType != 'E') && (MemoryType != 'F'))
|
||||
if ((MemoryType != MEMORY_TYPE_FLASH) && (MemoryType != MEMORY_TYPE_EEPROM))
|
||||
{
|
||||
/* Send error byte back to the host */
|
||||
WriteNextResponseByte('?');
|
||||
@@ -206,15 +261,15 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if command is to read memory */
|
||||
if (Command == 'g')
|
||||
/* Check if command is to read a memory block */
|
||||
if (Command == AVR109_COMMAND_BlockRead)
|
||||
{
|
||||
/* Re-enable RWW section */
|
||||
boot_rww_enable();
|
||||
|
||||
while (BlockSize--)
|
||||
{
|
||||
if (MemoryType == 'F')
|
||||
if (MemoryType == MEMORY_TYPE_FLASH)
|
||||
{
|
||||
/* Read the next FLASH byte from the current FLASH page */
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
@@ -243,7 +298,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
{
|
||||
uint32_t PageStartAddress = CurrAddress;
|
||||
|
||||
if (MemoryType == 'F')
|
||||
if (MemoryType == MEMORY_TYPE_FLASH)
|
||||
{
|
||||
boot_page_erase(PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
@@ -251,7 +306,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
|
||||
while (BlockSize--)
|
||||
{
|
||||
if (MemoryType == 'F')
|
||||
if (MemoryType == MEMORY_TYPE_FLASH)
|
||||
{
|
||||
/* If both bytes in current word have been written, increment the address counter */
|
||||
if (HighByte)
|
||||
@@ -266,7 +321,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
{
|
||||
LowByte = FetchNextCommandByte();
|
||||
}
|
||||
|
||||
|
||||
HighByte = !HighByte;
|
||||
}
|
||||
else
|
||||
@@ -280,7 +335,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
}
|
||||
|
||||
/* If in FLASH programming mode, commit the page after writing */
|
||||
if (MemoryType == 'F')
|
||||
if (MemoryType == MEMORY_TYPE_FLASH)
|
||||
{
|
||||
/* Commit the flash page to memory */
|
||||
boot_page_write(PageStartAddress);
|
||||
@@ -303,7 +358,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||
static uint8_t FetchNextCommandByte(void)
|
||||
{
|
||||
/* Select the OUT endpoint so that the next data byte can be read */
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPADDR);
|
||||
|
||||
/* If OUT endpoint empty, clear it and wait for the next packet from the host */
|
||||
while (!(Endpoint_IsReadWriteAllowed()))
|
||||
@@ -329,7 +384,7 @@ static uint8_t FetchNextCommandByte(void)
|
||||
static void WriteNextResponseByte(const uint8_t Response)
|
||||
{
|
||||
/* Select the IN endpoint so that the next data byte can be written */
|
||||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||
Endpoint_SelectEndpoint(CDC_TX_EPADDR);
|
||||
|
||||
/* If IN endpoint full, clear it and wait until ready for the next packet to the host */
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
@@ -350,10 +405,10 @@ static void WriteNextResponseByte(const uint8_t Response)
|
||||
/** Task to read in AVR910 commands from the CDC data OUT endpoint, process them, perform the required actions
|
||||
* and send the appropriate response back to the host.
|
||||
*/
|
||||
void CDC_Task(void)
|
||||
static void CDC_Task(void)
|
||||
{
|
||||
/* Select the OUT endpoint */
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPADDR);
|
||||
|
||||
/* Check if endpoint has a command in it sent from the host */
|
||||
if (!(Endpoint_IsOUTReceived()))
|
||||
@@ -362,71 +417,72 @@ void CDC_Task(void)
|
||||
/* Read in the bootloader command (first byte sent from host) */
|
||||
uint8_t Command = FetchNextCommandByte();
|
||||
|
||||
if (Command == 'E')
|
||||
if (Command == AVR109_COMMAND_ExitBootloader)
|
||||
{
|
||||
RunBootloader = false;
|
||||
|
||||
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if (Command == 'T')
|
||||
else if ((Command == AVR109_COMMAND_SetLED) || (Command == AVR109_COMMAND_ClearLED) ||
|
||||
(Command == AVR109_COMMAND_SelectDeviceType))
|
||||
{
|
||||
FetchNextCommandByte();
|
||||
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if ((Command == 'L') || (Command == 'P'))
|
||||
else if ((Command == AVR109_COMMAND_EnterProgrammingMode) || (Command == AVR109_COMMAND_LeaveProgrammingMode))
|
||||
{
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if (Command == 't')
|
||||
else if (Command == AVR109_COMMAND_ReadPartCode)
|
||||
{
|
||||
/* Return ATMEGA128 part code - this is only to allow AVRProg to use the bootloader */
|
||||
WriteNextResponseByte(0x44);
|
||||
WriteNextResponseByte(0x00);
|
||||
}
|
||||
else if (Command == 'a')
|
||||
else if (Command == AVR109_COMMAND_ReadAutoAddressIncrement)
|
||||
{
|
||||
/* Indicate auto-address increment is supported */
|
||||
WriteNextResponseByte('Y');
|
||||
}
|
||||
else if (Command == 'A')
|
||||
else if (Command == AVR109_COMMAND_SetCurrentAddress)
|
||||
{
|
||||
/* Set the current address to that given by the host */
|
||||
/* Set the current address to that given by the host (translate 16-bit word address to byte address) */
|
||||
CurrAddress = (FetchNextCommandByte() << 9);
|
||||
CurrAddress |= (FetchNextCommandByte() << 1);
|
||||
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if (Command == 'p')
|
||||
else if (Command == AVR109_COMMAND_ReadBootloaderInterface)
|
||||
{
|
||||
/* Indicate serial programmer back to the host */
|
||||
WriteNextResponseByte('S');
|
||||
}
|
||||
else if (Command == 'S')
|
||||
else if (Command == AVR109_COMMAND_ReadBootloaderIdentifier)
|
||||
{
|
||||
/* Write the 7-byte software identifier to the endpoint */
|
||||
for (uint8_t CurrByte = 0; CurrByte < 7; CurrByte++)
|
||||
WriteNextResponseByte(SOFTWARE_IDENTIFIER[CurrByte]);
|
||||
}
|
||||
else if (Command == 'V')
|
||||
else if (Command == AVR109_COMMAND_ReadBootloaderSWVersion)
|
||||
{
|
||||
WriteNextResponseByte('0' + BOOTLOADER_VERSION_MAJOR);
|
||||
WriteNextResponseByte('0' + BOOTLOADER_VERSION_MINOR);
|
||||
}
|
||||
else if (Command == 's')
|
||||
else if (Command == AVR109_COMMAND_ReadSignature)
|
||||
{
|
||||
WriteNextResponseByte(AVR_SIGNATURE_3);
|
||||
WriteNextResponseByte(AVR_SIGNATURE_2);
|
||||
WriteNextResponseByte(AVR_SIGNATURE_1);
|
||||
}
|
||||
else if (Command == 'e')
|
||||
else if (Command == AVR109_COMMAND_EraseFLASH)
|
||||
{
|
||||
/* Clear the application section of flash */
|
||||
for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < BOOT_START_ADDR; CurrFlashAddress += SPM_PAGESIZE)
|
||||
for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < (uint32_t)BOOT_START_ADDR; CurrFlashAddress += SPM_PAGESIZE)
|
||||
{
|
||||
boot_page_erase(CurrFlashAddress);
|
||||
boot_spm_busy_wait();
|
||||
@@ -438,7 +494,7 @@ void CDC_Task(void)
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
#if !defined(NO_LOCK_BYTE_WRITE_SUPPORT)
|
||||
else if (Command == 'l')
|
||||
else if (Command == AVR109_COMMAND_WriteLockbits)
|
||||
{
|
||||
/* Set the lock bits to those given by the host */
|
||||
boot_lock_bits_set(FetchNextCommandByte());
|
||||
@@ -447,24 +503,24 @@ void CDC_Task(void)
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
#endif
|
||||
else if (Command == 'r')
|
||||
else if (Command == AVR109_COMMAND_ReadLockbits)
|
||||
{
|
||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOCK_BITS));
|
||||
}
|
||||
else if (Command == 'F')
|
||||
else if (Command == AVR109_COMMAND_ReadLowFuses)
|
||||
{
|
||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS));
|
||||
}
|
||||
else if (Command == 'N')
|
||||
else if (Command == AVR109_COMMAND_ReadHighFuses)
|
||||
{
|
||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS));
|
||||
}
|
||||
else if (Command == 'Q')
|
||||
else if (Command == AVR109_COMMAND_ReadExtendedFuses)
|
||||
{
|
||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS));
|
||||
}
|
||||
#if !defined(NO_BLOCK_SUPPORT)
|
||||
else if (Command == 'b')
|
||||
else if (Command == AVR109_COMMAND_GetBlockWriteSupport)
|
||||
{
|
||||
WriteNextResponseByte('Y');
|
||||
|
||||
@@ -472,14 +528,14 @@ void CDC_Task(void)
|
||||
WriteNextResponseByte(SPM_PAGESIZE >> 8);
|
||||
WriteNextResponseByte(SPM_PAGESIZE & 0xFF);
|
||||
}
|
||||
else if ((Command == 'B') || (Command == 'g'))
|
||||
else if ((Command == AVR109_COMMAND_BlockWrite) || (Command == AVR109_COMMAND_BlockRead))
|
||||
{
|
||||
/* Delegate the block write/read to a separate function for clarity */
|
||||
ReadWriteMemoryBlock(Command);
|
||||
}
|
||||
#endif
|
||||
#if !defined(NO_FLASH_BYTE_SUPPORT)
|
||||
else if (Command == 'C')
|
||||
else if (Command == AVR109_COMMAND_FillFlashPageWordHigh)
|
||||
{
|
||||
/* Write the high byte to the current flash page */
|
||||
boot_page_fill(CurrAddress, FetchNextCommandByte());
|
||||
@@ -487,7 +543,7 @@ void CDC_Task(void)
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if (Command == 'c')
|
||||
else if (Command == AVR109_COMMAND_FillFlashPageWordLow)
|
||||
{
|
||||
/* Write the low byte to the current flash page */
|
||||
boot_page_fill(CurrAddress | 0x01, FetchNextCommandByte());
|
||||
@@ -498,7 +554,7 @@ void CDC_Task(void)
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if (Command == 'm')
|
||||
else if (Command == AVR109_COMMAND_WriteFlashPage)
|
||||
{
|
||||
/* Commit the flash page to memory */
|
||||
boot_page_write(CurrAddress);
|
||||
@@ -509,7 +565,7 @@ void CDC_Task(void)
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if (Command == 'R')
|
||||
else if (Command == AVR109_COMMAND_ReadFLASHWord)
|
||||
{
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
uint16_t ProgramWord = pgm_read_word_far(CurrAddress);
|
||||
@@ -522,7 +578,7 @@ void CDC_Task(void)
|
||||
}
|
||||
#endif
|
||||
#if !defined(NO_EEPROM_BYTE_SUPPORT)
|
||||
else if (Command == 'D')
|
||||
else if (Command == AVR109_COMMAND_WriteEEPROM)
|
||||
{
|
||||
/* Read the byte from the endpoint and write it to the EEPROM */
|
||||
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
||||
@@ -533,7 +589,7 @@ void CDC_Task(void)
|
||||
/* Send confirmation byte back to the host */
|
||||
WriteNextResponseByte('\r');
|
||||
}
|
||||
else if (Command == 'd')
|
||||
else if (Command == AVR109_COMMAND_ReadEEPROM)
|
||||
{
|
||||
/* Read the EEPROM byte and write it to the endpoint */
|
||||
WriteNextResponseByte(eeprom_read_byte((uint8_t*)((intptr_t)(CurrAddress >> 1))));
|
||||
@@ -542,14 +598,14 @@ void CDC_Task(void)
|
||||
CurrAddress += 2;
|
||||
}
|
||||
#endif
|
||||
else if (Command != 27)
|
||||
else if (Command != AVR109_COMMAND_Sync)
|
||||
{
|
||||
/* Unknown (non-sync) command, return fail code */
|
||||
WriteNextResponseByte('?');
|
||||
}
|
||||
|
||||
/* Select the IN endpoint */
|
||||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||
Endpoint_SelectEndpoint(CDC_TX_EPADDR);
|
||||
|
||||
/* Remember if the endpoint is completely full before clearing it */
|
||||
bool IsEndpointFull = !(Endpoint_IsReadWriteAllowed());
|
||||
@@ -577,7 +633,7 @@ void CDC_Task(void)
|
||||
}
|
||||
|
||||
/* Select the OUT endpoint */
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||
Endpoint_SelectEndpoint(CDC_RX_EPADDR);
|
||||
|
||||
/* Acknowledge the command from the host */
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -46,9 +46,17 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "BootloaderAPI.h"
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__OPTIMIZE_SIZE__)
|
||||
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
|
||||
#endif
|
||||
|
||||
/* Macros: */
|
||||
/** Version major of the CDC bootloader. */
|
||||
@@ -63,16 +71,64 @@
|
||||
/** Hardware version minor of the CDC bootloader. */
|
||||
#define BOOTLOADER_HWVERSION_MINOR 0x00
|
||||
|
||||
/** Eight character bootloader firmware identifier reported to the host when requested */
|
||||
/** Eight character bootloader firmware identifier reported to the host when requested. */
|
||||
#define SOFTWARE_IDENTIFIER "LUFACDC"
|
||||
|
||||
/** Magic bootloader key to unlock forced application start mode. */
|
||||
#define MAGIC_BOOT_KEY 0xDC42
|
||||
|
||||
/* Enums: */
|
||||
/** Possible memory types that can be addressed via the bootloader. */
|
||||
enum AVR109_Memories
|
||||
{
|
||||
MEMORY_TYPE_FLASH = 'F',
|
||||
MEMORY_TYPE_EEPROM = 'E',
|
||||
};
|
||||
|
||||
/** Possible commands that can be issued to the bootloader. */
|
||||
enum AVR109_Commands
|
||||
{
|
||||
AVR109_COMMAND_Sync = 27,
|
||||
AVR109_COMMAND_ReadEEPROM = 'd',
|
||||
AVR109_COMMAND_WriteEEPROM = 'D',
|
||||
AVR109_COMMAND_ReadFLASHWord = 'R',
|
||||
AVR109_COMMAND_WriteFlashPage = 'm',
|
||||
AVR109_COMMAND_FillFlashPageWordLow = 'c',
|
||||
AVR109_COMMAND_FillFlashPageWordHigh = 'C',
|
||||
AVR109_COMMAND_GetBlockWriteSupport = 'b',
|
||||
AVR109_COMMAND_BlockWrite = 'B',
|
||||
AVR109_COMMAND_BlockRead = 'g',
|
||||
AVR109_COMMAND_ReadExtendedFuses = 'Q',
|
||||
AVR109_COMMAND_ReadHighFuses = 'N',
|
||||
AVR109_COMMAND_ReadLowFuses = 'F',
|
||||
AVR109_COMMAND_ReadLockbits = 'r',
|
||||
AVR109_COMMAND_WriteLockbits = 'l',
|
||||
AVR109_COMMAND_EraseFLASH = 'e',
|
||||
AVR109_COMMAND_ReadSignature = 's',
|
||||
AVR109_COMMAND_ReadBootloaderSWVersion = 'V',
|
||||
AVR109_COMMAND_ReadBootloaderHWVersion = 'v',
|
||||
AVR109_COMMAND_ReadBootloaderIdentifier = 'S',
|
||||
AVR109_COMMAND_ReadBootloaderInterface = 'p',
|
||||
AVR109_COMMAND_SetCurrentAddress = 'A',
|
||||
AVR109_COMMAND_ReadAutoAddressIncrement = 'a',
|
||||
AVR109_COMMAND_ReadPartCode = 't',
|
||||
AVR109_COMMAND_EnterProgrammingMode = 'P',
|
||||
AVR109_COMMAND_LeaveProgrammingMode = 'L',
|
||||
AVR109_COMMAND_SelectDeviceType = 'T',
|
||||
AVR109_COMMAND_SetLED = 'x',
|
||||
AVR109_COMMAND_ClearLED = 'y',
|
||||
AVR109_COMMAND_ExitBootloader = 'E',
|
||||
};
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
|
||||
typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
|
||||
|
||||
/* Function Prototypes: */
|
||||
void CDC_Task(void);
|
||||
void SetupHardware(void);
|
||||
static void CDC_Task(void);
|
||||
static void SetupHardware(void);
|
||||
|
||||
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* - Series 7 USB AVRs (AT90USBxxx7)
|
||||
* - Series 6 USB AVRs (AT90USBxxx6)
|
||||
* - Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
@@ -37,7 +37,7 @@
|
||||
* <td>USBIF CDC Class Standard</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
@@ -47,9 +47,9 @@
|
||||
* This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109
|
||||
* protocol compatible programming software to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If
|
||||
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
|
||||
* values in the accompanying makefile.
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
@@ -86,32 +86,132 @@
|
||||
*
|
||||
* Refer to the AVRDude project documentation for additional usage instructions.
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_CDC_SIGNATURE 0xDF00
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
|
||||
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
|
||||
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
|
||||
* to the value \c BOOTLOADER_CDC_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
|
||||
* memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* \section Sec_KnownIssues Known Issues:
|
||||
*
|
||||
* \par On Linux machines, the CDC bootloader is unstable or inaccessible.
|
||||
* A change to the \c ModemManager module in many Linux distributions causes
|
||||
* this module to try to take control over inserted CDC devices, corrupting the
|
||||
* datastream. A UDEV rule is required to prevent this.
|
||||
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
|
||||
*
|
||||
* \par On Linux machines, the CDC bootloader is inaccessible.
|
||||
* On many Linux systems, non-root users do not have automatic access to newly
|
||||
* inserted CDC devices. Root privileges or a UDEV rule is required to gain
|
||||
* access.
|
||||
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
|
||||
*
|
||||
* \par After loading an application, it is not run automatically on startup.
|
||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
||||
* when needed.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <th><b>Define Name:</b></th>
|
||||
* <th><b>Location:</b></th>
|
||||
* <th><b>Description:</b></th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_BLOCK_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>Define to disable memory block read/write support in the bootloader, requiring all reads and writes to be made
|
||||
* using the byte-level commands.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_EEPROM_BYTE_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>Define to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes
|
||||
* to be made using the block-level commands.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_FLASH_BYTE_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>Define to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes
|
||||
* to be made using the block-level commands.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_LOCK_BYTE_WRITE_SUPPORT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>Define to disable lock byte write support in the bootloader, preventing the lock bits from being set programmatically.</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
|
||||
50
Bootloaders/CDC/Config/AppConfig.h
Normal file
50
Bootloaders/CDC/Config/AppConfig.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Application Configuration Header File
|
||||
*
|
||||
* This is a header file which is be used to configure LUFA's
|
||||
* compile time options, as an alternative to the compile time
|
||||
* constants supplied through a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the
|
||||
* \ref Sec_Options section of the application documentation.
|
||||
*/
|
||||
|
||||
#ifndef _APP_CONFIG_H_
|
||||
#define _APP_CONFIG_H_
|
||||
|
||||
// #define NO_BLOCK_SUPPORT
|
||||
// #define NO_EEPROM_BYTE_SUPPORT
|
||||
// #define NO_FLASH_BYTE_SUPPORT
|
||||
// #define NO_LOCK_BYTE_WRITE_SUPPORT
|
||||
|
||||
#endif
|
||||
93
Bootloaders/CDC/Config/LUFAConfig.h
Normal file
93
Bootloaders/CDC/Config/LUFAConfig.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Library Configuration Header File
|
||||
*
|
||||
* This header file is used to configure LUFA's compile time options,
|
||||
* as an alternative to the compile time constants supplied through
|
||||
* a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the LUFA
|
||||
* manual section "Summary of Compile Tokens".
|
||||
*/
|
||||
|
||||
#ifndef _LUFA_CONFIG_H_
|
||||
#define _LUFA_CONFIG_H_
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
|
||||
/* Non-USB Related Configuration Tokens: */
|
||||
// #define DISABLE_TERMINAL_CODES
|
||||
|
||||
/* USB Class Driver Related Tokens: */
|
||||
// #define HID_HOST_BOOT_PROTOCOL_ONLY
|
||||
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_MAX_COLLECTIONS {Insert Value Here}
|
||||
// #define HID_MAX_REPORTITEMS {Insert Value Here}
|
||||
// #define HID_MAX_REPORT_IDS {Insert Value Here}
|
||||
// #define NO_CLASS_DRIVER_AUTOFLUSH
|
||||
|
||||
/* General USB Driver Related Tokens: */
|
||||
#define ORDERED_EP_CONFIG
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
#define USB_DEVICE_ONLY
|
||||
// #define USB_HOST_ONLY
|
||||
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
|
||||
// #define NO_LIMITED_CONTROLLER_CONNECT
|
||||
#define NO_SOF_EVENTS
|
||||
|
||||
/* USB Device Mode Driver Related Tokens: */
|
||||
#define USE_RAM_DESCRIPTORS
|
||||
// #define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
#define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
#define DEVICE_STATE_AS_GPIOR 0
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
// #define CONTROL_ONLY_DEVICE
|
||||
// #define INTERRUPT_CONTROL_ENDPOINT
|
||||
#define NO_DEVICE_REMOTE_WAKEUP
|
||||
#define NO_DEVICE_SELF_POWER
|
||||
|
||||
/* USB Host Mode Driver Related Tokens: */
|
||||
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
|
||||
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
|
||||
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
|
||||
// #define NO_AUTO_VBUS_MANAGEMENT
|
||||
// #define INVERTED_VBUS_ENABLE_LINE
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported architecture for this LUFA configuration file.
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -55,10 +55,10 @@ const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x204A,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
.ReleaseNumber = VERSION_BCD(01.00),
|
||||
|
||||
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
||||
.ProductStrIndex = 0x01,
|
||||
.ManufacturerStrIndex = STRING_ID_Manufacturer,
|
||||
.ProductStrIndex = STRING_ID_Product,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
@@ -81,7 +81,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
@@ -115,7 +115,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = 0x02,
|
||||
|
||||
.Capabilities = 0x04,
|
||||
.Capabilities = 0x02,
|
||||
},
|
||||
|
||||
.CDC_Functional_Union =
|
||||
@@ -131,7 +131,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
||||
.EndpointAddress = CDC_NOTIFICATION_EPADDR,
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||
.PollingIntervalMS = 0xFF
|
||||
@@ -157,20 +157,20 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM),
|
||||
.EndpointAddress = CDC_RX_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
.PollingIntervalMS = 0x01
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
|
||||
.CDC_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DIR_IN | CDC_TX_EPNUM),
|
||||
.EndpointAddress = CDC_TX_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
.PollingIntervalMS = 0x01
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
@@ -185,15 +185,26 @@ const USB_Descriptor_String_t LanguageString =
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
||||
.Header = {.Size = USB_STRING_LEN(8), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"AVR CDC Bootloader"
|
||||
.UnicodeString = L"LUFA CDC"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors"
|
||||
@@ -223,12 +234,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
if (!(DescriptorNumber))
|
||||
if (DescriptorNumber == STRING_ID_Language)
|
||||
{
|
||||
Address = &LanguageString;
|
||||
Size = LanguageString.Header.Size;
|
||||
}
|
||||
else
|
||||
else if (DescriptorNumber == STRING_ID_Manufacturer)
|
||||
{
|
||||
Address = &ManufacturerString;
|
||||
Size = ManufacturerString.Header.Size;
|
||||
}
|
||||
else if (DescriptorNumber == STRING_ID_Product)
|
||||
{
|
||||
Address = &ProductString;
|
||||
Size = ProductString.Header.Size;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -39,6 +39,8 @@
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
/* Macros: */
|
||||
#if defined(__AVR_AT90USB1287__)
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
@@ -56,10 +58,6 @@
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
#define AVR_SIGNATURE_2 0x96
|
||||
#define AVR_SIGNATURE_3 0x82
|
||||
#elif defined(__AVR_ATmega32U6__)
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
#define AVR_SIGNATURE_2 0x95
|
||||
#define AVR_SIGNATURE_3 0x88
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
#define AVR_SIGNATURE_2 0x95
|
||||
@@ -92,14 +90,14 @@
|
||||
#error The selected AVR part is not currently supported by this bootloader.
|
||||
#endif
|
||||
|
||||
/** Endpoint number for the CDC control interface event notification endpoint. */
|
||||
#define CDC_NOTIFICATION_EPNUM 2
|
||||
/** Endpoint address for the CDC control interface event notification endpoint. */
|
||||
#define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
|
||||
|
||||
/** Endpoint number for the CDC data interface TX (data IN) endpoint. */
|
||||
#define CDC_TX_EPNUM 3
|
||||
/** Endpoint address for the CDC data interface TX (data IN) endpoint. */
|
||||
#define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Endpoint number for the CDC data interface RX (data OUT) endpoint. */
|
||||
#define CDC_RX_EPNUM 4
|
||||
/** Endpoint address for the CDC data interface RX (data OUT) endpoint. */
|
||||
#define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
|
||||
/** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */
|
||||
#define CDC_TXRX_EPSIZE 16
|
||||
@@ -115,20 +113,31 @@
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
|
||||
// CDC Control Interface
|
||||
USB_Descriptor_Interface_t CDC_CCI_Interface;
|
||||
USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
|
||||
USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
|
||||
USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
|
||||
USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
|
||||
|
||||
|
||||
// CDC Data Interface
|
||||
USB_Descriptor_Interface_t CDC_DCI_Interface;
|
||||
USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
|
||||
USB_Descriptor_Endpoint_t CDC_DataInEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
|
||||
* have a unique ID index associated with it, which can be used to refer to the string from
|
||||
* other descriptors.
|
||||
*/
|
||||
enum StringDescriptors_t
|
||||
{
|
||||
STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
|
||||
STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
|
||||
STRING_ID_Product = 2, /**< Product string ID */
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,78 +1,36 @@
|
||||
;************************************************************
|
||||
; Windows USB CDC ACM Setup File
|
||||
; Copyright (c) 2000 Microsoft Corporation
|
||||
|
||||
;************************************************************
|
||||
|
||||
[Version]
|
||||
Signature="$Windows NT$"
|
||||
Class=Ports
|
||||
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
|
||||
Provider=%MFGNAME%
|
||||
LayoutFile=layout.inf
|
||||
CatalogFile=%MFGFILENAME%.cat
|
||||
DriverVer=11/15/2007,5.1.2600.0
|
||||
DriverVer=7/1/2012,10.0.0.0
|
||||
|
||||
[Manufacturer]
|
||||
%MFGNAME%=DeviceList, NTamd64
|
||||
%MFGNAME%=DeviceList, NTx86, NTamd64, NTia64
|
||||
|
||||
[SourceDisksNames]
|
||||
|
||||
[SourceDisksFiles]
|
||||
|
||||
[DestinationDirs]
|
||||
DefaultDestDir=12
|
||||
|
||||
[DriverInstall]
|
||||
Include=mdmcpq.inf
|
||||
CopyFiles=FakeModemCopyFileSection
|
||||
AddReg=DriverInstall.AddReg
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Windows 2000/XP/Vista-32bit Sections
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
[DriverInstall.nt]
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=DriverCopyFiles.nt
|
||||
AddReg=DriverInstall.nt.AddReg
|
||||
|
||||
[DriverCopyFiles.nt]
|
||||
usbser.sys,,,0x20
|
||||
|
||||
[DriverInstall.nt.AddReg]
|
||||
HKR,,DevLoader,,*ntkern
|
||||
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[DriverInstall.nt.Services]
|
||||
AddService=usbser, 0x00000002, DriverService.nt
|
||||
|
||||
[DriverService.nt]
|
||||
DisplayName=%SERVICE%
|
||||
ServiceType=1
|
||||
StartType=3
|
||||
ErrorControl=1
|
||||
ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vista-64bit Sections
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
[DriverInstall.NTamd64]
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=DriverCopyFiles.NTamd64
|
||||
AddReg=DriverInstall.NTamd64.AddReg
|
||||
|
||||
[DriverCopyFiles.NTamd64]
|
||||
%DRIVERFILENAME%.sys,,,0x20
|
||||
|
||||
[DriverInstall.NTamd64.AddReg]
|
||||
HKR,,DevLoader,,*ntkern
|
||||
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[DriverInstall.NTamd64.Services]
|
||||
AddService=usbser, 0x00000002, DriverService.NTamd64
|
||||
|
||||
[DriverService.NTamd64]
|
||||
DisplayName=%SERVICE%
|
||||
ServiceType=1
|
||||
StartType=3
|
||||
ErrorControl=1
|
||||
ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
[DriverInstall.Services]
|
||||
Include=mdmcpq.inf
|
||||
AddService=usbser, 0x00000002, LowerFilter_Service_Inst
|
||||
|
||||
[DriverInstall.AddReg]
|
||||
HKR,,EnumPropPages32,,"msports.dll,SerialPortPropPageProvider"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vendor and Product ID Definitions
|
||||
@@ -83,14 +41,17 @@ ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
; Note: One INF file can be used for multiple devices with different VID and PIDs.
|
||||
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
|
||||
;------------------------------------------------------------------------------
|
||||
[SourceDisksFiles]
|
||||
[SourceDisksNames]
|
||||
[DeviceList]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
|
||||
|
||||
[DeviceList.NTx86]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
|
||||
|
||||
[DeviceList.NTamd64]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
|
||||
|
||||
[DeviceList.NTia64]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; String Definitions
|
||||
@@ -98,9 +59,5 @@ ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
;Modify these strings to customize your device
|
||||
;------------------------------------------------------------------------------
|
||||
[Strings]
|
||||
MFGFILENAME="CDC_vista"
|
||||
DRIVERFILENAME ="usbser"
|
||||
MFGNAME="http://www.lufa-lib.org"
|
||||
INSTDISK="LUFA CDC Bootloader Driver Installer"
|
||||
DESCRIPTION="Communications Port"
|
||||
SERVICE="USB RS-232 Emulation Driver"
|
||||
DESCRIPTION="LUFA CDC Class Bootloader"
|
||||
160
Bootloaders/CDC/asf.xml
Normal file
160
Bootloaders/CDC/asf.xml
Normal file
@@ -0,0 +1,160 @@
|
||||
<asf xmlversion="1.0">
|
||||
<project caption="CDC Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.128_4" force-caption="true" workspace-name="lufa_cdc_128kb_4kb_">
|
||||
<require idref="lufa.bootloaders.cdc"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb1287"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="CDC Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.64_4" force-caption="true" workspace-name="lufa_cdc_64kb_4kb_">
|
||||
<require idref="lufa.bootloaders.cdc"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb647"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="CDC Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.32_4" force-caption="true" workspace-name="lufa_cdc_32kb_4kb_">
|
||||
<require idref="lufa.bootloaders.cdc"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega32u4"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="CDC Bootloader - 16KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.16_4" force-caption="true" workspace-name="lufa_cdc_16kb_4kb_">
|
||||
<require idref="lufa.bootloaders.cdc"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega16u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="CDC Bootloader - 8KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.8_4" force-caption="true" workspace-name="lufa_cdc_8kb_4kb_">
|
||||
<require idref="lufa.bootloaders.cdc"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega8u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<module type="application" id="lufa.bootloaders.cdc" caption="CDC Bootloader">
|
||||
<info type="description" value="summary">
|
||||
CDC Class Bootloader, capable of reprogramming a device using avrdude or other AVR109 protocol compliant software when plugged into a host.
|
||||
</info>
|
||||
|
||||
<info type="gui-flag" value="move-to-root"/>
|
||||
|
||||
<info type="keyword" value="Technology">
|
||||
<keyword value="Bootloaders"/>
|
||||
<keyword value="USB Device"/>
|
||||
</info>
|
||||
|
||||
<device-support-alias value="lufa_avr8"/>
|
||||
<device-support-alias value="lufa_xmega"/>
|
||||
<device-support-alias value="lufa_uc3"/>
|
||||
|
||||
<build type="include-path" value="."/>
|
||||
<build type="c-source" value="BootloaderCDC.c"/>
|
||||
<build type="header-file" value="BootloaderCDC.h"/>
|
||||
<build type="c-source" value="Descriptors.c"/>
|
||||
<build type="header-file" value="Descriptors.h"/>
|
||||
<build type="c-source" value="BootloaderAPI.c"/>
|
||||
<build type="header-file" value="BootloaderAPI.h"/>
|
||||
<build type="asm-source" value="BootloaderAPITable.S"/>
|
||||
|
||||
<build type="module-config" subtype="path" value="Config"/>
|
||||
<build type="header-file" value="Config/LUFAConfig.h"/>
|
||||
<build type="header-file" value="Config/AppConfig.h"/>
|
||||
|
||||
<build type="distribute" subtype="user-file" value="BootloaderCDC.txt"/>
|
||||
<build type="distribute" subtype="user-file" value="LUFA CDC Bootloader.inf"/>
|
||||
|
||||
<require idref="lufa.common"/>
|
||||
<require idref="lufa.platform"/>
|
||||
<require idref="lufa.drivers.usb"/>
|
||||
<require idref="lufa.drivers.board"/>
|
||||
<require idref="lufa.drivers.board.leds"/>
|
||||
</module>
|
||||
</asf>
|
||||
@@ -1,717 +1,55 @@
|
||||
# Hey Emacs, this is a -*- makefile -*-
|
||||
#----------------------------------------------------------------------------
|
||||
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
|
||||
# >> Modified for use with the LUFA project. <<
|
||||
#
|
||||
# Released to the Public Domain
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# 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
|
||||
# Dean Camera
|
||||
# Opendous Inc.
|
||||
# Denver Gingerich
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# 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 = at90usb1287
|
||||
|
||||
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. 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.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Starting byte address of the bootloader, as a byte address - computed via the formula
|
||||
# BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 1024)
|
||||
#
|
||||
# Note that the bootloader size and start address given in AVRStudio is in words and not
|
||||
# bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 4
|
||||
BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
|
||||
|
||||
|
||||
# Output format. (can be srec, ihex, binary)
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = BootloaderCDC
|
||||
|
||||
|
||||
# Object files directory
|
||||
# To put object files in current directory, use a dot (.), do NOT make
|
||||
# this an empty or blank macro!
|
||||
OBJDIR = .
|
||||
|
||||
|
||||
# Path to the LUFA library
|
||||
LUFA_PATH = ../..
|
||||
|
||||
|
||||
# LUFA library compile-time options and predefined tokens
|
||||
LUFA_OPTS = -D USB_DEVICE_ONLY
|
||||
LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0
|
||||
LUFA_OPTS += -D ORDERED_EP_CONFIG
|
||||
LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
||||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_RAM_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
|
||||
LUFA_OPTS += -D NO_INTERNAL_SERIAL
|
||||
LUFA_OPTS += -D NO_DEVICE_SELF_POWER
|
||||
LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP
|
||||
LUFA_OPTS += -D NO_SOF_EVENTS
|
||||
|
||||
#LUFA_OPTS += -D NO_BLOCK_SUPPORT
|
||||
#LUFA_OPTS += -D NO_EEPROM_BYTE_SUPPORT
|
||||
#LUFA_OPTS += -D NO_FLASH_BYTE_SUPPORT
|
||||
#LUFA_OPTS += -D NO_LOCK_BYTE_WRITE_SUPPORT
|
||||
|
||||
|
||||
# Create the LUFA source path variables by including the LUFA root makefile
|
||||
include $(LUFA_PATH)/LUFA/makefile
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = $(TARGET).c \
|
||||
Descriptors.c \
|
||||
$(LUFA_SRC_USB) \
|
||||
|
||||
|
||||
# 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 = $(LUFA_PATH)/
|
||||
|
||||
|
||||
# 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=c99
|
||||
|
||||
|
||||
# Place -D or -U options here for C sources
|
||||
CDEFS = -DF_CPU=$(F_CPU)UL
|
||||
CDEFS += -DF_USB=$(F_USB)UL
|
||||
CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
|
||||
CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
CDEFS += $(LUFA_OPTS)
|
||||
|
||||
|
||||
# Place -D or -U options here for ASM sources
|
||||
ADEFS = -DF_CPU=$(F_CPU)
|
||||
ADEFS += -DF_USB=$(F_USB)UL
|
||||
ADEFS += -DBOARD=BOARD_$(BOARD)
|
||||
ADEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
ADEFS += $(LUFA_OPTS)
|
||||
|
||||
|
||||
# Place -D or -U options here for C++ sources
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL
|
||||
CPPDEFS += -DF_USB=$(F_USB)UL
|
||||
CPPDEFS += -DBOARD=BOARD_$(BOARD)
|
||||
CPPDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
CPPDEFS += $(LUFA_OPTS)
|
||||
#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 += -ffunction-sections
|
||||
CFLAGS += -fno-inline-small-functions
|
||||
CFLAGS += -fpack-struct
|
||||
CFLAGS += -fshort-enums
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
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
|
||||
CPPFLAGS += -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 += -Wl,--section-start=.text=$(BOOT_START)
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
||||
#LDFLAGS += -T linker_script.x
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options (avrdude) ----------------
|
||||
|
||||
# Programming hardware
|
||||
# Type: avrdude -c ?
|
||||
# to get a full listing.
|
||||
#
|
||||
AVRDUDE_PROGRAMMER = jtagmkII
|
||||
|
||||
# com1 = serial port. Use lpt1 to connect to parallel port.
|
||||
AVRDUDE_PORT = usb
|
||||
|
||||
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_FLAG) $(FORMAT_FLAG) $(TARGET).elf
|
||||
MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
|
||||
FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
|
||||
|
||||
|
||||
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 -R .fuse -R .lock $< $@
|
||||
|
||||
%.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 -z $< > $@
|
||||
|
||||
# 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) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
$(REMOVE) $(SRC:.c=.s)
|
||||
$(REMOVE) $(SRC:.c=.d)
|
||||
$(REMOVE) $(SRC:.c=.i)
|
||||
$(REMOVEDIR) .dep
|
||||
|
||||
doxygen:
|
||||
@echo Generating Project Documentation \($(TARGET)\)...
|
||||
@doxygen Doxygen.conf
|
||||
@echo Documentation Generation Complete.
|
||||
|
||||
clean_doxygen:
|
||||
rm -rf Documentation
|
||||
|
||||
checksource:
|
||||
@for f in $(SRC) $(CPPSRC) $(ASRC); do \
|
||||
if [ -f $$f ]; then \
|
||||
echo "Found Source File: $$f" ; \
|
||||
else \
|
||||
echo "Source File Not Found: $$f" ; \
|
||||
fi; done
|
||||
|
||||
|
||||
# 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 doxygen clean \
|
||||
clean_list clean_doxygen program debug gdb-config checksource
|
||||
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU = at90usb1287
|
||||
ARCH = AVR8
|
||||
BOARD = USBKEY
|
||||
F_CPU = 8000000
|
||||
F_USB = $(F_CPU)
|
||||
OPTIMIZATION = s
|
||||
TARGET = BootloaderCDC
|
||||
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB)
|
||||
LUFA_PATH = ../../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
|
||||
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
|
||||
|
||||
# Flash size and bootloader section sizes of the target, in KB. These must
|
||||
# match the target's total FLASH size and the bootloader size set in the
|
||||
# device's fuses.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 8
|
||||
|
||||
# Bootloader address calculation formulas
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
include $(LUFA_PATH)/Build/lufa_doxygen.mk
|
||||
include $(LUFA_PATH)/Build/lufa_avrdude.mk
|
||||
include $(LUFA_PATH)/Build/lufa_atprogram.mk
|
||||
|
||||
76
Bootloaders/DFU/BootloaderAPI.c
Normal file
76
Bootloaders/DFU/BootloaderAPI.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
|
||||
58
Bootloaders/DFU/BootloaderAPI.h
Normal file
58
Bootloaders/DFU/BootloaderAPI.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
91
Bootloaders/DFU/BootloaderAPITable.S
Normal file
91
Bootloaders/DFU/BootloaderAPITable.S
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
; Trampolines to actual API implementations if the target address is outside the
|
||||
; range of a rjmp instruction (can happen with large bootloader sections)
|
||||
.section .apitable_trampolines, "ax"
|
||||
.global BootloaderAPI_Trampolines
|
||||
BootloaderAPI_Trampolines:
|
||||
|
||||
BootloaderAPI_ErasePage_Trampoline:
|
||||
jmp BootloaderAPI_ErasePage
|
||||
BootloaderAPI_WritePage_Trampoline:
|
||||
jmp BootloaderAPI_WritePage
|
||||
BootloaderAPI_FillWord_Trampoline:
|
||||
jmp BootloaderAPI_FillWord
|
||||
BootloaderAPI_ReadSignature_Trampoline:
|
||||
jmp BootloaderAPI_ReadSignature
|
||||
BootloaderAPI_ReadFuse_Trampoline:
|
||||
jmp BootloaderAPI_ReadFuse
|
||||
BootloaderAPI_ReadLock_Trampoline:
|
||||
jmp BootloaderAPI_ReadLock
|
||||
BootloaderAPI_WriteLock_Trampoline:
|
||||
jmp BootloaderAPI_WriteLock
|
||||
BootloaderAPI_UNUSED1:
|
||||
ret
|
||||
BootloaderAPI_UNUSED2:
|
||||
ret
|
||||
BootloaderAPI_UNUSED3:
|
||||
ret
|
||||
BootloaderAPI_UNUSED4:
|
||||
ret
|
||||
BootloaderAPI_UNUSED5:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; API function jump table
|
||||
.section .apitable_jumptable, "ax"
|
||||
.global BootloaderAPI_JumpTable
|
||||
BootloaderAPI_JumpTable:
|
||||
|
||||
rjmp BootloaderAPI_ErasePage_Trampoline
|
||||
rjmp BootloaderAPI_WritePage_Trampoline
|
||||
rjmp BootloaderAPI_FillWord_Trampoline
|
||||
rjmp BootloaderAPI_ReadSignature_Trampoline
|
||||
rjmp BootloaderAPI_ReadFuse_Trampoline
|
||||
rjmp BootloaderAPI_ReadLock_Trampoline
|
||||
rjmp BootloaderAPI_WriteLock_Trampoline
|
||||
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
|
||||
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
|
||||
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
|
||||
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
|
||||
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
|
||||
|
||||
|
||||
|
||||
; Bootloader table signatures and information
|
||||
.section .apitable_signatures, "ax"
|
||||
.global BootloaderAPI_Signatures
|
||||
BootloaderAPI_Signatures:
|
||||
|
||||
.long BOOT_START_ADDR ; Start address of the bootloader
|
||||
.word 0xDF10 ; Signature for the DFU class bootloader, V1
|
||||
.word 0xDCFB ; Signature for a LUFA class bootloader
|
||||
@@ -1 +0,0 @@
|
||||
<AVRStudio><MANAGEMENT><ProjectName>BootloaderDFU</ProjectName><Created>13-Jul-2010 14:42:28</Created><LastEdit>13-Jul-2010 14:46:54</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:42:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderDFU.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\DFU\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderDFU.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderDFU.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderDFU.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -92,6 +92,55 @@ static uint16_t StartAddr = 0x0000;
|
||||
*/
|
||||
static uint16_t EndAddr = 0x0000;
|
||||
|
||||
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
|
||||
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
|
||||
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
|
||||
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
|
||||
*/
|
||||
uint16_t MagicBootKey ATTR_NO_INIT;
|
||||
|
||||
|
||||
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
|
||||
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
|
||||
* this will force the user application to start via a software jump.
|
||||
*/
|
||||
void Application_Jump_Check(void)
|
||||
{
|
||||
bool JumpToApplication = false;
|
||||
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
/* Disable JTAG debugging */
|
||||
JTAG_DISABLE();
|
||||
|
||||
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
|
||||
PORTF |= (1 << 4);
|
||||
Delay_MS(10);
|
||||
|
||||
/* If the TCK pin is not jumpered to ground, start the user application instead */
|
||||
JumpToApplication |= ((PINF & (1 << 4)) != 0);
|
||||
|
||||
/* Re-enable JTAG debugging */
|
||||
JTAG_ENABLE();
|
||||
#endif
|
||||
|
||||
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
||||
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||
JumpToApplication |= true;
|
||||
|
||||
/* If a request has been made to jump to the user application, honor it */
|
||||
if (JumpToApplication)
|
||||
{
|
||||
/* Turn off the watchdog */
|
||||
MCUSR &= ~(1<<WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Clear the boot key and jump to the user application */
|
||||
MagicBootKey = 0;
|
||||
|
||||
// cppcheck-suppress constStatement
|
||||
((void (*)(void))0x0000)();
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
|
||||
* runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start
|
||||
@@ -102,28 +151,11 @@ int main(void)
|
||||
/* Configure hardware required by the bootloader */
|
||||
SetupHardware();
|
||||
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
/* Disable JTAG debugging */
|
||||
MCUCR |= (1 << JTD);
|
||||
MCUCR |= (1 << JTD);
|
||||
|
||||
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
|
||||
PORTF |= (1 << 4);
|
||||
Delay_MS(10);
|
||||
|
||||
/* If the TCK pin is not jumpered to ground, start the user application instead */
|
||||
RunBootloader = (!(PINF & (1 << 4)));
|
||||
|
||||
/* Re-enable JTAG debugging */
|
||||
MCUCR &= ~(1 << JTD);
|
||||
MCUCR &= ~(1 << JTD);
|
||||
#endif
|
||||
|
||||
/* Turn on first LED on the board to indicate that the bootloader has started */
|
||||
LEDs_SetAllLEDs(LEDS_LED1);
|
||||
|
||||
/* Enable global interrupts so that the USB stack can function */
|
||||
sei();
|
||||
GlobalInterruptEnable();
|
||||
|
||||
/* Run the USB management task while the bootloader is supposed to be running */
|
||||
while (RunBootloader || WaitForExit)
|
||||
@@ -137,7 +169,7 @@ int main(void)
|
||||
}
|
||||
|
||||
/** Configures all hardware required for the bootloader. */
|
||||
void SetupHardware(void)
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
@@ -150,20 +182,25 @@ void SetupHardware(void)
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Initialize the USB subsystem */
|
||||
/* Initialize the USB and other board hardware drivers */
|
||||
USB_Init();
|
||||
LEDs_Init();
|
||||
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** Resets all configured hardware required for the bootloader back to their original states. */
|
||||
void ResetHardware(void)
|
||||
static void ResetHardware(void)
|
||||
{
|
||||
/* Shut down the USB subsystem */
|
||||
/* Shut down the USB and other board hardware drivers */
|
||||
USB_Disable();
|
||||
LEDs_Disable();
|
||||
|
||||
/* Disable Bootloader active LED toggle timer */
|
||||
TIMSK1 = 0;
|
||||
TCCR1B = 0;
|
||||
|
||||
/* Relocate the interrupt vector table back to the application section */
|
||||
MCUCR = (1 << IVCE);
|
||||
@@ -181,7 +218,7 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
* internally.
|
||||
*/
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
{
|
||||
/* Ignore any requests that aren't directed to the DFU interface */
|
||||
if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) !=
|
||||
(REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
@@ -452,6 +489,12 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
case DFU_REQ_GETSTATUS:
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
while (!(Endpoint_IsINReady()))
|
||||
{
|
||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Write 8-bit status value */
|
||||
Endpoint_Write_8(DFU_Status);
|
||||
|
||||
@@ -480,6 +523,12 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
case DFU_REQ_GETSTATE:
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
while (!(Endpoint_IsINReady()))
|
||||
{
|
||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Write the current device state to the endpoint */
|
||||
Endpoint_Write_8(DFU_State);
|
||||
|
||||
@@ -640,7 +689,7 @@ static void ProcessMemReadCommand(void)
|
||||
{
|
||||
uint32_t CurrFlashAddress = 0;
|
||||
|
||||
while (CurrFlashAddress < BOOT_START_ADDR)
|
||||
while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR)
|
||||
{
|
||||
/* Check if the current byte is not blank */
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
@@ -694,6 +743,9 @@ static void ProcessWriteCommand(void)
|
||||
{
|
||||
if (SentCommand.Data[1] == 0x00) // Start via watchdog
|
||||
{
|
||||
/* Unlock the forced application start mode of the bootloader if it is restarted */
|
||||
MagicBootKey = MAGIC_BOOT_KEY;
|
||||
|
||||
/* Start the watchdog to reset the AVR once the communications are finalized */
|
||||
wdt_enable(WDTO_250MS);
|
||||
}
|
||||
@@ -709,7 +761,7 @@ static void ProcessWriteCommand(void)
|
||||
uint32_t CurrFlashAddress = 0;
|
||||
|
||||
/* Clear the application section of flash */
|
||||
while (CurrFlashAddress < BOOT_START_ADDR)
|
||||
while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR)
|
||||
{
|
||||
boot_page_erase(CurrFlashAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -48,24 +48,28 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "BootloaderAPI.h"
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__OPTIMIZE_SIZE__)
|
||||
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
|
||||
#endif
|
||||
|
||||
/* Macros: */
|
||||
/** Configuration define. Define this token to true to case the bootloader to reject all memory commands
|
||||
* until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this
|
||||
* can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are
|
||||
* allowed at any time.
|
||||
*/
|
||||
#define SECURE_MODE false
|
||||
|
||||
/** Major bootloader version number. */
|
||||
#define BOOTLOADER_VERSION_MINOR 2
|
||||
|
||||
/** Minor bootloader version number. */
|
||||
#define BOOTLOADER_VERSION_REV 0
|
||||
|
||||
/** Magic bootloader key to unlock forced application start mode. */
|
||||
#define MAGIC_BOOT_KEY 0xDC42
|
||||
|
||||
/** Complete bootloader version number expressed as a packed byte, constructed from the
|
||||
* two individual bootloader version macros.
|
||||
*/
|
||||
@@ -147,7 +151,7 @@
|
||||
/** Type define for a structure containing a complete DFU command issued by the host. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Command; /**< Single byte command to perform, one of the COMMAND_* macro values */
|
||||
uint8_t Command; /**< Single byte command to perform, one of the \c COMMAND_* macro values */
|
||||
uint8_t Data[5]; /**< Command parameters */
|
||||
uint16_t DataSize; /**< Size of the command parameters */
|
||||
} DFU_Command_t;
|
||||
@@ -191,8 +195,8 @@
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void ResetHardware(void);
|
||||
static void SetupHardware(void);
|
||||
static void ResetHardware(void);
|
||||
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
|
||||
@@ -206,5 +210,7 @@
|
||||
static void ProcessReadCommand(void);
|
||||
#endif
|
||||
|
||||
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* - Series 7 USB AVRs (AT90USBxxx7)
|
||||
* - Series 6 USB AVRs (AT90USBxxx6)
|
||||
* - Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4) - <i>See \ref SSec_Aux_Space</i>
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) - <i>See \ref SSec_Aux_Space</i>
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
@@ -37,8 +37,9 @@
|
||||
* <td>USBIF DFU Class Standard, Atmel USB Bootloader Datasheet</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Low Speed Mode \n
|
||||
* Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
@@ -47,9 +48,9 @@
|
||||
* This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming
|
||||
* software to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the USB1287, and should fit into 4KB of bootloader space. If
|
||||
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
|
||||
* values in the accompanying makefile.
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
@@ -67,7 +68,7 @@
|
||||
* manually change them in Descriptors.c and alter your driver's INF file accordingly.
|
||||
*
|
||||
* \section Sec_HostApp Host Controller Application
|
||||
*
|
||||
*
|
||||
* This bootloader is compatible with Atmel's FLIP utility on Windows machines, and dfu-programmer on Linux machines.
|
||||
*
|
||||
* \subsection SSec_FLIP FLIP (Windows)
|
||||
@@ -89,22 +90,127 @@
|
||||
* dfu-programmer at90usb1287 erase flash Mouse.hex
|
||||
* \endcode
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* \warning The APIs exposed by the DFU class bootloader are \b NOT compatible with the API exposed by the official Atmel DFU bootloader.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_DFU_SIGNATURE 0xDF10
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
|
||||
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
|
||||
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
|
||||
* to the value \c BOOTLOADER_DFU_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
|
||||
* memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_AUX_SECTION_SIZE
|
||||
* | Booloader Start Trampoline |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - (BOOT_AUX_SECTION_SIZE - 4)
|
||||
* | |
|
||||
* | Auxillery Bootloader |
|
||||
* | Space for Smaller Devices |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* \subsection SSec_Aux_Space Auxiliary Bootloader Section
|
||||
* To make the bootloader function on smaller devices (those with a physical
|
||||
* bootloader section of smaller than 6KB)
|
||||
*
|
||||
* \section Sec_KnownIssues Known Issues:
|
||||
*
|
||||
* \par On Linux machines, the DFU bootloader is inaccessible.
|
||||
* On many Linux systems, non-root users do not have automatic access to newly
|
||||
* inserted DFU devices. Root privileges or a UDEV rule is required to gain
|
||||
* access.
|
||||
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
|
||||
*
|
||||
* \par After loading an application, it is not run automatically on startup.
|
||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
||||
* when needed.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>Define Name:</b></td>
|
||||
* <td><b>Location:</b></td>
|
||||
* <td><b>Description:</b></td>
|
||||
* <th><b>Define Name:</b></th>
|
||||
* <th><b>Location:</b></th>
|
||||
* <th><b>Description:</b></th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>SECURE_MODE</td>
|
||||
* <td>BootloaderDFU.h</td>
|
||||
* <td>If defined to true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>If defined to \c true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an
|
||||
* erase has been performed. This can be used in conjunction with the AVR's lockbits to prevent the AVRs firmware from
|
||||
* being dumped by unauthorized persons.</td>
|
||||
* being dumped by unauthorized persons. When false, all memory operations are allowed at any time.</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
48
Bootloaders/DFU/Config/AppConfig.h
Normal file
48
Bootloaders/DFU/Config/AppConfig.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Application Configuration Header File
|
||||
*
|
||||
* This is a header file which is be used to configure some of
|
||||
* the application's compile time options, as an alternative to
|
||||
* specifying the compile time constants supplied through a
|
||||
* makefile or build system.
|
||||
*
|
||||
* For information on what each token does, refer to the
|
||||
* \ref Sec_Options section of the application documentation.
|
||||
*/
|
||||
|
||||
#ifndef _APP_CONFIG_H_
|
||||
#define _APP_CONFIG_H_
|
||||
|
||||
#define SECURE_MODE false
|
||||
|
||||
#endif
|
||||
93
Bootloaders/DFU/Config/LUFAConfig.h
Normal file
93
Bootloaders/DFU/Config/LUFAConfig.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Library Configuration Header File
|
||||
*
|
||||
* This header file is used to configure LUFA's compile time options,
|
||||
* as an alternative to the compile time constants supplied through
|
||||
* a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the LUFA
|
||||
* manual section "Summary of Compile Tokens".
|
||||
*/
|
||||
|
||||
#ifndef _LUFA_CONFIG_H_
|
||||
#define _LUFA_CONFIG_H_
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
|
||||
/* Non-USB Related Configuration Tokens: */
|
||||
// #define DISABLE_TERMINAL_CODES
|
||||
|
||||
/* USB Class Driver Related Tokens: */
|
||||
// #define HID_HOST_BOOT_PROTOCOL_ONLY
|
||||
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_MAX_COLLECTIONS {Insert Value Here}
|
||||
// #define HID_MAX_REPORTITEMS {Insert Value Here}
|
||||
// #define HID_MAX_REPORT_IDS {Insert Value Here}
|
||||
// #define NO_CLASS_DRIVER_AUTOFLUSH
|
||||
|
||||
/* General USB Driver Related Tokens: */
|
||||
// #define ORDERED_EP_CONFIG
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
#define USB_DEVICE_ONLY
|
||||
// #define USB_HOST_ONLY
|
||||
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
|
||||
// #define NO_LIMITED_CONTROLLER_CONNECT
|
||||
#define NO_SOF_EVENTS
|
||||
|
||||
/* USB Device Mode Driver Related Tokens: */
|
||||
#define USE_RAM_DESCRIPTORS
|
||||
// #define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
#define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 32
|
||||
#define DEVICE_STATE_AS_GPIOR 0
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
#define CONTROL_ONLY_DEVICE
|
||||
// #define INTERRUPT_CONTROL_ENDPOINT
|
||||
#define NO_DEVICE_REMOTE_WAKEUP
|
||||
#define NO_DEVICE_SELF_POWER
|
||||
|
||||
/* USB Host Mode Driver Related Tokens: */
|
||||
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
|
||||
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
|
||||
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
|
||||
// #define NO_AUTO_VBUS_MANAGEMENT
|
||||
// #define INVERTED_VBUS_ENABLE_LINE
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported architecture for this LUFA configuration file.
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -57,8 +57,8 @@ const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
.ProductID = PRODUCT_ID_CODE,
|
||||
.ReleaseNumber = VERSION_BCD(00.00),
|
||||
|
||||
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
||||
.ProductStrIndex = 0x01,
|
||||
.ManufacturerStrIndex = STRING_ID_Manufacturer,
|
||||
.ProductStrIndex = STRING_ID_Product,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
@@ -81,7 +81,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
@@ -111,7 +111,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
.DetachTimeout = 0x0000,
|
||||
.TransferSize = 0x0C00,
|
||||
|
||||
.DFUSpecification = VERSION_BCD(01.01)
|
||||
.DFUSpecification = VERSION_BCD(01.10)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,15 +126,26 @@ const USB_Descriptor_String_t LanguageString =
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
||||
.Header = {.Size = USB_STRING_LEN(8), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"AVR DFU Bootloader"
|
||||
.UnicodeString = L"LUFA DFU"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
@@ -159,25 +170,30 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
if (!(DescriptorNumber))
|
||||
case DTYPE_String:
|
||||
if (DescriptorNumber == STRING_ID_Language)
|
||||
{
|
||||
Address = &LanguageString;
|
||||
Size = LanguageString.Header.Size;
|
||||
}
|
||||
else
|
||||
else if (DescriptorNumber == STRING_ID_Manufacturer)
|
||||
{
|
||||
Address = &ManufacturerString;
|
||||
Size = ManufacturerString.Header.Size;
|
||||
}
|
||||
else if (DescriptorNumber == STRING_ID_Product)
|
||||
{
|
||||
Address = &ProductString;
|
||||
Size = ProductString.Header.Size;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -39,6 +39,8 @@
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Descriptor type value for a DFU class functional descriptor. */
|
||||
#define DTYPE_DFUFunctional 0x21
|
||||
@@ -83,11 +85,6 @@
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
#define AVR_SIGNATURE_2 0x96
|
||||
#define AVR_SIGNATURE_3 0x82
|
||||
#elif defined(__AVR_ATmega32U6__)
|
||||
#define PRODUCT_ID_CODE 0x2FFB
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
#define AVR_SIGNATURE_2 0x95
|
||||
#define AVR_SIGNATURE_3 0x88
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
#define PRODUCT_ID_CODE 0x2FF4
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
@@ -114,12 +111,12 @@
|
||||
#define AVR_SIGNATURE_2 0x94
|
||||
#define AVR_SIGNATURE_3 0x82
|
||||
#elif defined(__AVR_ATmega8U2__)
|
||||
#define PRODUCT_ID_CODE 0x2FF7
|
||||
#define PRODUCT_ID_CODE 0x2FEE
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
#define AVR_SIGNATURE_2 0x93
|
||||
#define AVR_SIGNATURE_3 0x89
|
||||
#elif defined(__AVR_AT90USB82__)
|
||||
#define PRODUCT_ID_CODE 0x2FEE
|
||||
#define PRODUCT_ID_CODE 0x2FF7
|
||||
#define AVR_SIGNATURE_1 0x1E
|
||||
#define AVR_SIGNATURE_2 0x94
|
||||
#define AVR_SIGNATURE_3 0x82
|
||||
@@ -161,12 +158,23 @@
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
|
||||
// DFU Interface
|
||||
USB_Descriptor_Interface_t DFU_Interface;
|
||||
USB_Descriptor_DFU_Functional_t DFU_Functional;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
|
||||
* have a unique ID index associated with it, which can be used to refer to the string from
|
||||
* other descriptors.
|
||||
*/
|
||||
enum StringDescriptors_t
|
||||
{
|
||||
STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
|
||||
STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
|
||||
STRING_ID_Product = 2, /**< Product string ID */
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
155
Bootloaders/DFU/asf.xml
Normal file
155
Bootloaders/DFU/asf.xml
Normal file
@@ -0,0 +1,155 @@
|
||||
<asf xmlversion="1.0">
|
||||
<project caption="DFU Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.128_4" force-caption="true" workspace-name="lufa_dfu_128kb_4kb_">
|
||||
<require idref="lufa.bootloaders.dfu"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb1287"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="DFU Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.64_4" force-caption="true" workspace-name="lufa_dfu_64kb_4kb_">
|
||||
<require idref="lufa.bootloaders.dfu"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb647"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="DFU Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.32_4" force-caption="true" workspace-name="lufa_dfu_32kb_4kb_">
|
||||
<require idref="lufa.bootloaders.dfu"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega32u4"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="DFU Bootloader - 16KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.16_4" force-caption="true" workspace-name="lufa_dfu_16kb_4kb_">
|
||||
<require idref="lufa.bootloaders.dfu"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega16u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="DFU Bootloader - 8KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.8_4" force-caption="true" workspace-name="lufa_dfu_8kb_4kb_">
|
||||
<require idref="lufa.bootloaders.dfu"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega8u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<module type="application" id="lufa.bootloaders.dfu" caption="DFU Bootloader">
|
||||
<info type="description" value="summary">
|
||||
DFU Class Bootloader, capable of reprogramming a device using the Atmel FLIP or other AVR DFU programming software when plugged into a host.
|
||||
</info>
|
||||
|
||||
<info type="gui-flag" value="move-to-root"/>
|
||||
|
||||
<info type="keyword" value="Technology">
|
||||
<keyword value="Bootloaders"/>
|
||||
<keyword value="USB Device"/>
|
||||
</info>
|
||||
|
||||
<device-support-alias value="lufa_avr8"/>
|
||||
<device-support-alias value="lufa_xmega"/>
|
||||
<device-support-alias value="lufa_uc3"/>
|
||||
|
||||
<build type="include-path" value="."/>
|
||||
<build type="c-source" value="BootloaderDFU.c"/>
|
||||
<build type="header-file" value="BootloaderDFU.h"/>
|
||||
<build type="c-source" value="Descriptors.c"/>
|
||||
<build type="header-file" value="Descriptors.h"/>
|
||||
<build type="c-source" value="BootloaderAPI.c"/>
|
||||
<build type="header-file" value="BootloaderAPI.h"/>
|
||||
<build type="asm-source" value="BootloaderAPITable.S"/>
|
||||
|
||||
<build type="module-config" subtype="path" value="Config"/>
|
||||
<build type="header-file" value="Config/LUFAConfig.h"/>
|
||||
<build type="header-file" value="Config/AppConfig.h"/>
|
||||
|
||||
<build type="distribute" subtype="user-file" value="BootloaderDFU.txt"/>
|
||||
|
||||
<require idref="lufa.common"/>
|
||||
<require idref="lufa.platform"/>
|
||||
<require idref="lufa.drivers.usb"/>
|
||||
<require idref="lufa.drivers.board"/>
|
||||
<require idref="lufa.drivers.board.leds"/>
|
||||
</module>
|
||||
</asf>
|
||||
@@ -1,712 +1,55 @@
|
||||
# Hey Emacs, this is a -*- makefile -*-
|
||||
#----------------------------------------------------------------------------
|
||||
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
|
||||
# >> Modified for use with the LUFA project. <<
|
||||
#
|
||||
# Released to the Public Domain
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# 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
|
||||
# Dean Camera
|
||||
# Opendous Inc.
|
||||
# Denver Gingerich
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# 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 = at90usb1287
|
||||
|
||||
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. 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.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Starting byte address of the bootloader, as a byte address - computed via the formula
|
||||
# BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 1024)
|
||||
#
|
||||
# Note that the bootloader size and start address given in AVRStudio is in words and not
|
||||
# bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 4
|
||||
BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
|
||||
|
||||
|
||||
# Output format. (can be srec, ihex, binary)
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = BootloaderDFU
|
||||
|
||||
|
||||
# Object files directory
|
||||
# To put object files in current directory, use a dot (.), do NOT make
|
||||
# this an empty or blank macro!
|
||||
OBJDIR = .
|
||||
|
||||
|
||||
# Path to the LUFA library
|
||||
LUFA_PATH = ../..
|
||||
|
||||
|
||||
# LUFA library compile-time options and predefined tokens
|
||||
LUFA_OPTS = -D USB_DEVICE_ONLY
|
||||
LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0
|
||||
LUFA_OPTS += -D CONTROL_ONLY_DEVICE
|
||||
LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=32
|
||||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_RAM_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
|
||||
LUFA_OPTS += -D NO_INTERNAL_SERIAL
|
||||
LUFA_OPTS += -D NO_DEVICE_SELF_POWER
|
||||
LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP
|
||||
LUFA_OPTS += -D NO_SOF_EVENTS
|
||||
|
||||
|
||||
# Create the LUFA source path variables by including the LUFA root makefile
|
||||
include $(LUFA_PATH)/LUFA/makefile
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = $(TARGET).c \
|
||||
Descriptors.c \
|
||||
$(LUFA_SRC_USB) \
|
||||
|
||||
|
||||
# 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 = $(LUFA_PATH)/
|
||||
|
||||
|
||||
# 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=c99
|
||||
|
||||
|
||||
# Place -D or -U options here for C sources
|
||||
CDEFS = -DF_CPU=$(F_CPU)UL
|
||||
CDEFS += -DF_USB=$(F_USB)UL
|
||||
CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
|
||||
CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
CDEFS += $(LUFA_OPTS)
|
||||
|
||||
|
||||
# Place -D or -U options here for ASM sources
|
||||
ADEFS = -DF_CPU=$(F_CPU)
|
||||
ADEFS += -DF_USB=$(F_USB)UL
|
||||
ADEFS += -DBOARD=BOARD_$(BOARD)
|
||||
ADEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
ADEFS += $(LUFA_OPTS)
|
||||
|
||||
|
||||
# Place -D or -U options here for C++ sources
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL
|
||||
CPPDEFS += -DF_USB=$(F_USB)UL
|
||||
CPPDEFS += -DBOARD=BOARD_$(BOARD)
|
||||
CPPDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
CPPDEFS += $(LUFA_OPTS)
|
||||
#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 += -ffunction-sections
|
||||
CFLAGS += -fno-inline-small-functions
|
||||
CFLAGS += -fpack-struct
|
||||
CFLAGS += -fshort-enums
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
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
|
||||
CPPFLAGS += -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 += -Wl,--section-start=.text=$(BOOT_START)
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
||||
#LDFLAGS += -T linker_script.x
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options (avrdude) ----------------
|
||||
|
||||
# Programming hardware
|
||||
# Type: avrdude -c ?
|
||||
# to get a full listing.
|
||||
#
|
||||
AVRDUDE_PROGRAMMER = jtagmkII
|
||||
|
||||
# com1 = serial port. Use lpt1 to connect to parallel port.
|
||||
AVRDUDE_PORT = usb
|
||||
|
||||
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_FLAG) $(FORMAT_FLAG) $(TARGET).elf
|
||||
MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
|
||||
FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
|
||||
|
||||
|
||||
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 -R .fuse -R .lock $< $@
|
||||
|
||||
%.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 -z $< > $@
|
||||
|
||||
# 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) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
$(REMOVE) $(SRC:.c=.s)
|
||||
$(REMOVE) $(SRC:.c=.d)
|
||||
$(REMOVE) $(SRC:.c=.i)
|
||||
$(REMOVEDIR) .dep
|
||||
|
||||
doxygen:
|
||||
@echo Generating Project Documentation \($(TARGET)\)...
|
||||
@doxygen Doxygen.conf
|
||||
@echo Documentation Generation Complete.
|
||||
|
||||
clean_doxygen:
|
||||
rm -rf Documentation
|
||||
|
||||
checksource:
|
||||
@for f in $(SRC) $(CPPSRC) $(ASRC); do \
|
||||
if [ -f $$f ]; then \
|
||||
echo "Found Source File: $$f" ; \
|
||||
else \
|
||||
echo "Source File Not Found: $$f" ; \
|
||||
fi; done
|
||||
|
||||
|
||||
# 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 doxygen clean \
|
||||
clean_list clean_doxygen program debug gdb-config checksource
|
||||
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU = at90usb1287
|
||||
ARCH = AVR8
|
||||
BOARD = USBKEY
|
||||
F_CPU = 8000000
|
||||
F_USB = $(F_CPU)
|
||||
OPTIMIZATION = s
|
||||
TARGET = BootloaderDFU
|
||||
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB)
|
||||
LUFA_PATH = ../../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
|
||||
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
|
||||
|
||||
# Flash size and bootloader section sizes of the target, in KB. These must
|
||||
# match the target's total FLASH size and the bootloader size set in the
|
||||
# device's fuses.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 8
|
||||
|
||||
# Bootloader address calculation formulas
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
include $(LUFA_PATH)/Build/lufa_doxygen.mk
|
||||
include $(LUFA_PATH)/Build/lufa_avrdude.mk
|
||||
include $(LUFA_PATH)/Build/lufa_atprogram.mk
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<AVRStudio><MANAGEMENT><ProjectName>BootloaderHID</ProjectName><Created>15-Jan-2011 21:49:00</Created><LastEdit>15-Jan-2011 21:49:00</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderHID.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderHID.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderHID.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -32,7 +32,7 @@
|
||||
*
|
||||
* Main source file for the HID class bootloader. This file contains the complete bootloader logic.
|
||||
*/
|
||||
|
||||
|
||||
#include "BootloaderHID.h"
|
||||
|
||||
/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run
|
||||
@@ -41,23 +41,50 @@
|
||||
*/
|
||||
static bool RunBootloader = true;
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
|
||||
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
|
||||
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
|
||||
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
|
||||
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
|
||||
*/
|
||||
uint16_t MagicBootKey ATTR_NO_INIT;
|
||||
|
||||
|
||||
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
|
||||
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
|
||||
* this will force the user application to start via a software jump.
|
||||
*/
|
||||
void Application_Jump_Check(void)
|
||||
{
|
||||
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
||||
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||
{
|
||||
MagicBootKey = 0;
|
||||
|
||||
// cppcheck-suppress constStatement
|
||||
((void (*)(void))0x0000)();
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
|
||||
* runs the bootloader processing routine until instructed to soft-exit.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
/* Setup hardware required for the bootloader */
|
||||
SetupHardware();
|
||||
|
||||
|
||||
/* Enable global interrupts so that the USB stack can function */
|
||||
sei();
|
||||
GlobalInterruptEnable();
|
||||
|
||||
while (RunBootloader)
|
||||
USB_USBTask();
|
||||
|
||||
|
||||
/* Disconnect from the host - USB interface will be reset later along with the AVR */
|
||||
USB_Detach();
|
||||
|
||||
/* Unlock the forced application start mode of the bootloader if it is restarted */
|
||||
MagicBootKey = MAGIC_BOOT_KEY;
|
||||
|
||||
/* Enable the watchdog and force a timeout to reset the AVR */
|
||||
wdt_enable(WDTO_250MS);
|
||||
|
||||
@@ -65,7 +92,7 @@ int main(void)
|
||||
}
|
||||
|
||||
/** Configures all hardware required for the bootloader. */
|
||||
void SetupHardware(void)
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
@@ -85,9 +112,7 @@ void SetupHardware(void)
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
/* Setup HID Report Endpoint */
|
||||
Endpoint_ConfigureEndpoint(HID_IN_EPNUM, EP_TYPE_INTERRUPT,
|
||||
ENDPOINT_DIR_IN, HID_IN_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
Endpoint_ConfigureEndpoint(HID_IN_EPADDR, EP_TYPE_INTERRUPT, HID_IN_EPSIZE, 1);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
|
||||
@@ -108,17 +133,17 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
case HID_REQ_SetReport:
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
|
||||
/* Wait until the command has been sent by the host */
|
||||
while (!(Endpoint_IsOUTReceived()));
|
||||
|
||||
|
||||
/* Read in the write destination address */
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
uint32_t PageAddress = ((uint32_t)Endpoint_Read_16_LE() << 8);
|
||||
#else
|
||||
uint16_t PageAddress = Endpoint_Read_16_LE();
|
||||
#endif
|
||||
|
||||
|
||||
/* Check if the command is a program page command, or a start application command */
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION)
|
||||
@@ -133,9 +158,9 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
/* Erase the given FLASH page, ready to be programmed */
|
||||
boot_page_erase(PageAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
|
||||
/* Write each of the FLASH page's bytes in sequence */
|
||||
for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)
|
||||
for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)
|
||||
{
|
||||
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
|
||||
if (!(Endpoint_BytesInEndpoint()))
|
||||
@@ -162,3 +187,4 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -30,11 +30,11 @@
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for TeensyHID.c.
|
||||
* Header file for BootloaderHID.c.
|
||||
*/
|
||||
|
||||
#ifndef _TEENSYHID_H_
|
||||
#define _TEENSYHID_H_
|
||||
|
||||
#ifndef _BOOTLOADERHID_H_
|
||||
#define _BOOTLOADERHID_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
@@ -47,15 +47,27 @@
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
/* Macros: */
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__OPTIMIZE_SIZE__)
|
||||
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
|
||||
#endif
|
||||
|
||||
/* Macros: */
|
||||
/** Bootloader special address to start the user application */
|
||||
#define COMMAND_STARTAPPLICATION 0xFFFF
|
||||
|
||||
|
||||
/** Magic bootloader key to unlock forced application start mode. */
|
||||
#define MAGIC_BOOT_KEY 0xDC42
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
static void SetupHardware(void);
|
||||
|
||||
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage HID Class USB AVR Bootloader
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* - Series 7 USB AVRs (AT90USBxxx7)
|
||||
* - Series 6 USB AVRs (AT90USBxxx6)
|
||||
* - Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
*
|
||||
* \section SSec_Info USB Information:
|
||||
*
|
||||
@@ -28,7 +28,7 @@
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device Class (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
@@ -38,23 +38,23 @@
|
||||
* Teensy Programming Protocol Specification</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Low Speed Mode \n
|
||||
* Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* This bootloader enumerates to the host as a HID Class device, allowing for device FLASH programming through
|
||||
* the supplied command line software, which is a modified version of Paul's TeensyHID Command Line loader code
|
||||
* from PJRC (used with permission). This bootloader is deliberatley non-compatible with the properietary PJRC
|
||||
* HalfKay bootloader GUI; only the command line interface software accompanying this bootloader will work with it.
|
||||
*
|
||||
* Out of the box this bootloader builds for the USB1287, and will fit into 2KB of bootloader space for the
|
||||
* Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for all other models. If you wish to
|
||||
* enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU values in the
|
||||
* accompanying makefile.
|
||||
*
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 2KB of bootloader space for the Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for
|
||||
* all other models. If you wish to alter this size and/or change the AVR model, you will need to edit the MCU,
|
||||
* FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
@@ -74,6 +74,14 @@
|
||||
* hid_bootloader_cli -mmcu=at90usb1287 Mouse.hex
|
||||
* \endcode
|
||||
*
|
||||
* \section Sec_KnownIssues Known Issues:
|
||||
*
|
||||
* \par After loading an application, it is not run automatically on startup.
|
||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
||||
* when needed.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
|
||||
93
Bootloaders/HID/Config/LUFAConfig.h
Normal file
93
Bootloaders/HID/Config/LUFAConfig.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Library Configuration Header File
|
||||
*
|
||||
* This header file is used to configure LUFA's compile time options,
|
||||
* as an alternative to the compile time constants supplied through
|
||||
* a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the LUFA
|
||||
* manual section "Summary of Compile Tokens".
|
||||
*/
|
||||
|
||||
#ifndef _LUFA_CONFIG_H_
|
||||
#define _LUFA_CONFIG_H_
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
|
||||
/* Non-USB Related Configuration Tokens: */
|
||||
// #define DISABLE_TERMINAL_CODES
|
||||
|
||||
/* USB Class Driver Related Tokens: */
|
||||
// #define HID_HOST_BOOT_PROTOCOL_ONLY
|
||||
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_MAX_COLLECTIONS {Insert Value Here}
|
||||
// #define HID_MAX_REPORTITEMS {Insert Value Here}
|
||||
// #define HID_MAX_REPORT_IDS {Insert Value Here}
|
||||
// #define NO_CLASS_DRIVER_AUTOFLUSH
|
||||
|
||||
/* General USB Driver Related Tokens: */
|
||||
#define ORDERED_EP_CONFIG
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
#define USB_DEVICE_ONLY
|
||||
// #define USB_HOST_ONLY
|
||||
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
|
||||
// #define NO_LIMITED_CONTROLLER_CONNECT
|
||||
#define NO_SOF_EVENTS
|
||||
|
||||
/* USB Device Mode Driver Related Tokens: */
|
||||
#define USE_RAM_DESCRIPTORS
|
||||
// #define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
#define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
#define DEVICE_STATE_AS_GPIOR 0
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
// #define CONTROL_ONLY_DEVICE
|
||||
// #define INTERRUPT_CONTROL_ENDPOINT
|
||||
#define NO_DEVICE_REMOTE_WAKEUP
|
||||
#define NO_DEVICE_SELF_POWER
|
||||
|
||||
/* USB Host Mode Driver Related Tokens: */
|
||||
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
|
||||
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
|
||||
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
|
||||
// #define NO_AUTO_VBUS_MANAGEMENT
|
||||
// #define INVERTED_VBUS_ENABLE_LINE
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported architecture for this LUFA configuration file.
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -30,9 +30,9 @@
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
@@ -52,12 +52,12 @@ const USB_Descriptor_HIDReport_Datatype_t HIDReport[] =
|
||||
HID_RI_LOGICAL_MINIMUM(8, 0x00),
|
||||
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
|
||||
HID_RI_REPORT_SIZE(8, 0x08),
|
||||
HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),
|
||||
HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),
|
||||
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
|
||||
HID_RI_END_COLLECTION(0),
|
||||
};
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
@@ -84,63 +84,63 @@ const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
/** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.HID_Interface =
|
||||
|
||||
.HID_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0x00,
|
||||
.AlternateSetting = 0x00,
|
||||
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
|
||||
.Class = HID_CSCP_HIDClass,
|
||||
.SubClass = HID_CSCP_NonBootSubclass,
|
||||
.Protocol = HID_CSCP_NonBootProtocol,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.HID_VendorHID =
|
||||
{
|
||||
.HID_VendorHID =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||
|
||||
|
||||
.HIDSpec = VERSION_BCD(01.11),
|
||||
.CountryCode = 0x00,
|
||||
.TotalReportDescriptors = 1,
|
||||
.HIDReportType = HID_DTYPE_Report,
|
||||
.HIDReportLength = sizeof(HIDReport)
|
||||
},
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DIR_IN | HID_IN_EPNUM),
|
||||
.EndpointAddress = HID_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = HID_IN_EPSIZE,
|
||||
.PollingIntervalMS = 0x01
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
};
|
||||
|
||||
@@ -158,17 +158,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
|
||||
/* If/Else If chain compiles slightly smaller than a switch case */
|
||||
if (DescriptorType == DTYPE_Device)
|
||||
{
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
}
|
||||
else if (DescriptorType == DTYPE_Configuration)
|
||||
{
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
}
|
||||
else if (DescriptorType == HID_DTYPE_HID)
|
||||
{
|
||||
@@ -184,3 +184,4 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -47,18 +47,18 @@
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
|
||||
// Generic HID Interface
|
||||
USB_Descriptor_Interface_t HID_Interface;
|
||||
USB_HID_Descriptor_HID_t HID_VendorHID;
|
||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the HID data IN endpoint. */
|
||||
#define HID_IN_EPNUM 1
|
||||
|
||||
/** Size in bytes of the HID reporting IN endpoint. */
|
||||
/* Macros: */
|
||||
/** Endpoint address of the HID data IN endpoint. */
|
||||
#define HID_IN_EPADDR (ENDPOINT_DIR_IN | 1)
|
||||
|
||||
/** Size in bytes of the HID reporting IN endpoint. */
|
||||
#define HID_IN_EPSIZE 64
|
||||
|
||||
/* Function Prototypes: */
|
||||
@@ -68,3 +68,4 @@
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -195,7 +195,9 @@ usb_dev_handle * open_usb_device(int vid, int pid)
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev;
|
||||
usb_dev_handle *h;
|
||||
#ifdef LIBUSB_HAS_GET_DRIVER_NP
|
||||
char buf[128];
|
||||
#endif
|
||||
int r;
|
||||
|
||||
usb_init();
|
||||
@@ -390,21 +392,9 @@ int write_usb_device(HANDLE h, void *buf, int len, int timeout)
|
||||
if (r != WAIT_OBJECT_0) return 0;
|
||||
}
|
||||
if (!GetOverlappedResult(h, &ov, &n, FALSE)) return 0;
|
||||
if (n <= 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void print_win32_err(void)
|
||||
{
|
||||
char buf[256];
|
||||
DWORD err;
|
||||
|
||||
err = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
|
||||
0, buf, sizeof(buf), NULL);
|
||||
printf("err %ld: %s\n", err, buf);
|
||||
}
|
||||
|
||||
static HANDLE win32_teensy_handle = NULL;
|
||||
|
||||
int teensy_open(void)
|
||||
@@ -667,6 +657,11 @@ int hard_reboot(void)
|
||||
#include <dev/usb/usb_ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifndef USB_GET_DEVICEINFO
|
||||
# define USB_GET_DEVICEINFO 0
|
||||
# error The USB_GET_DEVICEINFO ioctl() value is not defined for your system.
|
||||
#endif
|
||||
|
||||
int open_usb_device(int vid, int pid)
|
||||
{
|
||||
int r, fd;
|
||||
@@ -710,10 +705,10 @@ int teensy_open(void)
|
||||
{
|
||||
teensy_close();
|
||||
uhid_teensy_fd = open_usb_device(0x16C0, 0x0478);
|
||||
|
||||
|
||||
if (uhid_teensy_fd < 0)
|
||||
uhid_teensy_fd = open_usb_device(0x03eb, 0x2067);
|
||||
|
||||
|
||||
if (uhid_teensy_fd < 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -722,7 +717,7 @@ int teensy_write(void *buf, int len, double timeout)
|
||||
{
|
||||
int r;
|
||||
|
||||
// TODO: imeplement timeout... how??
|
||||
// TODO: implement timeout... how??
|
||||
r = write(uhid_teensy_fd, buf, len);
|
||||
if (r == len) return 1;
|
||||
return 0;
|
||||
@@ -801,6 +796,7 @@ int read_intel_hex(const char *filename)
|
||||
if (*buf) {
|
||||
if (parse_hex_line(buf) == 0) {
|
||||
//printf("Warning, parse error line %d\n", lineno);
|
||||
fclose(fp);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
@@ -816,7 +812,7 @@ int read_intel_hex(const char *filename)
|
||||
|
||||
/* parses a line of intel hex code, stores the data in bytes[] */
|
||||
/* and the beginning address in addr, and returns a 1 if the */
|
||||
/* line was valid, or a 0 if an error occured. The variable */
|
||||
/* line was valid, or a 0 if an error occurred. The variable */
|
||||
/* num gets the number of bytes that were stored into bytes[] */
|
||||
|
||||
|
||||
@@ -826,7 +822,7 @@ parse_hex_line(char *line)
|
||||
int addr, code, num;
|
||||
int sum, len, cksum, i;
|
||||
char *ptr;
|
||||
|
||||
|
||||
num = 0;
|
||||
if (line[0] != ':') return 0;
|
||||
if (strlen(line) < 11) return 0;
|
||||
@@ -979,13 +975,9 @@ void parse_options(int argc, char **argv)
|
||||
} else if (strncmp(arg, "-mmcu=", 6) == 0) {
|
||||
arg += 6;
|
||||
|
||||
uint8_t valid_prefix = 0;
|
||||
|
||||
if (strncmp(arg, "at90usb", 7) == 0) {
|
||||
valid_prefix = 1;
|
||||
arg += 7;
|
||||
} else if (strncmp(arg, "atmega", 6) == 0) {
|
||||
valid_prefix = 1;
|
||||
arg += 6;
|
||||
} else {
|
||||
die("Unknown MCU type\n");
|
||||
|
||||
120
Bootloaders/HID/HostLoaderApp_Python/hid_bootloader_loader.py
Normal file
120
Bootloaders/HID/HostLoaderApp_Python/hid_bootloader_loader.py
Normal file
@@ -0,0 +1,120 @@
|
||||
"""
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
"""
|
||||
|
||||
"""
|
||||
Front-end programmer for the LUFA HID class bootloader.
|
||||
|
||||
Usage:
|
||||
python hid_bootloader_loader.py <Device> <Input>.hex
|
||||
|
||||
Example:
|
||||
python hid_bootloader_loader.py at90usb1287 Mouse.hex
|
||||
|
||||
Requires the pywinusb (https://pypi.python.org/pypi/pywinusb/) and
|
||||
IntelHex (http://bialix.com/intelhex/) libraries.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pywinusb import hid
|
||||
from intelhex import IntelHex
|
||||
|
||||
|
||||
# Device information table
|
||||
device_info_map = dict()
|
||||
device_info_map['at90usb1287'] = {'page_size': 256, 'flash_kb': 128}
|
||||
device_info_map['at90usb1286'] = {'page_size': 256, 'flash_kb': 128}
|
||||
device_info_map['at90usb647'] = {'page_size': 256, 'flash_kb': 64}
|
||||
device_info_map['at90usb646'] = {'page_size': 256, 'flash_kb': 64}
|
||||
device_info_map['atmega32u4'] = {'page_size': 128, 'flash_kb': 32}
|
||||
device_info_map['atmega32u2'] = {'page_size': 128, 'flash_kb': 32}
|
||||
device_info_map['atmega16u4'] = {'page_size': 128, 'flash_kb': 16}
|
||||
device_info_map['atmega16u2'] = {'page_size': 128, 'flash_kb': 16}
|
||||
device_info_map['at90usb162'] = {'page_size': 128, 'flash_kb': 16}
|
||||
device_info_map['atmega8u2'] = {'page_size': 128, 'flash_kb': 8}
|
||||
device_info_map['at90usb82'] = {'page_size': 128, 'flash_kb': 8}
|
||||
|
||||
|
||||
def get_hid_device_handle():
|
||||
hid_device_filter = hid.HidDeviceFilter(vendor_id=0x03EB,
|
||||
product_id=0x2067)
|
||||
|
||||
valid_hid_devices = hid_device_filter.get_devices()
|
||||
|
||||
if len(valid_hid_devices) is 0:
|
||||
return None
|
||||
else:
|
||||
return valid_hid_devices[0]
|
||||
|
||||
|
||||
def send_page_data(hid_device, address, data):
|
||||
# Bootloader page data should be the HID Report ID (always zero) followed
|
||||
# by the starting address to program, then one device's flash page worth
|
||||
# of data
|
||||
output_report_data = [0]
|
||||
output_report_data.extend([address & 0xFF, address >> 8])
|
||||
output_report_data.extend(data)
|
||||
|
||||
hid_device.send_output_report(output_report_data)
|
||||
|
||||
|
||||
def program_device(hex_data, device_info):
|
||||
hid_device = get_hid_device_handle()
|
||||
|
||||
if hid_device is None:
|
||||
print("No valid HID device found.")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
hid_device.open()
|
||||
print("Connected to bootloader.")
|
||||
|
||||
# Program in all data from the loaded HEX file, in a number of device
|
||||
# page sized chunks
|
||||
for addr in range(0, hex_data.maxaddr(), device_info['page_size']):
|
||||
# Compute the address range of the current page in the device
|
||||
current_page_range = range(addr, addr+device_info['page_size'])
|
||||
|
||||
# Extract the data from the hex file at the specified start page
|
||||
# address and convert it to a regular list of bytes
|
||||
page_data = [hex_data[i] for i in current_page_range]
|
||||
|
||||
print("Writing address 0x%04X-0x%04X" % (current_page_range[0], current_page_range[-1]))
|
||||
|
||||
# Devices with more than 64KB of flash should shift down the page
|
||||
# address so that it is 16-bit (page size is guaranteed to be
|
||||
# >= 256 bytes so no non-zero address bits are discarded)
|
||||
if device_info['flash_kb'] < 64:
|
||||
send_page_data(hid_device, addr, page_data)
|
||||
else:
|
||||
send_page_data(hid_device, addr >> 8, page_data)
|
||||
|
||||
# Once programming is complete, start the application via a dummy page
|
||||
# program to the page address 0xFFFF
|
||||
print("Programming complete, starting application.")
|
||||
send_page_data(hid_device, 0xFFFF, [0] * device_info['page_size'])
|
||||
|
||||
finally:
|
||||
hid_device.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Load the specified HEX file
|
||||
try:
|
||||
hex_data = IntelHex(sys.argv[2])
|
||||
except:
|
||||
print("Could not open the specified HEX file.")
|
||||
sys.exit(1)
|
||||
|
||||
# Retrieve the device information entry for the specified device
|
||||
try:
|
||||
device_info = device_info_map[sys.argv[1]]
|
||||
except:
|
||||
print("Unknown device name specified.")
|
||||
sys.exit(1)
|
||||
|
||||
program_device(hex_data, device_info)
|
||||
122
Bootloaders/HID/asf.xml
Normal file
122
Bootloaders/HID/asf.xml
Normal file
@@ -0,0 +1,122 @@
|
||||
<asf xmlversion="1.0">
|
||||
<project caption="HID Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.128_4" force-caption="true" workspace-name="lufa_hid_128kb_4kb_">
|
||||
<require idref="lufa.bootloaders.hid"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb1287"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
|
||||
</project>
|
||||
|
||||
<project caption="HID Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.64_4" force-caption="true" workspace-name="lufa_hid_64kb_4kb_">
|
||||
<require idref="lufa.bootloaders.hid"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb647"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
|
||||
</project>
|
||||
|
||||
<project caption="HID Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.32_4" force-caption="true" workspace-name="lufa_hid_32kb_4kb_">
|
||||
<require idref="lufa.bootloaders.hid"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega32u4"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
|
||||
</project>
|
||||
|
||||
<project caption="HID Bootloader - 16KB FLASH / 2KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.16_2" force-caption="true" workspace-name="lufa_hid_16kb_2kb_">
|
||||
<require idref="lufa.bootloaders.hid"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega16u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x3800"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3800"/>
|
||||
</project>
|
||||
|
||||
<project caption="HID Bootloader - 8KB FLASH / 2KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.8_2" force-caption="true" workspace-name="lufa_hid_8kb_2kb_">
|
||||
<require idref="lufa.bootloaders.hid"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega8u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1800"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1800"/>
|
||||
</project>
|
||||
|
||||
<module type="application" id="lufa.bootloaders.hid" caption="HID Bootloader">
|
||||
<info type="description" value="summary">
|
||||
HID Class Bootloader, capable of reprogramming a device via a custom cross-platform command line utility when plugged into a host.
|
||||
</info>
|
||||
|
||||
<info type="gui-flag" value="move-to-root"/>
|
||||
|
||||
<info type="keyword" value="Technology">
|
||||
<keyword value="Bootloaders"/>
|
||||
<keyword value="USB Device"/>
|
||||
</info>
|
||||
|
||||
<device-support-alias value="lufa_avr8"/>
|
||||
<device-support-alias value="lufa_xmega"/>
|
||||
<device-support-alias value="lufa_uc3"/>
|
||||
|
||||
<build type="include-path" value="."/>
|
||||
<build type="c-source" value="BootloaderHID.c"/>
|
||||
<build type="header-file" value="BootloaderHID.h"/>
|
||||
<build type="c-source" value="Descriptors.c"/>
|
||||
<build type="header-file" value="Descriptors.h"/>
|
||||
|
||||
<build type="module-config" subtype="path" value="Config"/>
|
||||
<build type="header-file" value="Config/LUFAConfig.h"/>
|
||||
|
||||
<build type="distribute" subtype="user-file" value="BootloaderHID.txt"/>
|
||||
<build type="distribute" subtype="directory" value="HostLoaderApp"/>
|
||||
<build type="distribute" subtype="directory" value="HostLoaderApp_Python"/>
|
||||
|
||||
<require idref="lufa.common"/>
|
||||
<require idref="lufa.platform"/>
|
||||
<require idref="lufa.drivers.usb"/>
|
||||
<require idref="lufa.drivers.board"/>
|
||||
<require idref="lufa.drivers.board.leds"/>
|
||||
</module>
|
||||
</asf>
|
||||
@@ -1,712 +1,48 @@
|
||||
# Hey Emacs, this is a -*- makefile -*-
|
||||
#----------------------------------------------------------------------------
|
||||
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
|
||||
# >> Modified for use with the LUFA project. <<
|
||||
#
|
||||
# Released to the Public Domain
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# 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
|
||||
# Dean Camera
|
||||
# Opendous Inc.
|
||||
# Denver Gingerich
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# 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 = at90usb1287
|
||||
|
||||
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. 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.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Starting byte address of the bootloader, as a byte address - computed via the formula
|
||||
# BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 1024)
|
||||
#
|
||||
# Note that the bootloader size and start address given in AVRStudio is in words and not
|
||||
# bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 4
|
||||
BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
|
||||
|
||||
|
||||
# Output format. (can be srec, ihex, binary)
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = BootloaderHID
|
||||
|
||||
|
||||
# Object files directory
|
||||
# To put object files in current directory, use a dot (.), do NOT make
|
||||
# this an empty or blank macro!
|
||||
OBJDIR = .
|
||||
|
||||
|
||||
# Path to the LUFA library
|
||||
LUFA_PATH = ../..
|
||||
|
||||
|
||||
# LUFA library compile-time options and predefined tokens
|
||||
LUFA_OPTS = -D USB_DEVICE_ONLY
|
||||
LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0
|
||||
LUFA_OPTS += -D ORDERED_EP_CONFIG
|
||||
LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
||||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_RAM_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
|
||||
LUFA_OPTS += -D NO_INTERNAL_SERIAL
|
||||
LUFA_OPTS += -D NO_DEVICE_SELF_POWER
|
||||
LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP
|
||||
LUFA_OPTS += -D NO_SOF_EVENTS
|
||||
|
||||
|
||||
# Create the LUFA source path variables by including the LUFA root makefile
|
||||
include $(LUFA_PATH)/LUFA/makefile
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = $(TARGET).c \
|
||||
Descriptors.c \
|
||||
$(LUFA_SRC_USB) \
|
||||
|
||||
|
||||
# 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 = $(LUFA_PATH)/
|
||||
|
||||
|
||||
# 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=c99
|
||||
|
||||
|
||||
# Place -D or -U options here for C sources
|
||||
CDEFS = -DF_CPU=$(F_CPU)UL
|
||||
CDEFS += -DF_USB=$(F_USB)UL
|
||||
CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
|
||||
CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
CDEFS += $(LUFA_OPTS)
|
||||
|
||||
|
||||
# Place -D or -U options here for ASM sources
|
||||
ADEFS = -DF_CPU=$(F_CPU)
|
||||
ADEFS += -DF_USB=$(F_USB)UL
|
||||
ADEFS += -DBOARD=BOARD_$(BOARD)
|
||||
ADEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
ADEFS += $(LUFA_OPTS)
|
||||
|
||||
|
||||
# Place -D or -U options here for C++ sources
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL
|
||||
CPPDEFS += -DF_USB=$(F_USB)UL
|
||||
CPPDEFS += -DBOARD=BOARD_$(BOARD)
|
||||
CPPDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
|
||||
CPPDEFS += $(LUFA_OPTS)
|
||||
#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 += -ffunction-sections
|
||||
CFLAGS += -fno-inline-small-functions
|
||||
CFLAGS += -fpack-struct
|
||||
CFLAGS += -fshort-enums
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
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
|
||||
CPPFLAGS += -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 += -Wl,--section-start=.text=$(BOOT_START)
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
||||
#LDFLAGS += -T linker_script.x
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options (avrdude) ----------------
|
||||
|
||||
# Programming hardware
|
||||
# Type: avrdude -c ?
|
||||
# to get a full listing.
|
||||
#
|
||||
AVRDUDE_PROGRAMMER = jtagmkII
|
||||
|
||||
# com1 = serial port. Use lpt1 to connect to parallel port.
|
||||
AVRDUDE_PORT = usb
|
||||
|
||||
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_FLAG) $(FORMAT_FLAG) $(TARGET).elf
|
||||
MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
|
||||
FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
|
||||
|
||||
|
||||
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 -R .fuse -R .lock $< $@
|
||||
|
||||
%.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 -z $< > $@
|
||||
|
||||
# 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) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
$(REMOVE) $(SRC:.c=.s)
|
||||
$(REMOVE) $(SRC:.c=.d)
|
||||
$(REMOVE) $(SRC:.c=.i)
|
||||
$(REMOVEDIR) .dep
|
||||
|
||||
doxygen:
|
||||
@echo Generating Project Documentation \($(TARGET)\)...
|
||||
@doxygen Doxygen.conf
|
||||
@echo Documentation Generation Complete.
|
||||
|
||||
clean_doxygen:
|
||||
rm -rf Documentation
|
||||
|
||||
checksource:
|
||||
@for f in $(SRC) $(CPPSRC) $(ASRC); do \
|
||||
if [ -f $$f ]; then \
|
||||
echo "Found Source File: $$f" ; \
|
||||
else \
|
||||
echo "Source File Not Found: $$f" ; \
|
||||
fi; done
|
||||
|
||||
|
||||
# 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 doxygen clean \
|
||||
clean_list clean_doxygen program debug gdb-config checksource
|
||||
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU = at90usb1287
|
||||
ARCH = AVR8
|
||||
BOARD = USBKEY
|
||||
F_CPU = 8000000
|
||||
F_USB = $(F_CPU)
|
||||
OPTIMIZATION = s
|
||||
TARGET = BootloaderHID
|
||||
SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB)
|
||||
LUFA_PATH = ../../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
|
||||
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET)
|
||||
|
||||
# Flash size and bootloader section sizes of the target, in KB. These must
|
||||
# match the target's total FLASH size and the bootloader size set in the
|
||||
# device's fuses.
|
||||
FLASH_SIZE_KB := 128
|
||||
BOOT_SECTION_SIZE_KB := 8
|
||||
|
||||
# Bootloader address calculation formulas
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
include $(LUFA_PATH)/Build/lufa_doxygen.mk
|
||||
include $(LUFA_PATH)/Build/lufa_avrdude.mk
|
||||
include $(LUFA_PATH)/Build/lufa_atprogram.mk
|
||||
|
||||
76
Bootloaders/MassStorage/BootloaderAPI.c
Normal file
76
Bootloaders/MassStorage/BootloaderAPI.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -28,36 +28,36 @@
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _SIDESHOW_APPLICATIONS_H_
|
||||
#define _SIDESHOW_APPLICATIONS_H_
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <string.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "SideshowCommon.h"
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
bool InUse;
|
||||
GUID_t ApplicationID;
|
||||
GUID_t EndpointID;
|
||||
UNICODE_STRING_t(50) ApplicationName;
|
||||
uint32_t CachePolicy;
|
||||
uint32_t OnlineOnly;
|
||||
bool HaveContent;
|
||||
uint32_t CurrentContentID;
|
||||
uint8_t CurrentContent[MAX_CONTENTBUFFER_PER_APP];
|
||||
} SideShow_Application_t;
|
||||
|
||||
/* External Variables: */
|
||||
extern SideShow_Application_t InstalledApplications[MAX_APPLICATIONS];
|
||||
/* Macros: */
|
||||
#if AUX_BOOT_SECTION_SIZE > 0
|
||||
#define AUX_BOOT_SECTION __attribute__((section(".boot_aux")))
|
||||
#else
|
||||
#define AUX_BOOT_SECTION
|
||||
#endif
|
||||
|
||||
/* Function Prototypes: */
|
||||
SideShow_Application_t* SideShow_GetFreeApplication(void);
|
||||
SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* const GUID);
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
102
Bootloaders/MassStorage/BootloaderAPITable.S
Normal file
102
Bootloaders/MassStorage/BootloaderAPITable.S
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if AUX_BOOT_SECTION_SIZE > 0
|
||||
#warning Using a AUX bootloader section in addition to the defined bootloader space (see documentation).
|
||||
|
||||
; Trampoline to jump over the AUX bootloader section to the start of the bootloader,
|
||||
; on devices where an AUX bootloader section is used.
|
||||
.section .boot_aux_trampoline, "ax"
|
||||
.global Boot_AUX_Trampoline
|
||||
Boot_AUX_Trampoline:
|
||||
jmp BOOT_START_ADDR
|
||||
#endif
|
||||
|
||||
; Trampolines to actual API implementations if the target address is outside the
|
||||
; range of a rjmp instruction (can happen with large bootloader sections)
|
||||
.section .apitable_trampolines, "ax"
|
||||
.global BootloaderAPI_Trampolines
|
||||
BootloaderAPI_Trampolines:
|
||||
|
||||
BootloaderAPI_ErasePage_Trampoline:
|
||||
jmp BootloaderAPI_ErasePage
|
||||
BootloaderAPI_WritePage_Trampoline:
|
||||
jmp BootloaderAPI_WritePage
|
||||
BootloaderAPI_FillWord_Trampoline:
|
||||
jmp BootloaderAPI_FillWord
|
||||
BootloaderAPI_ReadSignature_Trampoline:
|
||||
jmp BootloaderAPI_ReadSignature
|
||||
BootloaderAPI_ReadFuse_Trampoline:
|
||||
jmp BootloaderAPI_ReadFuse
|
||||
BootloaderAPI_ReadLock_Trampoline:
|
||||
jmp BootloaderAPI_ReadLock
|
||||
BootloaderAPI_WriteLock_Trampoline:
|
||||
jmp BootloaderAPI_WriteLock
|
||||
BootloaderAPI_UNUSED1:
|
||||
ret
|
||||
BootloaderAPI_UNUSED2:
|
||||
ret
|
||||
BootloaderAPI_UNUSED3:
|
||||
ret
|
||||
BootloaderAPI_UNUSED4:
|
||||
ret
|
||||
BootloaderAPI_UNUSED5:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; API function jump table
|
||||
.section .apitable_jumptable, "ax"
|
||||
.global BootloaderAPI_JumpTable
|
||||
BootloaderAPI_JumpTable:
|
||||
|
||||
rjmp BootloaderAPI_ErasePage_Trampoline
|
||||
rjmp BootloaderAPI_WritePage_Trampoline
|
||||
rjmp BootloaderAPI_FillWord_Trampoline
|
||||
rjmp BootloaderAPI_ReadSignature_Trampoline
|
||||
rjmp BootloaderAPI_ReadFuse_Trampoline
|
||||
rjmp BootloaderAPI_ReadLock_Trampoline
|
||||
rjmp BootloaderAPI_WriteLock_Trampoline
|
||||
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
|
||||
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
|
||||
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
|
||||
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
|
||||
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
|
||||
|
||||
|
||||
|
||||
; Bootloader table signatures and information
|
||||
.section .apitable_signatures, "ax"
|
||||
.global BootloaderAPI_Signatures
|
||||
BootloaderAPI_Signatures:
|
||||
|
||||
.long BOOT_START_ADDR ; Start address of the bootloader
|
||||
.word 0xDF30 ; Signature for the MS class bootloader, V1
|
||||
.word 0xDCFB ; Signature for a LUFA class bootloader
|
||||
238
Bootloaders/MassStorage/BootloaderMassStorage.c
Normal file
238
Bootloaders/MassStorage/BootloaderMassStorage.c
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the Mass Storage class bootloader. This file contains the complete bootloader logic.
|
||||
*/
|
||||
|
||||
#define INCLUDE_FROM_BOOTLOADER_MASSSTORAGE_C
|
||||
#include "BootloaderMassStorage.h"
|
||||
|
||||
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
|
||||
* passed to all Mass Storage Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_MS_Device_t Disk_MS_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = 0,
|
||||
.DataINEndpoint =
|
||||
{
|
||||
.Address = MASS_STORAGE_IN_EPADDR,
|
||||
.Size = MASS_STORAGE_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.DataOUTEndpoint =
|
||||
{
|
||||
.Address = MASS_STORAGE_OUT_EPADDR,
|
||||
.Size = MASS_STORAGE_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.TotalLUNs = 1,
|
||||
},
|
||||
};
|
||||
|
||||
/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run
|
||||
* via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application
|
||||
* started via a forced watchdog reset.
|
||||
*/
|
||||
bool RunBootloader = true;
|
||||
|
||||
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
|
||||
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
|
||||
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
|
||||
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
|
||||
*/
|
||||
uint16_t MagicBootKey ATTR_NO_INIT;
|
||||
|
||||
/** Indicates if the bootloader is allowed to exit immediately if \ref RunBootloader is \c false. During shutdown all
|
||||
* pending commands must be processed before jumping to the user-application, thus this tracks the main program loop
|
||||
* iterations since a SCSI command from the host was received.
|
||||
*/
|
||||
static uint8_t TicksSinceLastCommand = 0;
|
||||
|
||||
|
||||
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
|
||||
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
|
||||
* this will force the user application to start via a software jump.
|
||||
*/
|
||||
void Application_Jump_Check(void)
|
||||
{
|
||||
bool JumpToApplication = false;
|
||||
|
||||
#if (BOARD == BOARD_LEONARDO)
|
||||
/* Enable pull-up on the IO13 pin so we can use it to select the mode */
|
||||
PORTC |= (1 << 7);
|
||||
Delay_MS(10);
|
||||
|
||||
/* If IO13 is not jumpered to ground, start the user application instead */
|
||||
JumpToApplication |= ((PINC & (1 << 7)) != 0);
|
||||
|
||||
/* Disable pull-up after the check has completed */
|
||||
PORTC &= ~(1 << 7);
|
||||
#elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
/* Disable JTAG debugging */
|
||||
JTAG_DISABLE();
|
||||
|
||||
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
|
||||
PORTF |= (1 << 4);
|
||||
Delay_MS(10);
|
||||
|
||||
/* If the TCK pin is not jumpered to ground, start the user application instead */
|
||||
JumpToApplication |= ((PINF & (1 << 4)) != 0);
|
||||
|
||||
/* Re-enable JTAG debugging */
|
||||
JTAG_ENABLE();
|
||||
#endif
|
||||
|
||||
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
||||
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||
{
|
||||
MagicBootKey = 0;
|
||||
JumpToApplication = true;
|
||||
}
|
||||
|
||||
if (JumpToApplication)
|
||||
{
|
||||
// cppcheck-suppress constStatement
|
||||
((void (*)(void))0x0000)();
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
GlobalInterruptEnable();
|
||||
|
||||
while (RunBootloader || TicksSinceLastCommand++ < 0xFF)
|
||||
{
|
||||
MS_Device_USBTask(&Disk_MS_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
||||
/* Disconnect from the host - USB interface will be reset later along with the AVR */
|
||||
USB_Detach();
|
||||
|
||||
/* Unlock the forced application start mode of the bootloader if it is restarted */
|
||||
MagicBootKey = MAGIC_BOOT_KEY;
|
||||
|
||||
/* Enable the watchdog and force a timeout to reset the AVR */
|
||||
wdt_enable(WDTO_250MS);
|
||||
|
||||
for (;;);
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Relocate the interrupt vector table to the bootloader section */
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
|
||||
ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
{
|
||||
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs and stops the Mass Storage management task.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Configuration Changed event. */
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
bool ConfigSuccess = true;
|
||||
|
||||
/* Setup Mass Storage Data Endpoints */
|
||||
ConfigSuccess &= MS_Device_ConfigureEndpoints(&Disk_MS_Interface);
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Control Request reception event. */
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
MS_Device_ProcessControlRequest(&Disk_MS_Interface);
|
||||
}
|
||||
|
||||
/** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface configuration structure being referenced
|
||||
*/
|
||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
bool CommandSuccess;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
/* Signal that a command was processed, must not exit bootloader yet */
|
||||
TicksSinceLastCommand = 0;
|
||||
|
||||
return CommandSuccess;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -30,30 +30,32 @@
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for StandaloneProgrammer.c.
|
||||
* Header file for BootloaderMassStorage.c.
|
||||
*/
|
||||
|
||||
#ifndef _STANDALONE_PROG_H_
|
||||
#define _STANDALONE_PROG_H_
|
||||
#ifndef _BOOTLOADER_MASS_STORAGE_H_
|
||||
#define _BOOTLOADER_MASS_STORAGE_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DiskDevice.h"
|
||||
#include "DiskHost.h"
|
||||
#include "Descriptors.h"
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
#include "Lib/SCSI.h"
|
||||
#include "Lib/DataflashManager.h"
|
||||
#include "Lib/ProgrammerConfig.h"
|
||||
#include "Lib/PetiteFATFs/pff.h"
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/Board/Buttons.h>
|
||||
#include <LUFA/Drivers/Peripheral/Serial.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__OPTIMIZE_SIZE__)
|
||||
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
|
||||
#endif
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
@@ -71,19 +73,27 @@
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* External Variables: */
|
||||
extern FILE DiskStream;
|
||||
extern FATFS DiskFATState;
|
||||
/** Magic bootloader key to unlock forced application start mode. */
|
||||
#define MAGIC_BOOT_KEY 0xDC42
|
||||
|
||||
/* Global Variables: */
|
||||
extern bool RunBootloader;
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(INCLUDE_FROM_STANDALONEPROG_C)
|
||||
static int Disk_getchar(FILE* Stream);
|
||||
int main(void) AUX_BOOT_SECTION;
|
||||
|
||||
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
||||
|
||||
void EVENT_USB_Device_Connect(void) AUX_BOOT_SECTION;
|
||||
void EVENT_USB_Device_Disconnect(void) AUX_BOOT_SECTION;
|
||||
void EVENT_USB_Device_ConfigurationChanged(void) AUX_BOOT_SECTION;
|
||||
void EVENT_USB_Device_ControlRequest(void) AUX_BOOT_SECTION;
|
||||
|
||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
|
||||
#if defined(INCLUDE_FROM_BOOTLOADER_MASSSTORAGE_C)
|
||||
static void SetupHardware(void) AUX_BOOT_SECTION;
|
||||
#endif
|
||||
|
||||
void EVENT_USB_UIDChange(void);
|
||||
|
||||
void SetupHardware(void);
|
||||
void Programmer_Task(void);
|
||||
|
||||
#endif
|
||||
|
||||
206
Bootloaders/MassStorage/BootloaderMassStorage.txt
Normal file
206
Bootloaders/MassStorage/BootloaderMassStorage.txt
Normal file
@@ -0,0 +1,206 @@
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Mass Storage Class USB AVR Bootloader
|
||||
*
|
||||
* \section Sec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4) - <i>See \ref SSec_Aux_Space</i>
|
||||
* \li ATMEGA32U2 - <i>See \ref SSec_Aux_Space</i>
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Mass Storage Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Bulk-Only Transport</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Mass Storage Standard \n
|
||||
* USB Bulk-Only Transport Standard \n
|
||||
* SCSI Primary Commands Specification \n
|
||||
* SCSI Block Commands Specification</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section Sec_Description Project Description:
|
||||
*
|
||||
* This bootloader enumerates to the host as a Mass Storage device, capable of reading and writing a new binary
|
||||
* firmware image file, to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 6KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
* This bootloader uses the Mass Storage drivers inbuilt into all modern operating systems, thus no additional
|
||||
* drivers need to be supplied for correct operation.
|
||||
*
|
||||
* \section Sec_HostApp Host Controller Application
|
||||
*
|
||||
* This bootloader is compatible with all operating systems that support the FAT12 file system format. To reprogram the
|
||||
* device, overwrite a file stored on the virtual FAT filesystem with a new binary (BIN format) image. Remember to safely
|
||||
* remove your device from the host using the host OS's ejection APIs, to ensure all data is correctly flushed to the
|
||||
* bootloader's virtual filesystem and not cached in the OS's file system driver.
|
||||
*
|
||||
* The current device firmware can be read from the device by reading a file from the virtual FAT filesystem.
|
||||
*
|
||||
* \warning This bootloader is currently <b>incompatible with the Apple MacOS X OS Finder GUI</b>, due to the
|
||||
* large amount of meta files this OS attempts to write to the disk along with the new binaries. On
|
||||
* this platform, firmwares must be copied to the disk via the Terminal application only to prevent
|
||||
* firmware corruption.
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_MASS_STORAGE_SIGNATURE 0xDF30
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
|
||||
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
|
||||
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
|
||||
* to the value \c BOOTLOADER_MASS_STORAGE_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes
|
||||
* of FLASH memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \subsection SSec_Aux_Space Auxiliary Bootloader Section
|
||||
* To make the bootloader function on smaller devices (those with a physical bootloader section of smaller than 6KB) a second
|
||||
* section of memory (called the <i>Auxiliary Bootloader Section</i>) is added before the start of the real bootloader section,
|
||||
* and is filled with a portion of the bootloader code. This allows smaller devices to run the bootloader, at the cost of an
|
||||
* additional portion of the device's FLASH (the bootloader section size in KB subtracted from the 6KB total size). A small
|
||||
* trampoline is inserted at the start of the auxiliary section so that the bootloader will run normally in the case of a blank
|
||||
* application section.
|
||||
*
|
||||
* On devices supporting a 8KB bootloader section size, the AUX section is not created in the final binary.
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - BOOT_AUX_SECTION_SIZE
|
||||
* | Booloader Start Trampoline |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - BOOT_AUX_SECTION_SIZE + 4
|
||||
* | |
|
||||
* | Auxiliary Bootloader |
|
||||
* | Space for Smaller Devices |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* \section Sec_KnownIssues Known Issues:
|
||||
*
|
||||
* \par In some cases, the application is not fully loaded into the device.
|
||||
* Write-caching on some operating systems may interfere with the normal
|
||||
* operation of the bootloader. Write caching should be disabled when using the
|
||||
* Mass Storage bootloader, or the file system synced via an appropriate command
|
||||
* (such as the OS's normal disk ejection command) before disconnecting the device.
|
||||
*
|
||||
* \par After loading an application, it is not run automatically on startup.
|
||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
||||
* when needed.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <th><b>Define Name:</b></th>
|
||||
* <th><b>Location:</b></th>
|
||||
* <th><b>Description:</b></th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_APP_START_ON_EJECT</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>Define to disable automatic start of the loaded application when the virtual
|
||||
* Mass Storage disk is ejected on the host.</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
47
Bootloaders/MassStorage/Config/AppConfig.h
Normal file
47
Bootloaders/MassStorage/Config/AppConfig.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Application Configuration Header File
|
||||
*
|
||||
* This is a header file which is be used to configure LUFA's
|
||||
* compile time options, as an alternative to the compile time
|
||||
* constants supplied through a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the
|
||||
* \ref Sec_Options section of the application documentation.
|
||||
*/
|
||||
|
||||
#ifndef _APP_CONFIG_H_
|
||||
#define _APP_CONFIG_H_
|
||||
|
||||
// #define NO_APP_START_ON_EJECT
|
||||
|
||||
#endif
|
||||
93
Bootloaders/MassStorage/Config/LUFAConfig.h
Normal file
93
Bootloaders/MassStorage/Config/LUFAConfig.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Library Configuration Header File
|
||||
*
|
||||
* This header file is used to configure LUFA's compile time options,
|
||||
* as an alternative to the compile time constants supplied through
|
||||
* a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the LUFA
|
||||
* manual section "Summary of Compile Tokens".
|
||||
*/
|
||||
|
||||
#ifndef _LUFA_CONFIG_H_
|
||||
#define _LUFA_CONFIG_H_
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
|
||||
/* Non-USB Related Configuration Tokens: */
|
||||
// #define DISABLE_TERMINAL_CODES
|
||||
|
||||
/* USB Class Driver Related Tokens: */
|
||||
// #define HID_HOST_BOOT_PROTOCOL_ONLY
|
||||
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_MAX_COLLECTIONS {Insert Value Here}
|
||||
// #define HID_MAX_REPORTITEMS {Insert Value Here}
|
||||
// #define HID_MAX_REPORT_IDS {Insert Value Here}
|
||||
// #define NO_CLASS_DRIVER_AUTOFLUSH
|
||||
|
||||
/* General USB Driver Related Tokens: */
|
||||
#define ORDERED_EP_CONFIG
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
#define USB_DEVICE_ONLY
|
||||
// #define USB_HOST_ONLY
|
||||
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
|
||||
// #define NO_LIMITED_CONTROLLER_CONNECT
|
||||
#define NO_SOF_EVENTS
|
||||
|
||||
/* USB Device Mode Driver Related Tokens: */
|
||||
#define USE_RAM_DESCRIPTORS
|
||||
// #define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
#define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
#define DEVICE_STATE_AS_GPIOR 0
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
// #define CONTROL_ONLY_DEVICE
|
||||
#define INTERRUPT_CONTROL_ENDPOINT
|
||||
#define NO_DEVICE_REMOTE_WAKEUP
|
||||
#define NO_DEVICE_SELF_POWER
|
||||
|
||||
/* USB Host Mode Driver Related Tokens: */
|
||||
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
|
||||
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
|
||||
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
|
||||
// #define NO_AUTO_VBUS_MANAGEMENT
|
||||
// #define INVERTED_VBUS_ENABLE_LINE
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported architecture for this LUFA configuration file.
|
||||
|
||||
#endif
|
||||
#endif
|
||||
157
Bootloaders/MassStorage/Descriptors.c
Normal file
157
Bootloaders/MassStorage/Descriptors.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = USB_CSCP_NoDeviceClass,
|
||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2045,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
||||
.ProductStrIndex = NO_DESCRIPTOR,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.MS_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = MS_CSCP_MassStorageClass,
|
||||
.SubClass = MS_CSCP_SCSITransparentSubclass,
|
||||
.Protocol = MS_CSCP_BulkOnlyTransportProtocol,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MS_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = MASS_STORAGE_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
|
||||
.MS_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = MASS_STORAGE_OUT_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
/* If/Else If chain compiles slightly smaller than a switch case */
|
||||
if (DescriptorType == DTYPE_Device)
|
||||
{
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
}
|
||||
else if (DescriptorType == DTYPE_Configuration)
|
||||
{
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -41,23 +41,17 @@
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
/* Macros: */
|
||||
#if !defined(LIBUSB_DRIVER_COMPAT)
|
||||
/** Endpoint number of the AVRISP data OUT endpoint. */
|
||||
#define AVRISP_DATA_OUT_EPNUM 2
|
||||
/** Endpoint address of the Mass Storage device-to-host data IN endpoint. */
|
||||
#define MASS_STORAGE_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Endpoint number of the AVRISP data IN endpoint. */
|
||||
#define AVRISP_DATA_IN_EPNUM 2
|
||||
#else
|
||||
/** Endpoint number of the AVRISP data OUT endpoint. */
|
||||
#define AVRISP_DATA_OUT_EPNUM 2
|
||||
/** Endpoint address of the Mass Storage host-to-device data OUT endpoint. */
|
||||
#define MASS_STORAGE_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
|
||||
/** Endpoint number of the AVRISP data IN endpoint. */
|
||||
#define AVRISP_DATA_IN_EPNUM 3
|
||||
#endif
|
||||
|
||||
/** Size in bytes of the AVRISP data endpoint. */
|
||||
#define AVRISP_DATA_EPSIZE 64
|
||||
/** Size in bytes of the Mass Storage data endpoints. */
|
||||
#define MASS_STORAGE_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
@@ -66,19 +60,19 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Atmel AVRISP-MKII Interface
|
||||
USB_Descriptor_Interface_t AVRISP_Interface;
|
||||
USB_Descriptor_Endpoint_t AVRISP_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t AVRISP_DataOutEndpoint;
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Mass Storage Interface
|
||||
USB_Descriptor_Interface_t MS_Interface;
|
||||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3) AUX_BOOT_SECTION;
|
||||
|
||||
#endif
|
||||
|
||||
1919
Bootloaders/MassStorage/Doxygen.conf
Normal file
1919
Bootloaders/MassStorage/Doxygen.conf
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -38,7 +38,6 @@
|
||||
#define INCLUDE_FROM_SCSI_C
|
||||
#include "SCSI.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
||||
* features and capabilities.
|
||||
*/
|
||||
@@ -67,7 +66,7 @@ static const SCSI_Inquiry_Response_t InquiryData =
|
||||
.RelAddr = false,
|
||||
|
||||
.VendorID = "LUFA",
|
||||
.ProductID = "Dataflash Disk",
|
||||
.ProductID = "Bootloader",
|
||||
.RevisionID = {'0','.','0','0'},
|
||||
};
|
||||
|
||||
@@ -87,7 +86,7 @@ static SCSI_Request_Sense_Response_t SenseData =
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise
|
||||
*/
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -105,9 +104,6 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
case SCSI_CMD_READ_CAPACITY_10:
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_WRITE_10:
|
||||
CommandSuccess = SCSI_Command_ReadWrite_10(MSInterfaceInfo, DATA_WRITE);
|
||||
break;
|
||||
@@ -117,6 +113,12 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
case SCSI_CMD_MODE_SENSE_6:
|
||||
CommandSuccess = SCSI_Command_ModeSense_6(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_START_STOP_UNIT:
|
||||
#if !defined(NO_APP_START_ON_EJECT)
|
||||
/* If the user ejected the volume, signal bootloader exit at next opportunity. */
|
||||
RunBootloader = ((MSInterfaceInfo->State.CommandBlock.SCSICommandData[4] & 0x03) != 0x02);
|
||||
#endif
|
||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||
case SCSI_CMD_TEST_UNIT_READY:
|
||||
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
|
||||
case SCSI_CMD_VERIFY_10:
|
||||
@@ -150,7 +152,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -188,12 +190,12 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = MIN(AllocationLength, sizeof(SenseData));
|
||||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = MIN(AllocationLength, sizeof(SenseData));
|
||||
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NULL);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
@@ -210,15 +212,12 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
uint32_t LastBlockAddressInLUN = (VIRTUAL_MEMORY_BLOCKS - 1);
|
||||
uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;
|
||||
|
||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
|
||||
Endpoint_Write_32_BE(LUN_MEDIA_BLOCKS - 1);
|
||||
Endpoint_Write_32_BE(SECTOR_SIZE_BYTES);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
@@ -227,44 +226,6 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Command processing for an issued SCSI SEND DIAGNOSTIC command. This command performs a quick check of the Dataflash ICs on the
|
||||
* board, and indicates if they are present and functioning correctly. Only the Self-Test portion of the diagnostic command is
|
||||
* supported.
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
/* Check to see if the SELF TEST bit is not set */
|
||||
if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))
|
||||
{
|
||||
/* Only self-test supported - update SENSE key and fail the command */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
|
||||
SCSI_ASENSE_INVALID_FIELD_IN_CDB,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check to see if all attached Dataflash ICs are functional */
|
||||
if (!(DataflashManager_CheckDataflashOperation()))
|
||||
{
|
||||
/* Update SENSE key with a hardware error condition and return command fail */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Command processing for an issued SCSI READ (10) or WRITE (10) command. This command reads in the block start address
|
||||
* and total number of blocks to process, then calls the appropriate low-level Dataflash routine to handle the actual
|
||||
* reading and writing of the data.
|
||||
@@ -272,25 +233,14 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
* \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead)
|
||||
{
|
||||
uint32_t BlockAddress;
|
||||
uint16_t BlockAddress;
|
||||
uint16_t TotalBlocks;
|
||||
|
||||
/* Check if the disk is write protected or not */
|
||||
if ((IsDataRead == DATA_WRITE) && DISK_READ_ONLY)
|
||||
{
|
||||
/* Block address is invalid, update SENSE key and return command fail */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_DATA_PROTECT,
|
||||
SCSI_ASENSE_WRITE_PROTECTED,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
||||
|
||||
@@ -298,7 +248,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
||||
|
||||
/* Check if the block address is outside the maximum allowable value for the LUN */
|
||||
if (BlockAddress >= VIRTUAL_MEMORY_BLOCKS)
|
||||
if (BlockAddress >= LUN_MEDIA_BLOCKS)
|
||||
{
|
||||
/* Block address is invalid, update SENSE key and return command fail */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
|
||||
@@ -307,15 +257,18 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||
if (IsDataRead == DATA_READ)
|
||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||
else
|
||||
DataflashManager_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||
for (uint16_t i = 0; i < TotalBlocks; i++)
|
||||
{
|
||||
if (IsDataRead == DATA_READ)
|
||||
VirtualFAT_ReadBlock(BlockAddress + i);
|
||||
else
|
||||
VirtualFAT_WriteBlock(BlockAddress + i);
|
||||
}
|
||||
|
||||
/* Update the bytes transferred counter and succeed the command */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * SECTOR_SIZE_BYTES);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -325,15 +278,12 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
/* Send an empty header response with the Write Protect flag status */
|
||||
Endpoint_Write_8(0x00);
|
||||
Endpoint_Write_8(0x00);
|
||||
Endpoint_Write_8(DISK_READ_ONLY ? 0x80 : 0x00);
|
||||
Endpoint_Write_8(0x00);
|
||||
/* Send an empty header response indicating Write Protect flag is off */
|
||||
Endpoint_Write_32_LE(0);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Update the bytes transferred counter and succeed the command */
|
||||
@@ -341,4 +291,4 @@ static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfac
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -42,9 +42,9 @@
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "StandaloneProgrammer.h"
|
||||
#include "Descriptors.h"
|
||||
#include "DataflashManager.h"
|
||||
#include "../BootloaderMassStorage.h"
|
||||
#include "../Descriptors.h"
|
||||
#include "VirtualFAT.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
||||
@@ -68,22 +68,16 @@
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
||||
#define DEVICE_TYPE_BLOCK 0x00
|
||||
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
||||
#define DEVICE_TYPE_CDROM 0x05
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
|
||||
#if defined(INCLUDE_FROM_SCSI_C)
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead);
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
#endif
|
||||
#if defined(INCLUDE_FROM_SCSI_C)
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
482
Bootloaders/MassStorage/Lib/VirtualFAT.c
Normal file
482
Bootloaders/MassStorage/Lib/VirtualFAT.c
Normal file
@@ -0,0 +1,482 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Virtualized FAT12 filesystem implementation, to perform self-programming
|
||||
* in response to read and write requests to the virtual filesystem by the
|
||||
* host PC.
|
||||
*/
|
||||
|
||||
#define INCLUDE_FROM_VIRTUAL_FAT_C
|
||||
#include "VirtualFAT.h"
|
||||
|
||||
/** FAT filesystem boot sector block, must be the first sector on the physical
|
||||
* disk so that the host can identify the presence of a FAT filesystem. This
|
||||
* block is truncated; normally a large bootstrap section is located near the
|
||||
* end of the block for booting purposes however as this is not meant to be a
|
||||
* bootable disk it is omitted for space reasons.
|
||||
*
|
||||
* \note When returning the boot block to the host, the magic signature 0xAA55
|
||||
* must be added to the very end of the block to identify it as a boot
|
||||
* block.
|
||||
*/
|
||||
static const FATBootBlock_t BootBlock =
|
||||
{
|
||||
.Bootstrap = {0xEB, 0x3C, 0x90},
|
||||
.Description = "mkdosfs",
|
||||
.SectorSize = SECTOR_SIZE_BYTES,
|
||||
.SectorsPerCluster = SECTOR_PER_CLUSTER,
|
||||
.ReservedSectors = 1,
|
||||
.FATCopies = 2,
|
||||
.RootDirectoryEntries = (SECTOR_SIZE_BYTES / sizeof(FATDirectoryEntry_t)),
|
||||
.TotalSectors16 = LUN_MEDIA_BLOCKS,
|
||||
.MediaDescriptor = 0xF8,
|
||||
.SectorsPerFAT = 1,
|
||||
.SectorsPerTrack = (LUN_MEDIA_BLOCKS % 64),
|
||||
.Heads = (LUN_MEDIA_BLOCKS / 64),
|
||||
.HiddenSectors = 0,
|
||||
.TotalSectors32 = 0,
|
||||
.PhysicalDriveNum = 0,
|
||||
.ExtendedBootRecordSig = 0x29,
|
||||
.VolumeSerialNumber = 0x12345678,
|
||||
.VolumeLabel = "LUFA BOOT ",
|
||||
.FilesystemIdentifier = "FAT12 ",
|
||||
};
|
||||
|
||||
/** FAT 8.3 style directory entry, for the virtual FLASH contents file. */
|
||||
static FATDirectoryEntry_t FirmwareFileEntries[] =
|
||||
{
|
||||
/* Root volume label entry; disk label is contained in the Filename and
|
||||
* Extension fields (concatenated) with a special attribute flag - other
|
||||
* fields are ignored. Should be the same as the label in the boot block.
|
||||
*/
|
||||
[DISK_FILE_ENTRY_VolumeID] =
|
||||
{
|
||||
.MSDOS_Directory =
|
||||
{
|
||||
.Name = "LUFA BOOT ",
|
||||
.Attributes = FAT_FLAG_VOLUME_NAME,
|
||||
.Reserved = {0},
|
||||
.CreationTime = 0,
|
||||
.CreationDate = 0,
|
||||
.StartingCluster = 0,
|
||||
.Reserved2 = 0,
|
||||
}
|
||||
},
|
||||
|
||||
/* VFAT Long File Name entry for the virtual firmware file; required to
|
||||
* prevent corruption from systems that are unable to detect the device
|
||||
* as being a legacy MSDOS style FAT12 volume. */
|
||||
[DISK_FILE_ENTRY_FLASH_LFN] =
|
||||
{
|
||||
.VFAT_LongFileName =
|
||||
{
|
||||
.Ordinal = 1 | FAT_ORDINAL_LAST_ENTRY,
|
||||
.Attribute = FAT_FLAG_LONG_FILE_NAME,
|
||||
.Reserved1 = 0,
|
||||
.Reserved2 = 0,
|
||||
|
||||
.Checksum = FAT_CHECKSUM('F','L','A','S','H',' ',' ',' ','B','I','N'),
|
||||
|
||||
.Unicode1 = 'F',
|
||||
.Unicode2 = 'L',
|
||||
.Unicode3 = 'A',
|
||||
.Unicode4 = 'S',
|
||||
.Unicode5 = 'H',
|
||||
.Unicode6 = '.',
|
||||
.Unicode7 = 'B',
|
||||
.Unicode8 = 'I',
|
||||
.Unicode9 = 'N',
|
||||
.Unicode10 = 0,
|
||||
.Unicode11 = 0,
|
||||
.Unicode12 = 0,
|
||||
.Unicode13 = 0,
|
||||
}
|
||||
},
|
||||
|
||||
/* MSDOS file entry for the virtual Firmware image. */
|
||||
[DISK_FILE_ENTRY_FLASH_MSDOS] =
|
||||
{
|
||||
.MSDOS_File =
|
||||
{
|
||||
.Filename = "FLASH ",
|
||||
.Extension = "BIN",
|
||||
.Attributes = 0,
|
||||
.Reserved = {0},
|
||||
.CreationTime = FAT_TIME(1, 1, 0),
|
||||
.CreationDate = FAT_DATE(14, 2, 1989),
|
||||
.StartingCluster = 2,
|
||||
.FileSizeBytes = FLASH_FILE_SIZE_BYTES,
|
||||
}
|
||||
},
|
||||
|
||||
[DISK_FILE_ENTRY_EEPROM_LFN] =
|
||||
{
|
||||
.VFAT_LongFileName =
|
||||
{
|
||||
.Ordinal = 1 | FAT_ORDINAL_LAST_ENTRY,
|
||||
.Attribute = FAT_FLAG_LONG_FILE_NAME,
|
||||
.Reserved1 = 0,
|
||||
.Reserved2 = 0,
|
||||
|
||||
.Checksum = FAT_CHECKSUM('E','E','P','R','O','M',' ',' ','B','I','N'),
|
||||
|
||||
.Unicode1 = 'E',
|
||||
.Unicode2 = 'E',
|
||||
.Unicode3 = 'P',
|
||||
.Unicode4 = 'R',
|
||||
.Unicode5 = 'O',
|
||||
.Unicode6 = 'M',
|
||||
.Unicode7 = '.',
|
||||
.Unicode8 = 'B',
|
||||
.Unicode9 = 'I',
|
||||
.Unicode10 = 'N',
|
||||
.Unicode11 = 0,
|
||||
.Unicode12 = 0,
|
||||
.Unicode13 = 0,
|
||||
}
|
||||
},
|
||||
|
||||
[DISK_FILE_ENTRY_EEPROM_MSDOS] =
|
||||
{
|
||||
.MSDOS_File =
|
||||
{
|
||||
.Filename = "EEPROM ",
|
||||
.Extension = "BIN",
|
||||
.Attributes = 0,
|
||||
.Reserved = {0},
|
||||
.CreationTime = FAT_TIME(1, 1, 0),
|
||||
.CreationDate = FAT_DATE(14, 2, 1989),
|
||||
.StartingCluster = 2 + FILE_CLUSTERS(FLASH_FILE_SIZE_BYTES),
|
||||
.FileSizeBytes = EEPROM_FILE_SIZE_BYTES,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/** Starting cluster of the virtual FLASH.BIN file on disk, tracked so that the
|
||||
* offset from the start of the data sector can be determined. On Windows
|
||||
* systems files are usually replaced using the original file's disk clusters,
|
||||
* while Linux appears to overwrite with an offset which must be compensated for.
|
||||
*/
|
||||
static const uint16_t* FLASHFileStartCluster = &FirmwareFileEntries[DISK_FILE_ENTRY_FLASH_MSDOS].MSDOS_File.StartingCluster;
|
||||
|
||||
/** Starting cluster of the virtual EEPROM.BIN file on disk, tracked so that the
|
||||
* offset from the start of the data sector can be determined. On Windows
|
||||
* systems files are usually replaced using the original file's disk clusters,
|
||||
* while Linux appears to overwrite with an offset which must be compensated for.
|
||||
*/
|
||||
static const uint16_t* EEPROMFileStartCluster = &FirmwareFileEntries[DISK_FILE_ENTRY_EEPROM_MSDOS].MSDOS_File.StartingCluster;
|
||||
|
||||
/** Reads a byte of EEPROM out from the EEPROM memory space.
|
||||
*
|
||||
* \note This function is required as the avr-libc EEPROM functions do not cope
|
||||
* with linker relaxations, and a jump longer than 4K of FLASH on the
|
||||
* larger USB AVRs will break the linker. This function is marked as
|
||||
* never inlinable and placed into the normal text segment so that the
|
||||
* call to the EEPROM function will be short even if the AUX boot section
|
||||
* is used.
|
||||
*
|
||||
* \param[in] Address Address of the EEPROM location to read from
|
||||
*
|
||||
* \return Read byte of EEPROM data.
|
||||
*/
|
||||
static uint8_t ReadEEPROMByte(const uint8_t* const Address)
|
||||
{
|
||||
return eeprom_read_byte(Address);
|
||||
}
|
||||
|
||||
/** Writes a byte of EEPROM out to the EEPROM memory space.
|
||||
*
|
||||
* \note This function is required as the avr-libc EEPROM functions do not cope
|
||||
* with linker relaxations, and a jump longer than 4K of FLASH on the
|
||||
* larger USB AVRs will break the linker. This function is marked as
|
||||
* never inlinable and placed into the normal text segment so that the
|
||||
* call to the EEPROM function will be short even if the AUX boot section
|
||||
* is used.
|
||||
*
|
||||
* \param[in] Address Address of the EEPROM location to write to
|
||||
* \param[in] Data New data to write to the EEPROM location
|
||||
*/
|
||||
static void WriteEEPROMByte(uint8_t* const Address,
|
||||
const uint8_t Data)
|
||||
{
|
||||
eeprom_update_byte(Address, Data);
|
||||
}
|
||||
|
||||
/** Updates a FAT12 cluster entry in the FAT file table with the specified next
|
||||
* chain index. If the cluster is the last in the file chain, the magic value
|
||||
* \c 0xFFF should be used.
|
||||
*
|
||||
* \note FAT data cluster indexes are offset by 2, so that cluster 2 is the
|
||||
* first file data cluster on the disk. See the FAT specification.
|
||||
*
|
||||
* \param[out] FATTable Pointer to the FAT12 allocation table
|
||||
* \param[in] Index Index of the cluster entry to update
|
||||
* \param[in] ChainEntry Next cluster index in the file chain
|
||||
*/
|
||||
static void UpdateFAT12ClusterEntry(uint8_t* const FATTable,
|
||||
const uint16_t Index,
|
||||
const uint16_t ChainEntry)
|
||||
{
|
||||
/* Calculate the starting offset of the cluster entry in the FAT12 table */
|
||||
uint8_t FATOffset = (Index + (Index >> 1));
|
||||
bool UpperNibble = ((Index & 1) != 0);
|
||||
|
||||
/* Check if the start of the entry is at an upper nibble of the byte, fill
|
||||
* out FAT12 entry as required */
|
||||
if (UpperNibble)
|
||||
{
|
||||
FATTable[FATOffset] = (FATTable[FATOffset] & 0x0F) | ((ChainEntry & 0x0F) << 4);
|
||||
FATTable[FATOffset + 1] = (ChainEntry >> 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
FATTable[FATOffset] = ChainEntry;
|
||||
FATTable[FATOffset + 1] = (FATTable[FATOffset] & 0xF0) | (ChainEntry >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates a FAT12 cluster chain in the FAT file table with a linear chain of
|
||||
* the specified length.
|
||||
*
|
||||
* \note FAT data cluster indexes are offset by 2, so that cluster 2 is the
|
||||
* first file data cluster on the disk. See the FAT specification.
|
||||
*
|
||||
* \param[out] FATTable Pointer to the FAT12 allocation table
|
||||
* \param[in] Index Index of the start of the cluster chain to update
|
||||
* \param[in] ChainLength Length of the chain to write, in clusters
|
||||
*/
|
||||
static void UpdateFAT12ClusterChain(uint8_t* const FATTable,
|
||||
const uint16_t Index,
|
||||
const uint8_t ChainLength)
|
||||
{
|
||||
for (uint8_t i = 0; i < ChainLength; i++)
|
||||
{
|
||||
uint16_t CurrentCluster = Index + i;
|
||||
uint16_t NextCluster = CurrentCluster + 1;
|
||||
|
||||
/* Mark last cluster as end of file */
|
||||
if (i == (ChainLength - 1))
|
||||
NextCluster = 0xFFF;
|
||||
|
||||
UpdateFAT12ClusterEntry(FATTable, CurrentCluster, NextCluster);
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads or writes a block of data from/to the physical device FLASH using a
|
||||
* block buffer stored in RAM, if the requested block is within the virtual
|
||||
* firmware file's sector ranges in the emulated FAT file system.
|
||||
*
|
||||
* \param[in] BlockNumber Physical disk block to read from/write to
|
||||
* \param[in,out] BlockBuffer Pointer to the start of the block buffer in RAM
|
||||
* \param[in] Read If \c true, the requested block is read, if
|
||||
* \c false, the requested block is written
|
||||
*/
|
||||
static void ReadWriteFLASHFileBlock(const uint16_t BlockNumber,
|
||||
uint8_t* BlockBuffer,
|
||||
const bool Read)
|
||||
{
|
||||
uint16_t FileStartBlock = DISK_BLOCK_DataStartBlock + (*FLASHFileStartCluster - 2) * SECTOR_PER_CLUSTER;
|
||||
uint16_t FileEndBlock = FileStartBlock + (FILE_SECTORS(FLASH_FILE_SIZE_BYTES) - 1);
|
||||
|
||||
/* Range check the write request - abort if requested block is not within the
|
||||
* virtual firmware file sector range */
|
||||
if (!((BlockNumber >= FileStartBlock) && (BlockNumber <= FileEndBlock)))
|
||||
return;
|
||||
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
uint32_t FlashAddress = (uint32_t)(BlockNumber - FileStartBlock) * SECTOR_SIZE_BYTES;
|
||||
#else
|
||||
uint16_t FlashAddress = (uint16_t)(BlockNumber - FileStartBlock) * SECTOR_SIZE_BYTES;
|
||||
#endif
|
||||
|
||||
if (Read)
|
||||
{
|
||||
/* Read out the mapped block of data from the device's FLASH */
|
||||
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
|
||||
{
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
BlockBuffer[i] = pgm_read_byte_far(FlashAddress++);
|
||||
#else
|
||||
BlockBuffer[i] = pgm_read_byte(FlashAddress++);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write out the mapped block of data to the device's FLASH */
|
||||
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i += 2)
|
||||
{
|
||||
if ((FlashAddress % SPM_PAGESIZE) == 0)
|
||||
{
|
||||
/* Erase the given FLASH page, ready to be programmed */
|
||||
BootloaderAPI_ErasePage(FlashAddress);
|
||||
}
|
||||
|
||||
/* Write the next data word to the FLASH page */
|
||||
BootloaderAPI_FillWord(FlashAddress, (BlockBuffer[i + 1] << 8) | BlockBuffer[i]);
|
||||
FlashAddress += 2;
|
||||
|
||||
if ((FlashAddress % SPM_PAGESIZE) == 0)
|
||||
{
|
||||
/* Write the filled FLASH page to memory */
|
||||
BootloaderAPI_WritePage(FlashAddress - SPM_PAGESIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads or writes a block of data from/to the physical device EEPROM using a
|
||||
* block buffer stored in RAM, if the requested block is within the virtual
|
||||
* firmware file's sector ranges in the emulated FAT file system.
|
||||
*
|
||||
* \param[in] BlockNumber Physical disk block to read from/write to
|
||||
* \param[in,out] BlockBuffer Pointer to the start of the block buffer in RAM
|
||||
* \param[in] Read If \c true, the requested block is read, if
|
||||
* \c false, the requested block is written
|
||||
*/
|
||||
static void ReadWriteEEPROMFileBlock(const uint16_t BlockNumber,
|
||||
uint8_t* BlockBuffer,
|
||||
const bool Read)
|
||||
{
|
||||
uint16_t FileStartBlock = DISK_BLOCK_DataStartBlock + (*EEPROMFileStartCluster - 2) * SECTOR_PER_CLUSTER;
|
||||
uint16_t FileEndBlock = FileStartBlock + (FILE_SECTORS(EEPROM_FILE_SIZE_BYTES) - 1);
|
||||
|
||||
/* Range check the write request - abort if requested block is not within the
|
||||
* virtual firmware file sector range */
|
||||
if (!((BlockNumber >= FileStartBlock) && (BlockNumber <= FileEndBlock)))
|
||||
return;
|
||||
|
||||
uint16_t EEPROMAddress = (uint16_t)(BlockNumber - FileStartBlock) * SECTOR_SIZE_BYTES;
|
||||
|
||||
if (Read)
|
||||
{
|
||||
/* Read out the mapped block of data from the device's EEPROM */
|
||||
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
|
||||
BlockBuffer[i] = ReadEEPROMByte((uint8_t*)EEPROMAddress++);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write out the mapped block of data to the device's EEPROM */
|
||||
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
|
||||
WriteEEPROMByte((uint8_t*)EEPROMAddress++, BlockBuffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Writes a block of data to the virtual FAT filesystem, from the USB Mass
|
||||
* Storage interface.
|
||||
*
|
||||
* \param[in] BlockNumber Index of the block to write.
|
||||
*/
|
||||
void VirtualFAT_WriteBlock(const uint16_t BlockNumber)
|
||||
{
|
||||
uint8_t BlockBuffer[SECTOR_SIZE_BYTES];
|
||||
|
||||
/* Buffer the entire block to be written from the host */
|
||||
Endpoint_Read_Stream_LE(BlockBuffer, sizeof(BlockBuffer), NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
switch (BlockNumber)
|
||||
{
|
||||
case DISK_BLOCK_BootBlock:
|
||||
case DISK_BLOCK_FATBlock1:
|
||||
case DISK_BLOCK_FATBlock2:
|
||||
/* Ignore writes to the boot and FAT blocks */
|
||||
|
||||
break;
|
||||
|
||||
case DISK_BLOCK_RootFilesBlock:
|
||||
/* Copy over the updated directory entries */
|
||||
memcpy(FirmwareFileEntries, BlockBuffer, sizeof(FirmwareFileEntries));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
ReadWriteFLASHFileBlock(BlockNumber, BlockBuffer, false);
|
||||
ReadWriteEEPROMFileBlock(BlockNumber, BlockBuffer, false);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads a block of data from the virtual FAT filesystem, and sends it to the
|
||||
* host via the USB Mass Storage interface.
|
||||
*
|
||||
* \param[in] BlockNumber Index of the block to read.
|
||||
*/
|
||||
void VirtualFAT_ReadBlock(const uint16_t BlockNumber)
|
||||
{
|
||||
uint8_t BlockBuffer[SECTOR_SIZE_BYTES];
|
||||
memset(BlockBuffer, 0x00, sizeof(BlockBuffer));
|
||||
|
||||
switch (BlockNumber)
|
||||
{
|
||||
case DISK_BLOCK_BootBlock:
|
||||
memcpy(BlockBuffer, &BootBlock, sizeof(FATBootBlock_t));
|
||||
|
||||
/* Add the magic signature to the end of the block */
|
||||
BlockBuffer[SECTOR_SIZE_BYTES - 2] = 0x55;
|
||||
BlockBuffer[SECTOR_SIZE_BYTES - 1] = 0xAA;
|
||||
|
||||
break;
|
||||
|
||||
case DISK_BLOCK_FATBlock1:
|
||||
case DISK_BLOCK_FATBlock2:
|
||||
/* Cluster 0: Media type/Reserved */
|
||||
UpdateFAT12ClusterEntry(BlockBuffer, 0, 0xF00 | BootBlock.MediaDescriptor);
|
||||
|
||||
/* Cluster 1: Reserved */
|
||||
UpdateFAT12ClusterEntry(BlockBuffer, 1, 0xFFF);
|
||||
|
||||
/* Cluster 2 onwards: Cluster chain of FLASH.BIN */
|
||||
UpdateFAT12ClusterChain(BlockBuffer, *FLASHFileStartCluster, FILE_CLUSTERS(FLASH_FILE_SIZE_BYTES));
|
||||
|
||||
/* Cluster 2+n onwards: Cluster chain of EEPROM.BIN */
|
||||
UpdateFAT12ClusterChain(BlockBuffer, *EEPROMFileStartCluster, FILE_CLUSTERS(EEPROM_FILE_SIZE_BYTES));
|
||||
|
||||
break;
|
||||
|
||||
case DISK_BLOCK_RootFilesBlock:
|
||||
memcpy(BlockBuffer, FirmwareFileEntries, sizeof(FirmwareFileEntries));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
ReadWriteFLASHFileBlock(BlockNumber, BlockBuffer, true);
|
||||
ReadWriteEEPROMFileBlock(BlockNumber, BlockBuffer, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* Write the entire read block Buffer to the host */
|
||||
Endpoint_Write_Stream_LE(BlockBuffer, sizeof(BlockBuffer), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
302
Bootloaders/MassStorage/Lib/VirtualFAT.h
Normal file
302
Bootloaders/MassStorage/Lib/VirtualFAT.h
Normal file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _VIRTUALFAT_H_
|
||||
#define _VIRTUALFAT_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "../BootloaderAPI.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Size of the virtual FLASH.BIN file in bytes. */
|
||||
#define FLASH_FILE_SIZE_BYTES (FLASHEND - (FLASHEND - BOOT_START_ADDR) - AUX_BOOT_SECTION_SIZE)
|
||||
|
||||
/** Size of the virtual EEPROM.BIN file in bytes. */
|
||||
#define EEPROM_FILE_SIZE_BYTES E2END
|
||||
|
||||
/** Number of sectors that comprise a single logical disk cluster. */
|
||||
#define SECTOR_PER_CLUSTER 4
|
||||
|
||||
/** Size of a single logical sector on the disk. */
|
||||
#define SECTOR_SIZE_BYTES 512
|
||||
|
||||
/** Size of a logical cluster on the disk, in bytes */
|
||||
#define CLUSTER_SIZE_BYTES (SECTOR_PER_CLUSTER * SECTOR_SIZE_BYTES)
|
||||
|
||||
/** Number of sectors required to store a given size in bytes.
|
||||
*
|
||||
* \param[in] size Size of the data that needs to be stored
|
||||
*
|
||||
* \return Number of sectors required to store the given data on the disk.
|
||||
*/
|
||||
#define FILE_SECTORS(size) ((size / SECTOR_SIZE_BYTES) + ((size % SECTOR_SIZE_BYTES) ? 1 : 0))
|
||||
|
||||
/** Number of clusters required to store a given size in bytes.
|
||||
*
|
||||
* \param[in] size Size of the data that needs to be stored
|
||||
*
|
||||
* \return Number of clusters required to store the given data on the disk.
|
||||
*/
|
||||
#define FILE_CLUSTERS(size) ((size / CLUSTER_SIZE_BYTES) + ((size % CLUSTER_SIZE_BYTES) ? 1 : 0))
|
||||
|
||||
/** Total number of logical sectors/blocks on the disk. */
|
||||
#define LUN_MEDIA_BLOCKS (FILE_SECTORS(FLASH_FILE_SIZE_BYTES) + FILE_SECTORS(EEPROM_FILE_SIZE_BYTES) + 32)
|
||||
|
||||
/** Converts a given time in HH:MM:SS format to a FAT filesystem time.
|
||||
*
|
||||
* \note The minimum seconds resolution of FAT is 2, thus odd seconds
|
||||
* will be truncated to the previous integer multiple of 2 seconds.
|
||||
*
|
||||
* \param[in] hh Hours (0-23)
|
||||
* \param[in] mm Minutes (0-59)
|
||||
* \param[in] ss Seconds (0-59)
|
||||
*
|
||||
* \return Given time encoded as a FAT filesystem timestamp
|
||||
*/
|
||||
#define FAT_TIME(hh, mm, ss) ((hh << 11) | (mm << 5) | (ss >> 1))
|
||||
|
||||
/** Converts a given date in DD/MM/YYYY format to a FAT filesystem date.
|
||||
*
|
||||
* \param[in] dd Days in the month (1-31)
|
||||
* \param[in] mm Months in the year (1-12)
|
||||
* \param[in] yyyy Year (1980 - 2107)
|
||||
*
|
||||
* \return Given date encoded as a FAT filesystem datestamp
|
||||
*/
|
||||
#define FAT_DATE(dd, mm, yyyy) (((yyyy - 1980) << 9) | (mm << 5) | (dd << 0))
|
||||
|
||||
/** Bit-rotates a given 8-bit value once to the right.
|
||||
*
|
||||
* \param x Value to rotate right once
|
||||
*
|
||||
* \return Bit-rotated input value, rotated once to the right.
|
||||
*/
|
||||
#define _ROT8(x) ((((x) & 0xFE) >> 1) | (((x) & 1) ? 0x80 : 0x00))
|
||||
|
||||
/** Computes the LFN entry checksum of a MSDOS 8.3 format file entry,
|
||||
* to associate a LFN entry with its short file entry.
|
||||
*
|
||||
* \param n0 MSDOS Filename character 1
|
||||
* \param n1 MSDOS Filename character 2
|
||||
* \param n2 MSDOS Filename character 3
|
||||
* \param n3 MSDOS Filename character 4
|
||||
* \param n4 MSDOS Filename character 5
|
||||
* \param n5 MSDOS Filename character 6
|
||||
* \param n6 MSDOS Filename character 7
|
||||
* \param n7 MSDOS Filename character 8
|
||||
* \param e0 MSDOS Extension character 1
|
||||
* \param e1 MSDOS Extension character 2
|
||||
* \param e2 MSDOS Extension character 3
|
||||
*
|
||||
* \return LFN checksum of the given MSDOS 8.3 filename.
|
||||
*/
|
||||
#define FAT_CHECKSUM(n0, n1, n2, n3, n4, n5, n6, n7, e0, e1, e2) \
|
||||
(uint8_t)(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(n0)+n1)+n2)+n3)+n4)+n5)+n6)+n7)+e0)+e1)+e2)
|
||||
|
||||
/** \name FAT Filesystem Flags */
|
||||
//@{
|
||||
/** FAT attribute flag to indicate a read-only file. */
|
||||
#define FAT_FLAG_READONLY (1 << 0)
|
||||
|
||||
/** FAT attribute flag to indicate a hidden file. */
|
||||
#define FAT_FLAG_HIDDEN (1 << 1)
|
||||
|
||||
/** FAT attribute flag to indicate a system file. */
|
||||
#define FAT_FLAG_SYSTEM (1 << 2)
|
||||
|
||||
/** FAT attribute flag to indicate a Volume name entry. */
|
||||
#define FAT_FLAG_VOLUME_NAME (1 << 3)
|
||||
|
||||
/** FAT attribute flag to indicate a directory entry. */
|
||||
#define FAT_FLAG_DIRECTORY (1 << 4)
|
||||
|
||||
/** FAT attribute flag to indicate a file ready for archiving. */
|
||||
#define FAT_FLAG_ARCHIVE (1 << 5)
|
||||
|
||||
/** FAT pseudo-attribute flag to indicate a Long File Name entry. */
|
||||
#define FAT_FLAG_LONG_FILE_NAME 0x0F
|
||||
|
||||
/** Ordinal flag marker for FAT Long File Name entries to mark the last entry. */
|
||||
#define FAT_ORDINAL_LAST_ENTRY (1 << 6)
|
||||
//@}
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the Root FAT file entry indexes on the disk. This can be used
|
||||
* to retrieve the current contents of a known directory entry.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
/** Volume ID directory entry, giving the name of the virtual disk. */
|
||||
DISK_FILE_ENTRY_VolumeID = 0,
|
||||
/** Long File Name FAT file entry of the virtual FLASH.BIN image file. */
|
||||
DISK_FILE_ENTRY_FLASH_LFN = 1,
|
||||
/** Legacy MSDOS FAT file entry of the virtual FLASH.BIN image file. */
|
||||
DISK_FILE_ENTRY_FLASH_MSDOS = 2,
|
||||
/** Long File Name FAT file entry of the virtual EEPROM.BIN image file. */
|
||||
DISK_FILE_ENTRY_EEPROM_LFN = 3,
|
||||
/** Legacy MSDOS FAT file entry of the virtual EEPROM.BIN image file. */
|
||||
DISK_FILE_ENTRY_EEPROM_MSDOS = 4,
|
||||
};
|
||||
|
||||
/** Enum for the physical disk blocks of the virtual disk. */
|
||||
enum
|
||||
{
|
||||
/** Boot sector disk block. */
|
||||
DISK_BLOCK_BootBlock = 0,
|
||||
/** First copy of the FAT table block. */
|
||||
DISK_BLOCK_FATBlock1 = 1,
|
||||
/** Second copy of the FAT table block. */
|
||||
DISK_BLOCK_FATBlock2 = 2,
|
||||
/** Root file and directory entries block. */
|
||||
DISK_BLOCK_RootFilesBlock = 3,
|
||||
/** Start block of the disk data section. */
|
||||
DISK_BLOCK_DataStartBlock = 4,
|
||||
};
|
||||
|
||||
/* Type Definitions: */
|
||||
/** FAT boot block structure definition, used to identify the core
|
||||
* parameters of a FAT file system stored on a disk.
|
||||
*
|
||||
* \note This definition is truncated to save space; the magic signature
|
||||
* \c 0xAA55 must be appended to the very end of the block for it
|
||||
* to be detected by the host as a valid boot block.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Bootstrap[3];
|
||||
uint8_t Description[8];
|
||||
uint16_t SectorSize;
|
||||
uint8_t SectorsPerCluster;
|
||||
uint16_t ReservedSectors;
|
||||
uint8_t FATCopies;
|
||||
uint16_t RootDirectoryEntries;
|
||||
uint16_t TotalSectors16;
|
||||
uint8_t MediaDescriptor;
|
||||
uint16_t SectorsPerFAT;
|
||||
uint16_t SectorsPerTrack;
|
||||
uint16_t Heads;
|
||||
uint32_t HiddenSectors;
|
||||
uint32_t TotalSectors32;
|
||||
uint16_t PhysicalDriveNum;
|
||||
uint8_t ExtendedBootRecordSig;
|
||||
uint32_t VolumeSerialNumber;
|
||||
uint8_t VolumeLabel[11];
|
||||
uint8_t FilesystemIdentifier[8];
|
||||
/* uint8_t BootstrapProgram[448]; */
|
||||
/* uint16_t MagicSignature; */
|
||||
} FATBootBlock_t;
|
||||
|
||||
/** FAT directory entry structure, for the various kinds of File and
|
||||
* directory descriptors on a FAT disk.
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
/** VFAT Long File Name file entry. */
|
||||
struct
|
||||
{
|
||||
uint8_t Ordinal;
|
||||
uint16_t Unicode1;
|
||||
uint16_t Unicode2;
|
||||
uint16_t Unicode3;
|
||||
uint16_t Unicode4;
|
||||
uint16_t Unicode5;
|
||||
uint8_t Attribute;
|
||||
uint8_t Reserved1;
|
||||
uint8_t Checksum;
|
||||
uint16_t Unicode6;
|
||||
uint16_t Unicode7;
|
||||
uint16_t Unicode8;
|
||||
uint16_t Unicode9;
|
||||
uint16_t Unicode10;
|
||||
uint16_t Unicode11;
|
||||
uint16_t Reserved2;
|
||||
uint16_t Unicode12;
|
||||
uint16_t Unicode13;
|
||||
} VFAT_LongFileName;
|
||||
|
||||
/** Legacy FAT MSDOS 8.3 file entry. */
|
||||
struct
|
||||
{
|
||||
uint8_t Filename[8];
|
||||
uint8_t Extension[3];
|
||||
uint8_t Attributes;
|
||||
uint8_t Reserved[10];
|
||||
uint16_t CreationTime;
|
||||
uint16_t CreationDate;
|
||||
uint16_t StartingCluster;
|
||||
uint32_t FileSizeBytes;
|
||||
} MSDOS_File;
|
||||
|
||||
/** Legacy FAT MSDOS (sub-)directory entry. */
|
||||
struct
|
||||
{
|
||||
uint8_t Name[11];
|
||||
uint8_t Attributes;
|
||||
uint8_t Reserved[10];
|
||||
uint16_t CreationTime;
|
||||
uint16_t CreationDate;
|
||||
uint16_t StartingCluster;
|
||||
uint32_t Reserved2;
|
||||
} MSDOS_Directory;
|
||||
} FATDirectoryEntry_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(INCLUDE_FROM_VIRTUAL_FAT_C)
|
||||
static uint8_t ReadEEPROMByte(const uint8_t* const Address) ATTR_NEVER_INLINE;
|
||||
|
||||
static void WriteEEPROMByte(uint8_t* const Address,
|
||||
const uint8_t Data) ATTR_NEVER_INLINE;
|
||||
|
||||
static void UpdateFAT12ClusterEntry(uint8_t* const FATTable,
|
||||
const uint16_t Index,
|
||||
const uint16_t ChainEntry) AUX_BOOT_SECTION;
|
||||
|
||||
static void UpdateFAT12ClusterChain(uint8_t* const FATTable,
|
||||
const uint16_t StartIndex,
|
||||
const uint8_t ChainLength) AUX_BOOT_SECTION;
|
||||
|
||||
static void ReadWriteFLASHFileBlock(const uint16_t BlockNumber,
|
||||
uint8_t* BlockBuffer,
|
||||
const bool Read) AUX_BOOT_SECTION;
|
||||
|
||||
static void ReadWriteEEPROMFileBlock(const uint16_t BlockNumber,
|
||||
uint8_t* BlockBuffer,
|
||||
const bool Read) AUX_BOOT_SECTION;
|
||||
#endif
|
||||
|
||||
void VirtualFAT_WriteBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
|
||||
void VirtualFAT_ReadBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
|
||||
|
||||
#endif
|
||||
154
Bootloaders/MassStorage/asf.xml
Normal file
154
Bootloaders/MassStorage/asf.xml
Normal file
@@ -0,0 +1,154 @@
|
||||
<asf xmlversion="1.0">
|
||||
<project caption="Mass Storage Bootloader - 128KB FLASH / 8KB Boot - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.128_8" force-caption="true" workspace-name="lufa_ms_128kb_8kb_">
|
||||
<require idref="lufa.bootloaders.mass_storage"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb1287"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1E000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1E000"/>
|
||||
|
||||
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="0"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="Mass Storage Bootloader - 64KB FLASH / 8KB Boot - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.64_8" force-caption="true" workspace-name="lufa_ms_64kb_8kb_">
|
||||
<require idref="lufa.bootloaders.mass_storage"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb647"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0xE000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0xE000"/>
|
||||
|
||||
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="0"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="Mass Storage Bootloader - 32KB FLASH / 4KB Boot (2KB AUX) - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.32_4" force-caption="true" workspace-name="lufa_ms_32kb_4kb_">
|
||||
<require idref="lufa.bootloaders.mass_storage"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega32u4"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
|
||||
|
||||
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="2048"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux=0x6810"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux_trampoline=0x6800"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=Boot_AUX_Trampoline"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="Mass Storage Bootloader - 16KB FLASH / 4KB Boot (2KB AUX) - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.16_4" force-caption="true" workspace-name="lufa_ms_16kb_4kb_">
|
||||
<require idref="lufa.bootloaders.mass_storage"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega16u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
|
||||
|
||||
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="2048"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux=0x2810"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux_trampoline=0x2800"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=Boot_AUX_Trampoline"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<module type="application" id="lufa.bootloaders.mass_storage" caption="Mass Storage Bootloader">
|
||||
<info type="description" value="summary">
|
||||
Mass Storage Class Bootloader, capable of reprogramming a device via binary BIN files copied to the virtual FAT12 file-system it creates when plugged into a host.
|
||||
</info>
|
||||
|
||||
<info type="gui-flag" value="move-to-root"/>
|
||||
|
||||
<info type="keyword" value="Technology">
|
||||
<keyword value="Bootloaders"/>
|
||||
<keyword value="USB Device"/>
|
||||
</info>
|
||||
|
||||
<device-support-alias value="lufa_avr8"/>
|
||||
<device-support-alias value="lufa_xmega"/>
|
||||
<device-support-alias value="lufa_uc3"/>
|
||||
|
||||
<build type="include-path" value="."/>
|
||||
<build type="c-source" value="BootloaderMassStorage.c"/>
|
||||
<build type="header-file" value="BootloaderMassStorage.h"/>
|
||||
<build type="c-source" value="Descriptors.c"/>
|
||||
<build type="header-file" value="Descriptors.h"/>
|
||||
<build type="c-source" value="BootloaderAPI.c"/>
|
||||
<build type="header-file" value="BootloaderAPI.h"/>
|
||||
<build type="asm-source" value="BootloaderAPITable.S"/>
|
||||
|
||||
<build type="module-config" subtype="path" value="Config"/>
|
||||
<build type="header-file" value="Config/LUFAConfig.h"/>
|
||||
|
||||
<build type="include-path" value="Lib"/>
|
||||
<build type="header-file" value="Lib/VirtualFAT.h"/>
|
||||
<build type="c-source" value="Lib/VirtualFAT.c"/>
|
||||
<build type="header-file" value="Lib/SCSI.h"/>
|
||||
<build type="c-source" value="Lib/SCSI.c"/>
|
||||
|
||||
<build type="distribute" subtype="user-file" value="BootloaderMassStorage.txt"/>
|
||||
|
||||
<require idref="lufa.common"/>
|
||||
<require idref="lufa.platform"/>
|
||||
<require idref="lufa.drivers.usb"/>
|
||||
<require idref="lufa.drivers.board"/>
|
||||
<require idref="lufa.drivers.board.leds"/>
|
||||
</module>
|
||||
</asf>
|
||||
68
Bootloaders/MassStorage/makefile
Normal file
68
Bootloaders/MassStorage/makefile
Normal file
@@ -0,0 +1,68 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU = at90usb1287
|
||||
ARCH = AVR8
|
||||
BOARD = USBKEY
|
||||
F_CPU = 8000000
|
||||
F_USB = $(F_CPU)
|
||||
OPTIMIZATION = s
|
||||
TARGET = BootloaderMassStorage
|
||||
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S Lib/SCSI.c Lib/VirtualFAT.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
|
||||
LUFA_PATH = ../../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
|
||||
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
|
||||
|
||||
# Flash size and bootloader section sizes of the target, in KB. These must
|
||||
# match the target's total FLASH size and the bootloader size set in the
|
||||
# device's fuses.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 8
|
||||
|
||||
# Bootloader address calculation formulas
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Check if the bootloader needs an AUX section, located before the real bootloader section to store some of the
|
||||
# bootloader code. This is required for 32KB and smaller devices, where the actual bootloader is 6KB but the maximum
|
||||
# bootloader section size is 4KB. The actual usable application space will be reduced by 6KB for these devices.
|
||||
ifeq ($(BOOT_SECTION_SIZE_KB),8)
|
||||
CC_FLAGS += -DAUX_BOOT_SECTION_SIZE=0
|
||||
else
|
||||
AUX_BOOT_SECTION_SIZE_KB = (6 - $(BOOT_SECTION_SIZE_KB))
|
||||
|
||||
CC_FLAGS += -DAUX_BOOT_SECTION_SIZE='($(AUX_BOOT_SECTION_SIZE_KB) * 1024)'
|
||||
LD_FLAGS += -Wl,--section-start=.boot_aux=$(call BOOT_SEC_OFFSET, (($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024 - 16))
|
||||
LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .boot_aux_trampoline, Boot_AUX_Trampoline, ($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024)
|
||||
endif
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
include $(LUFA_PATH)/Build/lufa_doxygen.mk
|
||||
include $(LUFA_PATH)/Build/lufa_avrdude.mk
|
||||
include $(LUFA_PATH)/Build/lufa_atprogram.mk
|
||||
75
Bootloaders/Printer/BootloaderAPI.c
Normal file
75
Bootloaders/Printer/BootloaderAPI.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
56
Bootloaders/Printer/BootloaderAPI.h
Normal file
56
Bootloaders/Printer/BootloaderAPI.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Function Prototypes: */
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
91
Bootloaders/Printer/BootloaderAPITable.S
Normal file
91
Bootloaders/Printer/BootloaderAPITable.S
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
; Trampolines to actual API implementations if the target address is outside the
|
||||
; range of a rjmp instruction (can happen with large bootloader sections)
|
||||
.section .apitable_trampolines, "ax"
|
||||
.global BootloaderAPI_Trampolines
|
||||
BootloaderAPI_Trampolines:
|
||||
|
||||
BootloaderAPI_ErasePage_Trampoline:
|
||||
jmp BootloaderAPI_ErasePage
|
||||
BootloaderAPI_WritePage_Trampoline:
|
||||
jmp BootloaderAPI_WritePage
|
||||
BootloaderAPI_FillWord_Trampoline:
|
||||
jmp BootloaderAPI_FillWord
|
||||
BootloaderAPI_ReadSignature_Trampoline:
|
||||
jmp BootloaderAPI_ReadSignature
|
||||
BootloaderAPI_ReadFuse_Trampoline:
|
||||
jmp BootloaderAPI_ReadFuse
|
||||
BootloaderAPI_ReadLock_Trampoline:
|
||||
jmp BootloaderAPI_ReadLock
|
||||
BootloaderAPI_WriteLock_Trampoline:
|
||||
jmp BootloaderAPI_WriteLock
|
||||
BootloaderAPI_UNUSED1:
|
||||
ret
|
||||
BootloaderAPI_UNUSED2:
|
||||
ret
|
||||
BootloaderAPI_UNUSED3:
|
||||
ret
|
||||
BootloaderAPI_UNUSED4:
|
||||
ret
|
||||
BootloaderAPI_UNUSED5:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; API function jump table
|
||||
.section .apitable_jumptable, "ax"
|
||||
.global BootloaderAPI_JumpTable
|
||||
BootloaderAPI_JumpTable:
|
||||
|
||||
rjmp BootloaderAPI_ErasePage_Trampoline
|
||||
rjmp BootloaderAPI_WritePage_Trampoline
|
||||
rjmp BootloaderAPI_FillWord_Trampoline
|
||||
rjmp BootloaderAPI_ReadSignature_Trampoline
|
||||
rjmp BootloaderAPI_ReadFuse_Trampoline
|
||||
rjmp BootloaderAPI_ReadLock_Trampoline
|
||||
rjmp BootloaderAPI_WriteLock_Trampoline
|
||||
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
|
||||
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
|
||||
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
|
||||
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
|
||||
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
|
||||
|
||||
|
||||
|
||||
; Bootloader table signatures and information
|
||||
.section .apitable_signatures, "ax"
|
||||
.global BootloaderAPI_Signatures
|
||||
BootloaderAPI_Signatures:
|
||||
|
||||
.long BOOT_START_ADDR ; Start address of the bootloader
|
||||
.word 0xDF20 ; Signature for the Printer class bootloader
|
||||
.word 0xDCFB ; Signature for a LUFA class bootloader
|
||||
431
Bootloaders/Printer/BootloaderPrinter.c
Normal file
431
Bootloaders/Printer/BootloaderPrinter.c
Normal file
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the Printer class bootloader. This file contains the complete bootloader logic.
|
||||
*/
|
||||
|
||||
#include "BootloaderPrinter.h"
|
||||
|
||||
/** LUFA Printer Class driver interface configuration and state information. This structure is
|
||||
* passed to all Printer Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_PRNT_Device_t TextOnly_Printer_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = 0,
|
||||
.DataINEndpoint =
|
||||
{
|
||||
.Address = PRINTER_IN_EPADDR,
|
||||
.Size = PRINTER_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.DataOUTEndpoint =
|
||||
{
|
||||
.Address = PRINTER_OUT_EPADDR,
|
||||
.Size = PRINTER_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.IEEE1284String =
|
||||
"MFG:Generic;"
|
||||
"MDL:Generic_/_Text_Only;"
|
||||
"CMD:1284.4;"
|
||||
"CLS:PRINTER",
|
||||
},
|
||||
};
|
||||
|
||||
/** Intel HEX parser state machine state information, to track the contents of
|
||||
* a HEX file streamed in as a sequence of arbitrary bytes.
|
||||
*/
|
||||
struct
|
||||
{
|
||||
/** Current HEX parser state machine state. */
|
||||
uint8_t ParserState;
|
||||
/** Previously decoded numerical byte of data. */
|
||||
uint8_t PrevData;
|
||||
/** Currently decoded numerical byte of data. */
|
||||
uint8_t Data;
|
||||
/** Indicates if both bytes that correspond to a single decoded numerical
|
||||
* byte of data (HEX encodes values in ASCII HEX, two characters per byte)
|
||||
* have been read.
|
||||
*/
|
||||
bool ReadMSB;
|
||||
/** Intel HEX record type of the current Intel HEX record. */
|
||||
uint8_t RecordType;
|
||||
/** Numerical bytes of data remaining to be read in the current record. */
|
||||
uint8_t DataRem;
|
||||
/** Checksum of the current record received so far. */
|
||||
uint8_t Checksum;
|
||||
/** Starting address of the last addressed FLASH page. */
|
||||
uint32_t PageStartAddress;
|
||||
/** Current 32-bit byte extended base address in FLASH being targeted. */
|
||||
uint32_t CurrBaseAddress;
|
||||
/** Current 32-bit byte address in FLASH being targeted. */
|
||||
uint32_t CurrAddress;
|
||||
} HEXParser;
|
||||
|
||||
/** Indicates if there is data waiting to be written to a physical page of
|
||||
* memory in FLASH.
|
||||
*/
|
||||
static bool PageDirty = false;
|
||||
|
||||
/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run
|
||||
* via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application
|
||||
* started via a forced watchdog reset.
|
||||
*/
|
||||
static bool RunBootloader = true;
|
||||
|
||||
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
|
||||
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
|
||||
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
|
||||
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
|
||||
*/
|
||||
uint16_t MagicBootKey ATTR_NO_INIT;
|
||||
|
||||
|
||||
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
|
||||
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
|
||||
* this will force the user application to start via a software jump.
|
||||
*/
|
||||
void Application_Jump_Check(void)
|
||||
{
|
||||
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
||||
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||
{
|
||||
MagicBootKey = 0;
|
||||
|
||||
// cppcheck-suppress constStatement
|
||||
((void (*)(void))0x0000)();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given input byte of data from an ASCII encoded HEX value to an integer value.
|
||||
*
|
||||
* \note Input HEX bytes are expected to be in uppercase only.
|
||||
*
|
||||
* \param[in] Byte ASCII byte of data to convert
|
||||
*
|
||||
* \return Integer converted value of the input ASCII encoded HEX byte of data, or -1 if the
|
||||
* input is not valid ASCII encoded HEX.
|
||||
*/
|
||||
static int8_t HexToDecimal(const char Byte)
|
||||
{
|
||||
if ((Byte >= 'A') && (Byte <= 'F'))
|
||||
return (10 + (Byte - 'A'));
|
||||
else if ((Byte >= '0') && (Byte <= '9'))
|
||||
return (Byte - '0');
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes a partially written page of data to physical FLASH, if a page
|
||||
* boundary has been crossed.
|
||||
*
|
||||
* \note If a page flush occurs the global HEX parser state is updated.
|
||||
*/
|
||||
static void FlushPageIfRequired(void)
|
||||
{
|
||||
/* Abort if no data has been buffered for writing to the current page */
|
||||
if (!PageDirty)
|
||||
return;
|
||||
|
||||
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
|
||||
uint32_t NewPageStartAddress = (HEXParser.CurrAddress & ~(SPM_PAGESIZE - 1));
|
||||
if (HEXParser.PageStartAddress != NewPageStartAddress)
|
||||
{
|
||||
boot_page_write(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
HEXParser.PageStartAddress = NewPageStartAddress;
|
||||
|
||||
PageDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an input Intel HEX formatted stream one character at a time, loading
|
||||
* the data contents into the device's internal FLASH memory.
|
||||
*
|
||||
* \param[in] ReadCharacter Next input ASCII byte of data to parse
|
||||
*/
|
||||
static void ParseIntelHEXByte(const char ReadCharacter)
|
||||
{
|
||||
/* Reset the line parser while waiting for a new line to start */
|
||||
if ((HEXParser.ParserState == HEX_PARSE_STATE_WAIT_LINE) || (ReadCharacter == ':'))
|
||||
{
|
||||
HEXParser.Checksum = 0;
|
||||
HEXParser.CurrAddress = HEXParser.CurrBaseAddress;
|
||||
HEXParser.ReadMSB = false;
|
||||
|
||||
/* ASCII ':' indicates the start of a new HEX record */
|
||||
if (ReadCharacter == ':')
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_BYTE_COUNT;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Only allow ASCII HEX encoded digits, ignore all other characters */
|
||||
int8_t ReadCharacterDec = HexToDecimal(ReadCharacter);
|
||||
if (ReadCharacterDec < 0)
|
||||
return;
|
||||
|
||||
/* Read and convert the next nibble of data from the current character */
|
||||
HEXParser.Data = (HEXParser.Data << 4) | ReadCharacterDec;
|
||||
HEXParser.ReadMSB = !HEXParser.ReadMSB;
|
||||
|
||||
/* Only process further when a full byte (two nibbles) have been read */
|
||||
if (HEXParser.ReadMSB)
|
||||
return;
|
||||
|
||||
/* Intel HEX checksum is for all fields except starting character and the
|
||||
* checksum itself
|
||||
*/
|
||||
if (HEXParser.ParserState != HEX_PARSE_STATE_CHECKSUM)
|
||||
HEXParser.Checksum += HEXParser.Data;
|
||||
|
||||
switch (HEXParser.ParserState)
|
||||
{
|
||||
case HEX_PARSE_STATE_BYTE_COUNT:
|
||||
HEXParser.DataRem = HEXParser.Data;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_HIGH;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_ADDRESS_HIGH:
|
||||
HEXParser.CurrAddress += ((uint16_t)HEXParser.Data << 8);
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_LOW;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_ADDRESS_LOW:
|
||||
HEXParser.CurrAddress += HEXParser.Data;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_RECORD_TYPE;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_RECORD_TYPE:
|
||||
HEXParser.RecordType = HEXParser.Data;
|
||||
HEXParser.ParserState = (HEXParser.DataRem ? HEX_PARSE_STATE_READ_DATA : HEX_PARSE_STATE_CHECKSUM);
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_READ_DATA:
|
||||
/* Track the number of read data bytes in the record */
|
||||
HEXParser.DataRem--;
|
||||
|
||||
/* Protect the bootloader against being written to */
|
||||
if (HEXParser.CurrAddress >= BOOT_START_ADDR)
|
||||
{
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
PageDirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wait for a machine word (two bytes) of data to be read */
|
||||
if (HEXParser.DataRem & 0x01)
|
||||
{
|
||||
HEXParser.PrevData = HEXParser.Data;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Convert the last two received data bytes into a 16-bit word */
|
||||
uint16_t NewDataWord = ((uint16_t)HEXParser.Data << 8) | HEXParser.PrevData;
|
||||
|
||||
switch (HEXParser.RecordType)
|
||||
{
|
||||
case HEX_RECORD_TYPE_Data:
|
||||
/* If we are writing to a new page, we need to erase it first */
|
||||
if (!(PageDirty))
|
||||
{
|
||||
boot_page_erase(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
PageDirty = true;
|
||||
}
|
||||
|
||||
/* Fill the FLASH memory buffer with the new word of data */
|
||||
boot_page_fill(HEXParser.CurrAddress, NewDataWord);
|
||||
HEXParser.CurrAddress += 2;
|
||||
|
||||
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
|
||||
FlushPageIfRequired();
|
||||
break;
|
||||
|
||||
case HEX_RECORD_TYPE_ExtendedSegmentAddress:
|
||||
/* Extended address data - store the upper 12-bits of the new address */
|
||||
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 4);
|
||||
break;
|
||||
|
||||
case HEX_RECORD_TYPE_ExtendedLinearAddress:
|
||||
/* Extended address data - store the upper 16-bits of the new address */
|
||||
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 16);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!HEXParser.DataRem)
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_CHECKSUM;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_CHECKSUM:
|
||||
/* Verify checksum of the completed record */
|
||||
if (HEXParser.Data != ((~HEXParser.Checksum + 1) & 0xFF))
|
||||
break;
|
||||
|
||||
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
|
||||
FlushPageIfRequired();
|
||||
|
||||
/* If end of the HEX file reached, the bootloader should exit at next opportunity */
|
||||
if (HEXParser.RecordType == HEX_RECORD_TYPE_EndOfFile)
|
||||
RunBootloader = false;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
GlobalInterruptEnable();
|
||||
|
||||
while (RunBootloader)
|
||||
{
|
||||
uint8_t BytesReceived = PRNT_Device_BytesReceived(&TextOnly_Printer_Interface);
|
||||
|
||||
if (BytesReceived)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
while (BytesReceived--)
|
||||
{
|
||||
int16_t ReceivedByte = PRNT_Device_ReceiveByte(&TextOnly_Printer_Interface);
|
||||
|
||||
/* Feed the next byte of data to the HEX parser */
|
||||
ParseIntelHEXByte(ReceivedByte);
|
||||
}
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
|
||||
PRNT_Device_USBTask(&TextOnly_Printer_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
||||
/* Disconnect from the host - USB interface will be reset later along with the AVR */
|
||||
USB_Detach();
|
||||
|
||||
/* Unlock the forced application start mode of the bootloader if it is restarted */
|
||||
MagicBootKey = MAGIC_BOOT_KEY;
|
||||
|
||||
/* Enable the watchdog and force a timeout to reset the AVR */
|
||||
wdt_enable(WDTO_250MS);
|
||||
|
||||
for (;;);
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Relocate the interrupt vector table to the bootloader section */
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
|
||||
ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
{
|
||||
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs and stops the Printer management task.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
||||
* of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started.
|
||||
*/
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
bool ConfigSuccess = true;
|
||||
|
||||
/* Setup Printer Data Endpoints */
|
||||
ConfigSuccess &= PRNT_Device_ConfigureEndpoints(&TextOnly_Printer_Interface);
|
||||
|
||||
/* Reset the HEX parser upon successful connection to a host */
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
|
||||
* the device from the USB host before passing along unhandled control requests to the library for processing
|
||||
* internally.
|
||||
*/
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
PRNT_Device_ProcessControlRequest(&TextOnly_Printer_Interface);
|
||||
}
|
||||
108
Bootloaders/Printer/BootloaderPrinter.h
Normal file
108
Bootloaders/Printer/BootloaderPrinter.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderPrinter.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_PRINTER_H_
|
||||
#define _BOOTLOADER_PRINTER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__OPTIMIZE_SIZE__)
|
||||
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
|
||||
#endif
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/** Magic bootloader key to unlock forced application start mode. */
|
||||
#define MAGIC_BOOT_KEY 0xDC42
|
||||
|
||||
/* Enums: */
|
||||
/** Intel HEX parser state machine states. */
|
||||
enum HEX_Parser_States_t
|
||||
{
|
||||
HEX_PARSE_STATE_WAIT_LINE, /**< Parser is waiting for a HEX Start of Line character. */
|
||||
HEX_PARSE_STATE_BYTE_COUNT, /**< Parser is waiting for a record byte count. */
|
||||
HEX_PARSE_STATE_ADDRESS_HIGH, /**< Parser is waiting for the MSB of a record address. */
|
||||
HEX_PARSE_STATE_ADDRESS_LOW, /**< Parser is waiting for the LSB of a record address. */
|
||||
HEX_PARSE_STATE_RECORD_TYPE, /**< Parser is waiting for the record type. */
|
||||
HEX_PARSE_STATE_READ_DATA, /**< Parser is waiting for more data in the current record. */
|
||||
HEX_PARSE_STATE_CHECKSUM, /**< Parser is waiting for the checksum of the current record. */
|
||||
};
|
||||
|
||||
/** Intel HEX record types, used to indicate the type of record contained in a line of a HEX file. */
|
||||
enum HEX_Record_Types_t
|
||||
{
|
||||
HEX_RECORD_TYPE_Data = 0, /**< Record contains loadable data. */
|
||||
HEX_RECORD_TYPE_EndOfFile = 1, /**< End of file record. */
|
||||
HEX_RECORD_TYPE_ExtendedSegmentAddress = 2, /**< Extended segment start record. */
|
||||
HEX_RECORD_TYPE_StartSegmentAddress = 3, /**< Normal segment start record. */
|
||||
HEX_RECORD_TYPE_ExtendedLinearAddress = 4, /**< Extended linear address start record. */
|
||||
HEX_RECORD_TYPE_StartLinearAddress = 5, /**< Linear address start record. */
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
static void SetupHardware(void);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
|
||||
#endif
|
||||
|
||||
184
Bootloaders/Printer/BootloaderPrinter.txt
Normal file
184
Bootloaders/Printer/BootloaderPrinter.txt
Normal file
@@ -0,0 +1,184 @@
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Printer Class USB AVR Bootloader
|
||||
*
|
||||
* \section Sec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Printer Class</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Printer Subclass</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Printer Class Standard</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section Sec_Description Project Description:
|
||||
*
|
||||
* This bootloader enumerates to the host as a Generic Text Only Printer device, capable of reading and parsing
|
||||
* "printed" plain-text Intel HEX files to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
* This bootloader uses the Generic Text-Only printer drivers inbuilt into all modern operating systems, thus no
|
||||
* additional drivers need to be supplied for correct operation.
|
||||
*
|
||||
* \section Sec_HostApp Host Controller Application
|
||||
*
|
||||
* This bootloader is compatible with Notepad under Windows, and the command line \c lpr utility under Linux.
|
||||
*
|
||||
* \subsection SSec_Notepad Notepad (Windows)
|
||||
*
|
||||
* While most text applications under Windows will be compatible with the bootloader, the inbuilt Notepad utility
|
||||
* is recommended as it will introduce minimal formatting changes to the output stream. To program with Notepad,
|
||||
* open the target HEX file and print it to the Generic Text Only printer device the bootloader creates.
|
||||
*
|
||||
* \subsection SSec_LPR LPR (Linux)
|
||||
*
|
||||
* While the CUPS framework under Linux will enumerate the bootloader as a Generic Text-Only printer, many
|
||||
* applications will refuse to print to the device due to the lack of rich formatting options available. As a result,
|
||||
* under Linux HEX files must be printed via the low level \c lpr utility instead.
|
||||
*
|
||||
* \code
|
||||
* cat Mouse.hex | lpr
|
||||
* \endcode
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_PRINTER_SIGNATURE 0xDF20
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
|
||||
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
|
||||
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
|
||||
* to the value \c BOOTLOADER_PRINTER_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
|
||||
* memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
*
|
||||
* \section Sec_KnownIssues Known Issues:
|
||||
*
|
||||
* \par On Linux machines, new firmware fails to be sent to the device via CUPS.
|
||||
* Only a limited subset of normal printer functionality is exposed via the
|
||||
* bootloader, causing CUPS to reject print requests from applications that
|
||||
* are unable to handle true plain-text printing. For best results, the low
|
||||
* level \c lpr command should be used to print new firmware to the bootloader.
|
||||
*
|
||||
* \par After loading an application, it is not run automatically on startup.
|
||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
||||
* when needed.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
93
Bootloaders/Printer/Config/LUFAConfig.h
Normal file
93
Bootloaders/Printer/Config/LUFAConfig.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Library Configuration Header File
|
||||
*
|
||||
* This header file is used to configure LUFA's compile time options,
|
||||
* as an alternative to the compile time constants supplied through
|
||||
* a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the LUFA
|
||||
* manual section "Summary of Compile Tokens".
|
||||
*/
|
||||
|
||||
#ifndef _LUFA_CONFIG_H_
|
||||
#define _LUFA_CONFIG_H_
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
|
||||
/* Non-USB Related Configuration Tokens: */
|
||||
// #define DISABLE_TERMINAL_CODES
|
||||
|
||||
/* USB Class Driver Related Tokens: */
|
||||
// #define HID_HOST_BOOT_PROTOCOL_ONLY
|
||||
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_MAX_COLLECTIONS {Insert Value Here}
|
||||
// #define HID_MAX_REPORTITEMS {Insert Value Here}
|
||||
// #define HID_MAX_REPORT_IDS {Insert Value Here}
|
||||
// #define NO_CLASS_DRIVER_AUTOFLUSH
|
||||
|
||||
/* General USB Driver Related Tokens: */
|
||||
#define ORDERED_EP_CONFIG
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
#define USB_DEVICE_ONLY
|
||||
// #define USB_HOST_ONLY
|
||||
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
|
||||
// #define NO_LIMITED_CONTROLLER_CONNECT
|
||||
#define NO_SOF_EVENTS
|
||||
|
||||
/* USB Device Mode Driver Related Tokens: */
|
||||
#define USE_RAM_DESCRIPTORS
|
||||
// #define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
#define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
#define DEVICE_STATE_AS_GPIOR 0
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
// #define CONTROL_ONLY_DEVICE
|
||||
// #define INTERRUPT_CONTROL_ENDPOINT
|
||||
#define NO_DEVICE_REMOTE_WAKEUP
|
||||
#define NO_DEVICE_SELF_POWER
|
||||
|
||||
/* USB Host Mode Driver Related Tokens: */
|
||||
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
|
||||
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
|
||||
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
|
||||
// #define NO_AUTO_VBUS_MANAGEMENT
|
||||
// #define INVERTED_VBUS_ENABLE_LINE
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported architecture for this LUFA configuration file.
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -37,39 +37,40 @@
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = USB_CSCP_VendorSpecificClass,
|
||||
.Class = USB_CSCP_NoDeviceClass,
|
||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2104,
|
||||
.ReleaseNumber = VERSION_BCD(02.00),
|
||||
.ProductID = 0x206B,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = 0x03,
|
||||
.ManufacturerStrIndex = STRING_ID_Manufacturer,
|
||||
.ProductStrIndex = STRING_ID_Product,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
/** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
@@ -81,12 +82,12 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.AVRISP_Interface =
|
||||
.Printer_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
@@ -95,39 +96,39 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = USB_CSCP_VendorSpecificClass,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
.Class = PRNT_CSCP_PrinterClass,
|
||||
.SubClass = PRNT_CSCP_PrinterSubclass,
|
||||
.Protocol = PRNT_CSCP_BidirectionalProtocol,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.AVRISP_DataInEndpoint =
|
||||
.Printer_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DIR_IN | AVRISP_DATA_IN_EPNUM),
|
||||
.EndpointAddress = PRINTER_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = AVRISP_DATA_EPSIZE,
|
||||
.PollingIntervalMS = 0x0A
|
||||
.EndpointSize = PRINTER_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
|
||||
.AVRISP_DataOutEndpoint =
|
||||
.Printer_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DIR_OUT | AVRISP_DATA_OUT_EPNUM),
|
||||
.EndpointAddress = PRINTER_OUT_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = AVRISP_DATA_EPSIZE,
|
||||
.PollingIntervalMS = 0x0A
|
||||
},
|
||||
.EndpointSize = PRINTER_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
/** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
const USB_Descriptor_String_t LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
@@ -138,7 +139,7 @@ const USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
const USB_Descriptor_String_t ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
@@ -149,21 +150,11 @@ const USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM ProductString =
|
||||
const USB_Descriptor_String_t ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
|
||||
.Header = {.Size = USB_STRING_LEN(23), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"LUFA AVRISP MkII Clone"
|
||||
};
|
||||
|
||||
/** Serial number string. This is a Unicode string containing the device's unique serial number, expressed as a
|
||||
* series of uppercase hexadecimal digits.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM SerialString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"0000A00128255"
|
||||
.UnicodeString = L"LUFA Printer Bootloader"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
@@ -195,21 +186,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case STRING_ID_Language:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
Size = LanguageString.Header.Size;
|
||||
break;
|
||||
case 0x01:
|
||||
case STRING_ID_Manufacturer:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
Size = ManufacturerString.Header.Size;
|
||||
break;
|
||||
case 0x02:
|
||||
case STRING_ID_Product:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
case 0x03:
|
||||
Address = &SerialString;
|
||||
Size = pgm_read_byte(&SerialString.Header.Size);
|
||||
Size = ProductString.Header.Size;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -37,34 +37,19 @@
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the CDC device-to-host notification IN endpoint. */
|
||||
#define CDC_NOTIFICATION_EPNUM 5
|
||||
/** Endpoint address of the Printer device-to-host data IN endpoint. */
|
||||
#define PRINTER_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Endpoint number of the CDC device-to-host data IN endpoint. */
|
||||
#define CDC_TX_EPNUM 1
|
||||
/** Endpoint address of the Printer host-to-device data OUT endpoint. */
|
||||
#define PRINTER_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
|
||||
/** Endpoint number of the CDC host-to-device data OUT endpoint. */
|
||||
#define CDC_RX_EPNUM 2
|
||||
|
||||
/** Size in bytes of the CDC device-to-host notification IN endpoint. */
|
||||
#define CDC_NOTIFICATION_EPSIZE 8
|
||||
|
||||
/** Size in bytes of the CDC data IN and OUT endpoints. */
|
||||
#define CDC_TXRX_EPSIZE 16
|
||||
|
||||
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
||||
#define MASS_STORAGE_IN_EPNUM 3
|
||||
|
||||
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
||||
#define MASS_STORAGE_OUT_EPNUM 4
|
||||
|
||||
/** Size in bytes of the Mass Storage data endpoints. */
|
||||
#define MASS_STORAGE_IO_EPSIZE 64
|
||||
/** Size in bytes of the Printer data endpoints. */
|
||||
#define PRINTER_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
@@ -73,14 +58,25 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Mass Storage Interface
|
||||
USB_Descriptor_Interface_t MS_Interface;
|
||||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Printer Interface
|
||||
USB_Descriptor_Interface_t Printer_Interface;
|
||||
USB_Descriptor_Endpoint_t Printer_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t Printer_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
|
||||
* have a unique ID index associated with it, which can be used to refer to the string from
|
||||
* other descriptors.
|
||||
*/
|
||||
enum StringDescriptors_t
|
||||
{
|
||||
STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
|
||||
STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
|
||||
STRING_ID_Product = 2, /**< Product string ID */
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
1919
Bootloaders/Printer/Doxygen.conf
Normal file
1919
Bootloaders/Printer/Doxygen.conf
Normal file
File diff suppressed because it is too large
Load Diff
158
Bootloaders/Printer/asf.xml
Normal file
158
Bootloaders/Printer/asf.xml
Normal file
@@ -0,0 +1,158 @@
|
||||
<asf xmlversion="1.0">
|
||||
<project caption="Printer Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.128_4" force-caption="true" workspace-name="lufa_printer_128kb_4kb_">
|
||||
<require idref="lufa.bootloaders.printer"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb1287"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="Printer Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.64_4" force-caption="true" workspace-name="lufa_printer_64kb_4kb_">
|
||||
<require idref="lufa.bootloaders.printer"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="at90usb647"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="Printer Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.32_4" force-caption="true" workspace-name="lufa_printer_32kb_4kb_">
|
||||
<require idref="lufa.bootloaders.printer"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega32u4"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="Printer Bootloader - 16KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.16_4" force-caption="true" workspace-name="lufa_printer_16kb_4kb_">
|
||||
<require idref="lufa.bootloaders.printer"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega16u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<project caption="Printer Bootloader - 8KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.8_4" force-caption="true" workspace-name="lufa_printer_8kb_4kb_">
|
||||
<require idref="lufa.bootloaders.printer"/>
|
||||
<require idref="lufa.boards.dummy.avr8"/>
|
||||
<generator value="as5_8"/>
|
||||
|
||||
<device-support value="atmega8u2"/>
|
||||
<config name="lufa.drivers.board.name" value="none"/>
|
||||
|
||||
<config name="config.compiler.optimization.level" value="size"/>
|
||||
|
||||
<build type="define" name="F_CPU" value="16000000UL"/>
|
||||
<build type="define" name="F_USB" value="16000000UL"/>
|
||||
|
||||
<build type="define" name="BOOT_START_ADDR" value="0x1000"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1000"/>
|
||||
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FA0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FE0"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
|
||||
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FF8"/>
|
||||
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
|
||||
</project>
|
||||
|
||||
<module type="application" id="lufa.bootloaders.printer" caption="Printer Bootloader">
|
||||
<info type="description" value="summary">
|
||||
Printer Class Bootloader, capable of reprogramming a device by "printing" new HEX files to the virtual Plain-Text printer it creates when plugged into a host.
|
||||
</info>
|
||||
|
||||
<info type="gui-flag" value="move-to-root"/>
|
||||
|
||||
<info type="keyword" value="Technology">
|
||||
<keyword value="Bootloaders"/>
|
||||
<keyword value="USB Device"/>
|
||||
</info>
|
||||
|
||||
<device-support-alias value="lufa_avr8"/>
|
||||
<device-support-alias value="lufa_xmega"/>
|
||||
<device-support-alias value="lufa_uc3"/>
|
||||
|
||||
<build type="include-path" value="."/>
|
||||
<build type="c-source" value="BootloaderPrinter.c"/>
|
||||
<build type="header-file" value="BootloaderPrinter.h"/>
|
||||
<build type="c-source" value="Descriptors.c"/>
|
||||
<build type="header-file" value="Descriptors.h"/>
|
||||
<build type="c-source" value="BootloaderAPI.c"/>
|
||||
<build type="header-file" value="BootloaderAPI.h"/>
|
||||
<build type="asm-source" value="BootloaderAPITable.S"/>
|
||||
|
||||
<build type="module-config" subtype="path" value="Config"/>
|
||||
<build type="header-file" value="Config/LUFAConfig.h"/>
|
||||
|
||||
<build type="distribute" subtype="user-file" value="BootloaderPrinter.txt"/>
|
||||
|
||||
<require idref="lufa.common"/>
|
||||
<require idref="lufa.platform"/>
|
||||
<require idref="lufa.drivers.usb"/>
|
||||
<require idref="lufa.drivers.board"/>
|
||||
<require idref="lufa.drivers.board.leds"/>
|
||||
</module>
|
||||
</asf>
|
||||
55
Bootloaders/Printer/makefile
Normal file
55
Bootloaders/Printer/makefile
Normal file
@@ -0,0 +1,55 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU = at90usb1287
|
||||
ARCH = AVR8
|
||||
BOARD = USBKEY
|
||||
F_CPU = 8000000
|
||||
F_USB = $(F_CPU)
|
||||
OPTIMIZATION = s
|
||||
TARGET = BootloaderPrinter
|
||||
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
|
||||
LUFA_PATH = ../../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
|
||||
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
|
||||
|
||||
# Flash size and bootloader section sizes of the target, in KB. These must
|
||||
# match the target's total FLASH size and the bootloader size set in the
|
||||
# device's fuses.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 8
|
||||
|
||||
# Bootloader address calculation formulas
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
include $(LUFA_PATH)/Build/lufa_doxygen.mk
|
||||
include $(LUFA_PATH)/Build/lufa_avrdude.mk
|
||||
include $(LUFA_PATH)/Build/lufa_atprogram.mk
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2011.
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
@@ -13,18 +13,34 @@
|
||||
# custom LUFA library build options are reflected in the compiled
|
||||
# code.
|
||||
|
||||
all:
|
||||
$(MAKE) -C CDC clean
|
||||
$(MAKE) -C CDC all
|
||||
PROJECT_DIRECTORIES := $(shell ls -d */)
|
||||
|
||||
$(MAKE) -C HID clean
|
||||
$(MAKE) -C HID all
|
||||
# This makefile is potentially infinitely recursive if something really bad
|
||||
# happens when determining the set of project directories - hard-abort if
|
||||
# more than 10 levels deep to avoid angry emails.
|
||||
ifeq ($(MAKELEVEL), 10)
|
||||
$(error EMERGENCY ABORT: INFINITE RECURSION DETECTED)
|
||||
endif
|
||||
|
||||
$(MAKE) -C DFU clean
|
||||
$(MAKE) -C DFU all
|
||||
# Need to special-case building without a per-project object directory
|
||||
ifeq ($(OBJDIR),)
|
||||
# If no target specified, force "clean all" and disallow parallel build
|
||||
ifeq ($(MAKECMDGOALS),)
|
||||
MAKECMDGOALS := clean all
|
||||
.NOTPARALLEL:
|
||||
endif
|
||||
|
||||
%:
|
||||
$(MAKE) -C CDC $@
|
||||
$(MAKE) -C DFU $@
|
||||
$(MAKE) -C HID $@
|
||||
# If one of the targets is to build, force "clean" beforehand and disallow parallel build
|
||||
ifneq ($(findstring all, $(MAKECMDGOALS)),)
|
||||
MAKECMDGOALS := clean $(MAKECMDGOALS)
|
||||
.NOTPARALLEL:
|
||||
endif
|
||||
endif
|
||||
|
||||
%: $(PROJECT_DIRECTORIES)
|
||||
@echo . > /dev/null
|
||||
|
||||
$(PROJECT_DIRECTORIES):
|
||||
@$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||
|
||||
.PHONY: $(PROJECT_DIRECTORIES)
|
||||
|
||||
82
BuildTests/BoardDriverTest/Board/Board.h
Normal file
82
BuildTests/BoardDriverTest/Board/Board.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Custom Board Hardware Information Driver (Template)
|
||||
*
|
||||
* This is a stub driver header file, for implementing custom board
|
||||
* layout hardware with compatible LUFA board specific drivers. If
|
||||
* the library is configured to use the BOARD_USER board mode, this
|
||||
* driver file should be completed and copied into the "/Board/" folder
|
||||
* inside the application's folder.
|
||||
*
|
||||
* This stub is for the board-specific component of the LUFA Board Hardware
|
||||
* information driver.
|
||||
*/
|
||||
|
||||
#ifndef __BOARD_USER_H__
|
||||
#define __BOARD_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_BOARD_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/Board.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Indicates the board has a hardware Buttons mounted if defined. */
|
||||
// #define BOARD_HAS_BUTTONS
|
||||
|
||||
/** Indicates the board has a hardware Dataflash mounted if defined. */
|
||||
// #define BOARD_HAS_DATAFLASH
|
||||
|
||||
/** Indicates the board has a hardware Joystick mounted if defined. */
|
||||
// #define BOARD_HAS_JOYSTICK
|
||||
|
||||
/** Indicates the board has a hardware LEDs mounted if defined. */
|
||||
// #define BOARD_HAS_LEDS
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
92
BuildTests/BoardDriverTest/Board/Buttons.h
Normal file
92
BuildTests/BoardDriverTest/Board/Buttons.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Custom Board Button Hardware Driver (Template)
|
||||
*
|
||||
* This is a stub driver header file, for implementing custom board
|
||||
* layout hardware with compatible LUFA board specific drivers. If
|
||||
* the library is configured to use the BOARD_USER board mode, this
|
||||
* driver file should be completed and copied into the "/Board/" folder
|
||||
* inside the application's folder.
|
||||
*
|
||||
* This stub is for the board-specific component of the LUFA Buttons driver,
|
||||
* for the control of physical board-mounted GPIO pushbuttons.
|
||||
*/
|
||||
|
||||
#ifndef __BUTTONS_USER_H__
|
||||
#define __BUTTONS_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_BUTTONS_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
|
||||
#endif
|
||||
|
||||
#define BOARD_DUMMY_BUTTONS_IMPLEMENTATION
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Button mask for the first button on the board. */
|
||||
#define BUTTONS_BUTTON1 (1 << 0)
|
||||
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void Buttons_Init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void Buttons_Disable(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Buttons_GetStatus(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
197
BuildTests/BoardDriverTest/Board/Dataflash.h
Normal file
197
BuildTests/BoardDriverTest/Board/Dataflash.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Custom Board Dataflash Hardware Driver (Template)
|
||||
*
|
||||
* This is a stub driver header file, for implementing custom board
|
||||
* layout hardware with compatible LUFA board specific drivers. If
|
||||
* the library is configured to use the BOARD_USER board mode, this
|
||||
* driver file should be completed and copied into the "/Board/" folder
|
||||
* inside the application's folder.
|
||||
*
|
||||
* This stub is for the board-specific component of the LUFA Dataflash
|
||||
* driver.
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_USER_H__
|
||||
#define __DATAFLASH_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_DATAFLASH_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.
|
||||
#endif
|
||||
|
||||
#define BOARD_DUMMY_DATAFLASH_IMPLEMENTATION
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#define DATAFLASH_CHIPCS_MASK 0
|
||||
#define DATAFLASH_CHIPCS_DDR 0
|
||||
#define DATAFLASH_CHIPCS_PORT 0
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Constant indicating the total number of dataflash ICs mounted on the selected board. */
|
||||
#define DATAFLASH_TOTALCHIPS 1
|
||||
|
||||
/** Mask for no dataflash chip selected. */
|
||||
#define DATAFLASH_NO_CHIP 0
|
||||
|
||||
/** Mask for the first dataflash chip selected. */
|
||||
#define DATAFLASH_CHIP1 0
|
||||
|
||||
/** Mask for the second dataflash chip selected. */
|
||||
#define DATAFLASH_CHIP2 0
|
||||
|
||||
/** Internal main memory page size for the board's dataflash ICs. */
|
||||
#define DATAFLASH_PAGE_SIZE 0
|
||||
|
||||
/** Total number of pages inside each of the board's dataflash ICs. */
|
||||
#define DATAFLASH_PAGES 0
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
|
||||
* The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.
|
||||
*/
|
||||
static inline void Dataflash_Init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
|
||||
*
|
||||
* \param[in] Byte Byte of data to send to the dataflash
|
||||
*
|
||||
* \return Last response byte from the dataflash
|
||||
*/
|
||||
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
|
||||
*
|
||||
* \param[in] Byte Byte of data to send to the dataflash
|
||||
*/
|
||||
static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
|
||||
static inline void Dataflash_SendByte(const uint8_t Byte)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
|
||||
*
|
||||
* \return Last response byte from the dataflash
|
||||
*/
|
||||
static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Dataflash_ReceiveByte(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Determines the currently selected dataflash chip.
|
||||
*
|
||||
* \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected
|
||||
* or a DATAFLASH_CHIPn mask (where n is the chip number).
|
||||
*/
|
||||
static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Dataflash_GetSelectedChip(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Selects the given dataflash chip.
|
||||
*
|
||||
* \param[in] ChipMask Mask of the Dataflash IC to select, in the form of a \c DATAFLASH_CHIPn mask (where n is
|
||||
* the chip number).
|
||||
*/
|
||||
static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;
|
||||
static inline void Dataflash_SelectChip(const uint8_t ChipMask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Deselects the current dataflash chip, so that no dataflash is selected. */
|
||||
static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void Dataflash_DeselectChip(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Selects a dataflash IC from the given page number, which should range from 0 to
|
||||
* ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one
|
||||
* dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside
|
||||
* the total number of pages contained in the boards dataflash ICs, all dataflash ICs
|
||||
* are deselected.
|
||||
*
|
||||
* \param[in] PageAddress Address of the page to manipulate, ranging from
|
||||
* 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).
|
||||
*/
|
||||
static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive
|
||||
* a new command.
|
||||
*/
|
||||
static inline void Dataflash_ToggleSelectedChipCS(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Spin-loops while the currently selected dataflash is busy executing a command, such as a main
|
||||
* memory page program or main memory to buffer transfer.
|
||||
*/
|
||||
static inline void Dataflash_WaitWhileBusy(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with
|
||||
* dataflash commands which require a complete 24-bit address.
|
||||
*
|
||||
* \param[in] PageAddress Page address within the selected dataflash IC
|
||||
* \param[in] BufferByte Address within the dataflash's buffer
|
||||
*/
|
||||
static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
104
BuildTests/BoardDriverTest/Board/Joystick.h
Normal file
104
BuildTests/BoardDriverTest/Board/Joystick.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Custom Board Joystick Hardware Driver (Template)
|
||||
*
|
||||
* This is a stub driver header file, for implementing custom board
|
||||
* layout hardware with compatible LUFA board specific drivers. If
|
||||
* the library is configured to use the BOARD_USER board mode, this
|
||||
* driver file should be completed and copied into the "/Board/" folder
|
||||
* inside the application's folder.
|
||||
*
|
||||
* This stub is for the board-specific component of the LUFA Joystick
|
||||
* driver, for a digital four-way (plus button) joystick.
|
||||
*/
|
||||
|
||||
#ifndef __JOYSTICK_USER_H__
|
||||
#define __JOYSTICK_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_JOYSTICK_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.
|
||||
#endif
|
||||
|
||||
#define BOARD_DUMMY_JOYSTICK_IMPLEMENTATION
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Mask for the joystick being pushed in the left direction. */
|
||||
#define JOY_LEFT 0
|
||||
|
||||
/** Mask for the joystick being pushed in the right direction. */
|
||||
#define JOY_RIGHT 0
|
||||
|
||||
/** Mask for the joystick being pushed in the upward direction. */
|
||||
#define JOY_UP 0
|
||||
|
||||
/** Mask for the joystick being pushed in the downward direction. */
|
||||
#define JOY_DOWN 0
|
||||
|
||||
/** Mask for the joystick being pushed inward. */
|
||||
#define JOY_PRESS 0
|
||||
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void Joystick_Init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void Joystick_Disable(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Joystick_GetStatus(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
132
BuildTests/BoardDriverTest/Board/LEDs.h
Normal file
132
BuildTests/BoardDriverTest/Board/LEDs.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Custom Board LED Hardware Driver (Template)
|
||||
*
|
||||
* This is a stub driver header file, for implementing custom board
|
||||
* layout hardware with compatible LUFA board specific drivers. If
|
||||
* the library is configured to use the BOARD_USER board mode, this
|
||||
* driver file should be completed and copied into the "/Board/" folder
|
||||
* inside the application's folder.
|
||||
*
|
||||
* This stub is for the board-specific component of the LUFA LEDs driver,
|
||||
* for the LEDs (up to four) mounted on most development boards.
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_USER_H__
|
||||
#define __LEDS_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_LEDS_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
|
||||
#endif
|
||||
|
||||
#define BOARD_DUMMY_LEDS_IMPLEMENTATION
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** LED mask for the first LED on the board. */
|
||||
#define LEDS_LED1 (1 << 0)
|
||||
|
||||
/** LED mask for the second LED on the board. */
|
||||
#define LEDS_LED2 (1 << 1)
|
||||
|
||||
/** LED mask for the third LED on the board. */
|
||||
#define LEDS_LED3 (1 << 2)
|
||||
|
||||
/** LED mask for the fourth LED on the board. */
|
||||
#define LEDS_LED4 (1 << 3)
|
||||
|
||||
/** LED mask for all the LEDs on the board. */
|
||||
#define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)
|
||||
|
||||
/** LED mask for none of the board LEDs. */
|
||||
#define LEDS_NO_LEDS 0
|
||||
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void LEDs_Init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void LEDs_Disable(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t LEDs_GetLEDs(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
85
BuildTests/BoardDriverTest/BoardDeviceMap.cfg
Normal file
85
BuildTests/BoardDriverTest/BoardDeviceMap.cfg
Normal file
@@ -0,0 +1,85 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
#
|
||||
# =============================================================================
|
||||
# Board configuration map script, processed with the "BoardDriverTest"
|
||||
# makefile. This script file maps the possible LUFA target BOARD makefile
|
||||
# values in user projects to a specific architecture and device. This mapping is
|
||||
# then used by the makefile to build all possible drivers for that board, to
|
||||
# detect any missing or erroneous functions. To add a new board mapping, use
|
||||
# the syntax:
|
||||
#
|
||||
# BOARD DEFINE = {ARCH} : {MCU} :
|
||||
#
|
||||
# And re-run the makefile. Note that each board may have only one target.
|
||||
# =============================================================================
|
||||
#
|
||||
#
|
||||
# ----------------- AVR8 Boards ------------------
|
||||
BOARD_ADAFRUITU4 = AVR8 : atmega32u4 :
|
||||
BOARD_ATAVRUSBRF01 = AVR8 : at90usb1287 :
|
||||
BOARD_BENITO = AVR8 : at90usb162 :
|
||||
BOARD_BIGMULTIO = AVR8 : atmega32u4 :
|
||||
BOARD_BLACKCAT = AVR8 : at90usb162 :
|
||||
BOARD_BUI = AVR8 : at90usb646 :
|
||||
BOARD_BUMBLEB = AVR8 : at90usb162 :
|
||||
BOARD_CULV3 = AVR8 : atmega32u4 :
|
||||
BOARD_DUCE = AVR8 : atmega32u2 :
|
||||
BOARD_EVK527 = AVR8 : atmega32u4 :
|
||||
BOARD_JMDBU2 = AVR8 : atmega32u2 :
|
||||
BOARD_LEONARDO = AVR8 : atmega32u4 :
|
||||
BOARD_MAXIMUS = AVR8 : at90usb162 :
|
||||
BOARD_MICROPENDOUS_32U2 = AVR8 : atmega32u2 :
|
||||
BOARD_MICROPENDOUS_A = AVR8 : at90usb1287 :
|
||||
BOARD_MICROPENDOUS_1 = AVR8 : at90usb162 :
|
||||
BOARD_MICROPENDOUS_2 = AVR8 : atmega32u4 :
|
||||
BOARD_MICROPENDOUS_3 = AVR8 : at90usb1287 :
|
||||
BOARD_MICROPENDOUS_4 = AVR8 : at90usb1287 :
|
||||
BOARD_MICROPENDOUS_DIP = AVR8 : at90usb1287 :
|
||||
BOARD_MICROPENDOUS_REV1 = AVR8 : at90usb1287 :
|
||||
BOARD_MICROPENDOUS_REV2 = AVR8 : at90usb1287 :
|
||||
BOARD_MICROSIN162 = AVR8 : atmega162 :
|
||||
BOARD_MINIMUS = AVR8 : atmega32u2 :
|
||||
BOARD_MULTIO = AVR8 : at90usb162 :
|
||||
BOARD_NONE = AVR8 : at90usb1287 :
|
||||
BOARD_OLIMEX162 = AVR8 : at90usb162 :
|
||||
BOARD_OLIMEX32U4 = AVR8 : atmega32u4 :
|
||||
BOARD_OLIMEXT32U4 = AVR8 : atmega32u4 :
|
||||
BOARD_OLIMEXISPMK2 = AVR8 : at90usb162 :
|
||||
BOARD_RZUSBSTICK = AVR8 : at90usb1287 :
|
||||
BOARD_SPARKFUN8U2 = AVR8 : atmega8u2 :
|
||||
BOARD_STK525 = AVR8 : at90usb647 :
|
||||
BOARD_STK526 = AVR8 : at90usb162 :
|
||||
BOARD_TEENSY = AVR8 : at90usb162 :
|
||||
BOARD_TEENSY2 = AVR8 : at90usb646 :
|
||||
BOARD_TUL = AVR8 : atmega32u4 :
|
||||
BOARD_UDIP = AVR8 : atmega32u2 :
|
||||
BOARD_UNO = AVR8 : atmega8u2 :
|
||||
BOARD_USB2AX = AVR8 : atmega32u2 :
|
||||
BOARD_USB2AX_V3 = AVR8 : atmega32u2 :
|
||||
BOARD_USB2AX_V31 = AVR8 : atmega32u2 :
|
||||
BOARD_USBFOO = AVR8 : atmega162 :
|
||||
BOARD_USBKEY = AVR8 : at90usb1287 :
|
||||
BOARD_USBTINYMKII = AVR8 : at90usb162 :
|
||||
BOARD_USER = AVR8 : at90usb1287 :
|
||||
BOARD_XPLAIN = AVR8 : at90usb1287 :
|
||||
BOARD_XPLAIN_REV1 = AVR8 : at90usb1287 :
|
||||
BOARD_STANGE_ISP = AVR8 : at90usb162 :
|
||||
BOARD_U2S = AVR8 : atmega32u2 :
|
||||
#
|
||||
# ----------------- XMEGA Boards -----------------
|
||||
BOARD_A3BU_XPLAINED = XMEGA : atxmega256a3bu :
|
||||
BOARD_B1_XPLAINED = XMEGA : atxmega128b1 :
|
||||
BOARD_C3_XPLAINED = XMEGA : atxmega384c3 :
|
||||
#
|
||||
# ------------------ UC3 Boards ------------------
|
||||
BOARD_EVK1100 = UC3 : uc3a0512 :
|
||||
BOARD_EVK1101 = UC3 : uc3b0256 :
|
||||
BOARD_EVK1104 = UC3 : uc3a3256 :
|
||||
BOARD_UC3A3_XPLAINED = UC3 : uc3a3256 :
|
||||
#
|
||||
115
BuildTests/BoardDriverTest/Test.c
Normal file
115
BuildTests/BoardDriverTest/Test.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
#include <LUFA/Drivers/Board/Board.h>
|
||||
#include <LUFA/Drivers/Board/Buttons.h>
|
||||
#include <LUFA/Drivers/Board/Dataflash.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/Board/Joystick.h>
|
||||
|
||||
#if defined(BOARD_HAS_BUTTONS) == defined(BOARD_DUMMY_BUTTONS_IMPLEMENTATION)
|
||||
#error Mismatch between BOARD_HAS_BUTTONS and implementation.
|
||||
#endif
|
||||
|
||||
#if defined(BOARD_HAS_DATAFLASH) == defined(BOARD_DUMMY_DATAFLASH_IMPLEMENTATION)
|
||||
#error Mismatch between BOARD_HAS_DATAFLASH and implementation.
|
||||
#endif
|
||||
|
||||
#if defined(BOARD_HAS_LEDS) == defined(BOARD_DUMMY_LEDS_IMPLEMENTATION)
|
||||
#error Mismatch between BOARD_HAS_LEDS and implementation.
|
||||
#endif
|
||||
|
||||
#if defined(BOARD_HAS_JOYSTICK) == defined(BOARD_DUMMY_JOYSTICK_IMPLEMENTATION)
|
||||
#error Mismatch between BOARD_HAS_JOYSTICK and implementation.
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint_reg_t Dummy;
|
||||
|
||||
/* =============================
|
||||
* Buttons Compile Check
|
||||
* ============================= */
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = BUTTONS_BUTTON1;
|
||||
Buttons_Init();
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = Buttons_GetStatus();
|
||||
Buttons_Disable();
|
||||
|
||||
/* =============================
|
||||
* Dataflash Compile Check
|
||||
* ============================= */
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = DATAFLASH_TOTALCHIPS + DATAFLASH_NO_CHIP + DATAFLASH_CHIP1 + DATAFLASH_PAGE_SIZE + DATAFLASH_PAGES;
|
||||
Dataflash_Init();
|
||||
Dataflash_TransferByte(0);
|
||||
Dataflash_SendByte(0);
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = Dataflash_ReceiveByte();
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = Dataflash_GetSelectedChip();
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||
Dataflash_DeselectChip();
|
||||
Dataflash_SelectChipFromPage(0);
|
||||
Dataflash_ToggleSelectedChipCS();
|
||||
Dataflash_WaitWhileBusy();
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
|
||||
/* =============================
|
||||
* LEDs Compile Check
|
||||
* ============================= */
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = LEDS_LED1 + LEDS_LED2 + LEDS_LED3 + LEDS_LED4;
|
||||
LEDs_Init();
|
||||
LEDs_TurnOnLEDs(LEDS_ALL_LEDS);
|
||||
LEDs_TurnOffLEDs(LEDS_ALL_LEDS);
|
||||
LEDs_SetAllLEDs(LEDS_ALL_LEDS);
|
||||
LEDs_ChangeLEDs(LEDS_ALL_LEDS, LEDS_NO_LEDS);
|
||||
LEDs_ToggleLEDs(LEDS_ALL_LEDS);
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = LEDs_GetLEDs();
|
||||
LEDs_Disable();
|
||||
|
||||
/* =============================
|
||||
* Joystick Compile Check
|
||||
* ============================= */
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = JOY_LEFT + JOY_RIGHT + JOY_UP + JOY_DOWN + JOY_PRESS;
|
||||
Joystick_Init();
|
||||
// cppcheck-suppress redundantAssignment
|
||||
Dummy = Joystick_GetStatus();
|
||||
Joystick_Disable();
|
||||
|
||||
(void)Dummy;
|
||||
}
|
||||
|
||||
|
||||
68
BuildTests/BoardDriverTest/makefile
Normal file
68
BuildTests/BoardDriverTest/makefile
Normal file
@@ -0,0 +1,68 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
# Makefile for the board driver build test. This
|
||||
# test attempts to build a dummy project with all
|
||||
# possible board targets using their respective
|
||||
# compiler.
|
||||
|
||||
# Path to the LUFA library core
|
||||
LUFA_PATH := ../../LUFA/
|
||||
|
||||
# Build test cannot be run with multiple parallel jobs
|
||||
.NOTPARALLEL:
|
||||
|
||||
all: begin makeboardlist testboards clean end
|
||||
|
||||
begin:
|
||||
@echo Executing build test "BoardDriverTest".
|
||||
@echo
|
||||
|
||||
end:
|
||||
@echo Build test "BoardDriverTest" complete.
|
||||
@echo
|
||||
|
||||
makeboardlist:
|
||||
@grep "BOARD_" $(patsubst %/,%,$(LUFA_PATH))/Common/BoardTypes.h | cut -d'#' -f2 | cut -d' ' -f2 | grep "BOARD_" > BoardList.txt
|
||||
|
||||
testboards:
|
||||
@echo "buildtest:" > BuildMakefile
|
||||
|
||||
@while read line; \
|
||||
do \
|
||||
build_cfg=`grep "$$line " BoardDeviceMap.cfg | grep -v "#" | cut -d'=' -f2- | sed 's/ //g'`; \
|
||||
\
|
||||
build_board=$$line; \
|
||||
build_arch=`echo $$build_cfg | cut -d':' -f1`; \
|
||||
build_mcu=`echo $$build_cfg | cut -d':' -f2`; \
|
||||
\
|
||||
if ( test -z "$$build_cfg" ); then \
|
||||
echo "No matching information set for board $$build_board"; \
|
||||
else \
|
||||
echo "Found board configuration for $$build_board - $$build_arch, $$build_mcu"; \
|
||||
\
|
||||
printf "\t@echo Building dummy project for $$build_board...\n" >> BuildMakefile; \
|
||||
printf "\t$(MAKE) -f makefile.test clean elf MCU=%s ARCH=%s BOARD=%s\n\n" $$build_mcu $$build_arch $$build_board >> BuildMakefile; \
|
||||
fi; \
|
||||
done < BoardList.txt
|
||||
|
||||
$(MAKE) -f BuildMakefile buildtest
|
||||
|
||||
clean:
|
||||
rm -f BuildMakefile
|
||||
rm -f BoardList.txt
|
||||
$(MAKE) -f makefile.test clean BOARD=NONE ARCH=AVR8 MCU=at90usb1287
|
||||
$(MAKE) -f makefile.test clean BOARD=NONE ARCH=XMEGA MCU=atxmega128a1u
|
||||
$(MAKE) -f makefile.test clean BOARD=NONE ARCH=UC3 MCU=uc3a0256
|
||||
|
||||
%:
|
||||
|
||||
.PHONY: all begin end makeboardlist testboards clean
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
27
BuildTests/BoardDriverTest/makefile.test
Normal file
27
BuildTests/BoardDriverTest/makefile.test
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU =
|
||||
ARCH =
|
||||
BOARD =
|
||||
F_CPU = $(F_USB)
|
||||
F_USB = 8000000
|
||||
OPTIMIZATION = 1
|
||||
TARGET = Test
|
||||
SRC = $(TARGET).c
|
||||
LUFA_PATH = ../../LUFA
|
||||
CC_FLAGS = -Werror
|
||||
DEBUG_LEVEL = 0
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
167
BuildTests/BootloaderTest/BootloaderDeviceMap.cfg
Normal file
167
BuildTests/BootloaderTest/BootloaderDeviceMap.cfg
Normal file
@@ -0,0 +1,167 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
#
|
||||
# =============================================================================
|
||||
# Bootloader configuration map script, processed with the "BootloaderTest"
|
||||
# makefile. This script file defines the targets for each LUFA bootloader,
|
||||
# which are then built as part of the build test to ensure that there are no
|
||||
# failures on all standard configurations. To add a new build target for a
|
||||
# bootloader to this script, use the format:
|
||||
#
|
||||
# BOOTLOADER = {ARCH} : {MCU} : {BOARD} : {FLASH SIZE KB} : {BOOT SIZE KB} : {F_USB MHZ}
|
||||
#
|
||||
# And re-run the makefile.
|
||||
# =============================================================================
|
||||
#
|
||||
#
|
||||
# ------------ CDC Bootloader --------------------
|
||||
CDC = AVR8 : at90usb1287 : XPLAIN : 128 : 8 : 8 :
|
||||
CDC = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
|
||||
CDC = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
|
||||
CDC = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
|
||||
CDC = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
|
||||
CDC = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
|
||||
CDC = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
|
||||
CDC = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
|
||||
CDC = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
|
||||
CDC = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
|
||||
CDC = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
|
||||
CDC = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
|
||||
CDC = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
|
||||
CDC = AVR8 : at90usb82 : NONE : 8 : 4 : 8 :
|
||||
CDC = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
|
||||
CDC = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
|
||||
CDC = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
|
||||
CDC = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
|
||||
CDC = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
|
||||
CDC = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
|
||||
CDC = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
|
||||
CDC = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
|
||||
CDC = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
|
||||
CDC = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
|
||||
CDC = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
|
||||
CDC = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
|
||||
CDC = AVR8 : at90usb82 : NONE : 8 : 4 : 16 :
|
||||
#
|
||||
# ------------ DFU Bootloader --------------------
|
||||
DFU = AVR8 : at90usb1287 : XPLAIN : 128 : 8 : 8 :
|
||||
DFU = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
|
||||
DFU = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
|
||||
DFU = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
|
||||
DFU = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
|
||||
DFU = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
|
||||
DFU = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
|
||||
DFU = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
|
||||
DFU = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
|
||||
DFU = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
|
||||
DFU = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
|
||||
DFU = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
|
||||
DFU = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
|
||||
DFU = AVR8 : at90usb82 : NONE : 8 : 4 : 8 :
|
||||
DFU = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
|
||||
DFU = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
|
||||
DFU = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
|
||||
DFU = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
|
||||
DFU = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
|
||||
DFU = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
|
||||
DFU = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
|
||||
DFU = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
|
||||
DFU = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
|
||||
DFU = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
|
||||
DFU = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
|
||||
DFU = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
|
||||
DFU = AVR8 : at90usb82 : NONE : 8 : 4 : 16 :
|
||||
#
|
||||
# ------------ HID Bootloader --------------------
|
||||
HID = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
|
||||
HID = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
|
||||
HID = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
|
||||
HID = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
|
||||
HID = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
|
||||
HID = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
|
||||
HID = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
|
||||
HID = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
|
||||
HID = AVR8 : atmega32u2 : NONE : 32 : 2 : 8 :
|
||||
HID = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
|
||||
HID = AVR8 : atmega16u2 : NONE : 16 : 2 : 8 :
|
||||
HID = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
|
||||
HID = AVR8 : atmega8u2 : NONE : 8 : 2 : 8 :
|
||||
HID = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 8 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 8 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
|
||||
HID = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
|
||||
HID = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
|
||||
HID = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
|
||||
HID = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
|
||||
HID = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
|
||||
HID = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
|
||||
HID = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
|
||||
HID = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
|
||||
HID = AVR8 : atmega32u2 : NONE : 32 : 2 : 16 :
|
||||
HID = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
|
||||
HID = AVR8 : atmega16u2 : NONE : 16 : 2 : 16 :
|
||||
HID = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
|
||||
HID = AVR8 : atmega8u2 : NONE : 8 : 2 : 16 :
|
||||
HID = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 16 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 16 :
|
||||
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
|
||||
#
|
||||
# ---------- Printer Bootloader ------------------
|
||||
Printer = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
|
||||
Printer = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
|
||||
Printer = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
|
||||
Printer = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
|
||||
Printer = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
|
||||
Printer = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
|
||||
Printer = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
|
||||
Printer = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
|
||||
Printer = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
|
||||
Printer = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
|
||||
Printer = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
|
||||
Printer = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
|
||||
Printer = AVR8 : at90usb82 : NONE : 8 : 4 : 8 :
|
||||
Printer = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
|
||||
Printer = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
|
||||
Printer = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
|
||||
Printer = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
|
||||
Printer = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
|
||||
Printer = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
|
||||
Printer = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
|
||||
Printer = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
|
||||
Printer = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
|
||||
Printer = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
|
||||
Printer = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
|
||||
Printer = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
|
||||
Printer = AVR8 : at90usb82 : NONE : 8 : 4 : 16 :
|
||||
#
|
||||
# ---------- Mass Storage Bootloader -----------------
|
||||
MassStorage = AVR8 : at90usb1287 : XPLAIN : 128 : 8 : 8 :
|
||||
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
|
||||
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
|
||||
MassStorage = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
|
||||
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
|
||||
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
|
||||
MassStorage = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
|
||||
MassStorage = AVR8 : atmega32u4 : LEONARDO : 32 : 4 : 16 :
|
||||
MassStorage = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
|
||||
MassStorage = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
|
||||
MassStorage = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
|
||||
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
|
||||
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
|
||||
MassStorage = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
|
||||
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
|
||||
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
|
||||
MassStorage = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
|
||||
MassStorage = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
|
||||
MassStorage = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
|
||||
MassStorage = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
|
||||
#
|
||||
64
BuildTests/BootloaderTest/makefile
Normal file
64
BuildTests/BootloaderTest/makefile
Normal file
@@ -0,0 +1,64 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
# Makefile for the bootloader build test. This
|
||||
# test attempts to build all the bootloaders
|
||||
# with all supported device configurations.
|
||||
|
||||
# Path to the LUFA library core
|
||||
LUFA_PATH := ../../LUFA/
|
||||
|
||||
# Build test cannot be run with multiple parallel jobs
|
||||
.NOTPARALLEL:
|
||||
|
||||
all: begin testbootloaders clean end
|
||||
|
||||
begin:
|
||||
@echo Executing build test "BootloaderTest".
|
||||
@echo
|
||||
|
||||
end:
|
||||
@echo Build test "BootloaderTest" complete.
|
||||
@echo
|
||||
|
||||
testbootloaders:
|
||||
@echo "buildtest:" > BuildMakefile
|
||||
|
||||
@while read line; \
|
||||
do \
|
||||
build_cfg=`echo $$line | grep -v "#" | sed 's/ //g'`; \
|
||||
\
|
||||
if ( test -n "$$build_cfg" ); then \
|
||||
build_bootloader=`echo $$build_cfg | cut -d'=' -f1`; \
|
||||
build_cfg=`echo $$build_cfg | cut -d'=' -f2-`; \
|
||||
\
|
||||
build_arch=`echo $$build_cfg | cut -d':' -f1`; \
|
||||
build_mcu=`echo $$build_cfg | cut -d':' -f2`; \
|
||||
build_board=`echo $$build_cfg | cut -d':' -f3`; \
|
||||
build_flashsize=`echo $$build_cfg | cut -d':' -f4`; \
|
||||
build_bootsize=`echo $$build_cfg | cut -d':' -f5`; \
|
||||
build_fusb=`echo $$build_cfg | cut -d':' -f6`; \
|
||||
\
|
||||
printf "Found '%s' bootloader configuration (FLASH: %3s KB | BOOT: %3s KB | MCU: %12s / %4s | BOARD: %s | F_USB: %sMHz)\n" $$build_bootloader $$build_flashsize $$build_bootsize $$build_mcu $$build_arch $$build_board $$build_fusb; \
|
||||
\
|
||||
printf "\t@echo Building bootloader %s - %s - FLASH: %s KB, BOOT: %s KB, BOARD: %s, F_USB: %sMHz\n" $$build_bootloader $$build_mcu $$build_flashsize $$build_bootsize $$build_board $$build_fusb >> BuildMakefile; \
|
||||
printf "\t$(MAKE) -C $(patsubst %/,%,$(LUFA_PATH))/../Bootloaders/%s/ clean elf ARCH=%s MCU=%s BOARD=%s FLASH_SIZE_KB=%s BOOT_SECTION_SIZE_KB=%s F_USB=%s000000 DEBUG_LEVEL=0\n\n" $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_flashsize $$build_bootsize $$build_fusb >> BuildMakefile; \
|
||||
fi; \
|
||||
done < BootloaderDeviceMap.cfg
|
||||
|
||||
$(MAKE) -f BuildMakefile buildtest
|
||||
|
||||
clean:
|
||||
rm -f BuildMakefile
|
||||
|
||||
%:
|
||||
|
||||
.PHONY: all begin end testbootloaders clean
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -28,18 +28,14 @@
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _PROGRAMMER_CONFIG_H_
|
||||
#define _PROGRAMMER_CONFIG_H_
|
||||
.section .text
|
||||
|
||||
/* Includes: */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../StandaloneProgrammer.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool ProgrammerConfig_ProcessConfiguration(void);
|
||||
|
||||
#endif
|
||||
# Mandatory entry point for successful compilation and link
|
||||
.global main
|
||||
main:
|
||||
|
||||
|
||||
# Mandatory callback needed for base compile of the USB driver
|
||||
.global CALLBACK_USB_GetDescriptor
|
||||
CALLBACK_USB_GetDescriptor:
|
||||
56
BuildTests/ModuleTest/Modules.h
Normal file
56
BuildTests/ModuleTest/Modules.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Misc/RingBuffer.h>
|
||||
#include <LUFA/Drivers/Misc/TerminalCodes.h>
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#if defined(TWCR)
|
||||
#include <LUFA/Drivers/Peripheral/TWI.h>
|
||||
#endif
|
||||
|
||||
#if defined(ADC)
|
||||
#include <LUFA/Drivers/Peripheral/ADC.h>
|
||||
#endif
|
||||
|
||||
#include <LUFA/Drivers/Peripheral/Serial.h>
|
||||
#include <LUFA/Drivers/Peripheral/SPI.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialSPI.h>
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include <LUFA/Drivers/Peripheral/TWI.h>
|
||||
#include <LUFA/Drivers/Peripheral/Serial.h>
|
||||
#include <LUFA/Drivers/Peripheral/SPI.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialSPI.h>
|
||||
#endif
|
||||
31
BuildTests/ModuleTest/Test_C.c
Normal file
31
BuildTests/ModuleTest/Test_C.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include "Modules.h"
|
||||
31
BuildTests/ModuleTest/Test_CPP.cpp
Normal file
31
BuildTests/ModuleTest/Test_CPP.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include "Modules.h"
|
||||
66
BuildTests/ModuleTest/makefile
Normal file
66
BuildTests/ModuleTest/makefile
Normal file
@@ -0,0 +1,66 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
# Makefile for the module build test. This test
|
||||
# attempts to build as many modules as possible
|
||||
# under all supported architectures, and include
|
||||
# all module headers in a simple C and C++
|
||||
# application.
|
||||
|
||||
# Path to the LUFA library core
|
||||
LUFA_PATH := ../../LUFA/
|
||||
|
||||
# Build test cannot be run with multiple parallel jobs
|
||||
.NOTPARALLEL:
|
||||
|
||||
# List of device families per architecture, one device per architecture sub-family
|
||||
AVR8_FAMILIES := at90usb1287 at90usb1286 atmega16u4 atmega16u2 at90usb162
|
||||
XMEGA_FAMILIES := atxmega128a1u atxmega128a3u atxmega256a3bu atxmega128a4u atxmega128b1 atxmega128b3 atxmega128c3 atxmega32c4
|
||||
UC3_FAMILIES := uc3a0256 uc3a1256 uc3a3256 uc3a4256 uc3b0256 uc3b1256
|
||||
|
||||
# List of all device families, with a family postfix
|
||||
DEVICE_FAMILIES := $(AVR8_FAMILIES:%=%.avr8) $(XMEGA_FAMILIES:%=%.xmega) $(UC3_FAMILIES:%=%.uc3)
|
||||
|
||||
|
||||
all: begin $(DEVICE_FAMILIES) clean end
|
||||
|
||||
arch_avr8: begin $(AVR8_FAMILIES:%=%.avr8) end
|
||||
arch_xmega: begin $(XMEGA_FAMILIES:%=%.xmega) end
|
||||
arch_uc3: begin $(UC3_FAMILIES:%=%.uc3) end
|
||||
|
||||
begin:
|
||||
@echo Executing build test "ModuleTest".
|
||||
@echo
|
||||
|
||||
end:
|
||||
@echo Build test "ModuleTest" complete.
|
||||
@echo
|
||||
|
||||
%.avr8:
|
||||
@echo Building ModuleTest for ARCH=AVR8 MCU=$(@:%.avr8=%)...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=AVR8 MCU=$(@:%.avr8=%)
|
||||
|
||||
%.xmega:
|
||||
@echo Building ModuleTest for ARCH=XMEGA MCU=$(@:%.xmega=%)...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=XMEGA MCU=$(@:%.xmega=%)
|
||||
|
||||
%.uc3:
|
||||
@echo Building ModuleTest for ARCH=UC3 MCU=$(@:%.uc3=%)...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=UC3 MCU=$(@:%.uc3=%)
|
||||
|
||||
clean:
|
||||
$(MAKE) -f makefile.test clean ARCH=AVR8 MCU=$(firstword $(AVR8_FAMILIES))
|
||||
$(MAKE) -f makefile.test clean ARCH=XMEGA MCU=$(firstword $(XMEGA_FAMILIES))
|
||||
$(MAKE) -f makefile.test clean ARCH=UC3 MCU=$(firstword $(UC3_FAMILIES))
|
||||
|
||||
%:
|
||||
|
||||
.PHONY: all arch_avr8 arch_xmega arch_uc3 begin end
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
88
BuildTests/ModuleTest/makefile.test
Normal file
88
BuildTests/ModuleTest/makefile.test
Normal file
@@ -0,0 +1,88 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU =
|
||||
ARCH =
|
||||
BOARD = NONE
|
||||
F_CPU = $(F_USB)
|
||||
OPTIMIZATION = 1
|
||||
TARGET = Test
|
||||
SRC = $(TARGET)_C.c $(TARGET)_CPP.cpp Dummy.S $(LUFA_SRC_USB)
|
||||
LUFA_PATH = ../../LUFA
|
||||
DEBUG_LEVEL = 0
|
||||
|
||||
ifeq ($(ARCH), AVR8)
|
||||
F_USB = 8000000
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
F_USB = 48000000
|
||||
else ifeq ($(ARCH), UC3)
|
||||
F_USB = 48000000
|
||||
endif
|
||||
|
||||
# Generic C/C++ compiler flags
|
||||
CC_FLAGS = -Wextra
|
||||
CC_FLAGS += -Werror
|
||||
CC_FLAGS += -Wformat=2
|
||||
CC_FLAGS += -Winit-self
|
||||
CC_FLAGS += -Wswitch-enum
|
||||
CC_FLAGS += -Wunused
|
||||
CC_FLAGS += -Wundef
|
||||
CC_FLAGS += -Wpointer-arith
|
||||
CC_FLAGS += -Wcast-align
|
||||
CC_FLAGS += -Wwrite-strings
|
||||
CC_FLAGS += -Wlogical-op
|
||||
CC_FLAGS += -Wmissing-declarations
|
||||
CC_FLAGS += -Wmissing-field-initializers
|
||||
CC_FLAGS += -Wmissing-format-attribute
|
||||
CC_FLAGS += -Woverlength-strings
|
||||
CC_FLAGS += -Wswitch-default
|
||||
CC_FLAGS += -Wfloat-equal
|
||||
CC_FLAGS += -Waggregate-return
|
||||
CC_FLAGS += -Wmissing-include-dirs
|
||||
|
||||
# Disable warnings not supported by the version of GCC used for UC3 targets (FIXME)
|
||||
ifneq ($(ARCH), UC3)
|
||||
CC_FLAGS += -Wdouble-promotion
|
||||
endif
|
||||
|
||||
# Only enable redundant declaration warnings for AVR8 target (FIXME)
|
||||
ifeq ($(ARCH), AVR8)
|
||||
CC_FLAGS += -Wredundant-decls
|
||||
endif
|
||||
|
||||
# C compiler only flags
|
||||
C_FLAGS += -Wmissing-parameter-type
|
||||
C_FLAGS += -Wmissing-prototypes
|
||||
C_FLAGS += -Wnested-externs
|
||||
C_FLAGS += -Wbad-function-cast
|
||||
C_FLAGS += -Wstrict-prototypes
|
||||
C_FLAGS += -Wold-style-definition
|
||||
|
||||
# Disable warnings not supported by the version of GCC used for UC3 targets (FIXME)
|
||||
ifneq ($(ARCH), UC3)
|
||||
C_FLAGS += -Wunsuffixed-float-constants
|
||||
C_FLAGS += -Wjump-misses-init
|
||||
endif
|
||||
|
||||
# Only check C++ compatibility on the build files, to ensure headers are C++ compatible
|
||||
Test_C.c Test_CPP.c: CC_FLAGS += -Wc++-compat
|
||||
|
||||
# Potential additional warnings to enable in the future (FIXME)
|
||||
#CC_FLAGS += -Wcast-qual
|
||||
#CC_FLAGS += -Wconversion
|
||||
#CC_FLAGS += -Wsign-conversion
|
||||
#CC_FLAGS += -pedantic
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
42
BuildTests/SingleUSBModeTest/Dummy.S
Normal file
42
BuildTests/SingleUSBModeTest/Dummy.S
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
.section .text
|
||||
|
||||
|
||||
# Mandatory entry point for successful compilation and link
|
||||
.global main
|
||||
main:
|
||||
# Force code generation of the base USB stack
|
||||
call USB_Init
|
||||
|
||||
# Mandatory callback needed for base compile of the USB driver
|
||||
.global CALLBACK_USB_GetDescriptor
|
||||
CALLBACK_USB_GetDescriptor:
|
||||
32
BuildTests/SingleUSBModeTest/Test.c
Normal file
32
BuildTests/SingleUSBModeTest/Test.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
56
BuildTests/SingleUSBModeTest/makefile
Normal file
56
BuildTests/SingleUSBModeTest/makefile
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
# Makefile for the single USB mode build test.
|
||||
# This test attempts to build the USB module
|
||||
# under fixed device and fixed host modes under
|
||||
# all supported architectures
|
||||
|
||||
# Path to the LUFA library core
|
||||
LUFA_PATH := ../../LUFA/
|
||||
|
||||
# Build test cannot be run with multiple parallel jobs
|
||||
.NOTPARALLEL:
|
||||
|
||||
all: begin compile clean end
|
||||
|
||||
begin:
|
||||
@echo Executing build test "SingleUSBModeTest".
|
||||
@echo
|
||||
|
||||
end:
|
||||
@echo Build test "SingleUSBModeTest" complete.
|
||||
@echo
|
||||
|
||||
compile:
|
||||
@echo Building SingleUSBModeTest for ARCH=AVR8 in device only mode...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=AVR8 MCU=at90usb1287 CC_FLAGS='-D USB_DEVICE_ONLY'
|
||||
|
||||
@echo Building SingleUSBModeTest for ARCH=AVR8 in host only mode...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=AVR8 MCU=at90usb1287 CC_FLAGS='-D USB_HOST_ONLY'
|
||||
|
||||
@echo Building SingleUSBModeTest for ARCH=XMEGA in device only mode...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=XMEGA MCU=atxmega128a1u CC_FLAGS='-D USB_DEVICE_ONLY'
|
||||
|
||||
@echo Building SingleUSBModeTest for ARCH=UC3 in device only mode...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=UC3 MCU=uc3a0256 CC_FLAGS='-D USB_DEVICE_ONLY'
|
||||
|
||||
@echo Building SingleUSBModeTest for ARCH=UC3 in host only mode...
|
||||
$(MAKE) -f makefile.test clean elf ARCH=UC3 MCU=uc3a0256 CC_FLAGS='-D USB_HOST_ONLY'
|
||||
|
||||
clean:
|
||||
$(MAKE) -f makefile.test clean ARCH=AVR8 MCU=at90usb1287
|
||||
$(MAKE) -f makefile.test clean ARCH=XMEGA MCU=atxmega128a1u
|
||||
$(MAKE) -f makefile.test clean ARCH=UC3 MCU=uc3a0256
|
||||
|
||||
%:
|
||||
|
||||
.PHONY: begin end compile clean
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
69
BuildTests/SingleUSBModeTest/makefile.test
Normal file
69
BuildTests/SingleUSBModeTest/makefile.test
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU =
|
||||
ARCH =
|
||||
BOARD = NONE
|
||||
F_CPU = $(F_USB)
|
||||
DEBUG_LEVEL = 0
|
||||
|
||||
ifeq ($(ARCH), AVR8)
|
||||
F_USB = 8000000
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
F_USB = 48000000
|
||||
else ifeq ($(ARCH), UC3)
|
||||
F_USB = 48000000
|
||||
endif
|
||||
|
||||
OPTIMIZATION = 1
|
||||
TARGET = Test
|
||||
SRC = Test.c Dummy.S $(LUFA_SRC_USB)
|
||||
LUFA_PATH = ../../LUFA
|
||||
|
||||
# Generic C/C++ compiler flags
|
||||
CC_FLAGS = -Wextra
|
||||
CC_FLAGS += -Werror
|
||||
CC_FLAGS += -Wformat=2
|
||||
CC_FLAGS += -Winit-self
|
||||
CC_FLAGS += -Wswitch-enum
|
||||
CC_FLAGS += -Wunused
|
||||
CC_FLAGS += -Wundef
|
||||
CC_FLAGS += -Wpointer-arith
|
||||
CC_FLAGS += -Wcast-align
|
||||
CC_FLAGS += -Wwrite-strings
|
||||
CC_FLAGS += -Wlogical-op
|
||||
CC_FLAGS += -Wmissing-declarations
|
||||
CC_FLAGS += -Wmissing-field-initializers
|
||||
CC_FLAGS += -Wmissing-format-attribute
|
||||
CC_FLAGS += -Woverlength-strings
|
||||
|
||||
# Only enable rendundant declaration warnings for AVR8 target (FIXME)
|
||||
ifeq ($(ARCH), AVR8)
|
||||
CC_FLAGS += -Wredundant-decls
|
||||
endif
|
||||
|
||||
# C compiler only flags
|
||||
C_FLAGS += -Wmissing-parameter-type
|
||||
C_FLAGS += -Wnested-externs
|
||||
|
||||
# Potential additional warnings to enable in the future (FIXME)
|
||||
#CC_FLAGS += -Wswitch-default
|
||||
#CC_FLAGS += -Wc++-compat
|
||||
#CC_FLAGS += -Wcast-qual
|
||||
#CC_FLAGS += -Wconversion
|
||||
#CC_FLAGS += -Wjump-misses-init
|
||||
#CC_FLAGS += -pedantic
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
47
BuildTests/StaticAnalysisTest/makefile
Normal file
47
BuildTests/StaticAnalysisTest/makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
# Static anlysis of the entire LUFA source tree, using the free cross-platform "cppcheck" tool.
|
||||
|
||||
# Path to the LUFA library core
|
||||
LUFA_PATH := ../../LUFA/
|
||||
|
||||
CPPCHECK_EXCLUDES := FATFs/ \
|
||||
PetiteFATFs/ \
|
||||
uip/
|
||||
|
||||
CPPCHECK_INCLUDES := $(patsubst %/,%,$(LUFA_PATH))/CodeTemplates/ \
|
||||
$(patsubst %/,%,$(LUFA_PATH))/../Projects/AVRISP-MKII/
|
||||
|
||||
CPPCHECK_FLAGS := -U TEMPLATE_FUNC_NAME -U __GNUC__ -U __DOXYGEN__
|
||||
|
||||
CPPCHECK_SUPPRESS := variableScope missingInclude unusedFunction
|
||||
|
||||
SRC := $(patsubst %/,%,$(LUFA_PATH))/..
|
||||
|
||||
# Build test cannot be run with multiple parallel jobs
|
||||
.NOTPARALLEL:
|
||||
|
||||
all: begin cppcheck end
|
||||
|
||||
begin:
|
||||
@echo Executing build test "StaticAnalysisTest".
|
||||
@echo
|
||||
|
||||
end:
|
||||
@echo Build test "StaticAnalysisTest" complete.
|
||||
@echo
|
||||
|
||||
%:
|
||||
|
||||
|
||||
.PHONY: all begin end
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
24
BuildTests/makefile
Normal file
24
BuildTests/makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
# Makefile to build all the LUFA Build Tests. Build Tests are
|
||||
# used to verify the correctness of the LUFA library, and are
|
||||
# not intended to be modified or compiled by non-developers.
|
||||
|
||||
all:
|
||||
|
||||
%:
|
||||
@echo Executing \"make $@\" on all LUFA build tests.
|
||||
@echo
|
||||
$(MAKE) -C BoardDriverTest $@
|
||||
$(MAKE) -C BootloaderTest $@
|
||||
$(MAKE) -C ModuleTest $@
|
||||
$(MAKE) -C SingleUSBModeTest $@
|
||||
$(MAKE) -C StaticAnalysisTest $@
|
||||
@echo
|
||||
@echo LUFA build test \"make $@\" operation complete.
|
||||
@@ -1 +0,0 @@
|
||||
<AVRStudio><MANAGEMENT><ProjectName>AudioInput</ProjectName><Created>13-Jul-2010 15:22:28</Created><LastEdit>13-Jul-2010 15:22:44</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:22:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\AudioInput\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>AudioInput.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>AudioInput.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>AudioInput.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -44,10 +44,14 @@ USB_ClassInfo_Audio_Device_t Microphone_Audio_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.ControlInterfaceNumber = 0,
|
||||
.StreamingInterfaceNumber = 1,
|
||||
|
||||
.DataINEndpointNumber = AUDIO_STREAM_EPNUM,
|
||||
.DataINEndpointSize = AUDIO_STREAM_EPSIZE,
|
||||
.DataINEndpoint =
|
||||
{
|
||||
.Address = AUDIO_STREAM_EPADDR,
|
||||
.Size = AUDIO_STREAM_EPSIZE,
|
||||
.Banks = 2,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -63,7 +67,7 @@ int main(void)
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
GlobalInterruptEnable();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -75,12 +79,14 @@ int main(void)
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
#endif
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
@@ -90,7 +96,7 @@ void SetupHardware(void)
|
||||
USB_Init();
|
||||
|
||||
/* Start the ADC conversion in free running mode */
|
||||
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_MUX_MASK);
|
||||
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_GET_CHANNEL_MASK(MIC_IN_ADC_CHANNEL));
|
||||
}
|
||||
|
||||
/** ISR to handle the reloading of the data endpoint with the next sample. */
|
||||
@@ -106,11 +112,11 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
||||
#if defined(USE_TEST_TONE)
|
||||
static uint8_t SquareWaveSampleCount;
|
||||
static int16_t CurrentWaveValue;
|
||||
|
||||
|
||||
/* In test tone mode, generate a square wave at 1/256 of the sample rate */
|
||||
if (SquareWaveSampleCount++ == 0xFF)
|
||||
CurrentWaveValue ^= 0x8000;
|
||||
|
||||
|
||||
/* Only generate audio if the board button is being pressed */
|
||||
AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0;
|
||||
#else
|
||||
@@ -122,7 +128,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
||||
AudioSample -= (SAMPLE_MAX_RANGE / 2);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Audio_Device_WriteSample16(&Microphone_Audio_Interface, AudioSample);
|
||||
}
|
||||
|
||||
@@ -171,7 +177,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
*
|
||||
* When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for
|
||||
* the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations
|
||||
* to indicate the size of the retreived data.
|
||||
* to indicate the size of the retrieved data.
|
||||
*
|
||||
* \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value
|
||||
* of the \c DataLength parameter.
|
||||
@@ -186,7 +192,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
* \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where
|
||||
* the retrieved data is to be stored for GET operations.
|
||||
*
|
||||
* \return Boolean true if the property get/set was successful, false otherwise
|
||||
* \return Boolean \c true if the property get/set was successful, \c false otherwise
|
||||
*/
|
||||
bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
|
||||
const uint8_t EndpointProperty,
|
||||
@@ -196,7 +202,7 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
|
||||
uint8_t* Data)
|
||||
{
|
||||
/* Check the requested endpoint to see if a supported endpoint is being manipulated */
|
||||
if (EndpointAddress == (ENDPOINT_DIR_IN | Microphone_Audio_Interface.Config.DataINEndpointNumber))
|
||||
if (EndpointAddress == Microphone_Audio_Interface.Config.DataINEndpoint.Address)
|
||||
{
|
||||
/* Check the requested control to see if a supported control is being manipulated */
|
||||
if (EndpointControl == AUDIO_EPCONTROL_SamplingFreq)
|
||||
@@ -211,10 +217,10 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
|
||||
CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]);
|
||||
|
||||
/* Adjust sample reload timer to the new frequency */
|
||||
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
|
||||
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
return true;
|
||||
case AUDIO_REQ_GetCurrent:
|
||||
/* Check if we are just testing for a valid property, or actually reading it */
|
||||
if (DataLength != NULL)
|
||||
@@ -223,13 +229,46 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
|
||||
|
||||
Data[2] = (CurrentAudioSampleFrequency >> 16);
|
||||
Data[1] = (CurrentAudioSampleFrequency >> 8);
|
||||
Data[0] = (CurrentAudioSampleFrequency & 0xFF);
|
||||
Data[0] = (CurrentAudioSampleFrequency & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Audio class driver callback for the setting and retrieval of streaming interface properties. This callback must be implemented
|
||||
* in the user application to handle property manipulations on streaming audio interfaces.
|
||||
*
|
||||
* When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for
|
||||
* the given entity and should return as fast as possible. When non-NULL, this value may be altered for GET operations
|
||||
* to indicate the size of the retrieved data.
|
||||
*
|
||||
* \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value
|
||||
* of the \c DataLength parameter.
|
||||
*
|
||||
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
|
||||
* \param[in] Property Property of the interface to get or set, a value from Audio_ClassRequests_t.
|
||||
* \param[in] EntityAddress Address of the audio entity whose property is being referenced.
|
||||
* \param[in] Parameter Parameter of the entity to get or set, specific to each type of entity (see USB Audio specification).
|
||||
* \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum
|
||||
* length of the retrieved data. When NULL, the function should return whether the given property
|
||||
* and parameter is valid for the requested endpoint without reading or modifying the Data buffer.
|
||||
* \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where
|
||||
* the retrieved data is to be stored for GET operations.
|
||||
*
|
||||
* \return Boolean \c true if the property GET/SET was successful, \c false otherwise
|
||||
*/
|
||||
bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
|
||||
const uint8_t Property,
|
||||
const uint8_t EntityAddress,
|
||||
const uint16_t Parameter,
|
||||
uint16_t* const DataLength,
|
||||
uint8_t* Data)
|
||||
{
|
||||
/* No audio interface entities in the device descriptor, thus no properties to get or set. */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -42,21 +42,16 @@
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/Board/Buttons.h>
|
||||
#include <LUFA/Drivers/Peripheral/ADC.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Platform/Platform.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "Config/AppConfig.h"
|
||||
|
||||
/* Macros: */
|
||||
/** ADC channel number for the microphone input. */
|
||||
#define MIC_IN_ADC_CHANNEL 2
|
||||
|
||||
/** ADC channel MUX mask for the microphone input. */
|
||||
#define MIC_IN_ADC_MUX_MASK ADC_CHANNEL2
|
||||
|
||||
/** Maximum audio sample value for the microphone input. */
|
||||
#define SAMPLE_MAX_RANGE 0xFFFF
|
||||
|
||||
@@ -83,5 +78,17 @@
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
|
||||
bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
|
||||
const uint8_t EndpointProperty,
|
||||
const uint8_t EndpointAddress,
|
||||
const uint8_t EndpointControl,
|
||||
uint16_t* const DataLength,
|
||||
uint8_t* Data) ATTR_NON_NULL_PTR_ARG(1);
|
||||
bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
|
||||
const uint8_t Property,
|
||||
const uint8_t EntityAddress,
|
||||
const uint16_t Parameter,
|
||||
uint16_t* const DataLength,
|
||||
uint8_t* Data);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* - Series 7 USB AVRs (AT90USBxxx7)
|
||||
* - Series 6 USB AVRs (AT90USBxxx6)
|
||||
* - Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4)
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
@@ -38,7 +38,7 @@
|
||||
* USBIF Audio 1.0 Data Formats Specification</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
@@ -50,7 +50,7 @@
|
||||
* basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers
|
||||
* required).
|
||||
*
|
||||
* On start-up the system will automatically enumerate and function as a
|
||||
* On start-up the system will automatically enumerate and function as a
|
||||
* USB microphone. By default, the demo will produce a square wave test tone
|
||||
* when the board button is pressed. If USE_TEST_TONE is not defined in the
|
||||
* project makefile, incoming audio from the ADC channel 1 will be sampled
|
||||
@@ -67,19 +67,24 @@
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>Define Name:</b></td>
|
||||
* <td><b>Location:</b></td>
|
||||
* <td><b>Description:</b></td>
|
||||
* <th><b>Define Name:</b></th>
|
||||
* <th><b>Location:</b></th>
|
||||
* <th><b>Description:</b></th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MIC_IN_ADC_CHANNEL</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>Sets the ADC channel used by the demo for the input audio samples from an attached microphone.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>USE_TEST_TONE</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>When defined, this alters the demo to produce a square wave test tone when the first board button is pressed
|
||||
* instead of sampling the board microphone.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MICROPHONE_BIASED_TO_HALF_RAIL</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>AppConfig.h</td>
|
||||
* <td>When defined, this alters the demo so that the half VCC bias of the microphone input is subtracted.</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
@@ -18,7 +18,7 @@
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
@@ -28,33 +28,24 @@
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include "SideshowApplications.h"
|
||||
/** \file
|
||||
* \brief Application Configuration Header File
|
||||
*
|
||||
* This is a header file which is be used to configure some of
|
||||
* the application's compile time options, as an alternative to
|
||||
* specifying the compile time constants supplied through a
|
||||
* makefile or build system.
|
||||
*
|
||||
* For information on what each token does, refer to the
|
||||
* \ref Sec_Options section of the application documentation.
|
||||
*/
|
||||
|
||||
SideShow_Application_t InstalledApplications[MAX_APPLICATIONS];
|
||||
#ifndef _APP_CONFIG_H_
|
||||
#define _APP_CONFIG_H_
|
||||
|
||||
#define MIC_IN_ADC_CHANNEL 2
|
||||
|
||||
SideShow_Application_t* SideShow_GetFreeApplication(void)
|
||||
{
|
||||
for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++)
|
||||
{
|
||||
if (!(InstalledApplications[App].InUse))
|
||||
return &InstalledApplications[App];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* const GUID)
|
||||
{
|
||||
for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++)
|
||||
{
|
||||
if (InstalledApplications[App].InUse)
|
||||
{
|
||||
if (GUID_COMPARE(&InstalledApplications[App].ApplicationID, GUID))
|
||||
return &InstalledApplications[App];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#define MICROPHONE_BIASED_TO_HALF_RAIL
|
||||
#define USE_TEST_TONE
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user