mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-11-04 06:57:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6180d8a26b | ||
|
|
6b24be5f69 | ||
|
|
ede0f06e03 | ||
|
|
cef2651b0d | ||
|
|
5bb68e6125 | ||
|
|
1069753842 | ||
|
|
5a11529409 | ||
|
|
a6f668ece4 | ||
|
|
7cf6787810 | ||
|
|
29173a4de1 | ||
|
|
583d67b30d | ||
|
|
a76d419c34 | ||
|
|
e6da12ab45 | ||
|
|
4d1ca56d0a | ||
|
|
e8ffbd019a | ||
|
|
d0f13ea1fe | ||
|
|
cb30e6f172 | ||
|
|
87b8354d1f | ||
|
|
d435d66921 | ||
|
|
3249f41dd9 | ||
|
|
da75a5443f | ||
|
|
6770e15527 | ||
|
|
210c6f4a40 | ||
|
|
30c734971e | ||
|
|
794aef2053 | ||
|
|
698bfa2c09 | ||
|
|
c9dd183d4d | ||
|
|
29dd14ee46 | ||
|
|
e1ea1c6dd1 | ||
|
|
78540d604f | ||
|
|
3c4470889b | ||
|
|
3e87e07921 | ||
|
|
827edd212b | ||
|
|
16477539d9 | ||
|
|
6b5158a682 | ||
|
|
0623a20120 | ||
|
|
33070836f9 | ||
|
|
01290c728b | ||
|
|
c8af92c4d8 | ||
|
|
f20bfe9f63 | ||
|
|
d8c27bb7fd | ||
|
|
88eab38a6c | ||
|
|
450ce3b3c6 | ||
|
|
efe383d090 | ||
|
|
ca46deb0a2 | ||
|
|
d28c2e0871 | ||
|
|
36422ba612 | ||
|
|
04d029a5bd | ||
|
|
b5ddc1879e | ||
|
|
2910556adc | ||
|
|
f5ab453f75 | ||
|
|
0147d71e73 | ||
|
|
24768bcd9a | ||
|
|
859a721b41 | ||
|
|
d7e4a2572a | ||
|
|
4493a352cb | ||
|
|
c4b2c5039f | ||
|
|
a766738509 | ||
|
|
6250be4bf1 | ||
|
|
4ca93c5139 | ||
|
|
fa1caccd67 | ||
|
|
6a9a6a3e6d | ||
|
|
31c3081668 | ||
|
|
d475f25154 | ||
|
|
4bce0cc1f2 | ||
|
|
b1e088396a | ||
|
|
df983b53c7 | ||
|
|
0e98348d96 | ||
|
|
70da7d88f4 | ||
|
|
3182f6036d | ||
|
|
de9a9b79f4 | ||
|
|
b8544f5c8c | ||
|
|
00b5e72496 | ||
|
|
389e5b004d | ||
|
|
ddcb2dba8c | ||
|
|
73020f3567 | ||
|
|
a48e944f0b | ||
|
|
c83fa9fc2b | ||
|
|
8970125e51 | ||
|
|
22224cef7b | ||
|
|
4329614a8f | ||
|
|
bd12455029 | ||
|
|
3a2708b30a | ||
|
|
fb557b2af9 | ||
|
|
7f2b127506 | ||
|
|
5a96435322 | ||
|
|
f3b3a0de40 | ||
|
|
6940c5b73e | ||
|
|
4786a4a251 | ||
|
|
9027359cec | ||
|
|
eefbe6bda9 | ||
|
|
ab74be4811 | ||
|
|
488711a9b3 | ||
|
|
91fc6735e9 | ||
|
|
6b62aacdc9 | ||
|
|
4f747e416b | ||
|
|
155dedb048 | ||
|
|
29ca3ebfab | ||
|
|
4e700d4904 | ||
|
|
8473ff6f35 | ||
|
|
5f99d530ff | ||
|
|
c5150ccf02 | ||
|
|
438a08e0ac | ||
|
|
2d68ec56e3 | ||
|
|
836c8dcc76 | ||
|
|
9e25f4ac0a | ||
|
|
a73fe207a8 | ||
|
|
ea3bb737de | ||
|
|
0bc8a8993f | ||
|
|
78b39b4347 | ||
|
|
e7450022a8 | ||
|
|
4f8c2afabf | ||
|
|
2e6c877d1b | ||
|
|
59df4f9e8c | ||
|
|
64d8e34567 | ||
|
|
3d920bf62b | ||
|
|
ed9bf7a8dd | ||
|
|
0eead42aec | ||
|
|
a6a8962b1d | ||
|
|
79add7baf5 | ||
|
|
101a54da10 | ||
|
|
e81391f395 | ||
|
|
eaaf5f8e84 | ||
|
|
1c85a7a5be | ||
|
|
f5a1947974 | ||
|
|
66db5aeda3 | ||
|
|
36a1f428dd | ||
|
|
7210c3914d | ||
|
|
8b8c9d58be | ||
|
|
39da39544b | ||
|
|
386ed04058 | ||
|
|
c87ea51b86 | ||
|
|
9924e54654 | ||
|
|
2de2fbf82f | ||
|
|
dbc7648649 | ||
|
|
ffa2379818 | ||
|
|
aebee3dfd4 | ||
|
|
277a0c83f4 | ||
|
|
e34b183f1d | ||
|
|
188e25948b | ||
|
|
80c3a8401b | ||
|
|
5f95de1314 | ||
|
|
a980696dd0 | ||
|
|
2107d4e97f | ||
|
|
1bca78c0c8 | ||
|
|
d7494e81ce | ||
|
|
aac573642b | ||
|
|
a5bf0bad6e | ||
|
|
cf3f39f576 | ||
|
|
99ad4d5c0f | ||
|
|
da70d4a6ab | ||
|
|
4f908f3330 | ||
|
|
b55f516c11 | ||
|
|
d2977b16c8 | ||
|
|
0cb582d10c | ||
|
|
7229caf9d6 | ||
|
|
3af7f744b4 | ||
|
|
de32e8cf0a | ||
|
|
5217eb6dbc | ||
|
|
c42dce080c | ||
|
|
6f869065b4 | ||
|
|
b36925d92a | ||
|
|
b60ef5c3f7 | ||
|
|
f4b503e829 | ||
|
|
90c856e9bf | ||
|
|
c9a548f0c8 | ||
|
|
cda1798d70 | ||
|
|
dbeaafa7b5 | ||
|
|
0811a477ae | ||
|
|
6c0bb9d8ec | ||
|
|
597dc6f0a9 | ||
|
|
9e396b0a03 | ||
|
|
e75aa4f40a | ||
|
|
787de9bd56 | ||
|
|
dc41079c4f | ||
|
|
4e839b1dea | ||
|
|
f390e751df | ||
|
|
cf963945cf | ||
|
|
503609f021 | ||
|
|
150a8a51f7 | ||
|
|
daabc3d447 | ||
|
|
5e6e04abcf | ||
|
|
ef9f181beb | ||
|
|
cc8ea2bd2f | ||
|
|
8021308f2a | ||
|
|
166db6d561 | ||
|
|
b20af27340 | ||
|
|
b545673672 | ||
|
|
4dab09085f | ||
|
|
af15d74e71 | ||
|
|
4d25d35098 | ||
|
|
8d4e89fdde | ||
|
|
8a8364481c | ||
|
|
7f912dd7b2 | ||
|
|
5424d55e76 | ||
|
|
9ced2bcefd | ||
|
|
7008762664 | ||
|
|
c0666e4545 | ||
|
|
dd5275b1bb | ||
|
|
0f40a6076e | ||
|
|
f9c032fbd7 | ||
|
|
941b1ddfeb | ||
|
|
f6c9614976 | ||
|
|
68959e00c4 | ||
|
|
1d85a000e2 | ||
|
|
de1d6b4ad5 | ||
|
|
7f307ce0d9 | ||
|
|
19cf4dc9d7 | ||
|
|
ba4724e17f | ||
|
|
b053001ac6 | ||
|
|
084dbc5ae0 | ||
|
|
14e31117bf | ||
|
|
113c806bfa | ||
|
|
05fcc9f32d | ||
|
|
527aa4df08 | ||
|
|
7211d3847c | ||
|
|
d02d6c8114 | ||
|
|
993ac762ca | ||
|
|
d099cda94c | ||
|
|
569e64f504 | ||
|
|
4946c0388f | ||
|
|
d6743ea8a1 | ||
|
|
27b0c2ff40 | ||
|
|
cd26cbc09b | ||
|
|
f1e6e7ce79 | ||
|
|
b3ff9844c2 | ||
|
|
6e3ec05c04 | ||
|
|
c9f04a5b96 | ||
|
|
20ccfdabe3 | ||
|
|
2ad0f5fa7d | ||
|
|
0e4e8770df | ||
|
|
13390f93da | ||
|
|
b2f81775fc | ||
|
|
b3ed95f020 | ||
|
|
95926c6024 | ||
|
|
e9ad63ba3d | ||
|
|
bc51b6696a | ||
|
|
f205fcd6fb | ||
|
|
41db95f28e | ||
|
|
3f80d62ca5 | ||
|
|
33e3e65b78 | ||
|
|
0d8cdbc42a | ||
|
|
498ab10ef7 | ||
|
|
c3bc374eef | ||
|
|
66b6712682 | ||
|
|
0d97c2108d | ||
|
|
0889a68a7a | ||
|
|
38a67d1896 | ||
|
|
0fc9f2f4bd | ||
|
|
3791f9376e | ||
|
|
0f052bcee0 | ||
|
|
3d04d61bc6 | ||
|
|
58e756e6cc | ||
|
|
5e1fe6aeb8 | ||
|
|
235c0fac5b | ||
|
|
f82d1bc4b6 | ||
|
|
90f163f6d8 | ||
|
|
a427853ae0 | ||
|
|
d7d084673f | ||
|
|
1a6d8eae97 | ||
|
|
a2b3ae4970 | ||
|
|
97fbda552d | ||
|
|
142ed6057a | ||
|
|
2f9ed3e447 | ||
|
|
9e188d7370 | ||
|
|
dedbb74562 | ||
|
|
eae198000c | ||
|
|
9622b4f903 | ||
|
|
80fca98113 | ||
|
|
a7fe7c98a3 | ||
|
|
6e33825e9f | ||
|
|
b1e0d2fd72 | ||
|
|
42d9d9fe9d | ||
|
|
3f528bae0b | ||
|
|
13118196d8 | ||
|
|
6126d1192e | ||
|
|
627ce5d9a9 | ||
|
|
a754296a8a | ||
|
|
2e59aa3a6b | ||
|
|
082a0f2064 | ||
|
|
1e6b74f427 | ||
|
|
881dac1486 | ||
|
|
20a5b93402 | ||
|
|
2577833136 | ||
|
|
0ec25a7add | ||
|
|
81240bfdb9 | ||
|
|
7a728eeaa6 | ||
|
|
398ede8f90 | ||
|
|
cef07b4eeb | ||
|
|
0c086c2a4c | ||
|
|
566410a7e2 | ||
|
|
0e87ce6e3e | ||
|
|
4c1344c612 | ||
|
|
4e54deb050 | ||
|
|
6755bd101c | ||
|
|
7255b55ffe | ||
|
|
12d36857c2 | ||
|
|
a40d98dca2 | ||
|
|
f33fdd2e5a | ||
|
|
0edf5175a9 | ||
|
|
0a677620ab | ||
|
|
fc487794b3 | ||
|
|
4f74d41871 | ||
|
|
77c7b7f6dc | ||
|
|
488c6c4463 | ||
|
|
f1b4740579 | ||
|
|
0098324683 | ||
|
|
26bafdcf24 | ||
|
|
5e6690e296 | ||
|
|
78d0c3ae27 | ||
|
|
3895ffbda6 | ||
|
|
a4b5aa4ad1 | ||
|
|
84e843ac86 | ||
|
|
0299cfedb5 | ||
|
|
b404dabe15 | ||
|
|
d88ab7427a | ||
|
|
d481de3e00 | ||
|
|
1a5df60739 | ||
|
|
cb916d3087 | ||
|
|
0670265be0 | ||
|
|
6f7dc38d3c | ||
|
|
91f16ade72 | ||
|
|
81da515ae6 | ||
|
|
3aaef724b2 | ||
|
|
ba5d783c20 | ||
|
|
755cfa95e4 | ||
|
|
b37c078213 | ||
|
|
ba5977d679 | ||
|
|
4ba802d127 | ||
|
|
f9125593b2 | ||
|
|
15e26618dc | ||
|
|
a1412543c8 | ||
|
|
01b032ee7d | ||
|
|
72160554dc | ||
|
|
eab7e687de | ||
|
|
b39cd8ff45 | ||
|
|
38ff498101 | ||
|
|
4199430fe6 | ||
|
|
6fc2145871 | ||
|
|
b960b99182 | ||
|
|
64ea299572 | ||
|
|
d19e26fc9b | ||
|
|
7963ebcad9 | ||
|
|
d7af151e72 | ||
|
|
771cabbf94 | ||
|
|
705990bce8 | ||
|
|
0443811140 | ||
|
|
d37a3ae640 | ||
|
|
f5a48c3356 | ||
|
|
88bc14bb4e | ||
|
|
18b6b44b1e | ||
|
|
035e5ba9ac | ||
|
|
e5e10260d7 | ||
|
|
7b86264376 | ||
|
|
3da8e987df | ||
|
|
093b0091b6 | ||
|
|
cf72b29e21 | ||
|
|
66097042bb | ||
|
|
35e8ad97ac | ||
|
|
73d5190081 | ||
|
|
8966b2077e | ||
|
|
e1339e9d45 | ||
|
|
27218de969 | ||
|
|
ef3341d43f | ||
|
|
5f39316cd9 | ||
|
|
11572aa83d | ||
|
|
33195c9db8 | ||
|
|
bf4e000e93 | ||
|
|
8b49f47cac | ||
|
|
9ad10c8b1b | ||
|
|
8ba551c07e | ||
|
|
9ae36fe7e8 | ||
|
|
a5b78ff410 | ||
|
|
934d141b7e | ||
|
|
9d86c6b81e | ||
|
|
5b507ac126 | ||
|
|
bb3f0c8667 | ||
|
|
1fac639352 | ||
|
|
8ab7a41fab | ||
|
|
f22e19e81b | ||
|
|
43cfc4c0f0 | ||
|
|
86a6622724 | ||
|
|
307125255b | ||
|
|
75c89998c6 | ||
|
|
4263c8ff79 | ||
|
|
7d76c828ec | ||
|
|
791906ca32 | ||
|
|
2e5b45edfe | ||
|
|
6a092abb5e | ||
|
|
e843045f4d | ||
|
|
aa8cd83961 | ||
|
|
cb04d5338e | ||
|
|
1a138da50d | ||
|
|
dc90457828 | ||
|
|
b3a2afa5c5 | ||
|
|
0b3c515d9e | ||
|
|
73ec884012 | ||
|
|
0d13cb445c | ||
|
|
301e4ace3e | ||
|
|
764147d269 | ||
|
|
d790f4adc9 | ||
|
|
4c9df5bc41 | ||
|
|
35429d0f64 | ||
|
|
32a43b71e6 | ||
|
|
209c611a8b | ||
|
|
2118c82eaf | ||
|
|
8e52dd5e49 | ||
|
|
0b0677d0d7 | ||
|
|
2aad7be11b | ||
|
|
3512f27da5 | ||
|
|
10b470afad | ||
|
|
6642747a2d | ||
|
|
d7016237d2 | ||
|
|
6b4cf21ba2 | ||
|
|
7966e5e85c | ||
|
|
c7ec6baabe | ||
|
|
d6b28e6605 | ||
|
|
c6d9ca8082 | ||
|
|
4ba551827f | ||
|
|
6217eb9eeb | ||
|
|
28e09e0aba | ||
|
|
513cc7ab44 | ||
|
|
1b0816163b | ||
|
|
041defeb63 | ||
|
|
2c9826acd9 | ||
|
|
09697eb541 | ||
|
|
cc829aa405 | ||
|
|
614da97a4a | ||
|
|
00669e813e | ||
|
|
763c7df557 | ||
|
|
f157069595 | ||
|
|
947045239a | ||
|
|
da2aca70cc | ||
|
|
ff120ffadb | ||
|
|
2df81e6543 | ||
|
|
a4084e0f46 | ||
|
|
26e02484f3 | ||
|
|
148723984c | ||
|
|
62336dc766 | ||
|
|
316891dbd5 | ||
|
|
cf1ccfecad | ||
|
|
e6de13f679 | ||
|
|
7929dc3dae | ||
|
|
7c8e1e59e5 | ||
|
|
0e4995c680 | ||
|
|
29a62bc0ed | ||
|
|
d50796ff4c | ||
|
|
c41dd59b5f | ||
|
|
f841a4593d | ||
|
|
013458ad97 | ||
|
|
d594cbc1a4 | ||
|
|
27882cdce6 | ||
|
|
afeb645a87 | ||
|
|
46adc425a4 | ||
|
|
08c0f27f45 | ||
|
|
5ed4d509f5 | ||
|
|
cf4efa2c94 | ||
|
|
4bbdeab8d1 | ||
|
|
348f268113 | ||
|
|
72902e6931 | ||
|
|
6adf9810a6 | ||
|
|
609473760a | ||
|
|
54a0ad7070 | ||
|
|
447207b875 | ||
|
|
570bd5b664 | ||
|
|
99d31d2c82 | ||
|
|
dad8e10f6c | ||
|
|
f12c837479 | ||
|
|
bce102e34a | ||
|
|
d95684ce8b | ||
|
|
74c650851e | ||
|
|
af105128f3 | ||
|
|
ed7c5ac2f3 | ||
|
|
0b84f428d2 | ||
|
|
725c82c7e8 | ||
|
|
9f80139ee8 | ||
|
|
3426778a27 | ||
|
|
6ac95d3798 | ||
|
|
1dbe7c3b80 | ||
|
|
3ca3b92e2a | ||
|
|
1c1104e989 | ||
|
|
3bf0635676 | ||
|
|
630a271372 | ||
|
|
d142418b0f | ||
|
|
632e4611bf | ||
|
|
3ee1955e1b | ||
|
|
fe1a7ea4f2 | ||
|
|
795fd2ee17 | ||
|
|
b062026606 | ||
|
|
56c6378c39 | ||
|
|
2b5dd6c614 | ||
|
|
1c48833336 | ||
|
|
9a7eeeb499 | ||
|
|
e92937e9d5 | ||
|
|
8e85c9aa8a | ||
|
|
c467875ca3 | ||
|
|
79a6a0c4f7 | ||
|
|
392f69a2c3 | ||
|
|
f097cae0cd | ||
|
|
1db3ffe968 | ||
|
|
9ea3f08e23 | ||
|
|
2128d60cc9 | ||
|
|
6b3f70db47 | ||
|
|
09fdd7dee2 | ||
|
|
7438933f2f | ||
|
|
c0f75b21b0 | ||
|
|
98271c9f56 | ||
|
|
b91a76a16e | ||
|
|
b2d4b016a9 | ||
|
|
01ac2b3d46 | ||
|
|
79ae930f15 | ||
|
|
0516c2e247 | ||
|
|
487871db8e | ||
|
|
54ddaa142d | ||
|
|
e37c884463 | ||
|
|
5c5b9945bc | ||
|
|
f99645ede8 | ||
|
|
42734a1ab5 | ||
|
|
86809ca043 | ||
|
|
54f4fdab58 | ||
|
|
cb735eaf8b | ||
|
|
bfa269c55f | ||
|
|
74d5dac7a8 | ||
|
|
fb8c743d3b | ||
|
|
c01b7f9285 | ||
|
|
3718aaeeaf | ||
|
|
0526a2b120 | ||
|
|
ab4ecd141f | ||
|
|
8ccb638a84 | ||
|
|
fc63d5096a | ||
|
|
7d59a758da | ||
|
|
e2e220a505 | ||
|
|
9df8b8b870 | ||
|
|
802437220c | ||
|
|
80e0c1501e | ||
|
|
7bd3c5489f | ||
|
|
2446d02e59 | ||
|
|
c55783d9b5 | ||
|
|
c7cb5f971e | ||
|
|
be2ba81b4b | ||
|
|
7ddab6435f | ||
|
|
fe5cbd8183 | ||
|
|
563f15158d | ||
|
|
c5c2039bfd | ||
|
|
dd43e2ac87 | ||
|
|
be87aac09d | ||
|
|
27cd385c58 | ||
|
|
995b977b8a | ||
|
|
ddae34c381 | ||
|
|
6c2867bc00 | ||
|
|
9c6c0d3031 | ||
|
|
db63651473 | ||
|
|
32bfb2adae | ||
|
|
3114f92afb | ||
|
|
467bd2bf1c | ||
|
|
a83f5d8e11 | ||
|
|
9ff2378a25 | ||
|
|
5d04a6c26a | ||
|
|
2fe17d9996 | ||
|
|
54ca93d499 | ||
|
|
0e6936de76 | ||
|
|
454b281201 | ||
|
|
5b2b688d03 | ||
|
|
e25b63a43a | ||
|
|
6df0bfdc4c | ||
|
|
3adfba32c8 | ||
|
|
a78d555f79 | ||
|
|
16e7af43a3 | ||
|
|
1597434ed7 | ||
|
|
e3449cd771 | ||
|
|
c4cf262b95 | ||
|
|
cf6aca19b0 | ||
|
|
d0389fe8f4 | ||
|
|
7cd90551c9 | ||
|
|
254ed6253e | ||
|
|
8a979d33bc | ||
|
|
c6d02901b3 | ||
|
|
126115a2cb | ||
|
|
3d99a55940 | ||
|
|
f8fdf47823 | ||
|
|
85a1556864 | ||
|
|
9c474844be | ||
|
|
5f5371b9b3 | ||
|
|
1d7ca6a1dc | ||
|
|
7691f08ff0 | ||
|
|
5b6488ca70 | ||
|
|
9556f2ace8 | ||
|
|
ef4d0e7564 | ||
|
|
fc00e2b202 | ||
|
|
8906b2a8bd | ||
|
|
c751975f1d | ||
|
|
c3fc0dba91 | ||
|
|
a921f27ee8 | ||
|
|
04290e7bea | ||
|
|
d78322519a | ||
|
|
09daa09a5e | ||
|
|
661827c166 | ||
|
|
2c13fd53f4 | ||
|
|
b1029c6ae5 | ||
|
|
95325465cc | ||
|
|
580ae2e7fc | ||
|
|
4ce961f25b | ||
|
|
90e3149050 | ||
|
|
fb847b942e | ||
|
|
dfc3db25c3 | ||
|
|
bc40cd7c46 | ||
|
|
bc418d6630 | ||
|
|
ee199d797c | ||
|
|
31e21d8b38 | ||
|
|
f19189cd2f | ||
|
|
7d47317e17 | ||
|
|
da2de8d519 | ||
|
|
a7c19a4d99 | ||
|
|
8f00fb9270 | ||
|
|
01f854c3db | ||
|
|
5eac387b5a | ||
|
|
b3b9e089f4 | ||
|
|
6bbcab7f50 | ||
|
|
137785f2f0 | ||
|
|
4ec938230d | ||
|
|
9a0ee51d91 | ||
|
|
3fec038ed8 | ||
|
|
69a1b555e4 | ||
|
|
ca400565b3 | ||
|
|
bcbd3fa089 | ||
|
|
44967695a4 | ||
|
|
2f314e1486 | ||
|
|
389c05b643 | ||
|
|
9d7de45aeb | ||
|
|
4653c07f06 | ||
|
|
d3f5249a61 | ||
|
|
d4cc11e132 | ||
|
|
f5b654eb5e | ||
|
|
60debfc217 | ||
|
|
2713069643 | ||
|
|
8df909f0a8 | ||
|
|
1d816c5cf3 | ||
|
|
66d1770407 | ||
|
|
8ab4774c93 | ||
|
|
1b54f0457d | ||
|
|
a004b7619e | ||
|
|
04fc396fd8 | ||
|
|
04e0df1c18 | ||
|
|
6d58633db0 | ||
|
|
15ca75d10d | ||
|
|
174e6e9724 | ||
|
|
53a99195bf | ||
|
|
8def8aee53 | ||
|
|
c51a227fd9 | ||
|
|
f3e3cefb23 | ||
|
|
73456ac80e | ||
|
|
113195eabd | ||
|
|
0eeff3e679 | ||
|
|
be5a925f72 | ||
|
|
ae28f5b425 | ||
|
|
b8a0551678 | ||
|
|
0f216b8618 | ||
|
|
52cfdaa2d2 | ||
|
|
a258c6d988 | ||
|
|
e0251415e7 | ||
|
|
12bb62eadd | ||
|
|
e2afc36dae | ||
|
|
4ea74d4600 | ||
|
|
9bc01fb061 | ||
|
|
01492634b6 | ||
|
|
05726e2575 | ||
|
|
14f87f61e6 | ||
|
|
7df44a5425 | ||
|
|
0cc0289c60 | ||
|
|
992229cf2f | ||
|
|
57aa554430 | ||
|
|
9ed3f5ea32 | ||
|
|
158c284423 | ||
|
|
2aefebaf00 | ||
|
|
d9b275c321 | ||
|
|
a3de7e8f04 | ||
|
|
6338794c61 | ||
|
|
641d9fe811 | ||
|
|
981a6976e2 | ||
|
|
7ec0ff51f0 | ||
|
|
3737d4bc12 | ||
|
|
7279bd9b32 | ||
|
|
2f1eec7118 | ||
|
|
3611a0579e | ||
|
|
04f05dac64 | ||
|
|
95cbe3b129 | ||
|
|
9ece5f64a9 | ||
|
|
61b4ca3354 | ||
|
|
a316c8bd67 | ||
|
|
25f6d395bc | ||
|
|
e66ee2af6d | ||
|
|
89be1cf9f8 | ||
|
|
d79fcb2ea5 | ||
|
|
19c3721151 | ||
|
|
47f0bed840 |
No files matched your search
@@ -0,0 +1,99 @@
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
AcrossComments: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
AcrossComments: true
|
||||
AlignCaseColons: false
|
||||
AlignEscapedNewlines: LeftWithLastLine
|
||||
AlignOperands: true
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 2
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseExpressionOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: true
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BracedInitializerIndentWidth: 2
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ContinuationIndentWidth: 2
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
Cpp11BracedListStyle: true
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*'
|
||||
Priority: 1
|
||||
- Regex: '^".*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IndentPPDirectives: BeforeHash
|
||||
InsertBraces: true
|
||||
IndentCaseLabels: true
|
||||
InsertNewlineAtEOF: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
PenaltyBreakBeforeFirstCallParameter: 1000000
|
||||
PenaltyBreakOpenParenthesis: 1000000
|
||||
PPIndentWidth: 2
|
||||
QualifierAlignment: Custom
|
||||
QualifierOrder: ['static', 'const', 'volatile', 'restrict', 'type']
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SortIncludes: false
|
||||
TabWidth: 2
|
||||
...
|
||||
@@ -0,0 +1,61 @@
|
||||
name: Bug Report
|
||||
description: Report a problem
|
||||
labels: 'Bug'
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
It's okay to leave some blank if it doesn't apply to your problem.
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Operating System
|
||||
options:
|
||||
- Linux
|
||||
- MacOS
|
||||
- RaspberryPi OS
|
||||
- Windows 7
|
||||
- Windows 10
|
||||
- Windows 11
|
||||
- Others
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: INFO_UF2.TXT
|
||||
placeholder: Paste your INFO_UF2.TXT contents here
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: What happened ?
|
||||
placeholder: A clear and concise description of what the bug is.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: How to reproduce ?
|
||||
placeholder: |
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. See error
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Debug Log
|
||||
placeholder: Debug log attached txt file.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Screenshots
|
||||
description: If applicable, add screenshots to help explain your problem.
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,4 @@
|
||||
contact_links:
|
||||
- name: Adafruit Support Forum
|
||||
url: https://forums.adafruit.com
|
||||
about: If you have other questions or need help, post it here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,16 @@
|
||||
## Checklist
|
||||
|
||||
*By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes*
|
||||
|
||||
- [ ] Please provide specific title of the PR describing the change
|
||||
- [ ] If you are adding an new boards, please make sure
|
||||
- [ ] Provide link to your allocated VID/PID if applicable
|
||||
- [ ] `UF2_BOARD_ID` in your board.h follow correct format from [uf2 specs](https://github.com/microsoft/uf2#files-exposed-by-bootloaders)
|
||||
|
||||
*This checklist items that are not applicable to your PR can be deleted.*
|
||||
|
||||
-----------
|
||||
|
||||
## Description of Change
|
||||
|
||||
Please describe your proposed Pull Request and it's impact.
|
||||
@@ -0,0 +1,68 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
repository_dispatch:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
jobs:
|
||||
set-matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set matrix
|
||||
id: set-matrix
|
||||
working-directory: src/boards
|
||||
run: |
|
||||
MATRIX_JSON=$(ls -d */ | sed 's/\/$//' | jq -R -s -c 'split("\n")[:-1]')
|
||||
echo "matrix=$MATRIX_JSON"
|
||||
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
|
||||
|
||||
build:
|
||||
needs: set-matrix
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
board: ${{ fromJSON(needs.set-matrix.outputs.matrix) }}
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- name: Install ARM GCC
|
||||
uses: carlosperate/arm-none-eabi-gcc-action@v1
|
||||
with:
|
||||
release: '12.3.Rel1'
|
||||
|
||||
- name: Install Tools
|
||||
run: |
|
||||
pip3 install adafruit-nrfutil uritemplate requests intelhex setuptools
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
make BOARD=${{ matrix.board }} all
|
||||
make BOARD=${{ matrix.board }} copy-artifact
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: _bin/${{ matrix.board }}
|
||||
|
||||
- name: Upload Release Asset
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
with:
|
||||
files: |
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.zip
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.hex
|
||||
_bin/${{ matrix.board }}/update-${{ matrix.board }}_bootloader-*.uf2
|
||||
+17
-2
@@ -36,6 +36,9 @@
|
||||
*.x86_64
|
||||
#*.hex
|
||||
|
||||
# VSCode files
|
||||
.vscode/
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
@@ -51,6 +54,18 @@ Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
src/segger/Output
|
||||
_build-*/
|
||||
segger/Output
|
||||
_build/
|
||||
bin/
|
||||
*.emSession
|
||||
*.jlink
|
||||
.idea/
|
||||
|
||||
TAGS
|
||||
|
||||
.DS_Store
|
||||
Makefile.user
|
||||
|
||||
# Exclude all SoftDevice S340 files
|
||||
lib/softdevice/s340*
|
||||
|
||||
+8
-2
@@ -1,7 +1,13 @@
|
||||
[submodule "tinyusb"]
|
||||
[submodule "lib/tinyusb"]
|
||||
path = lib/tinyusb
|
||||
url = https://github.com/hathach/tinyusb.git
|
||||
branch = develop
|
||||
[submodule "lib/nrfx"]
|
||||
path = lib/nrfx
|
||||
url = https://github.com/NordicSemiconductor/nrfx.git
|
||||
[submodule "lib/uf2"]
|
||||
path = lib/uf2
|
||||
url = https://github.com/microsoft/uf2.git
|
||||
|
||||
[submodule "lib/tinycrypt"]
|
||||
path = lib/tinycrypt
|
||||
url = https://github.com/intel/tinycrypt
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
sudo: required
|
||||
dist: xenial
|
||||
language: c
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key: "$GITHUB_TOKEN"
|
||||
file_glob: true
|
||||
file: "$TRAVIS_BUILD_DIR/bin/*/*"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
|
||||
before_script:
|
||||
- (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb)
|
||||
- (wget https://www.nordicsemi.com/api/sitecore/Products/DownloadPlatform --post-data=fileid=8F19D314130548209E75EFFADD9348DB -O cli-tools.tar && tar -xv -f cli-tools.tar && mv mergehex mergehex_all && mv mergehex_all/mergehex .)
|
||||
- export PATH=.:$PATH
|
||||
- mergehex --version
|
||||
|
||||
# report some good version numbers to the build
|
||||
- gcc --version
|
||||
- arm-none-eabi-gcc --version
|
||||
- python3 --version
|
||||
- python --version
|
||||
- sudo apt-get install -y python3-pip python3-setuptools
|
||||
- pip3 install --user adafruit-nrfutil
|
||||
|
||||
script:
|
||||
- python3 tools/build_all.py
|
||||
@@ -0,0 +1,25 @@
|
||||
# Agent Instructions
|
||||
|
||||
## Style
|
||||
- Follow the repo `.clang-format` when making changes.
|
||||
|
||||
## Build / Verify
|
||||
- Prefer CMake for testing/verification.
|
||||
- Always build both boards during verification:
|
||||
- `feather_nrf52832`
|
||||
- `feather_nrf52840_express`
|
||||
|
||||
### CMake (preferred)
|
||||
```bash
|
||||
cmake -S . -B cmake-build-feather_nrf52832 -DBOARD=feather_nrf52832
|
||||
cmake --build cmake-build-feather_nrf52832
|
||||
|
||||
cmake -S . -B cmake-build-feather_nrf52840_express -DBOARD=feather_nrf52840_express
|
||||
cmake --build cmake-build-feather_nrf52840_express
|
||||
```
|
||||
|
||||
### Make (alternate)
|
||||
```bash
|
||||
make BOARD=feather_nrf52832 all
|
||||
make BOARD=feather_nrf52840_express all
|
||||
```
|
||||
+384
@@ -0,0 +1,384 @@
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
include(CMakePrintHelpers)
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
|
||||
if (NOT DEFINED BOARD)
|
||||
message(FATAL_ERROR "BOARD is not defined")
|
||||
endif ()
|
||||
|
||||
# include board specific
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/src/boards/${BOARD}/board.cmake)
|
||||
|
||||
# toolchain set up
|
||||
if (MCU_VARIANT STREQUAL "nrf5340_application")
|
||||
set(CMAKE_SYSTEM_PROCESSOR cortex-m33 CACHE INTERNAL "System Processor")
|
||||
set(JLINK_DEVICE nrf5340_xxaa_app)
|
||||
else ()
|
||||
set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
|
||||
set(JLINK_DEVICE ${MCU_VARIANT}_xxaa)
|
||||
endif ()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/arm_gcc.cmake)
|
||||
|
||||
set(NRFX_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/nrfx)
|
||||
set(SDK11_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/sdk11/components)
|
||||
set(SDK_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/sdk/components)
|
||||
set(SOFTDEVICE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/softdevice)
|
||||
set(MBR_HEX ${SOFTDEVICE_DIR}/mbr/hex/mbr_nrf52_2.4.1_mbr.hex)
|
||||
set(TINYUSB_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
|
||||
set(TCRYPT_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/tinycrypt/lib)
|
||||
|
||||
option(DEFAULT_TO_OTA_DFU "Default to OTA DFU instead of Serial DFU" OFF)
|
||||
option(SIGNED_FW "Enable signed firmware verification" OFF)
|
||||
option(DUALBANK_FW "Enable dual bank DFU support" OFF)
|
||||
option(FORCE_UF2 "Force UF2 support even with SIGNED_FW" OFF)
|
||||
set(SIGNED_FW_QX "" CACHE STRING "Public key Qx (comma-separated bytes)")
|
||||
set(SIGNED_FW_QY "" CACHE STRING "Public key Qy (comma-separated bytes)")
|
||||
|
||||
set(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py)
|
||||
set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c)
|
||||
|
||||
#-------------------
|
||||
# Bootloader
|
||||
#-------------------
|
||||
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
|
||||
endif ()
|
||||
|
||||
project(Adafruit_nRF52_Bootloader C ASM)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX .elf)
|
||||
add_executable(bootloader
|
||||
# src
|
||||
src/dfu_ble_svc.c
|
||||
src/dfu_init.c
|
||||
src/flash_nrf5x.c
|
||||
src/main.c
|
||||
src/screen.c
|
||||
src/images.c
|
||||
src/boards/boards.c
|
||||
# nrfx
|
||||
${NRFX_DIR}/drivers/src/nrfx_power.c
|
||||
${NRFX_DIR}/drivers/src/nrfx_nvmc.c
|
||||
${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c
|
||||
# sdk 11
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/bootloader.c
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/bootloader_settings.c
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/bootloader_util.c
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/dfu_transport_serial.c
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/dfu_transport_ble.c
|
||||
${SDK11_DIR}/ble/ble_services/ble_dfu/ble_dfu.c
|
||||
${SDK11_DIR}/ble/ble_services/ble_dis/ble_dis.c
|
||||
${SDK11_DIR}/drivers_nrf/pstorage/pstorage_raw.c
|
||||
# latest sdk
|
||||
${SDK_DIR}/libraries/timer/app_timer.c
|
||||
${SDK_DIR}/libraries/scheduler/app_scheduler.c
|
||||
${SDK_DIR}/libraries/util/app_error.c
|
||||
${SDK_DIR}/libraries/util/app_util_platform.c
|
||||
${SDK_DIR}/libraries/crc16/crc16.c
|
||||
${SDK_DIR}/libraries/hci/hci_mem_pool.c
|
||||
${SDK_DIR}/libraries/hci/hci_slip.c
|
||||
${SDK_DIR}/libraries/hci/hci_transport.c
|
||||
${SDK_DIR}/libraries/util/nrf_assert.c
|
||||
# startup
|
||||
${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S
|
||||
)
|
||||
|
||||
if (DUALBANK_FW)
|
||||
target_sources(bootloader PUBLIC
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/dfu_dual_bank.c
|
||||
)
|
||||
else ()
|
||||
target_sources(bootloader PUBLIC
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/dfu_single_bank.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (SIGNED_FW)
|
||||
target_sources(bootloader PUBLIC
|
||||
${TCRYPT_DIR}/source/sha256.c
|
||||
${TCRYPT_DIR}/source/ecc.c
|
||||
${TCRYPT_DIR}/source/ecc_dsa.c
|
||||
${TCRYPT_DIR}/source/utils.c
|
||||
)
|
||||
|
||||
target_include_directories(bootloader PUBLIC
|
||||
${TCRYPT_DIR}/include
|
||||
)
|
||||
endif ()
|
||||
|
||||
target_include_directories(bootloader PUBLIC
|
||||
src
|
||||
src/boards
|
||||
src/boards/${BOARD}
|
||||
src/cmsis/include
|
||||
src/usb
|
||||
${TINYUSB_DIR}
|
||||
# nrfx
|
||||
${NRFX_DIR}
|
||||
${NRFX_DIR}/mdk
|
||||
${NRFX_DIR}/hal
|
||||
${NRFX_DIR}/drivers/include
|
||||
${NRFX_DIR}/drivers/src
|
||||
# sdk 11 for cdc/ble dfu
|
||||
${SDK11_DIR}/libraries/bootloader_dfu
|
||||
${SDK11_DIR}/libraries/bootloader_dfu/hci_transport
|
||||
${SDK11_DIR}/drivers_nrf/pstorage
|
||||
${SDK11_DIR}/ble/common
|
||||
${SDK11_DIR}/ble/ble_services/ble_dfu
|
||||
${SDK11_DIR}/ble/ble_services/ble_dis
|
||||
# later sdk with updated drivers
|
||||
${SDK_DIR}/libraries/timer
|
||||
${SDK_DIR}/libraries/scheduler
|
||||
${SDK_DIR}/libraries/crc16
|
||||
${SDK_DIR}/libraries/util
|
||||
${SDK_DIR}/libraries/hci/config
|
||||
${SDK_DIR}/libraries/hci
|
||||
${SDK_DIR}/libraries/uart
|
||||
${SDK_DIR}/drivers_nrf/delay
|
||||
# Softdevice
|
||||
${SOFTDEVICE_DIR}/mbr/headers
|
||||
)
|
||||
|
||||
# Debug linker file
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_debug.ld)
|
||||
else ()
|
||||
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}.ld)
|
||||
endif ()
|
||||
|
||||
target_link_options(bootloader PUBLIC
|
||||
"LINKER:--script=${LD_FILE}"
|
||||
-L${NRFX_DIR}/mdk
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
target_compile_options(bootloader PUBLIC
|
||||
-fno-builtin
|
||||
-fshort-enums
|
||||
-fstack-usage
|
||||
-fno-strict-aliasing
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfatal-errors
|
||||
-Werror-implicit-function-declaration
|
||||
-Wfloat-equal
|
||||
-Wundef
|
||||
-Wshadow
|
||||
-Wwrite-strings
|
||||
-Wsign-compare
|
||||
-Wmissing-format-attribute
|
||||
-Wno-endif-labels
|
||||
-Wunreachable-code
|
||||
# Suppress warning caused by SDK
|
||||
-Wno-unused-parameter -Wno-expansion-to-defined -Wno-array-bounds
|
||||
)
|
||||
target_compile_definitions(bootloader PUBLIC
|
||||
SOFTDEVICE_PRESENT
|
||||
CONFIG_GPIO_AS_PINRESET
|
||||
__START=main
|
||||
__STARTUP_CLEAR_BSS
|
||||
)
|
||||
|
||||
if (SIGNED_FW)
|
||||
if (SIGNED_FW_QX STREQUAL "" OR SIGNED_FW_QY STREQUAL "")
|
||||
message(FATAL_ERROR "SIGNED_FW requires SIGNED_FW_QX and SIGNED_FW_QY to be set")
|
||||
endif ()
|
||||
string(REPLACE " " "" SIGNED_FW_QX_STR "${SIGNED_FW_QX}")
|
||||
string(REPLACE " " "" SIGNED_FW_QY_STR "${SIGNED_FW_QY}")
|
||||
target_compile_definitions(bootloader PUBLIC
|
||||
SIGNED_FW
|
||||
"SIGNED_FW_QX=${SIGNED_FW_QX_STR}"
|
||||
"SIGNED_FW_QY=${SIGNED_FW_QY_STR}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (FORCE_UF2)
|
||||
target_compile_definitions(bootloader PUBLIC FORCE_UF2)
|
||||
endif ()
|
||||
|
||||
if (DEFAULT_TO_OTA_DFU)
|
||||
target_compile_definitions(bootloader PUBLIC DEFAULT_TO_OTA_DFU)
|
||||
endif ()
|
||||
|
||||
if (TRACE_ETM STREQUAL "1")
|
||||
# ENABLE_TRACE will cause system_nrf5x.c to set up ETM trace
|
||||
target_compile_definitions(bootloader PUBLIC ENABLE_TRACE)
|
||||
endif ()
|
||||
|
||||
if (MCU_VARIANT STREQUAL "nrf52")
|
||||
# UART transport
|
||||
target_sources(bootloader PUBLIC
|
||||
${SDK_DIR}/libraries/uart/app_uart.c
|
||||
${SDK_DIR}/drivers_nrf/uart/nrf_drv_uart.c
|
||||
${SDK_DIR}/drivers_nrf/common/nrf_drv_common.c
|
||||
)
|
||||
target_include_directories(bootloader PUBLIC
|
||||
${SDK11_DIR}/libraries/util
|
||||
${SDK_DIR}/drivers_nrf/common
|
||||
${SDK_DIR}/drivers_nrf/uart
|
||||
)
|
||||
else ()
|
||||
# USB transport
|
||||
target_sources(bootloader PUBLIC
|
||||
src/boards/${BOARD}/pinconfig.c
|
||||
src/usb/msc_uf2.c
|
||||
src/usb/usb.c
|
||||
src/usb/usb_desc.c
|
||||
src/usb/uf2/ghostfat.c
|
||||
# TinyUSB
|
||||
${TINYUSB_DIR}/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
${TINYUSB_DIR}/common/tusb_fifo.c
|
||||
${TINYUSB_DIR}/device/usbd.c
|
||||
${TINYUSB_DIR}/device/usbd_control.c
|
||||
${TINYUSB_DIR}/class/cdc/cdc_device.c
|
||||
${TINYUSB_DIR}/class/msc/msc_device.c
|
||||
${TINYUSB_DIR}/tusb.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
#----------------------------------------------------
|
||||
# MCU Variant differences
|
||||
# Supported are: nrf52 (nrf52832), nrf52833, nrf52840
|
||||
#----------------------------------------------------
|
||||
|
||||
# SD_VERSION can be overwritten by board.cmake
|
||||
if(NOT DEFINED SD_VERSION)
|
||||
if(MCU_VARIANT STREQUAL "nrf52833")
|
||||
set(SD_VERSION 7.3.0)
|
||||
else()
|
||||
set(SD_VERSION 6.1.1)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (MCU_VARIANT STREQUAL "nrf52")
|
||||
set(SD_NAME s132)
|
||||
set(DFU_DEV_REV 0xADAF)
|
||||
set(DFU_APP_DATA_RESERVED 7*4096)
|
||||
target_compile_definitions(bootloader PUBLIC NRF52 NRF52832_XXAA)
|
||||
elseif (MCU_VARIANT STREQUAL "nrf52833")
|
||||
set(DFU_DEV_REV 52833)
|
||||
set(DFU_APP_DATA_RESERVED 7*4096)
|
||||
target_compile_definitions(bootloader PUBLIC NRF52833_XXAA)
|
||||
if (NOT DEFINED SD_NAME)
|
||||
set(SD_NAME s140)
|
||||
endif ()
|
||||
elseif (MCU_VARIANT STREQUAL "nrf52840")
|
||||
set(DFU_DEV_REV 52840)
|
||||
# App reserved 40KB (8+32) to match circuitpython for 840
|
||||
set(DFU_APP_DATA_RESERVED 10*4096)
|
||||
target_compile_definitions(bootloader PUBLIC NRF52840_XXAA)
|
||||
if (NOT DEFINED SD_NAME)
|
||||
set(SD_NAME s140)
|
||||
endif ()
|
||||
else ()
|
||||
message(FATAL_ERROR "MCU_VARIANT ${MCU_VARIANT} is unknown")
|
||||
endif ()
|
||||
|
||||
set(SD_FILENAME ${SD_NAME}_nrf52_${SD_VERSION})
|
||||
set(SD_HEX ${SOFTDEVICE_DIR}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex)
|
||||
|
||||
string(TOUPPER ${SD_NAME} SD_NAME_UPPER)
|
||||
target_compile_definitions(bootloader PUBLIC ${SD_NAME_UPPER})
|
||||
target_include_directories(bootloader PUBLIC
|
||||
${SOFTDEVICE_DIR}/${SD_FILENAME}/${SD_FILENAME}_API/include
|
||||
)
|
||||
|
||||
# debug build
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
# TODO not work yet, also need to add segger rtt, DFU_APP_DATA_RESERVED=0, BOOTLOADER_REGION_START=0xED000
|
||||
target_sources(bootloader PUBLIC lib/SEGGER_RTT/RTT/SEGGER_RTT.c)
|
||||
target_include_directories(bootloader PUBLIC lib/SEGGER_RTT/RTT)
|
||||
target_compile_definitions(bootloader PUBLIC
|
||||
CFG_DEBUG
|
||||
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
DFU_APP_DATA_RESERVED=0
|
||||
)
|
||||
if (MCU_VARIANT STREQUAL "nrf52840")
|
||||
target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0xEA000)
|
||||
else ()
|
||||
target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0x6D000)
|
||||
endif ()
|
||||
else ()
|
||||
target_compile_definitions(bootloader PUBLIC DFU_APP_DATA_RESERVED=${DFU_APP_DATA_RESERVED})
|
||||
endif ()
|
||||
|
||||
#----------------------------------
|
||||
# ANT_LICENSE_KEY handling
|
||||
#----------------------------------
|
||||
if (DEFINED ANT_LICENSE_KEY)
|
||||
target_compile_definitions(bootloader PUBLIC ANT_LICENSE_KEY=${ANT_LICENSE_KEY})
|
||||
endif()
|
||||
|
||||
#----------------------------------
|
||||
# Get UF2 version from git
|
||||
#----------------------------------
|
||||
execute_process(COMMAND git describe --dirty --always --tags OUTPUT_VARIABLE GIT_VERSION)
|
||||
string(STRIP ${GIT_VERSION} GIT_VERSION)
|
||||
|
||||
string(REPLACE "-" ";" RELEASE_VERSION ${GIT_VERSION})
|
||||
list(GET RELEASE_VERSION 0 RELEASE_VERSION)
|
||||
string(REPLACE "." ";" RELEASE_VERSION ${RELEASE_VERSION})
|
||||
list(GET RELEASE_VERSION 0 RELEASE_VERSION_MAJOR)
|
||||
list(GET RELEASE_VERSION 1 RELEASE_VERSION_MINOR)
|
||||
list(GET RELEASE_VERSION 2 RELEASE_VERSION_PATCH)
|
||||
math(EXPR MK_BOOTLOADER_VERSION "(${RELEASE_VERSION_MAJOR} << 16) + (${RELEASE_VERSION_MINOR} << 8) + ${RELEASE_VERSION_PATCH}")
|
||||
|
||||
cmake_print_variables(GIT_VERSION MK_BOOTLOADER_VERSION)
|
||||
|
||||
target_compile_definitions(bootloader PUBLIC
|
||||
UF2_VERSION="${GIT_VERSION}"
|
||||
BLEDIS_FW_VERSION="${GIT_VERSION} ${SD_NAME} ${SD_VERSION}"
|
||||
MK_BOOTLOADER_VERSION=${MK_BOOTLOADER_VERSION}
|
||||
)
|
||||
|
||||
# Add bin/hex output
|
||||
add_custom_command(TARGET bootloader POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.bin
|
||||
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.hex
|
||||
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/tools/hexmerge.py --overlap=replace -o $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.hex $<TARGET_FILE_DIR:bootloader>/bootloader.hex ${MBR_HEX}
|
||||
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} -c -o $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.uf2 $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.hex
|
||||
VERBATIM)
|
||||
|
||||
#----------------------------------
|
||||
# Flashing target
|
||||
#----------------------------------
|
||||
if (NOT DEFINED NRFJPROG)
|
||||
set(NRFJPROG nrfjprog)
|
||||
endif()
|
||||
|
||||
add_custom_target(flash-bootloader
|
||||
DEPENDS bootloader
|
||||
COMMAND ${NRFJPROG} --program $<TARGET_FILE:bootloader> --verify --sectoranduicrerase -f nrf52 --reset
|
||||
)
|
||||
|
||||
add_custom_target(flash-uf2
|
||||
DEPENDS bootloader
|
||||
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} --deploy $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.uf2
|
||||
)
|
||||
|
||||
add_custom_target(flash-sd
|
||||
DEPENDS flash-mbr
|
||||
COMMAND ${NRFJPROG} --program ${SD_HEX} --verify --sectorerase -f nrf52
|
||||
)
|
||||
|
||||
add_custom_target(flash-mbr
|
||||
COMMAND ${NRFJPROG} --program ${MBR_HEX} --verify --sectorerase -f nrf52
|
||||
)
|
||||
|
||||
add_custom_target(flash-erase
|
||||
COMMAND ${NRFJPROG} -f nrf52 --eraseall
|
||||
)
|
||||
|
||||
add_custom_target(flash-all
|
||||
DEPENDS bootloader flash-erase
|
||||
COMMAND ${NRFJPROG} --program ${SD_HEX} --verify --sectorerase -f nrf52
|
||||
COMMAND ${NRFJPROG} --program $<TARGET_FILE:bootloader> --verify --sectoranduicrerase -f nrf52 --reset
|
||||
)
|
||||
|
||||
# flash skip crc magic ( app valid = 0x0001, crc = 0x0000 )
|
||||
#add_custom_target(flash-skip-crc
|
||||
# #COMMAND ${NRFJPROG} --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f nrf52
|
||||
# COMMAND ${NRFJPROG} --memwr 0xFF000 --val 0x00000001 -f nrf52
|
||||
# #COMMAND ${NRFJPROG} --memwr 0x7F000 --val 0x00000001 -f nrf52
|
||||
# )
|
||||
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at . All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
@@ -1,334 +1,430 @@
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# CONFIGURE
|
||||
# - SDK_PATH : path to SDK directory
|
||||
# - SRC_PATH : path to src folder
|
||||
# - SDK_PATH : path to SDK directory
|
||||
#
|
||||
# - SD_NAME : e.g s132, s140
|
||||
# - SD_VER1, SD_VER2, SD_VER3: SoftDevice version e.g 6.0.0
|
||||
# - SD_HEX : to bootloader hex binary
|
||||
#******************************************************************************
|
||||
SRC_PATH = src
|
||||
# - SD_NAME : e.g s132, s140
|
||||
# - SD_VERSION : SoftDevice version e.g 6.0.0
|
||||
# - SD_HEX : to bootloader hex binary
|
||||
# - SIGNED_FW : if bootloader will ONLY accept signed firmware
|
||||
# - SIGNED_FW_QX : Qx for signed firmware verification
|
||||
# - SIGNED_FW_QY : Qy for signed firmware verification
|
||||
# - DUALBANK_FW : If bootloader will implement a dual bank feature to allow autorecover from failed
|
||||
# - FORCE_UF2 : if SIGNED_FW is 1, will force to include UF2 support (UNSECURE, UF2 does NOT validate signature!)
|
||||
# - DEFAULT_TO_OTA_DFU : if entering DFU, by default enter OTA DFU instead of Serial DFU
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
PYTHON = python
|
||||
|
||||
# local customization
|
||||
-include Makefile.user
|
||||
|
||||
# Board specific
|
||||
-include src/boards/$(BOARD)/board.mk
|
||||
|
||||
SDK_PATH = lib/sdk/components
|
||||
SDK11_PATH = lib/sdk11/components
|
||||
TUSB_PATH = lib/tinyusb/src
|
||||
TCRYPT_PATH = lib/tinycrypt/lib
|
||||
NRFX_PATH = lib/nrfx
|
||||
SD_PATH = lib/softdevice/$(SD_FILENAME)
|
||||
|
||||
TUSB_PATH = lib/tinyusb/src
|
||||
NRFX_PATH = lib/nrfx
|
||||
# SD_VERSION can be overwritten by board.mk
|
||||
ifndef SD_VERSION
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52833)
|
||||
SD_VERSION = 7.3.0
|
||||
else
|
||||
SD_VERSION = 6.1.1
|
||||
endif
|
||||
endif
|
||||
|
||||
SD_VER1 = 6
|
||||
SD_VER2 = 1
|
||||
SD_VER3 = 1
|
||||
|
||||
SD_VERSION = $(SD_VER1).$(SD_VER2).$(SD_VER3)
|
||||
SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
|
||||
SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API
|
||||
SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
|
||||
|
||||
LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(SD_VER1).ld
|
||||
|
||||
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
|
||||
RELEASE_DIR = bin/$(BOARD)
|
||||
|
||||
|
||||
MK_DIS_FIRMWARE = "$(SD_NAME) $(SD_VERSION)"
|
||||
|
||||
GIT_VERSION = $(shell git describe --dirty --always --tags)
|
||||
GIT_SUBMODULE_VERSIONS = $(shell git submodule status | cut -d' ' -f3,4 | paste -s -d" " -)
|
||||
|
||||
OUTPUT_FILENAME = $(BOARD)_bootloader-$(GIT_VERSION)
|
||||
#******************************************************************************
|
||||
# Tool configure
|
||||
#******************************************************************************
|
||||
NRFUTIL = adafruit-nrfutil
|
||||
|
||||
ifneq ($(JLINK),)
|
||||
NRFJPROG = nrfjprog -s $(JLINK)
|
||||
else
|
||||
NRFJPROG = nrfjprog
|
||||
endif
|
||||
MBR_HEX = lib/softdevice/mbr/hex/mbr_nrf52_2.4.1_mbr.hex
|
||||
|
||||
# Detect the operating system
|
||||
# The "OS" environment variable on Windows is always "Windows_NT"
|
||||
# when running under a modern shell like cmd.exe or powershell
|
||||
ifeq ($(OS),Windows_NT)
|
||||
PROGFILES = C:/Program Files (x86)
|
||||
GNU_INSTALL_ROOT = $(PROGFILES)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
|
||||
endif
|
||||
|
||||
MK := mkdir
|
||||
RM := rm -rf
|
||||
|
||||
ifeq ("$(V)","2")
|
||||
QUIET :=
|
||||
NULL_DEVICE = NUL
|
||||
else
|
||||
QUIET := @
|
||||
NULL_DEVICE = /dev/null
|
||||
endif
|
||||
|
||||
GNU_PREFIX = arm-none-eabi
|
||||
# linker by MCU eg. nrf52840.ld
|
||||
ifeq ($(DEBUG), 1)
|
||||
LD_FILE = linker/$(MCU_SUB_VARIANT)_debug.ld
|
||||
else
|
||||
LD_FILE = linker/$(MCU_SUB_VARIANT).ld
|
||||
endif
|
||||
|
||||
GIT_VERSION := $(shell git describe --dirty --always --tags)
|
||||
|
||||
# compiled file name
|
||||
OUT_NAME = $(BOARD)_bootloader-$(GIT_VERSION)
|
||||
|
||||
# merged file = compiled + sd
|
||||
MERGED_FILE = $(OUT_NAME)_$(SD_NAME)_$(SD_VERSION)
|
||||
|
||||
UF2_FAMILY_ID_BOOTLOADER = 0xd663823c
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Tool Configure
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Toolchain commands
|
||||
CC := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-gcc'
|
||||
AS := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-as'
|
||||
AR := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-ar' -r
|
||||
LD := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-ld'
|
||||
NM := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-nm'
|
||||
OBJDUMP := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objdump'
|
||||
OBJCOPY := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objcopy'
|
||||
SIZE := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-size'
|
||||
# Should be added to your PATH
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
AS = $(CROSS_COMPILE)as
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
GDB = $(CROSS_COMPILE)gdb
|
||||
|
||||
#function for removing duplicates in a list
|
||||
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
||||
|
||||
#*********************************
|
||||
# Select the board to build
|
||||
#*********************************
|
||||
BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*.h))))
|
||||
|
||||
NRF52840_BOARDLIST = pca10056 pca10059 feather_nrf52840_express particle_argon particle_boron particle_xenon
|
||||
IS_NRF52840 = $(filter $(BOARD),$(NRF52840_BOARDLIST))
|
||||
|
||||
ifeq ($(filter $(MAKECMDGOALS),all-board all-release help),)
|
||||
ifeq ($(BOARD),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD=')
|
||||
$(info Supported boards are: $(BOARD_LIST))
|
||||
$(info Run 'make help' for usage)
|
||||
$(error BOARD not defined)
|
||||
else
|
||||
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
BUILD = _build-$(BOARD)
|
||||
|
||||
ifneq ($(IS_NRF52840),)
|
||||
SD_NAME = s140
|
||||
DFU_DEV_REV = 52840
|
||||
# Set make directory command, Windows tries to create a directory named "-p" if that flag is there.
|
||||
ifneq ($(OS), Windows_NT)
|
||||
MKDIR = mkdir -p
|
||||
else
|
||||
SD_NAME = s132
|
||||
DFU_DEV_REV = 0xADAF
|
||||
MKDIR = mkdir
|
||||
endif
|
||||
|
||||
RM = rm -rf
|
||||
CP = cp
|
||||
|
||||
# Flasher utility options
|
||||
NRFUTIL = adafruit-nrfutil
|
||||
NRFJPROG = nrfjprog
|
||||
FLASHER ?= nrfjprog
|
||||
PYOCD ?= pyocd
|
||||
|
||||
#******************************************************************************
|
||||
# Flasher will default to nrfjprog,
|
||||
# Check for pyocd, error on unexpected value.
|
||||
ifeq ($(FLASHER),nrfjprog)
|
||||
FLASH_CMD = $(NRFJPROG) --program $1 --sectoranduicrerase -f nrf52 --reset
|
||||
FLASH_NOUICR_CMD = $(NRFJPROG) --program $1 -f nrf52 --sectorerase --reset
|
||||
FLASH_ERASE_CMD = $(NRFJPROG) -f nrf52 --eraseall
|
||||
else ifeq ($(FLASHER),pyocd)
|
||||
FLASH_CMD = $(PYOCD) flash -t $(MCU_SUB_VARIANT) $1
|
||||
FLASH_NOUICR_CMD = $(PYOCD) flash -t $(MCU_SUB_VARIANT) $1
|
||||
FLASH_ERASE_CMD = $(PYOCD) erase -t $(MCU_SUB_VARIANT) --chip
|
||||
else
|
||||
$(error Unsupported flash utility: "$(FLASHER)")
|
||||
endif
|
||||
|
||||
# auto-detect BMP on macOS, otherwise have to specify
|
||||
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
|
||||
GDB_BMP = $(GDB) -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1'
|
||||
|
||||
# Build directory
|
||||
BUILD = _build/build-$(BOARD)
|
||||
BIN = _bin/$(BOARD)
|
||||
|
||||
# MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52)
|
||||
CFLAGS += -DNRF52 -DNRF52832_XXAA
|
||||
SD_NAME = s132
|
||||
DFU_DEV_REV = 0xADAF
|
||||
DFU_APP_DATA_RESERVED=7*4096
|
||||
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
|
||||
CFLAGS += -DNRF52833_XXAA
|
||||
DFU_DEV_REV = 52833
|
||||
DFU_APP_DATA_RESERVED=7*4096
|
||||
ifndef SD_NAME
|
||||
SD_NAME = s140
|
||||
endif
|
||||
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
||||
CFLAGS += -DNRF52840_XXAA
|
||||
DFU_DEV_REV = 52840
|
||||
# App reserved 40KB (8+32) to match circuitpython for 840
|
||||
DFU_APP_DATA_RESERVED=10*4096
|
||||
ifndef SD_NAME
|
||||
SD_NAME = s140
|
||||
endif
|
||||
else
|
||||
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
|
||||
endif
|
||||
|
||||
SD_NAME_UPPER = $(subst s,S,${SD_NAME})
|
||||
CFLAGS += -D$(SD_NAME_UPPER)
|
||||
|
||||
#----------------------------------
|
||||
# ANT_LICENSE_KEY handling
|
||||
#----------------------------------
|
||||
ifdef ANT_LICENSE_KEY
|
||||
CFLAGS += -DANT_LICENSE_KEY=\"$(ANT_LICENSE_KEY)\"
|
||||
endif
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# SOURCE FILES
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# src
|
||||
C_SOURCE_FILES += $(SRC_PATH)/main.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/boards.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/flash_nrf5x.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/dfu_init.c
|
||||
# all files in src
|
||||
C_SRC += \
|
||||
src/dfu_ble_svc.c \
|
||||
src/dfu_init.c \
|
||||
src/flash_nrf5x.c \
|
||||
src/main.c \
|
||||
src/screen.c \
|
||||
src/images.c \
|
||||
|
||||
# if using a signed firmware
|
||||
ifeq ($(SIGNED_FW), 1)
|
||||
C_SRC += \
|
||||
$(TCRYPT_PATH)/source/sha256.c \
|
||||
$(TCRYPT_PATH)/source/ecc.c \
|
||||
$(TCRYPT_PATH)/source/ecc_dsa.c \
|
||||
$(TCRYPT_PATH)/source/utils.c
|
||||
endif
|
||||
|
||||
# all files in boards
|
||||
C_SRC += src/boards/boards.c
|
||||
|
||||
# nrfx
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/hal/nrf_nvmc.c
|
||||
|
||||
# SDK 11 files
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_util.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_serial.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_ble.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_single_bank.c
|
||||
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/drivers_nrf/pstorage/pstorage_raw.c
|
||||
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c
|
||||
C_SOURCE_FILES += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c
|
||||
|
||||
# Latest SDK files
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/timer/app_timer.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/scheduler/app_scheduler.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/app_error.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/app_util_platform.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/crc16/crc16.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_mem_pool.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_slip.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_transport.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/nrf_assert.c
|
||||
|
||||
ifneq ($(IS_NRF52840),)
|
||||
|
||||
# src
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/usb_desc.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/usb.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/msc_uf2.c
|
||||
C_SOURCE_FILES += $(SRC_PATH)/usb/uf2/ghostfat.c
|
||||
|
||||
# nrfx
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52840.c
|
||||
|
||||
# Tinyusb stack
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/hal_nrf5x.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/common/tusb_fifo.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/device/usbd.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/device/usbd_control.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/class/cdc/cdc_device.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/class/msc/msc_device.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/class/custom/custom_device.c
|
||||
C_SOURCE_FILES += $(TUSB_PATH)/tusb.c
|
||||
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
||||
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_nvmc.c
|
||||
C_SRC += $(NRFX_PATH)/mdk/system_$(MCU_SUB_VARIANT).c
|
||||
|
||||
# SDK 11 files: serial + OTA DFU
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_util.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_serial.c
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_ble.c
|
||||
ifeq ($(DUALBANK_FW), 1)
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_dual_bank.c
|
||||
else
|
||||
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_single_bank.c
|
||||
endif
|
||||
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c
|
||||
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c
|
||||
C_SRC += $(SDK11_PATH)/drivers_nrf/pstorage/pstorage_raw.c
|
||||
|
||||
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.c
|
||||
# Latest SDK files: peripheral drivers
|
||||
C_SRC += $(SDK_PATH)/libraries/timer/app_timer.c
|
||||
C_SRC += $(SDK_PATH)/libraries/scheduler/app_scheduler.c
|
||||
C_SRC += $(SDK_PATH)/libraries/util/app_error.c
|
||||
C_SRC += $(SDK_PATH)/libraries/util/app_util_platform.c
|
||||
C_SRC += $(SDK_PATH)/libraries/crc16/crc16.c
|
||||
C_SRC += $(SDK_PATH)/libraries/hci/hci_mem_pool.c
|
||||
C_SRC += $(SDK_PATH)/libraries/hci/hci_slip.c
|
||||
C_SRC += $(SDK_PATH)/libraries/hci/hci_transport.c
|
||||
C_SRC += $(SDK_PATH)/libraries/util/nrf_assert.c
|
||||
|
||||
C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
||||
# UART or USB Serial
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52)
|
||||
|
||||
C_SRC += $(SDK_PATH)/libraries/uart/app_uart.c
|
||||
C_SRC += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
|
||||
C_SRC += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
||||
|
||||
IPATH += $(SDK11_PATH)/libraries/util
|
||||
IPATH += $(SDK_PATH)/drivers_nrf/common
|
||||
IPATH += $(SDK_PATH)/drivers_nrf/uart
|
||||
|
||||
endif
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# Assembly Files
|
||||
#******************************************************************************
|
||||
ifneq ($(IS_NRF52840),)
|
||||
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52840.S
|
||||
else
|
||||
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52.S
|
||||
|
||||
# pinconfig is required for 840 for CF2
|
||||
C_SRC += src/boards/$(BOARD)/pinconfig.c
|
||||
|
||||
# USB Application ( MSC + UF2 )
|
||||
C_SRC += \
|
||||
src/usb/usb_desc.c \
|
||||
src/usb/msc_uf2.c \
|
||||
src/usb/uf2/ghostfat.c \
|
||||
src/usb/usb.c
|
||||
|
||||
# TinyUSB stack
|
||||
C_SRC += \
|
||||
$(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c \
|
||||
$(TUSB_PATH)/common/tusb_fifo.c \
|
||||
$(TUSB_PATH)/device/usbd.c \
|
||||
$(TUSB_PATH)/device/usbd_control.c \
|
||||
$(TUSB_PATH)/class/cdc/cdc_device.c \
|
||||
$(TUSB_PATH)/class/msc/msc_device.c \
|
||||
$(TUSB_PATH)/tusb.c
|
||||
endif
|
||||
|
||||
#******************************************************************************
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Assembly Files
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_SRC = $(NRFX_PATH)/mdk/gcc_startup_$(MCU_SUB_VARIANT).S
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# INCLUDE PATH
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# src
|
||||
IPATH += $(SRC_PATH)
|
||||
IPATH += $(SRC_PATH)/cmsis/include
|
||||
IPATH += $(SRC_PATH)/usb
|
||||
IPATH += $(TUSB_PATH)
|
||||
IPATH += \
|
||||
src \
|
||||
src/boards \
|
||||
src/boards/$(BOARD) \
|
||||
src/cmsis/include \
|
||||
src/usb \
|
||||
$(TUSB_PATH)
|
||||
|
||||
ifeq ($(SIGNED_FW), 1)
|
||||
IPATH += \
|
||||
$(TCRYPT_PATH)/include
|
||||
endif
|
||||
|
||||
# nrfx
|
||||
IPATH += $(NRFX_PATH)
|
||||
IPATH += $(NRFX_PATH)/mdk
|
||||
IPATH += $(NRFX_PATH)/hal
|
||||
IPATH += $(NRFX_PATH)/drivers/include
|
||||
IPATH += \
|
||||
$(NRFX_PATH) \
|
||||
$(NRFX_PATH)/mdk \
|
||||
$(NRFX_PATH)/hal \
|
||||
$(NRFX_PATH)/drivers/include \
|
||||
$(NRFX_PATH)/drivers/src
|
||||
|
||||
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
|
||||
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu
|
||||
IPATH += $(SDK11_PATH)/drivers_nrf/pstorage
|
||||
IPATH += $(SDK11_PATH)/ble/common
|
||||
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dfu
|
||||
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dis
|
||||
# sdk11 for cdc/ble dfu
|
||||
IPATH += \
|
||||
$(SDK11_PATH)/libraries/bootloader_dfu/hci_transport \
|
||||
$(SDK11_PATH)/libraries/bootloader_dfu \
|
||||
$(SDK11_PATH)/drivers_nrf/pstorage \
|
||||
$(SDK11_PATH)/ble/common \
|
||||
$(SDK11_PATH)/ble/ble_services/ble_dfu \
|
||||
$(SDK11_PATH)/ble/ble_services/ble_dis
|
||||
|
||||
IPATH += $(SDK_PATH)/libraries/timer
|
||||
IPATH += $(SDK_PATH)/libraries/scheduler
|
||||
IPATH += $(SDK_PATH)/libraries/crc16
|
||||
IPATH += $(SDK_PATH)/libraries/util
|
||||
IPATH += $(SDK_PATH)/libraries/hci/config
|
||||
IPATH += $(SDK_PATH)/libraries/uart
|
||||
IPATH += $(SDK_PATH)/libraries/hci
|
||||
IPATH += $(SDK_PATH)/drivers_nrf/delay
|
||||
# later sdk with updated drivers
|
||||
IPATH += \
|
||||
$(SDK_PATH)/libraries/timer \
|
||||
$(SDK_PATH)/libraries/scheduler \
|
||||
$(SDK_PATH)/libraries/crc16 \
|
||||
$(SDK_PATH)/libraries/util \
|
||||
$(SDK_PATH)/libraries/hci/config \
|
||||
$(SDK_PATH)/libraries/uart \
|
||||
$(SDK_PATH)/libraries/hci \
|
||||
$(SDK_PATH)/drivers_nrf/delay
|
||||
|
||||
# Softdevice
|
||||
IPATH += $(SD_API_PATH)/include
|
||||
IPATH += $(SD_API_PATH)/include/nrf52
|
||||
# SoftDevice
|
||||
IPATH += \
|
||||
$(SD_PATH)/$(SD_FILENAME)_API/include \
|
||||
$(SD_PATH)/$(SD_FILENAME)_API/include/nrf52
|
||||
|
||||
|
||||
INC_PATHS = $(addprefix -I,$(IPATH))
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# Compiler Flags
|
||||
# - Additional compiler flags
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#flags common to all targets
|
||||
CFLAGS += -mcpu=cortex-m4
|
||||
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
|
||||
CFLAGS += -Wall -Werror -Os -g3
|
||||
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mabi=aapcs \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-ggdb \
|
||||
-Os \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-fno-builtin \
|
||||
-fshort-enums \
|
||||
-fstack-usage \
|
||||
-fno-strict-aliasing \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wfatal-errors \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wno-endif-labels \
|
||||
-Wunreachable-code
|
||||
|
||||
# keep every function in separate section. This will allow linker to dump unused functions
|
||||
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||
CFLAGS += -fno-builtin --short-enums -fstack-usage
|
||||
# Suppress warning caused by SDK
|
||||
CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
|
||||
|
||||
# Nordic Softdevice SDK header files contains inline assembler that has
|
||||
# broken constraints. As a result the IPA-modref pass, introduced in gcc-11,
|
||||
# is able to "prove" that arguments to wrapper functions generated with
|
||||
# the SVCALL() macro are unused and, as a result, the optimizer will remove
|
||||
# code within the callers that sets up these arguments (which results in
|
||||
# a broken bootloader). The broken headers come from Nordic-supplied zip
|
||||
# files and are not trivial to patch so, for now, we'll simply disable the
|
||||
# new gcc-11 inter-procedural optimizations.
|
||||
ifeq (,$(findstring unrecognized,$(shell $(CC) $(CFLAGS) -fno-ipa-modref 2>&1)))
|
||||
CFLAGS += -fno-ipa-modref
|
||||
endif
|
||||
|
||||
# Defined Symbol (MACROS)
|
||||
CFLAGS += -DMK_BOOTLOADER_VERSION=0x0$(SD_VER1)0$(SD_VER2)0$(SD_VER3)UL
|
||||
|
||||
CFLAGS += -D__HEAP_SIZE=0
|
||||
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
CFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
CFLAGS += -DBSP_DEFINES_ONLY
|
||||
CFLAGS += -DSWI_DISABLE0
|
||||
|
||||
# Skip defining CONFIG_NFCT_PINS_AS_GPIOS if the device uses the NFCT.
|
||||
ifneq ($(USE_NFCT),yes)
|
||||
CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
|
||||
endif
|
||||
|
||||
CFLAGS += -DSOFTDEVICE_PRESENT
|
||||
CFLAGS += -DFLOAT_ABI_HARD
|
||||
CFLAGS += -DMK_DIS_FIRMWARE='$(MK_DIS_FIRMWARE)'
|
||||
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
||||
|
||||
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS) $(SD_NAME) $(SD_VERSION)"'
|
||||
|
||||
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
ifneq ($(IS_NRF52840),)
|
||||
|
||||
CFLAGS += -DNRF52840_XXAA
|
||||
CFLAGS += -DS140
|
||||
|
||||
else
|
||||
|
||||
CFLAGS += -DNRF52
|
||||
CFLAGS += -DNRF52832_XXAA
|
||||
CFLAGS += -DS132
|
||||
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION)"'
|
||||
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
|
||||
|
||||
ifeq ($(SIGNED_FW), 1)
|
||||
CFLAGS += -DSIGNED_FW
|
||||
CFLAGS += -DSIGNED_FW_QX='$(SIGNED_FW_QX)'
|
||||
CFLAGS += -DSIGNED_FW_QY='$(SIGNED_FW_QY)'
|
||||
endif
|
||||
|
||||
ifeq ($(FORCE_UF2), 1)
|
||||
CFLAGS += -DFORCE_UF2
|
||||
endif
|
||||
|
||||
#******************************************************************************
|
||||
ifeq ($(DEFAULT_TO_OTA_DFU), 1)
|
||||
CFLAGS += -DDEFAULT_TO_OTA_DFU
|
||||
endif
|
||||
|
||||
_VER = $(subst ., ,$(word 1, $(subst -, ,$(GIT_VERSION))))
|
||||
CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)) << 8) + $(word 3,$(_VER))'
|
||||
|
||||
# Debug option use RTT for printf
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
RTT_SRC = lib/SEGGER_RTT
|
||||
IPATH += $(RTT_SRC)/RTT
|
||||
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
|
||||
DFU_APP_DATA_RESERVED = 0
|
||||
|
||||
# expand bootloader address to 28KB/40KB of reserved app
|
||||
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
||||
CFLAGS += -DBOOTLOADER_REGION_START=0xEA000
|
||||
else
|
||||
CFLAGS += -DBOOTLOADER_REGION_START=0x6D000
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS += -DDFU_APP_DATA_RESERVED=$(DFU_APP_DATA_RESERVED)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Linker Flags
|
||||
#
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# keep every function in separate section. This will allow linker to dump unused functions
|
||||
LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUTPUT_FILENAME).map
|
||||
LDFLAGS += -mthumb -mabi=aapcs -L$(SRC_PATH)/linker -T$(LD_FILE)
|
||||
LDFLAGS += -mcpu=cortex-m4
|
||||
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
LDFLAGS += \
|
||||
$(CFLAGS) \
|
||||
-Wl,-L,linker -Wl,-T,$(LD_FILE) \
|
||||
-Wl,--print-memory-usage \
|
||||
-Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections \
|
||||
-specs=nosys.specs -specs=nano.specs
|
||||
|
||||
# let linker to dump unused sections
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LIBS += -lm -lc
|
||||
|
||||
# use newlib in nano version
|
||||
LDFLAGS += --specs=nano.specs -lc -lnosys
|
||||
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
# Assembler flags
|
||||
#
|
||||
#******************************************************************************
|
||||
ASMFLAGS += -x assembler-with-cpp
|
||||
ASMFLAGS += -D__HEAP_SIZE=0
|
||||
ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
ASMFLAGS += -DBSP_DEFINES_ONLY
|
||||
ASMFLAGS += -DSWI_DISABLE0
|
||||
ASMFLAGS += -DSOFTDEVICE_PRESENT
|
||||
ASMFLAGS += -DFLOAT_ABI_HARD
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
ifneq ($(IS_NRF52840),)
|
||||
ASFLAGS += $(CFLAGS)
|
||||
|
||||
ASMFLAGS += -DNRF52840_XXAA
|
||||
ASMFLAGS += -DS140
|
||||
#function for removing duplicates in a list
|
||||
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
||||
|
||||
else
|
||||
|
||||
ASMFLAGS += -DNRF52
|
||||
ASMFLAGS += -DS132
|
||||
|
||||
endif
|
||||
|
||||
|
||||
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
|
||||
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
|
||||
C_SOURCE_FILE_NAMES = $(notdir $(C_SRC))
|
||||
C_PATHS = $(call remduplicates, $(dir $(C_SRC) ) )
|
||||
C_OBJECTS = $(addprefix $(BUILD)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
|
||||
|
||||
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES))
|
||||
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) ))
|
||||
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SRC))
|
||||
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SRC) ))
|
||||
ASM_OBJECTS = $(addprefix $(BUILD)/, $(ASM_SOURCE_FILE_NAMES:.S=.o) )
|
||||
|
||||
vpath %.c $(C_PATHS)
|
||||
@@ -336,55 +432,90 @@ vpath %.S $(ASM_PATHS)
|
||||
|
||||
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
|
||||
|
||||
#******************************************************************************
|
||||
INC_PATHS = $(addprefix -I,$(IPATH))
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# BUILD TARGETS
|
||||
#******************************************************************************
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
ifeq ("$(V)","1")
|
||||
$(info CFLAGS $(CFLAGS))
|
||||
$(info )
|
||||
$(info LDFLAGS $(LDFLAGS))
|
||||
$(info )
|
||||
endif
|
||||
|
||||
.phony: all clean size flash sd erase
|
||||
.PHONY: all clean flash flash-dfu flash-sd flash-mbr dfu-flash sd mbr gdbflash gdb
|
||||
|
||||
# default target to build
|
||||
all: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out size
|
||||
all: $(BUILD)/$(OUT_NAME).out $(BUILD)/$(OUT_NAME)_nosd.hex $(BUILD)/update-$(OUT_NAME)_nosd.uf2 $(BUILD)/$(MERGED_FILE).hex $(BUILD)/$(MERGED_FILE).zip
|
||||
|
||||
# Rule using BOARD_LIST, nl is newline
|
||||
define nl
|
||||
# Print out the value of a make variable.
|
||||
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||||
print-%:
|
||||
@echo $* = $($*)
|
||||
|
||||
#------------------- Compile rules -------------------
|
||||
|
||||
endef
|
||||
# Create build directories
|
||||
$(BUILD):
|
||||
@$(MKDIR) "$@"
|
||||
|
||||
_make_board = $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=$1 $2 $(nl)
|
||||
_make_all_board = $(foreach b,$(BOARD_LIST), $(call _make_board,$b,$1))
|
||||
clean:
|
||||
@$(RM) $(BUILD)
|
||||
@$(RM) $(BIN)
|
||||
|
||||
# build all the boards
|
||||
all-board:
|
||||
$(call _make_all_board,clean all)
|
||||
# linkermap must be install previously at https://github.com/hathach/linkermap
|
||||
linkermap: $(BUILD)/$(OUT_NAME).out
|
||||
@linkermap -v $<.map
|
||||
|
||||
all-release:
|
||||
$(call _make_all_board,clean all release)
|
||||
# Create objects from C SRC files
|
||||
$(BUILD)/%.o: %.c
|
||||
@echo CC $(notdir $<)
|
||||
@$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
|
||||
help:
|
||||
@echo To flash (with jlink) a pre-built binary with a specific version to a board
|
||||
@echo $$ make BOARD=feather_nrf52840_express VERSION=6.1.1r0 flash
|
||||
@echo
|
||||
@echo To flash (with dfu) a pre-built binary with a specific version to a board
|
||||
@echo $$ make BOARD=feather_nrf52840_express VERSION=6.1.1r0 SERIAL=/dev/ttyACM0 dfu0-flash
|
||||
@echo
|
||||
@echo To compile and build the current code for a board
|
||||
@echo $$ make BOARD=feather_nrf52840_express all
|
||||
@echo
|
||||
@echo To flash current code using jlink
|
||||
@echo $$ make BOARD=feather_nrf52840_express flash
|
||||
@echo
|
||||
@echo To flash current code using existing bootloader dfu
|
||||
@echo $$ make BOARD=feather_nrf52840_express SERIAL=/dev/ttyACM0 dfu-flash
|
||||
# Assemble files
|
||||
$(BUILD)/%.o: %.S
|
||||
@echo AS $(notdir $<)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
|
||||
#******************* Flash target *******************
|
||||
# Link
|
||||
$(BUILD)/$(OUT_NAME).out: $(BUILD) $(OBJECTS)
|
||||
@echo LD $(notdir $@)
|
||||
@$(CC) -o $@ $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
@$(SIZE) $@
|
||||
|
||||
#------------------- Binary generator -------------------
|
||||
|
||||
# Create hex file (no sd, no mbr)
|
||||
$(BUILD)/$(OUT_NAME).hex: $(BUILD)/$(OUT_NAME).out
|
||||
@echo Create $(notdir $@)
|
||||
@$(OBJCOPY) -O ihex $< $@
|
||||
|
||||
# Hex file with mbr (still no SD)
|
||||
$(BUILD)/$(OUT_NAME)_nosd.hex: $(BUILD)/$(OUT_NAME).hex
|
||||
@echo Create $(notdir $@)
|
||||
@$(PYTHON) tools/hexmerge.py --overlap=replace -o $@ $< $(MBR_HEX)
|
||||
|
||||
# Bootolader self-update uf2
|
||||
$(BUILD)/update-$(OUT_NAME)_nosd.uf2: $(BUILD)/$(OUT_NAME)_nosd.hex
|
||||
@echo Create $(notdir $@)
|
||||
$(PYTHON) lib/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_BOOTLOADER) -c -o $@ $^
|
||||
|
||||
# merge bootloader and sd hex together
|
||||
$(BUILD)/$(MERGED_FILE).hex: $(BUILD)/$(OUT_NAME).hex
|
||||
@echo Create $(notdir $@)
|
||||
@$(PYTHON) tools/hexmerge.py -o $@ $< $(SD_HEX)
|
||||
|
||||
# Create pkg zip file for bootloader+SD combo to use with DFU CDC
|
||||
$(BUILD)/$(MERGED_FILE).zip: $(BUILD)/$(OUT_NAME).hex
|
||||
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@
|
||||
|
||||
#-------------- Artifacts --------------
|
||||
$(BIN):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
copy-artifact: $(BIN)
|
||||
@$(CP) $(BUILD)/update-$(OUT_NAME)_nosd.uf2 $(BIN)
|
||||
@$(CP) $(BUILD)/$(MERGED_FILE).hex $(BIN)
|
||||
@$(CP) $(BUILD)/$(MERGED_FILE).zip $(BIN)
|
||||
|
||||
#--------------------------------------
|
||||
# Flash Target
|
||||
#--------------------------------------
|
||||
|
||||
check_defined = \
|
||||
$(strip $(foreach 1,$1, \
|
||||
@@ -393,101 +524,50 @@ __check_defined = \
|
||||
$(if $(value $1),, \
|
||||
$(error Undefined make flag: $1$(if $2, ($2))))
|
||||
|
||||
ifeq ($(VERSION),)
|
||||
# erase chip
|
||||
erase:
|
||||
@echo Erasing flash
|
||||
$(call FLASH_ERASE_CMD)
|
||||
|
||||
# Flash the compiled
|
||||
flash: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
@echo Flashing: $<
|
||||
$(NRFJPROG) --program $< --sectoranduicrerase -f nrf52 --reset
|
||||
flash: $(BUILD)/$(OUT_NAME)_nosd.hex
|
||||
@echo Flashing: $(notdir $<)
|
||||
$(call FLASH_CMD,$<)
|
||||
|
||||
dfu-flash: $(BUILD)/$(MERGED_FNAME).zip
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank
|
||||
|
||||
else
|
||||
|
||||
ifeq ($(VERSION),latest)
|
||||
VERSION_FPATH = $(RELEASE_DIR)/$(MERGED_FNAME)
|
||||
else
|
||||
VERSION_FPATH = bin/$(BOARD)/$(VERSION)/$(OUTPUT_FILENAME)_$(SD_NAME)_$(VERSION)
|
||||
endif
|
||||
|
||||
# Flash specific version in binary release folder
|
||||
flash:
|
||||
@echo Flashing: $(VERSION_FPATH).hex
|
||||
$(NRFJPROG) --program $(VERSION_FPATH).hex --chiperase -f nrf52 --reset
|
||||
|
||||
dfu-flash:
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $(VERSION_FPATH).zip -p $(SERIAL) -b 115200 --singlebank
|
||||
|
||||
endif
|
||||
|
||||
sd:
|
||||
# flash SD only
|
||||
sd: flash-sd
|
||||
flash-sd:
|
||||
@echo Flashing: $(SD_HEX)
|
||||
$(NRFJPROG) --program $(SD_HEX) -f nrf52 --chiperase --reset
|
||||
$(call FLASH_NOUICR_CMD,$(SD_HEX))
|
||||
|
||||
erase:
|
||||
@echo Erasing chip
|
||||
$(NRFJPROG) --eraseall -f nrf52
|
||||
# flash MBR only
|
||||
mbr: flash-mbr
|
||||
flash-mbr:
|
||||
@echo Flashing: $(MBR_HEX)
|
||||
$(call FLASH_NOUICR_CMD,$(MBR_HEX))
|
||||
|
||||
#******************* Compile rules *******************
|
||||
# flash using uf2
|
||||
flash-uf2: $(BUILD)/update-$(OUT_NAME)_nosd.uf2
|
||||
@echo Flashing: $(notdir $<)
|
||||
python lib/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_BOOTLOADER) --deploy $<
|
||||
|
||||
## Create build directories
|
||||
$(BUILD):
|
||||
@$(MK) $@
|
||||
# dfu with adafruit-nrfutil using CDC interface
|
||||
dfu-flash: flash-dfu
|
||||
flash-dfu: $(BUILD)/$(MERGED_FILE).zip
|
||||
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
||||
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank --touch 1200
|
||||
|
||||
clean:
|
||||
@$(RM) $(BUILD)
|
||||
# flash skip crc magic ( app valid = 0x0001, crc = 0x0000 )
|
||||
#flash-skip-crc:
|
||||
# nrfjprog --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f nrf52
|
||||
# nrfjprog --memwr 0xFF000 --val 0x00000001 -f nrf52
|
||||
# nrfjprog --memwr 0x7F000 --val 0x00000001 -f nrf52
|
||||
|
||||
# Create objects from C SRC files
|
||||
$(BUILD)/%.o: %.c
|
||||
@echo CC $(notdir $<)
|
||||
$(QUIET)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
#------------------- Debugging -------------------
|
||||
|
||||
# Assemble files
|
||||
$(BUILD)/%.o: %.S
|
||||
@echo AS $(notdir $<)
|
||||
$(QUIET)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $<
|
||||
gdbflash: $(BUILD)/$(MERGED_FILE).hex
|
||||
@echo Flashing: $<
|
||||
@$(GDB_BMP) -nx --batch -ex 'load $<' -ex 'compare-sections' -ex 'kill'
|
||||
|
||||
# Link
|
||||
$(BUILD)/$(OUTPUT_FILENAME)-nosd.out: $(BUILD) $(OBJECTS)
|
||||
@echo LD $(OUTPUT_FILENAME)-nosd.out
|
||||
$(QUIET)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -lm -o $@
|
||||
|
||||
size: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
|
||||
-@echo ''
|
||||
$(QUIET)$(SIZE) $<
|
||||
-@echo ''
|
||||
|
||||
|
||||
#******************* Binary generator *******************
|
||||
.phony: genhex genpkg release
|
||||
|
||||
## Create binary .hex file from the .out file
|
||||
genhex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
|
||||
$(BUILD)/$(OUTPUT_FILENAME)-nosd.hex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
|
||||
@echo CR $(OUTPUT_FILENAME)-nosd.hex
|
||||
$(QUIET)$(OBJCOPY) -O ihex $< $@
|
||||
|
||||
# merge bootloader and sd hex together
|
||||
combinehex: $(BUILD)/$(MERGED_FNAME).hex
|
||||
|
||||
$(BUILD)/$(MERGED_FNAME).hex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
@echo CR $(MERGED_FNAME).hex
|
||||
@mergehex -q -m $< $(SD_HEX) -o $@
|
||||
|
||||
## Create pkg file for bootloader+SD combo to use with DFU
|
||||
genpkg: $(BUILD)/$(MERGED_FNAME).zip
|
||||
|
||||
$(BUILD)/$(MERGED_FNAME).zip: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
||||
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@
|
||||
|
||||
# Create SD+bootloader combo with hex & dfu package at release folder
|
||||
release: combinehex genpkg
|
||||
@echo CR $(RELEASE_DIR)/$(MERGED_FNAME).hex
|
||||
@echo CR $(RELEASE_DIR)/$(MERGED_FNAME).zip
|
||||
@mkdir -p $(RELEASE_DIR)
|
||||
@cp $(BUILD)/$(MERGED_FNAME).hex $(RELEASE_DIR)/$(MERGED_FNAME).hex
|
||||
@cp $(BUILD)/$(MERGED_FNAME).zip $(RELEASE_DIR)/$(MERGED_FNAME).zip
|
||||
gdb: $(BUILD)/$(OUT_NAME).out
|
||||
$(GDB_BMP) $<
|
||||
@@ -1,51 +1,44 @@
|
||||
# Adafruit Bluefruit nRF52 Bootloader
|
||||
# Adafruit nRF52 Bootloader
|
||||
|
||||
This is a CDC/DFU/UF2 bootloader for nRF52 boards.
|
||||
[](https://github.com/adafruit/Adafruit_nRF52_Bootloader/actions)
|
||||
|
||||
- [Adafruit Feather nRF52832](https://www.adafruit.com/product/3406)
|
||||
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
|
||||
- Nordic nRF52840DK PCA10056
|
||||
- Nordic nRF52840DK PCA10059 ("Dongle")
|
||||
- Particle Argon
|
||||
- Particle Boron
|
||||
- Particle Xenon
|
||||
A CDC/DFU/UF2 bootloader for Nordic nRF52 microcontroller. UF2 is an easy-to-use bootloader that appears as a flash drive. You can just copy `.uf2`-format application images to the flash drive to load new firmware. See https://github.com/Microsoft/uf2 for more information.
|
||||
|
||||
UF2 is an easy-to-use bootloader that appears as a flash drive. You can just copy `.uf2`-format
|
||||
application images to the flash drive to load new firmware.
|
||||
See https://github.com/Microsoft/uf2 and https://github.com/adafruit/uf2-samdx1
|
||||
for more information.
|
||||
|
||||
[adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil),
|
||||
a modified version of [Nordic nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil),
|
||||
is required to perform DFU.
|
||||
Install `python3` if it is not installed already and run this command to install adafruit-nrfutil from PyPi:
|
||||
DFU via serial/CDC requires [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil), a modified version of [Nordic nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil). Install `python3` if it is not installed already and run this command to install adafruit-nrfutil from PyPi:
|
||||
|
||||
```
|
||||
$ pip3 install --user adafruit-nrfutil
|
||||
```
|
||||
|
||||
This repository depends on the following submodules:
|
||||
## Supported Boards
|
||||
|
||||
- [tinyusb](https://github.com/hathach/tinyusb/tree/develop)
|
||||
- [nrfx](https://github.com/NordicSemiconductor/nrfx)
|
||||
Officially supported boards are:
|
||||
|
||||
Note that `tinyusb` also includes `nrfx` as a submodule, so you need
|
||||
to initialize and update submodules with the `--recursive`` flag.
|
||||
- [Adafruit CLUE](https://www.adafruit.com/product/4500)
|
||||
- [Adafruit Circuit Playground Bluefruit](https://www.adafruit.com/product/4333)
|
||||
- [Adafruit Feather nRF52832](https://www.adafruit.com/product/3406)
|
||||
- [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
|
||||
- [Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
|
||||
- [Adafruit ItsyBitsy nRF52840 Express](https://www.adafruit.com/product/4481)
|
||||
- [Adafruit LED Glasses Driver nRF52840](https://www.adafruit.com/product/5217)
|
||||
- Adafruit Metro nRF52840 Express
|
||||
- [Raytac MDBT50Q-RX Dongle](https://www.adafruit.com/product/5199)
|
||||
|
||||
Clone this repo with following commands, or fork it for your own development
|
||||
|
||||
```
|
||||
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
|
||||
cd Adafruit_nRF52_Bootloader
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
In addition, there is also lots of other 3rd-party boards which are added by other makers, users and community. Check
|
||||
out the [complete list of all boards here](/supported_boards.md).
|
||||
|
||||
## Features
|
||||
|
||||
- DFU over Serial and OTA ( application, Bootloader+SD )
|
||||
- DFU over Serial and OTA (application, Bootloader+SD)
|
||||
- Self-upgradable via Serial and OTA
|
||||
- DFU using UF2 (https://github.com/Microsoft/uf2) (application only)
|
||||
- Auto-enter DFU briefly on startup for DTR auto-reset trick (832 only)
|
||||
- Supports dual bank firmware updates (disabled by default)
|
||||
- Supports signed firmware updates (disabled by default)
|
||||
|
||||
Note: For OTA, `Packet Receipt Notification` (PRN) must be 8 or less, which can be configured in nRF DFU. Otherwise, the
|
||||
bootloader will run out of
|
||||
memory.
|
||||
|
||||
## How to use
|
||||
|
||||
@@ -54,11 +47,19 @@ There are two pins, `DFU` and `FRST` that bootloader will check upon reset/power
|
||||
- `Double Reset` Reset twice within 500 ms will enter DFU with UF2 and CDC support (only works with nRF52840)
|
||||
- `DFU = LOW` and `FRST = HIGH`: Enter bootloader with UF2 and CDC support
|
||||
- `DFU = LOW` and `FRST = LOW`: Enter bootloader with OTA, to upgrade with a mobile application such as Nordic nrfConnect/Toolbox
|
||||
- `DFU = HIGH and `FRST = LOW`: Factory Reset mode: erase firmware application and its data
|
||||
- `DFU = HIGH and `FRST = HIGH`: Go to application code if it is present, otherwise enter DFU with UF2
|
||||
- <s>`DFU = HIGH` and `FRST = LOW`: Factory Reset mode: erase firmware application and its data</s>
|
||||
- `DFU = HIGH` and `FRST = HIGH`: Go to application code if it is present, otherwise enter DFU with UF2
|
||||
- The `GPREGRET` register can also be set to force the bootloader can enter any of above modes (plus a CDC-only mode for Arduino).
|
||||
`GPREGRET` is set by the application before performing a soft reset.
|
||||
|
||||
```c
|
||||
#include "nrf_nvic.h"
|
||||
void reset_to_uf2(void) {
|
||||
NRF_POWER->GPREGRET = 0x57; // 0xA8 OTA, 0x4e Serial
|
||||
NVIC_SystemReset(); // or sd_nvic_SystemReset();
|
||||
}
|
||||
```
|
||||
|
||||
On the Nordic PCA10056 DK board, `DFU` is connected to **Button1**, and `FRST` is connected to **Button2**.
|
||||
So holding down **Button1** while clicking **RESET** will put the board into USB bootloader mode, with UF2 and CDC support.
|
||||
Holding down **Button2** while clicking **RESET** will put the board into OTA (over-the-air) bootloader mode.
|
||||
@@ -69,6 +70,34 @@ There is an adjacent ground pad.
|
||||
|
||||
For other boards, please check the board definition for details.
|
||||
|
||||
### Making your own UF2
|
||||
|
||||
To create your own UF2 DFU update image, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file or .hex file, specifying the family as **0xADA52840** (nRF52840) or **0x621E937A** (nRF52833).
|
||||
|
||||
```
|
||||
nRF52840
|
||||
uf2conv.py firmware.hex -c -f 0xADA52840
|
||||
|
||||
nRF52833
|
||||
uf2conv.py firmware.hex -c -f 0x621E937A
|
||||
```
|
||||
|
||||
If using a .bin file with the conversion script you must specify application address with the -b switch, this address depend on the SoftDevice size/version e.g S140 v6 is 0x26000, v7 is 0x27000
|
||||
|
||||
```
|
||||
nRF52840
|
||||
uf2conv.py firmware.bin -c -b 0x26000 -f 0xADA52840
|
||||
|
||||
nRF52833
|
||||
uf2conv.py firmware.bin -c -b 0x27000 -f 0x621E937A
|
||||
```
|
||||
|
||||
To create a UF2 image for bootloader from a .hex file using separated family of **0xd663823c**
|
||||
|
||||
```
|
||||
uf2conv.py bootloader.hex -c -f 0xd663823c
|
||||
```
|
||||
|
||||
## Burn & Upgrade with pre-built binaries
|
||||
|
||||
You can burn and/or upgrade the bootloader with either a J-link or DFU (serial) to a specific pre-built binary version
|
||||
@@ -77,94 +106,194 @@ This is preferred if you are not developing/customizing the bootloader.
|
||||
Pre-builtin binaries are available on GitHub [releases](https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases)
|
||||
|
||||
Note: The bootloader can be downgraded. Since the binary release is a merged version of
|
||||
of both bootloader and the Nordic SoftDevice, you can freely upgrade/downgrade to any version you like.
|
||||
both bootloader and the Nordic SoftDevice, you can freely upgrade/downgrade to any version you like.
|
||||
|
||||
## How to compile and build
|
||||
## How to compile and build
|
||||
|
||||
You should only continue if you are looking to develop bootloader for your own.
|
||||
You must have have a J-Link available to "unbrick" your device.
|
||||
You must have have a J-Link available to "unbrick" your device.
|
||||
|
||||
### Option 1: Build with Makefile
|
||||
|
||||
Prerequisites
|
||||
### Prerequisites
|
||||
|
||||
- ARM GCC
|
||||
- Nordic's [nRF5x Command Line Tools](http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrf5x_command_line_tools%2Fnrf5x_installation.html)
|
||||
- Nordic's [nRF5x Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools)
|
||||
- [Python IntelHex](https://pypi.org/project/IntelHex/)
|
||||
|
||||
To build:
|
||||
### Build:
|
||||
|
||||
Firstly clone this repo including its submodules with following command:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express all combinehex
|
||||
git clone --recurse-submodules https://github.com/adafruit/Adafruit_nRF52_Bootloader
|
||||
```
|
||||
|
||||
To flash the bootloader:
|
||||
|
||||
For git versions before `2.13.0` you have to do that manually:
|
||||
```
|
||||
make BOARD=feather_nrf52840_express flash
|
||||
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
|
||||
cd Adafruit_nRF52_Bootloader
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
To flash SoftDevice (and chip erase):
|
||||
#### Build using `make`
|
||||
Then build it with `make BOARD={board} all`, for example:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express sd
|
||||
```
|
||||
|
||||
To erase all of flash:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express erase
|
||||
make BOARD=feather_nrf52840_express all
|
||||
```
|
||||
|
||||
For the list of supported boards, run `make` without `BOARD=` :
|
||||
|
||||
```
|
||||
$ make
|
||||
make
|
||||
You must provide a BOARD parameter with 'BOARD='
|
||||
Supported boards are: feather_nrf52840_express feather_nrf52840_express pca10056
|
||||
Makefile:90: *** BOARD not defined. Stop
|
||||
```
|
||||
|
||||
#### Build using `cmake`
|
||||
|
||||
Firstly initialize your build environment by passing your board to `cmake` via `-DBOARD={board}`:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DBOARD=feather_nrf52840_express
|
||||
```
|
||||
|
||||
And then build it with:
|
||||
|
||||
```bash
|
||||
make
|
||||
```
|
||||
|
||||
You can also use the generator of your choice. For example adding the `-GNinja` and then you can invoke `ninja build` instead of `make`.
|
||||
|
||||
To list all supported targets, run:
|
||||
|
||||
```bash
|
||||
cmake --build . --target help
|
||||
```
|
||||
|
||||
To build individual targets, you can specify it directly with `make` or using `cmake --build`:
|
||||
|
||||
```bash
|
||||
make bootloader
|
||||
cmake --build . --target bootloader
|
||||
```
|
||||
|
||||
### Flash
|
||||
|
||||
To flash the bootloader (without softdevice/mbr) using JLink:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express flash
|
||||
```
|
||||
|
||||
If you are using pyocd as debugger, add `FLASHER=pyocd` to make command:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express FLASHER=pyocd flash
|
||||
```
|
||||
|
||||
To upgrade the bootloader using DFU Serial via port /dev/ttyACM0
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express SERIAL=/dev/ttyACM0 flash-dfu
|
||||
```
|
||||
|
||||
To flash SoftDevice (will also erase chip):
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express flash-sd
|
||||
```
|
||||
|
||||
To flash MBR only
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express flash-mbr
|
||||
```
|
||||
|
||||
### Dual bank firmware support:
|
||||
|
||||
This bootloader can split the FLASH memory into 2 partitions, one for the last successfully uploaded firmware, and the other for the new firmware that is being uploaded. In case the firmware upload fails, the bootloader will revert to the last working firmware version. The only drawback is that the maximum firmware size is half of the device FLASH size: That is why it is disabled by default.
|
||||
You can enable this feature by passing DUALBANK_FW=1 to the make process while compiling the bootloader
|
||||
|
||||
### Signed firmware support:
|
||||
This bootloader can validate that the uploaded firmware is digitally signed, and refuse to install unsigned or signed with the improper key firmware. Because this will make Arduino uploads stop working (because they are not digitally signed), this feature is disabled by default.
|
||||
But if you want to ensure noone else is allowed to upload firmware to your device, this option is probably what you want to enable.
|
||||
|
||||
To create a signing key, you will need the adafruit-nrfutil utility. First, generate a signing key and store at given path by using
|
||||
|
||||
```
|
||||
adafruit-nrfutil keys --gen-key stored_key.pem
|
||||
```
|
||||
|
||||
This command will create a signing key and store it in the file stored_key.pem. STORE THIS FILE IN A SAFE PLACE, as without it, you won't be able to sign your firmware packages, and the bootloader will refuse to flash them!!
|
||||
|
||||
Now, you must show the verification key (that is calculated from the signing key):
|
||||
|
||||
```
|
||||
adafruit-nrfutil keys --show-vk code stored_key.pem
|
||||
```
|
||||
|
||||
This command will read your signing key (from the file stored_key.pem) and display C source code with the Qx and Qy arrays: Something along the lines
|
||||
|
||||
```
|
||||
static uint8_t Qx[] = { ... };
|
||||
static uint8_t Qy[] = { ... };
|
||||
```
|
||||
|
||||
You must save the Qx and Qy values, remove all spaces, and pass them to the make command line
|
||||
```
|
||||
make BOARD=feather_nrf52840_express SIGNED_FW=1 SIGNED_FW_QX='Qx values' SIGNED_FW_QY='Qy values'
|
||||
```
|
||||
|
||||
And replace Qx values with the Qx array values, and the Qy values with the Qy array values. That will create a bootloader that ONLY accepts firmware signed with the stored_key.pem signing key. Take into account that the option SIGNED_FW=1 is what enables to build a bootloader that enforces signing, and will ALSO result in disabling UF2 support, as UF2 format does NOT support signing keys. There is an option (only for testing!) called FORCE_UF2 that will FORCE UF2 support on bootloaders that enforce firmware security. It is there to bypass security so you can test a secure bootloader and have a way to recover it something goes wrong, but should NEVER be used if you want to enforce security
|
||||
|
||||
Finally, to create a signed firmware application/bootloader update package, you can use, for example
|
||||
|
||||
```
|
||||
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0x0123 --application "application.hex" --key-file "stored_key.pem" "application_package.zip"
|
||||
```
|
||||
|
||||
Please, use full paths for all files. The examples omit them for clarity!
|
||||
|
||||
And, to upload it to your device,
|
||||
|
||||
```
|
||||
adafruit-nrfutil.exe --verbose dfu serial -pkg "application_package.zip" -p /dev/tty0 -b 115200
|
||||
```
|
||||
|
||||
### Common makefile problems
|
||||
|
||||
#### 1. `arm-none-eabi-gcc`: No such file or directory
|
||||
#### `arm-none-eabi-gcc`: No such file or directory
|
||||
|
||||
If you get the following error ...
|
||||
|
||||
```
|
||||
$ make BOARD=feather_nrf52840_express all
|
||||
make BOARD=feather_nrf52840_express all
|
||||
Compiling file: main.c
|
||||
/bin/sh: /usr/bin/arm-none-eabi-gcc: No such file or directory
|
||||
make: *** [_build/main.o] Error 127
|
||||
```
|
||||
|
||||
... you may need to edit the `Makefile` and update `GNU_INSTALL_ROOT` to point to the root path of your GCC ARM toolchain.
|
||||
... you may need to pass the location of the GCC ARM toolchain binaries to `make` using
|
||||
the variable `CROSS_COMPILE` as below:
|
||||
```
|
||||
make CROSS_COMPILE=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- BOARD=feather_nrf52832 all
|
||||
```
|
||||
|
||||
#### 2. `mergehex: No such file or directory`
|
||||
For other compile errors, check the gcc version with `arm-none-eabi-gcc --version` to insure it is at least 9.x.
|
||||
|
||||
Make sure that `mergehex` is available from the command-line. This binary is
|
||||
part of Nordic's nRF5x Command Line Tools.
|
||||
#### `ModuleNotFoundError: No module named 'intelhex'`
|
||||
|
||||
#### 3. `make: nrfjprog: No such file or directory`
|
||||
Install python-intelhex with
|
||||
|
||||
```
|
||||
pip install intelhex
|
||||
```
|
||||
|
||||
#### `make: nrfjprog: No such file or directory`
|
||||
|
||||
Make sure that `nrfjprog` is available from the command-line. This binary is
|
||||
part of Nordic's nRF5x Command Line Tools.
|
||||
|
||||
On POSIX-type systems you can temporarily add the path to `nrfjprog` via a
|
||||
variation on the following command:
|
||||
|
||||
```
|
||||
$ export PATH=$PATH:/location/of/nRF5x-Command-Line-Tools_9_7_2_OSX/nrfjprog
|
||||
```
|
||||
|
||||
### Option 2: Build using Segger Embedded Studio
|
||||
|
||||
For easier debugging you can also use [SES](https://www.segger.com/products/development-tools/embedded-studio/).
|
||||
The project file is located at `src/segger/Adafruit_nRF52_Bootloader.emProject`.
|
||||
|
||||
> **Note**: SES only flashes the bootloader when you click download, not the SoftDevice.
|
||||
You need to flash the SoftDevice beforehand if you haven't already done so.
|
||||
As mentioned above do something like:
|
||||
|
||||
```
|
||||
make BOARD=feather_nrf52840_express sd
|
||||
```
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
# Adafruit nRF52 Bootloader Changelog
|
||||
|
||||
## 0.6.2 - 2021.09.10
|
||||
|
||||
- Add new board "LED Glasses Driver nRF52840"
|
||||
|
||||
## 0.6.1 - 2021.08.04
|
||||
|
||||
- Fix failed to upgrade ssue when flashing uf2 with more than 512KB payload
|
||||
- Increased application reserved from 28KB to 40KB for nrf52840 to match circuitpython usage.
|
||||
|
||||
## 0.6.0 - 2021.06.19
|
||||
|
||||
- Update tinyusb to latest to fix the race condition with control transfer, which could cause failed to connect to DFU Serial occasionally.
|
||||
|
||||
## 0.5.1 - 2021.06.02
|
||||
|
||||
- more boards support
|
||||
|
||||
## 0.5.0 - 2021.04.04
|
||||
|
||||
- Update tinyusb to latest to fix the race condition causing cdc out dropping packet. Which cause DFU failed occasionally
|
||||
- Add support for Dotstar LED (APA102)
|
||||
- Add sparkfun_nrf52840_micromod board
|
||||
- Allow skipping DFU entirely when reset or wakeup from deep sleep
|
||||
- Fix an issue with OTA when using shared bond with application
|
||||
|
||||
## 0.4.1 - 2021.02.17
|
||||
|
||||
- Add USB connect timeout for app reset to UF2 or Serial via GPREGRET
|
||||
- Fix pollution of REGOUT0 reserved bits
|
||||
|
||||
## 0.4.0 - 2021.01.19
|
||||
|
||||
- Decouple bootloader and softdevice i.e bootloader will always work with and/or without softdevice present. This allows application to pack firmware + softdevice into an uf2/serial for DFU.
|
||||
- Add self-update feature with update-{board}.uf2. This allow bootloader to update itself easily (requires running bootloader with at least 0.4.0)
|
||||
- Enlarge the fake FAT disk to ~ 32MB to allow piggy-pack multiple application (different family ID) within the same uf2.
|
||||
- Support uf2 with family ID = vendor ID + product ID
|
||||
- Reset into application if there is no USB connection in ~3 seconds.
|
||||
- Remove DFU idle 300 seconds timeout
|
||||
- Support power supply configuration with `ENABLE_DCDC_0` and `ENABLE_DCDC_1`
|
||||
- Add new boards support: nice nano, bast ble, ikigaisense vita, nrf52840 M2, Pitaya Go, AE-BL652-BO, BlueMicro, ADM_B_NRF52840_1
|
||||
|
||||
## 0.3.2 - 2020.03.12
|
||||
|
||||
- Make sure all pins are in reset state when jumping to app mode.
|
||||
|
||||
## 0.3.1 - 2020.03.05
|
||||
- Correct LED1 for Feather Sense and change volume name to FTHRSNSBOOT.
|
||||
|
||||
## 0.3.0 - 2020.01.13
|
||||
|
||||
- Upgrade nrfx to v2 for supporting future nrf mcu such as nrf52833, nrf5340
|
||||
- Upgrade TinyUSB
|
||||
- New boards support
|
||||
- Arduino ble nano 33
|
||||
- Adafruit CLUE
|
||||
- Raytac MDBT50Q-RX dongle
|
||||
- Migrate CI to github Action
|
||||
|
||||
## 0.2.13 - 2019.09.25
|
||||
|
||||
- Fixed button pulldown with Adafruit Circuit Playground Bluefruit, PR #77 thanks to @khanning
|
||||
|
||||
## 0.2.12 - 2019.08.22
|
||||
|
||||
- Fixed block alignment bug also in dfu_sd_image_validate (single & dual banks), PR #71 thanks to @fanoush
|
||||
- Added new board: Adafruit Circuit Playground Bluefruit
|
||||
- Added new board: Adafruit ItsyBitsy nRF52840 Express (WIP)
|
||||
- Fixed bug in __DOSTIME__ macro, PR #75 thanks to @henrygab
|
||||
|
||||
## 0.2.11
|
||||
|
||||
- Fixed various FAT issues, thanks to @henrygab
|
||||
- Added MakerDiary MDK nrf52840 USB dongle support, thanks to @gpshead
|
||||
- Fixed incorrect button mapping for Feather nRF52840
|
||||
- NFC pins are forced to GPIO mode by bootloader
|
||||
- Added Metro nRF52840 Express VID/PID
|
||||
- Enhance board management
|
||||
- Added electronut/papyr_support
|
||||
|
||||
## 0.2.9
|
||||
|
||||
- Fixed incomplete writes on Windows. Upated tinyusb to handle write10 completion, and use it for finalizing dfu process. Will prevent windows error message pop up. This will also give an extra time for flash writing to complete.
|
||||
|
||||
## 0.2.8
|
||||
|
||||
- Fixed OTA issue with nrfConnect on iOS
|
||||
- Increased LED conn cycle when ble connected for easier recognition
|
||||
|
||||
## 0.2.7
|
||||
|
||||
- Fixed PWM psel[1] is not reset
|
||||
- Fixed #41 move RXD, TXD into board header
|
||||
- Added Metro nRF52840 Rev A
|
||||
- Fixed #40 OTA issue with BLE_GAP_EVT_PHY_UPDATE_REQUEST e.g connecting with iPhone X
|
||||
|
||||
## 0.2.6
|
||||
|
||||
- Fixed copy/restore current.uf2 issue
|
||||
- Fixed neopixel won't turn off after dfu cdc
|
||||
|
||||
## 0.2.5
|
||||
|
||||
- Make led pattern more consistent
|
||||
- Fixed issue nrf52840 not reset properly when upgrading bootloader+sd combo
|
||||
- Make led pattern more consistent
|
||||
|
||||
## 0.2.3
|
||||
|
||||
- Fully support Feather nRF52840
|
||||
- Update bootloader with new led pattern
|
||||
- Fix #203: return software timer handle
|
||||
@@ -0,0 +1,19 @@
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
-mthumb
|
||||
-mcpu=cortex-m33
|
||||
-mfloat-abi=hard
|
||||
-mfpu=fpv5-sp-d16
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT GCC_ARM_CM33_NTZ_NONSECURE CACHE INTERNAL "")
|
||||
|
||||
elseif (TOOLCHAIN STREQUAL "iar")
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
--cpu cortex-m33
|
||||
--fpu VFPv5-SP
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT IAR_ARM_CM4F CACHE INTERNAL "")
|
||||
|
||||
endif ()
|
||||
@@ -0,0 +1,6 @@
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
-mthumb
|
||||
-mcpu=cortex-m4
|
||||
-mfloat-abi=hard
|
||||
-mfpu=fpv4-sp-d16
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
|
||||
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
|
||||
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
|
||||
|
||||
# Look for includes and libraries only in the target system prefix.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
|
||||
|
||||
# enable all possible warnings for building examples
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
-fdata-sections
|
||||
-ffunction-sections
|
||||
-fsingle-precision-constant
|
||||
-fno-strict-aliasing
|
||||
-g
|
||||
)
|
||||
|
||||
set(TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
-Wl,--print-memory-usage
|
||||
-Wl,--gc-sections
|
||||
#-Wl,--cref
|
||||
)
|
||||
|
||||
# join the toolchain flags into a single string
|
||||
list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
|
||||
list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)
|
||||
|
||||
set(CMAKE_C_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS} ${TOOLCHAIN_C_FLAGS}")
|
||||
set(CMAKE_ASM_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS} ${TOOLCHAIN_ASM_FLAGS}")
|
||||
@@ -0,0 +1,34 @@
|
||||
Important - Read carefully:
|
||||
|
||||
SEGGER RTT - Real Time Transfer for embedded targets
|
||||
|
||||
All rights reserved.
|
||||
|
||||
SEGGER strongly recommends to not make any changes
|
||||
to or modify the source code of this software in order to stay
|
||||
compatible with the RTT protocol and J-Link.
|
||||
|
||||
Redistribution and use in source and binary forms, with or
|
||||
without modification, are permitted provided that the following
|
||||
condition is met:
|
||||
|
||||
o Redistributions of source code must retain the above copyright
|
||||
notice, this condition and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
|
||||
|
||||
(c) 2014 - 2016 SEGGER Microcontroller GmbH
|
||||
www.segger.com
|
||||
@@ -0,0 +1,20 @@
|
||||
README.txt for the SEGGER RTT Implementation Pack.
|
||||
|
||||
Included files:
|
||||
===============
|
||||
Root Directory
|
||||
- Examples
|
||||
- Main_RTT_InputEchoApp.c - Sample application which echoes input on Channel 0.
|
||||
- Main_RTT_MenuApp.c - Sample application to demonstrate RTT bi-directional functionality.
|
||||
- Main_RTT_PrintfTest.c - Sample application to test RTT small printf implementation.
|
||||
- Main_RTT_SpeedTestApp.c - Sample application for measuring RTT performance. embOS needed.
|
||||
- RTT
|
||||
- SEGGER_RTT.c - The RTT implementation.
|
||||
- SEGGER_RTT.h - Header for RTT implementation.
|
||||
- SEGGER_RTT_Conf.h - Pre-processor configuration for the RTT implementation.
|
||||
- SEGGER_RTT_Printf.c - Simple implementation of printf to write formatted strings via RTT.
|
||||
- Syscalls
|
||||
- RTT_Syscalls_GCC.c - Low-level syscalls to retarget printf() to RTT with GCC / Newlib.
|
||||
- RTT_Syscalls_IAR.c - Low-level syscalls to retarget printf() to RTT with IAR compiler.
|
||||
- RTT_Syscalls_KEIL.c - Low-level syscalls to retarget printf() to RTT with KEIL/uVision compiler.
|
||||
- RTT_Syscalls_SES.c - Low-level syscalls to retarget printf() to RTT with SEGGER Embedded Studio.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,321 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT.h
|
||||
Purpose : Implementation of SEGGER real-time transfer which allows
|
||||
real-time communication on targets which support debugger
|
||||
memory accesses while the CPU is running.
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_H
|
||||
#define SEGGER_RTT_H
|
||||
|
||||
#include "SEGGER_RTT_Conf.h"
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, defaults
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifndef RTT_USE_ASM
|
||||
#if (defined __SES_ARM) // SEGGER Embedded Studio
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __CROSSWORKS_ARM) // Rowley Crossworks
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __GNUC__) // GCC
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __clang__) // Clang compiler
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __IASMARM__) // IAR assembler
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ICCARM__) // IAR compiler
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 1
|
||||
#else
|
||||
#define _CC_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
#if (defined __ARM_ARCH_7M__) // Cortex-M3/4
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ARM_ARCH_7EM__) // Cortex-M7
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#elif (defined __ARM7M__) // IAR Cortex-M3/4
|
||||
#if (__CORE__ == __ARM7M__)
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#else
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
#elif (defined __ARM7EM__) // IAR Cortex-M7
|
||||
#if (__CORE__ == __ARM7EM__)
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 1
|
||||
#else
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
#else
|
||||
#define _CORE_HAS_RTT_ASM_SUPPORT 0
|
||||
#endif
|
||||
//
|
||||
// If IDE and core support the ASM version, enable ASM version by default
|
||||
//
|
||||
#if (_CC_HAS_RTT_ASM_SUPPORT && _CORE_HAS_RTT_ASM_SUPPORT)
|
||||
#define RTT_USE_ASM (1)
|
||||
#else
|
||||
#define RTT_USE_ASM (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, fixed
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Types
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Description for a circular buffer (also called "ring buffer")
|
||||
// which is used as up-buffer (T->H)
|
||||
//
|
||||
typedef struct {
|
||||
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
|
||||
char* pBuffer; // Pointer to start of buffer
|
||||
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
|
||||
unsigned WrOff; // Position of next item to be written by either target.
|
||||
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
|
||||
unsigned Flags; // Contains configuration flags
|
||||
} SEGGER_RTT_BUFFER_UP;
|
||||
|
||||
//
|
||||
// Description for a circular buffer (also called "ring buffer")
|
||||
// which is used as down-buffer (H->T)
|
||||
//
|
||||
typedef struct {
|
||||
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
|
||||
char* pBuffer; // Pointer to start of buffer
|
||||
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
|
||||
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
|
||||
unsigned RdOff; // Position of next item to be read by target (down-buffer).
|
||||
unsigned Flags; // Contains configuration flags
|
||||
} SEGGER_RTT_BUFFER_DOWN;
|
||||
|
||||
//
|
||||
// RTT control block which describes the number of buffers available
|
||||
// as well as the configuration for each buffer
|
||||
//
|
||||
//
|
||||
typedef struct {
|
||||
char acID[16]; // Initialized to "SEGGER RTT"
|
||||
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
|
||||
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
|
||||
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
|
||||
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
|
||||
} SEGGER_RTT_CB;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global data
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
extern SEGGER_RTT_CB _SEGGER_RTT;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT API functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_GetKey (void);
|
||||
unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
|
||||
int SEGGER_RTT_HasKey (void);
|
||||
unsigned SEGGER_RTT_HasDataUp (unsigned BufferIndex);
|
||||
void SEGGER_RTT_Init (void);
|
||||
unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
|
||||
unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
|
||||
int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName);
|
||||
int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
|
||||
int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags);
|
||||
int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags);
|
||||
int SEGGER_RTT_WaitKey (void);
|
||||
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_ASM_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
|
||||
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c);
|
||||
unsigned SEGGER_RTT_PutCharSkip (unsigned BufferIndex, char c);
|
||||
unsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c);
|
||||
unsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex);
|
||||
unsigned SEGGER_RTT_GetBytesInBuffer (unsigned BufferIndex);
|
||||
//
|
||||
// Function macro for performance optimization
|
||||
//
|
||||
#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
|
||||
|
||||
#if RTT_USE_ASM
|
||||
#define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT transfer functions to send RTT data via other channels.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
unsigned SEGGER_RTT_ReadUpBuffer (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
|
||||
unsigned SEGGER_RTT_ReadUpBufferNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
|
||||
unsigned SEGGER_RTT_WriteDownBuffer (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteDownBufferNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
|
||||
#define SEGGER_RTT_HASDATA_UP(n) (_SEGGER_RTT.aUp[n].WrOff - _SEGGER_RTT.aUp[n].RdOff)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT "Terminal" API functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_SetTerminal (unsigned char TerminalId);
|
||||
int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT printf functions (require SEGGER_RTT_printf.c)
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
|
||||
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ifndef(SEGGER_RTT_ASM)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
|
||||
//
|
||||
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) // Skip. Do not block, output nothing. (Default)
|
||||
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1) // Trim: Do not block, output as much as fits.
|
||||
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2) // Block: Wait until there is space in the buffer.
|
||||
#define SEGGER_RTT_MODE_MASK (3)
|
||||
|
||||
//
|
||||
// Control sequences, based on ANSI.
|
||||
// Can be used to control color, and clear the screen
|
||||
//
|
||||
#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors
|
||||
#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left
|
||||
|
||||
#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m"
|
||||
#define RTT_CTRL_TEXT_RED "\x1B[2;31m"
|
||||
#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m"
|
||||
#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m"
|
||||
#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m"
|
||||
#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m"
|
||||
#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m"
|
||||
#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m"
|
||||
|
||||
#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m"
|
||||
|
||||
#define RTT_CTRL_BG_BLACK "\x1B[24;40m"
|
||||
#define RTT_CTRL_BG_RED "\x1B[24;41m"
|
||||
#define RTT_CTRL_BG_GREEN "\x1B[24;42m"
|
||||
#define RTT_CTRL_BG_YELLOW "\x1B[24;43m"
|
||||
#define RTT_CTRL_BG_BLUE "\x1B[24;44m"
|
||||
#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m"
|
||||
#define RTT_CTRL_BG_CYAN "\x1B[24;46m"
|
||||
#define RTT_CTRL_BG_WHITE "\x1B[24;47m"
|
||||
|
||||
#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m"
|
||||
#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m"
|
||||
#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m"
|
||||
#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m"
|
||||
#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m"
|
||||
#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m"
|
||||
#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m"
|
||||
#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,235 @@
|
||||
/*********************************************************************
|
||||
* (c) SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
* www.segger.com *
|
||||
**********************************************************************
|
||||
|
||||
-------------------------- END-OF-HEADER -----------------------------
|
||||
|
||||
File : SEGGER_RTT_ASM_ARMv7M.S
|
||||
Purpose : Assembler implementation of RTT functions for ARMv7M
|
||||
|
||||
Additional information:
|
||||
This module is written to be assembler-independent and works with
|
||||
GCC and clang (Embedded Studio) and IAR.
|
||||
*/
|
||||
|
||||
#define SEGGER_RTT_ASM // Used to control processed input from header file
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, fixed
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#define _CCIAR 0
|
||||
#define _CCCLANG 1
|
||||
|
||||
#if (defined __SES_ARM) || (defined __GNUC__) || (defined __clang__)
|
||||
#define _CC_TYPE _CCCLANG
|
||||
#define _PUB_SYM .global
|
||||
#define _EXT_SYM .extern
|
||||
#define _END .end
|
||||
#define _WEAK .weak
|
||||
#define _THUMB_FUNC .thumb_func
|
||||
#define _THUMB_CODE .code 16
|
||||
#define _WORD .word
|
||||
#define _SECTION(Sect, Type, AlignExp) .section Sect ##, "ax"
|
||||
#define _ALIGN(Exp) .align Exp
|
||||
#define _PLACE_LITS .ltorg
|
||||
#define _DATA_SECT_START
|
||||
#define _C_STARTUP _start
|
||||
#define _STACK_END __stack_end__
|
||||
#define _RAMFUNC
|
||||
//
|
||||
// .text => Link to flash
|
||||
// .fast => Link to RAM
|
||||
// OtherSect => Usually link to RAM
|
||||
// Alignment is 2^x
|
||||
//
|
||||
#elif defined (__IASMARM__)
|
||||
#define _CC_TYPE _CCIAR
|
||||
#define _PUB_SYM PUBLIC
|
||||
#define _EXT_SYM EXTERN
|
||||
#define _END END
|
||||
#define _WEAK _WEAK
|
||||
#define _THUMB_FUNC
|
||||
#define _THUMB_CODE THUMB
|
||||
#define _WORD DCD
|
||||
#define _SECTION(Sect, Type, AlignExp) SECTION Sect ## : ## Type ## :REORDER:NOROOT ## (AlignExp)
|
||||
#define _ALIGN(Exp) alignrom Exp
|
||||
#define _PLACE_LITS
|
||||
#define _DATA_SECT_START DATA
|
||||
#define _C_STARTUP __iar_program_start
|
||||
#define _STACK_END sfe(CSTACK)
|
||||
#define _RAMFUNC SECTION_TYPE SHT_PROGBITS, SHF_WRITE | SHF_EXECINSTR
|
||||
//
|
||||
// .text => Link to flash
|
||||
// .textrw => Link to RAM
|
||||
// OtherSect => Usually link to RAM
|
||||
// NOROOT => Allows linker to throw away the function, if not referenced
|
||||
// Alignment is 2^x
|
||||
//
|
||||
#endif
|
||||
|
||||
#if (_CC_TYPE == _CCIAR)
|
||||
NAME SEGGER_RTT_ASM_ARMv7M
|
||||
#else
|
||||
.syntax unified
|
||||
#endif
|
||||
|
||||
#if defined (RTT_USE_ASM) && (RTT_USE_ASM == 1)
|
||||
#define SHT_PROGBITS 0x1
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public / external symbols
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
_EXT_SYM __aeabi_memcpy
|
||||
_EXT_SYM __aeabi_memcpy4
|
||||
_EXT_SYM _SEGGER_RTT
|
||||
|
||||
_PUB_SYM SEGGER_RTT_ASM_WriteSkipNoLock
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* SEGGER_RTT_WriteSkipNoLock
|
||||
*
|
||||
* Function description
|
||||
* Stores a specified number of characters in SEGGER RTT
|
||||
* control block which is then read by the host.
|
||||
* SEGGER_RTT_WriteSkipNoLock does not lock the application and
|
||||
* skips all data, if the data does not fit into the buffer.
|
||||
*
|
||||
* Parameters
|
||||
* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
|
||||
* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
|
||||
* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
|
||||
* MUST be > 0!!!
|
||||
* This is done for performance reasons, so no initial check has do be done.
|
||||
*
|
||||
* Return value
|
||||
* 1: Data has been copied
|
||||
* 0: No space, data has not been copied
|
||||
*
|
||||
* Notes
|
||||
* (1) If there is not enough space in the "Up"-buffer, all data is dropped.
|
||||
* (2) For performance reasons this function does not call Init()
|
||||
* and may only be called after RTT has been initialized.
|
||||
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
|
||||
*/
|
||||
_SECTION(.text, CODE, 2)
|
||||
_ALIGN(2)
|
||||
_THUMB_FUNC
|
||||
SEGGER_RTT_ASM_WriteSkipNoLock: // unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pData, unsigned NumBytes) {
|
||||
//
|
||||
// Cases:
|
||||
// 1) RdOff <= WrOff => Space until wrap-around is sufficient
|
||||
// 2) RdOff <= WrOff => Space after wrap-around needed (copy in 2 chunks)
|
||||
// 3) RdOff < WrOff => No space in buf
|
||||
// 4) RdOff > WrOff => Space is sufficient
|
||||
// 5) RdOff > WrOff => No space in buf
|
||||
//
|
||||
// 1) is the most common case for large buffers and assuming that J-Link reads the data fast enough
|
||||
//
|
||||
// Register usage:
|
||||
// R0 Temporary needed as RdOff, <Tmp> register later on
|
||||
// R1 pData
|
||||
// R2 <NumBytes>
|
||||
// R3 <Tmp> register. Hold free for subroutine calls
|
||||
// R4 <Rem>
|
||||
// R5 pRing->pBuffer
|
||||
// R6 pRing (Points to active struct SEGGER_RTT_BUFFER_DOWN)
|
||||
// R7 WrOff
|
||||
//
|
||||
PUSH {R4-R7}
|
||||
ADD R3,R0,R0, LSL #+1
|
||||
LDR.W R0,=_SEGGER_RTT // pRing = &_SEGGER_RTT.aUp[BufferIndex];
|
||||
ADD R0,R0,R3, LSL #+3
|
||||
ADD R6,R0,#+24
|
||||
LDR R0,[R6, #+16] // RdOff = pRing->RdOff;
|
||||
LDR R7,[R6, #+12] // WrOff = pRing->WrOff;
|
||||
LDR R5,[R6, #+4] // pRing->pBuffer
|
||||
CMP R7,R0
|
||||
BCC.N _CheckCase4 // if (RdOff <= WrOff) { => Case 1), 2) or 3)
|
||||
//
|
||||
// Handling for case 1, later on identical to case 4
|
||||
//
|
||||
LDR R3,[R6, #+8] // Avail = pRing->SizeOfBuffer - WrOff - 1u; => Space until wrap-around (assume 1 byte not usable for case that RdOff == 0)
|
||||
SUBS R4,R3,R7 // <Rem> (Used in case we jump into case 2 afterwards)
|
||||
SUBS R3,R4,#+1 // <Avail>
|
||||
CMP R3,R2
|
||||
BCC.N _CheckCase2 // if (Avail >= NumBytes) { => Case 1)?
|
||||
_Case4:
|
||||
ADDS R5,R7,R5 // pBuffer += WrOff
|
||||
ADDS R0,R2,R7 // v = WrOff + NumBytes
|
||||
//
|
||||
// 2x unrolling for the copy loop that is used most of the time
|
||||
// This is a special optimization for small SystemView packets and makes them even faster
|
||||
//
|
||||
_ALIGN(2)
|
||||
_LoopCopyStraight: // memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
|
||||
LDRB R3,[R1], #+1
|
||||
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R2,R2,#+1
|
||||
BEQ _CSDone
|
||||
LDRB R3,[R1], #+1
|
||||
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R2,R2,#+1
|
||||
BNE _LoopCopyStraight
|
||||
_CSDone:
|
||||
STR R0,[R6, #+12] // pRing->WrOff = WrOff + NumBytes;
|
||||
MOVS R0,#+1
|
||||
POP {R4-R7}
|
||||
BX LR // Return 1
|
||||
_CheckCase2:
|
||||
ADDS R0,R0,R3 // Avail += RdOff; => Space incl. wrap-around
|
||||
CMP R0,R2
|
||||
BCC.N _Case3 // if (Avail >= NumBytes) { => Case 2? => If not, we have case 3) (does not fit)
|
||||
//
|
||||
// Handling for case 2
|
||||
//
|
||||
ADDS R0,R7,R5 // v = pRing->pBuffer + WrOff => Do not change pRing->pBuffer here because 2nd chunk needs org. value
|
||||
SUBS R2,R2,R4 // NumBytes -= Rem; (Rem = pRing->SizeOfBuffer - WrOff; => Space until end of buffer)
|
||||
_LoopCopyBeforeWrapAround: // memcpy(pRing->pBuffer + WrOff, pData, Rem); => Copy 1st chunk
|
||||
LDRB R3,[R1], #+1
|
||||
STRB R3,[R0], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R4,R4,#+1
|
||||
BNE _LoopCopyBeforeWrapAround
|
||||
//
|
||||
// Special case: First check that assumed RdOff == 0 calculated that last element before wrap-around could not be used
|
||||
// But 2nd check (considering space until wrap-around and until RdOff) revealed that RdOff is not 0, so we can use the last element
|
||||
// In this case, we may use a copy straight until buffer end anyway without needing to copy 2 chunks
|
||||
// Therefore, check if 2nd memcpy is necessary at all
|
||||
//
|
||||
ADDS R4,R2,#+0 // Save <NumBytes> (needed as counter in loop but must be written to <WrOff> after the loop). Also use this inst to update the flags to skip 2nd loop if possible
|
||||
BEQ.N _No2ChunkNeeded // if (NumBytes) {
|
||||
_LoopCopyAfterWrapAround: // memcpy(pRing->pBuffer, pData + Rem, NumBytes);
|
||||
LDRB R3,[R1], #+1 // pData already points to the next src byte due to copy loop increment before this loop
|
||||
STRB R3,[R5], #+1 // *pDest++ = *pSrc++
|
||||
SUBS R2,R2,#+1
|
||||
BNE _LoopCopyAfterWrapAround
|
||||
_No2ChunkNeeded:
|
||||
STR R4,[R6, #+12] // pRing->WrOff = NumBytes; => Must be written after copying data because J-Link may read control block asynchronously while writing into buffer
|
||||
MOVS R0,#+1
|
||||
POP {R4-R7}
|
||||
BX LR // Return 1
|
||||
_CheckCase4:
|
||||
SUBS R0,R0,R7
|
||||
SUBS R0,R0,#+1 // Avail = RdOff - WrOff - 1u;
|
||||
CMP R0,R2
|
||||
BCS.N _Case4 // if (Avail >= NumBytes) { => Case 4) == 1) ? => If not, we have case 5) == 3) (does not fit)
|
||||
_Case3:
|
||||
MOVS R0,#+0
|
||||
POP {R4-R7}
|
||||
BX LR // Return 0
|
||||
_PLACE_LITS
|
||||
|
||||
#endif // defined (RTT_USE_ASM) && (RTT_USE_ASM == 1)
|
||||
_END
|
||||
|
||||
/*************************** End of file ****************************/
|
||||
@@ -1,9 +1,9 @@
|
||||
/*********************************************************************
|
||||
* SEGGER MICROCONTROLLER GmbH & Co. KG *
|
||||
* Solutions for real time microcontroller applications *
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
@@ -15,15 +15,16 @@
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* * This software may in its unmodified form be freely redistributed *
|
||||
* in source form. *
|
||||
* * The source code may be modified, provided the source code *
|
||||
* retains the above copyright notice, this list of conditions and *
|
||||
* the following disclaimer. *
|
||||
* * Modified versions of this software in source or linkable form *
|
||||
* may not be distributed without prior consent of SEGGER. *
|
||||
* * This software may only be used for communication with SEGGER *
|
||||
* J-Link debug probes. *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
@@ -40,22 +41,19 @@
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* RTT version: 5.12e *
|
||||
* *
|
||||
**********************************************************************
|
||||
----------------------------------------------------------------------
|
||||
File : SEGGER_RTT_Conf.h
|
||||
Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
allows real-time communication on targets which support
|
||||
debugger memory accesses while the CPU is running.
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Conf.h
|
||||
Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
allows real-time communication on targets which support
|
||||
debugger memory accesses while the CPU is running.
|
||||
Revision: $Rev: 18601 $
|
||||
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_CONF_H
|
||||
#define SEGGER_RTT_CONF_H
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#include <intrinsics.h>
|
||||
#endif
|
||||
|
||||
@@ -65,58 +63,94 @@ Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
|
||||
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
|
||||
#endif
|
||||
|
||||
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (2) // Max. number of up-buffers (T->H) available on this target (Default: 2)
|
||||
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (2) // Max. number of down-buffers (H->T) available on this target (Default: 2)
|
||||
#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
|
||||
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
|
||||
#endif
|
||||
|
||||
#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
|
||||
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
|
||||
#ifndef BUFFER_SIZE_UP
|
||||
#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
|
||||
#endif
|
||||
|
||||
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
|
||||
#ifndef BUFFER_SIZE_DOWN
|
||||
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
|
||||
#endif
|
||||
|
||||
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
|
||||
#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
|
||||
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_MODE_DEFAULT
|
||||
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT memcpy configuration
|
||||
*
|
||||
* memcpy() is good for large amounts of data,
|
||||
* but the overhead is big for small amounts, which are usually stored via RTT.
|
||||
* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead.
|
||||
*
|
||||
* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions.
|
||||
* This is may be required with memory access restrictions,
|
||||
* such as on Cortex-A devices with MMU.
|
||||
*/
|
||||
#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP
|
||||
#define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
|
||||
#endif
|
||||
//
|
||||
// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets
|
||||
//
|
||||
//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__))
|
||||
// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes))
|
||||
//#endif
|
||||
|
||||
//
|
||||
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
|
||||
// Otherwise we would probably end up with a mixed string in the buffer.
|
||||
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
|
||||
//
|
||||
//
|
||||
// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
|
||||
// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
|
||||
// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
|
||||
// (Higher priority = lower priority number)
|
||||
// Default value for embOS: 128u
|
||||
// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
// In case of doubt mask all interrupts: 0u
|
||||
//
|
||||
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
|
||||
// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
|
||||
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
|
||||
//
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for SEGGER Embedded Studio,
|
||||
* RTT lock configuration for SEGGER Embedded Studio,
|
||||
* Rowley CrossStudio and GCC
|
||||
*/
|
||||
#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)
|
||||
#ifdef __ARM_ARCH_6M__
|
||||
#if ((defined(__SES_ARM) || defined(__SES_RISCV) || defined(__CROSSWORKS_ARM) || defined(__GNUC__) || defined(__clang__)) && !defined (__CC_ARM) && !defined(WIN32))
|
||||
#if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__))
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("mrs %0, primask \n\t" \
|
||||
"mov r1, $1 \n\t" \
|
||||
"movs r1, $1 \n\t" \
|
||||
"msr primask, r1 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: \
|
||||
); \
|
||||
}
|
||||
|
||||
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
|
||||
}
|
||||
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
@@ -128,15 +162,15 @@ Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
: "=r" (LockState) \
|
||||
: "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: \
|
||||
); \
|
||||
}
|
||||
|
||||
|
||||
#elif defined(__ARM_ARCH_7A__)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
@@ -160,8 +194,27 @@ Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
: "r0", "r1" \
|
||||
); \
|
||||
}
|
||||
#else
|
||||
#define SEGGER_RTT_LOCK()
|
||||
#elif defined(__riscv) || defined(__riscv_xlen)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("csrr %0, mstatus \n\t" \
|
||||
"csrci mstatus, 8 \n\t" \
|
||||
"andi %0, %0, 8 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: \
|
||||
: \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" \
|
||||
"or %0, %0, a1 \n\t" \
|
||||
"csrs mstatus, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: "a1" \
|
||||
); \
|
||||
}
|
||||
#else
|
||||
#define SEGGER_RTT_LOCK()
|
||||
#define SEGGER_RTT_UNLOCK()
|
||||
#endif
|
||||
#endif
|
||||
@@ -171,28 +224,60 @@ Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
* RTT lock configuration for IAR EWARM
|
||||
*/
|
||||
#ifdef __ICCARM__
|
||||
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__))
|
||||
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || \
|
||||
(defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__))
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_PRIMASK(); \
|
||||
__set_PRIMASK(1);
|
||||
|
||||
__set_PRIMASK(1);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
|
||||
}
|
||||
#elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)))
|
||||
#elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || \
|
||||
(defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || \
|
||||
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || \
|
||||
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_BASEPRI(); \
|
||||
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
|
||||
|
||||
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for IAR RX
|
||||
*/
|
||||
#ifdef __ICCRX__
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned long LockState; \
|
||||
LockState = __get_interrupt_state(); \
|
||||
__disable_interrupt();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for IAR RL78
|
||||
*/
|
||||
#ifdef __ICCRL78__
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
__istate_t LockState; \
|
||||
LockState = __get_interrupt_state(); \
|
||||
__disable_interrupt();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for KEIL ARM
|
||||
@@ -226,6 +311,63 @@ Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for TI ARM
|
||||
*/
|
||||
#ifdef __TI_ARM__
|
||||
#if defined (__TI_ARM_V6M0__)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_PRIMASK(); \
|
||||
__set_PRIMASK(1);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
|
||||
}
|
||||
#elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() _set_interrupt_priority(LockState); \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for CCRX
|
||||
*/
|
||||
#ifdef __RX
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned long LockState; \
|
||||
LockState = get_psw() & 0x010000; \
|
||||
clrpsw_i();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() set_psw(get_psw() | LockState); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for embOS Simulation on Windows
|
||||
* (Can also be used for generic RTT locking with embOS)
|
||||
*/
|
||||
#if defined(WIN32) || defined(SEGGER_RTT_LOCK_EMBOS)
|
||||
|
||||
void OS_SIM_EnterCriticalSection(void);
|
||||
void OS_SIM_LeaveCriticalSection(void);
|
||||
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
OS_SIM_EnterCriticalSection();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration fallback
|
||||
@@ -0,0 +1,500 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_printf.c
|
||||
Purpose : Replacement for printf to write formatted data via RTT
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#include "SEGGER_RTT.h"
|
||||
#include "SEGGER_RTT_Conf.h"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
|
||||
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64)
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#define FORMAT_FLAG_LEFT_JUSTIFY (1u << 0)
|
||||
#define FORMAT_FLAG_PAD_ZERO (1u << 1)
|
||||
#define FORMAT_FLAG_PRINT_SIGN (1u << 2)
|
||||
#define FORMAT_FLAG_ALTERNATE (1u << 3)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Types
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char* pBuffer;
|
||||
unsigned BufferSize;
|
||||
unsigned Cnt;
|
||||
|
||||
int ReturnValue;
|
||||
|
||||
unsigned RTTBufferIndex;
|
||||
} SEGGER_RTT_PRINTF_DESC;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Static code
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* _StoreChar
|
||||
*/
|
||||
static void _StoreChar(SEGGER_RTT_PRINTF_DESC * p, char c) {
|
||||
unsigned Cnt;
|
||||
|
||||
Cnt = p->Cnt;
|
||||
if ((Cnt + 1u) <= p->BufferSize) {
|
||||
*(p->pBuffer + Cnt) = c;
|
||||
p->Cnt = Cnt + 1u;
|
||||
p->ReturnValue++;
|
||||
}
|
||||
//
|
||||
// Write part of string, when the buffer is full
|
||||
//
|
||||
if (p->Cnt == p->BufferSize) {
|
||||
if (SEGGER_RTT_Write(p->RTTBufferIndex, p->pBuffer, p->Cnt) != p->Cnt) {
|
||||
p->ReturnValue = -1;
|
||||
} else {
|
||||
p->Cnt = 0u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _PrintUnsigned
|
||||
*/
|
||||
static void _PrintUnsigned(SEGGER_RTT_PRINTF_DESC * pBufferDesc, unsigned v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
|
||||
static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
unsigned Div;
|
||||
unsigned Digit;
|
||||
unsigned Number;
|
||||
unsigned Width;
|
||||
char c;
|
||||
|
||||
Number = v;
|
||||
Digit = 1u;
|
||||
//
|
||||
// Get actual field width
|
||||
//
|
||||
Width = 1u;
|
||||
while (Number >= Base) {
|
||||
Number = (Number / Base);
|
||||
Width++;
|
||||
}
|
||||
if (NumDigits > Width) {
|
||||
Width = NumDigits;
|
||||
}
|
||||
//
|
||||
// Print leading chars if necessary
|
||||
//
|
||||
if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) {
|
||||
if (FieldWidth != 0u) {
|
||||
if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && (NumDigits == 0u)) {
|
||||
c = '0';
|
||||
} else {
|
||||
c = ' ';
|
||||
}
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, c);
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
//
|
||||
// Compute Digit.
|
||||
// Loop until Digit has the value of the highest digit required.
|
||||
// Example: If the output is 345 (Base 10), loop 2 times until Digit is 100.
|
||||
//
|
||||
while (1) {
|
||||
if (NumDigits > 1u) { // User specified a min number of digits to print? => Make sure we loop at least that often, before checking anything else (> 1 check avoids problems with NumDigits being signed / unsigned)
|
||||
NumDigits--;
|
||||
} else {
|
||||
Div = v / Digit;
|
||||
if (Div < Base) { // Is our divider big enough to extract the highest digit from value? => Done
|
||||
break;
|
||||
}
|
||||
}
|
||||
Digit *= Base;
|
||||
}
|
||||
//
|
||||
// Output digits
|
||||
//
|
||||
do {
|
||||
Div = v / Digit;
|
||||
v -= Div * Digit;
|
||||
_StoreChar(pBufferDesc, _aV2C[Div]);
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
Digit /= Base;
|
||||
} while (Digit);
|
||||
//
|
||||
// Print trailing spaces if necessary
|
||||
//
|
||||
if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == FORMAT_FLAG_LEFT_JUSTIFY) {
|
||||
if (FieldWidth != 0u) {
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, ' ');
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _PrintInt
|
||||
*/
|
||||
static void _PrintInt(SEGGER_RTT_PRINTF_DESC * pBufferDesc, int v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) {
|
||||
unsigned Width;
|
||||
int Number;
|
||||
|
||||
Number = (v < 0) ? -v : v;
|
||||
|
||||
//
|
||||
// Get actual field width
|
||||
//
|
||||
Width = 1u;
|
||||
while (Number >= (int)Base) {
|
||||
Number = (Number / (int)Base);
|
||||
Width++;
|
||||
}
|
||||
if (NumDigits > Width) {
|
||||
Width = NumDigits;
|
||||
}
|
||||
if ((FieldWidth > 0u) && ((v < 0) || ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN))) {
|
||||
FieldWidth--;
|
||||
}
|
||||
|
||||
//
|
||||
// Print leading spaces if necessary
|
||||
//
|
||||
if ((((FormatFlags & FORMAT_FLAG_PAD_ZERO) == 0u) || (NumDigits != 0u)) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u)) {
|
||||
if (FieldWidth != 0u) {
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, ' ');
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Print sign if necessary
|
||||
//
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
if (v < 0) {
|
||||
v = -v;
|
||||
_StoreChar(pBufferDesc, '-');
|
||||
} else if ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN) {
|
||||
_StoreChar(pBufferDesc, '+');
|
||||
} else {
|
||||
|
||||
}
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
//
|
||||
// Print leading zeros if necessary
|
||||
//
|
||||
if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) && (NumDigits == 0u)) {
|
||||
if (FieldWidth != 0u) {
|
||||
while ((FieldWidth != 0u) && (Width < FieldWidth)) {
|
||||
FieldWidth--;
|
||||
_StoreChar(pBufferDesc, '0');
|
||||
if (pBufferDesc->ReturnValue < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pBufferDesc->ReturnValue >= 0) {
|
||||
//
|
||||
// Print number without sign
|
||||
//
|
||||
_PrintUnsigned(pBufferDesc, (unsigned)v, Base, NumDigits, FieldWidth, FormatFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public code
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* SEGGER_RTT_vprintf
|
||||
*
|
||||
* Function description
|
||||
* Stores a formatted string in SEGGER RTT control block.
|
||||
* This data is read by the host.
|
||||
*
|
||||
* Parameters
|
||||
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
|
||||
* sFormat Pointer to format string
|
||||
* pParamList Pointer to the list of arguments for the format string
|
||||
*
|
||||
* Return values
|
||||
* >= 0: Number of bytes which have been stored in the "Up"-buffer.
|
||||
* < 0: Error
|
||||
*/
|
||||
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList) {
|
||||
char c;
|
||||
SEGGER_RTT_PRINTF_DESC BufferDesc;
|
||||
int v;
|
||||
unsigned NumDigits;
|
||||
unsigned FormatFlags;
|
||||
unsigned FieldWidth;
|
||||
char acBuffer[SEGGER_RTT_PRINTF_BUFFER_SIZE];
|
||||
|
||||
BufferDesc.pBuffer = acBuffer;
|
||||
BufferDesc.BufferSize = SEGGER_RTT_PRINTF_BUFFER_SIZE;
|
||||
BufferDesc.Cnt = 0u;
|
||||
BufferDesc.RTTBufferIndex = BufferIndex;
|
||||
BufferDesc.ReturnValue = 0;
|
||||
|
||||
do {
|
||||
c = *sFormat;
|
||||
sFormat++;
|
||||
if (c == 0u) {
|
||||
break;
|
||||
}
|
||||
if (c == '%') {
|
||||
//
|
||||
// Filter out flags
|
||||
//
|
||||
FormatFlags = 0u;
|
||||
v = 1;
|
||||
do {
|
||||
c = *sFormat;
|
||||
switch (c) {
|
||||
case '-': FormatFlags |= FORMAT_FLAG_LEFT_JUSTIFY; sFormat++; break;
|
||||
case '0': FormatFlags |= FORMAT_FLAG_PAD_ZERO; sFormat++; break;
|
||||
case '+': FormatFlags |= FORMAT_FLAG_PRINT_SIGN; sFormat++; break;
|
||||
case '#': FormatFlags |= FORMAT_FLAG_ALTERNATE; sFormat++; break;
|
||||
default: v = 0; break;
|
||||
}
|
||||
} while (v);
|
||||
//
|
||||
// filter out field with
|
||||
//
|
||||
FieldWidth = 0u;
|
||||
do {
|
||||
c = *sFormat;
|
||||
if ((c < '0') || (c > '9')) {
|
||||
break;
|
||||
}
|
||||
sFormat++;
|
||||
FieldWidth = (FieldWidth * 10u) + ((unsigned)c - '0');
|
||||
} while (1);
|
||||
|
||||
//
|
||||
// Filter out precision (number of digits to display)
|
||||
//
|
||||
NumDigits = 0u;
|
||||
c = *sFormat;
|
||||
if (c == '.') {
|
||||
sFormat++;
|
||||
do {
|
||||
c = *sFormat;
|
||||
if ((c < '0') || (c > '9')) {
|
||||
break;
|
||||
}
|
||||
sFormat++;
|
||||
NumDigits = NumDigits * 10u + ((unsigned)c - '0');
|
||||
} while (1);
|
||||
}
|
||||
//
|
||||
// Filter out length modifier
|
||||
//
|
||||
c = *sFormat;
|
||||
do {
|
||||
if ((c == 'l') || (c == 'h')) {
|
||||
sFormat++;
|
||||
c = *sFormat;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
//
|
||||
// Handle specifiers
|
||||
//
|
||||
switch (c) {
|
||||
case 'c': {
|
||||
char c0;
|
||||
v = va_arg(*pParamList, int);
|
||||
c0 = (char)v;
|
||||
_StoreChar(&BufferDesc, c0);
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintInt(&BufferDesc, v, 10u, NumDigits, FieldWidth, FormatFlags);
|
||||
break;
|
||||
case 'u':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintUnsigned(&BufferDesc, (unsigned)v, 10u, NumDigits, FieldWidth, FormatFlags);
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintUnsigned(&BufferDesc, (unsigned)v, 16u, NumDigits, FieldWidth, FormatFlags);
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
const char * s = va_arg(*pParamList, const char *);
|
||||
do {
|
||||
c = *s;
|
||||
s++;
|
||||
if (c == '\0') {
|
||||
break;
|
||||
}
|
||||
_StoreChar(&BufferDesc, c);
|
||||
} while (BufferDesc.ReturnValue >= 0);
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
v = va_arg(*pParamList, int);
|
||||
_PrintUnsigned(&BufferDesc, (unsigned)v, 16u, 8u, 8u, 0u);
|
||||
break;
|
||||
case '%':
|
||||
_StoreChar(&BufferDesc, '%');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sFormat++;
|
||||
} else {
|
||||
_StoreChar(&BufferDesc, c);
|
||||
}
|
||||
} while (BufferDesc.ReturnValue >= 0);
|
||||
|
||||
if (BufferDesc.ReturnValue > 0) {
|
||||
//
|
||||
// Write remaining data, if any
|
||||
//
|
||||
if (BufferDesc.Cnt != 0u) {
|
||||
SEGGER_RTT_Write(BufferIndex, acBuffer, BufferDesc.Cnt);
|
||||
}
|
||||
BufferDesc.ReturnValue += (int)BufferDesc.Cnt;
|
||||
}
|
||||
return BufferDesc.ReturnValue;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* SEGGER_RTT_printf
|
||||
*
|
||||
* Function description
|
||||
* Stores a formatted string in SEGGER RTT control block.
|
||||
* This data is read by the host.
|
||||
*
|
||||
* Parameters
|
||||
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
|
||||
* sFormat Pointer to format string, followed by the arguments for conversion
|
||||
*
|
||||
* Return values
|
||||
* >= 0: Number of bytes which have been stored in the "Up"-buffer.
|
||||
* < 0: Error
|
||||
*
|
||||
* Notes
|
||||
* (1) Conversion specifications have following syntax:
|
||||
* %[flags][FieldWidth][.Precision]ConversionSpecifier
|
||||
* (2) Supported flags:
|
||||
* -: Left justify within the field width
|
||||
* +: Always print sign extension for signed conversions
|
||||
* 0: Pad with 0 instead of spaces. Ignored when using '-'-flag or precision
|
||||
* Supported conversion specifiers:
|
||||
* c: Print the argument as one char
|
||||
* d: Print the argument as a signed integer
|
||||
* u: Print the argument as an unsigned integer
|
||||
* x: Print the argument as an hexadecimal integer
|
||||
* s: Print the string pointed to by the argument
|
||||
* p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer to void.)
|
||||
*/
|
||||
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...) {
|
||||
int r;
|
||||
va_list ParamList;
|
||||
|
||||
va_start(ParamList, sFormat);
|
||||
r = SEGGER_RTT_vprintf(BufferIndex, sFormat, &ParamList);
|
||||
va_end(ParamList);
|
||||
return r;
|
||||
}
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,120 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Syscalls_GCC.c
|
||||
Purpose : Low-level functions for using printf() via RTT in GCC.
|
||||
To use RTT for printf output, include this file in your
|
||||
application.
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#if (defined __GNUC__) && !(defined __SES_ARM) && !(defined __CROSSWORKS_ARM)
|
||||
|
||||
#include <reent.h> // required for _write_r
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Types
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//
|
||||
// If necessary define the _reent struct
|
||||
// to match the one passed by the used standard library.
|
||||
//
|
||||
struct _reent;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int _write(int file, char *ptr, int len);
|
||||
int _write_r(struct _reent *r, int file, const void *ptr, int len);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _write()
|
||||
*
|
||||
* Function description
|
||||
* Low-level write function.
|
||||
* libc subroutines will use this system routine for output to all files,
|
||||
* including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
int _write(int file, char *ptr, int len) {
|
||||
(void) file; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, ptr, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _write_r()
|
||||
*
|
||||
* Function description
|
||||
* Low-level reentrant write function.
|
||||
* libc subroutines will use this system routine for output to all files,
|
||||
* including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
int _write_r(struct _reent *r, int file, const void *ptr, int len) {
|
||||
(void) file; /* Not used, avoid warning */
|
||||
(void) r; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, ptr, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
#endif
|
||||
/****** End Of File *************************************************/
|
||||
@@ -0,0 +1,115 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Syscalls_IAR.c
|
||||
Purpose : Low-level functions for using printf() via RTT in IAR.
|
||||
To use RTT for printf output, include this file in your
|
||||
application and set the Library Configuration to Normal.
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
|
||||
//
|
||||
// Since IAR EWARM V8 and EWRX V4, yfuns.h is considered as deprecated and LowLevelIOInterface.h
|
||||
// shall be used instead. To not break any compatibility with older compiler versions, we have a
|
||||
// version check in here.
|
||||
//
|
||||
#if ((defined __ICCARM__) && (__VER__ >= 8000000)) || ((defined __ICCRX__) && (__VER__ >= 400))
|
||||
#include <LowLevelIOInterface.h>
|
||||
#else
|
||||
#include <yfuns.h>
|
||||
#endif
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#pragma module_name = "?__write"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
size_t __write(int handle, const unsigned char * buffer, size_t size);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* __write()
|
||||
*
|
||||
* Function description
|
||||
* Low-level write function.
|
||||
* Standard library subroutines will use this system routine
|
||||
* for output to all files, including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
size_t __write(int handle, const unsigned char * buffer, size_t size) {
|
||||
(void) handle; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, (const char*)buffer, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* __write_buffered()
|
||||
*
|
||||
* Function description
|
||||
* Low-level write function.
|
||||
* Standard library subroutines will use this system routine
|
||||
* for output to all files, including stdout.
|
||||
* Write data via RTT.
|
||||
*/
|
||||
size_t __write_buffered(int handle, const unsigned char * buffer, size_t size) {
|
||||
(void) handle; /* Not used, avoid warning */
|
||||
SEGGER_RTT_Write(0, (const char*)buffer, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
#endif
|
||||
/****** End Of File *************************************************/
|
||||
@@ -0,0 +1,386 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : RTT_Syscalls_KEIL.c
|
||||
Purpose : Retargeting module for KEIL MDK-CM3.
|
||||
Low-level functions for using printf() via RTT
|
||||
Revision: $Rev: 17697 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef __CC_ARM
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rt_sys.h>
|
||||
#include <rt_misc.h>
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
/*********************************************************************
|
||||
*
|
||||
* #pragmas
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#pragma import(__use_no_semihosting)
|
||||
|
||||
#ifdef _MICROLIB
|
||||
#pragma import(__use_full_stdio)
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines non-configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/* Standard IO device handles - arbitrary, but any real file system handles must be
|
||||
less than 0x8000. */
|
||||
#define STDIN 0x8001 // Standard Input Stream
|
||||
#define STDOUT 0x8002 // Standard Output Stream
|
||||
#define STDERR 0x8003 // Standard Error Stream
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public const
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#if __ARMCC_VERSION < 5000000
|
||||
//const char __stdin_name[] = "STDIN";
|
||||
const char __stdout_name[] = "STDOUT";
|
||||
const char __stderr_name[] = "STDERR";
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Public code
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _ttywrch
|
||||
*
|
||||
* Function description:
|
||||
* Outputs a character to the console
|
||||
*
|
||||
* Parameters:
|
||||
* c - character to output
|
||||
*
|
||||
*/
|
||||
void _ttywrch(int c) {
|
||||
fputc(c, stdout); // stdout
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_open
|
||||
*
|
||||
* Function description:
|
||||
* Opens the device/file in order to do read/write operations
|
||||
*
|
||||
* Parameters:
|
||||
* sName - sName of the device/file to open
|
||||
* OpenMode - This parameter is currently ignored
|
||||
*
|
||||
* Return value:
|
||||
* != 0 - Handle to the object to open, otherwise
|
||||
* == 0 -"device" is not handled by this module
|
||||
*
|
||||
*/
|
||||
FILEHANDLE _sys_open(const char * sName, int OpenMode) {
|
||||
(void)OpenMode;
|
||||
// Register standard Input Output devices.
|
||||
if (strcmp(sName, __stdout_name) == 0) {
|
||||
return (STDOUT);
|
||||
} else if (strcmp(sName, __stderr_name) == 0) {
|
||||
return (STDERR);
|
||||
} else
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_close
|
||||
*
|
||||
* Function description:
|
||||
* Closes the handle to the open device/file
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* 0 - device/file closed
|
||||
*
|
||||
*/
|
||||
int _sys_close(FILEHANDLE hFile) {
|
||||
(void)hFile;
|
||||
return 0; // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_write
|
||||
*
|
||||
* Function description:
|
||||
* Writes the data to an open handle.
|
||||
* Currently this function only outputs data to the console
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
* pBuffer - Pointer to the data that shall be written
|
||||
* NumBytes - Number of bytes to write
|
||||
* Mode - The Mode that shall be used
|
||||
*
|
||||
* Return value:
|
||||
* Number of bytes *not* written to the file/device
|
||||
*
|
||||
*/
|
||||
int _sys_write(FILEHANDLE hFile, const unsigned char * pBuffer, unsigned NumBytes, int Mode) {
|
||||
int r = 0;
|
||||
|
||||
(void)Mode;
|
||||
if (hFile == STDOUT) {
|
||||
SEGGER_RTT_Write(0, (const char*)pBuffer, NumBytes);
|
||||
return 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_read
|
||||
*
|
||||
* Function description:
|
||||
* Reads data from an open handle.
|
||||
* Currently this modules does nothing.
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
* pBuffer - Pointer to buffer to store the read data
|
||||
* NumBytes - Number of bytes to read
|
||||
* Mode - The Mode that shall be used
|
||||
*
|
||||
* Return value:
|
||||
* Number of bytes read from the file/device
|
||||
*
|
||||
*/
|
||||
int _sys_read(FILEHANDLE hFile, unsigned char * pBuffer, unsigned NumBytes, int Mode) {
|
||||
(void)hFile;
|
||||
(void)pBuffer;
|
||||
(void)NumBytes;
|
||||
(void)Mode;
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_istty
|
||||
*
|
||||
* Function description:
|
||||
* This function shall return whether the opened file
|
||||
* is a console device or not.
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* 1 - Device is a console
|
||||
* 0 - Device is not a console
|
||||
*
|
||||
*/
|
||||
int _sys_istty(FILEHANDLE hFile) {
|
||||
if (hFile > 0x8000) {
|
||||
return (1);
|
||||
}
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_seek
|
||||
*
|
||||
* Function description:
|
||||
* Seeks via the file to a specific position
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
* Pos -
|
||||
*
|
||||
* Return value:
|
||||
* int -
|
||||
*
|
||||
*/
|
||||
int _sys_seek(FILEHANDLE hFile, long Pos) {
|
||||
(void)hFile;
|
||||
(void)Pos;
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_ensure
|
||||
*
|
||||
* Function description:
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* int -
|
||||
*
|
||||
*/
|
||||
int _sys_ensure(FILEHANDLE hFile) {
|
||||
(void)hFile;
|
||||
return (-1); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_flen
|
||||
*
|
||||
* Function description:
|
||||
* Returns the length of the opened file handle
|
||||
*
|
||||
* Parameters:
|
||||
* hFile - Handle to a file opened via _sys_open
|
||||
*
|
||||
* Return value:
|
||||
* Length of the file
|
||||
*
|
||||
*/
|
||||
long _sys_flen(FILEHANDLE hFile) {
|
||||
(void)hFile;
|
||||
return (0); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_tmpnam
|
||||
*
|
||||
* Function description:
|
||||
* This function converts the file number fileno for a temporary
|
||||
* file to a unique filename, for example, tmp0001.
|
||||
*
|
||||
* Parameters:
|
||||
* pBuffer - Pointer to a buffer to store the name
|
||||
* FileNum - file number to convert
|
||||
* MaxLen - Size of the buffer
|
||||
*
|
||||
* Return value:
|
||||
* 1 - Error
|
||||
* 0 - Success
|
||||
*
|
||||
*/
|
||||
int _sys_tmpnam(char * pBuffer, int FileNum, unsigned MaxLen) {
|
||||
(void)pBuffer;
|
||||
(void)FileNum;
|
||||
(void)MaxLen;
|
||||
return (1); // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_command_string
|
||||
*
|
||||
* Function description:
|
||||
* This function shall execute a system command.
|
||||
*
|
||||
* Parameters:
|
||||
* cmd - Pointer to the command string
|
||||
* len - Length of the string
|
||||
*
|
||||
* Return value:
|
||||
* == NULL - Command was not successfully executed
|
||||
* == sCmd - Command was passed successfully
|
||||
*
|
||||
*/
|
||||
char * _sys_command_string(char * cmd, int len) {
|
||||
(void)len;
|
||||
return cmd; // Not implemented
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* _sys_exit
|
||||
*
|
||||
* Function description:
|
||||
* This function is called when the application returns from main
|
||||
*
|
||||
* Parameters:
|
||||
* ReturnCode - Return code from the main function
|
||||
*
|
||||
*
|
||||
*/
|
||||
void _sys_exit(int ReturnCode) {
|
||||
(void)ReturnCode;
|
||||
while (1); // Not implemented
|
||||
}
|
||||
|
||||
#if __ARMCC_VERSION >= 5000000
|
||||
/*********************************************************************
|
||||
*
|
||||
* stdout_putchar
|
||||
*
|
||||
* Function description:
|
||||
* Put a character to the stdout
|
||||
*
|
||||
* Parameters:
|
||||
* ch - Character to output
|
||||
*
|
||||
*
|
||||
*/
|
||||
int stdout_putchar(int ch) {
|
||||
(void)ch;
|
||||
return ch; // Not implemented
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*************************** End of file ****************************/
|
||||
@@ -0,0 +1,247 @@
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* SEGGER strongly recommends to not make any changes *
|
||||
* to or modify the source code of this software in order to stay *
|
||||
* compatible with the RTT protocol and J-Link. *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or *
|
||||
* without modification, are permitted provided that the following *
|
||||
* condition is met: *
|
||||
* *
|
||||
* o Redistributions of source code must retain the above copyright *
|
||||
* notice, this condition and the following disclaimer. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT_Syscalls_SES.c
|
||||
Purpose : Reimplementation of printf, puts and __getchar using RTT
|
||||
in SEGGER Embedded Studio.
|
||||
To use RTT for printf output, include this file in your
|
||||
application.
|
||||
Revision: $Rev: 18539 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#if (defined __SES_ARM) || (defined __SES_RISCV) || (defined __CROSSWORKS_ARM)
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "limits.h"
|
||||
#include "__libc.h"
|
||||
#include "__vfprintf.h"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//
|
||||
// Select string formatting implementation.
|
||||
//
|
||||
// RTT printf formatting
|
||||
// - Configurable stack usage. (SEGGER_RTT_PRINTF_BUFFER_SIZE in SEGGER_RTT_Conf.h)
|
||||
// - No maximum string length.
|
||||
// - Limited conversion specifiers and flags. (See SEGGER_RTT_printf.c)
|
||||
// Standard library printf formatting
|
||||
// - Configurable formatting capabilities.
|
||||
// - Full conversion specifier and flag support.
|
||||
// - Maximum string length has to be known or (slightly) slower character-wise output.
|
||||
//
|
||||
// #define PRINTF_USE_SEGGER_RTT_FORMATTING 0 // Use standard library formatting
|
||||
// #define PRINTF_USE_SEGGER_RTT_FORMATTING 1 // Use RTT formatting
|
||||
//
|
||||
#ifndef PRINTF_USE_SEGGER_RTT_FORMATTING
|
||||
#define PRINTF_USE_SEGGER_RTT_FORMATTING 0
|
||||
#endif
|
||||
//
|
||||
// If using standard library formatting,
|
||||
// select maximum output string buffer size or character-wise output.
|
||||
//
|
||||
// #define PRINTF_BUFFER_SIZE 0 // Use character-wise output
|
||||
// #define PRINTF_BUFFER_SIZE 128 // Default maximum string length
|
||||
//
|
||||
#ifndef PRINTF_BUFFER_SIZE
|
||||
#define PRINTF_BUFFER_SIZE 128
|
||||
#endif
|
||||
|
||||
#if PRINTF_USE_SEGGER_RTT_FORMATTING // Use SEGGER RTT formatting implementation
|
||||
/*********************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions, printf
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* printf()
|
||||
*
|
||||
* Function description
|
||||
* print a formatted string using RTT and SEGGER RTT formatting.
|
||||
*/
|
||||
int printf(const char *fmt,...) {
|
||||
int n;
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
n = SEGGER_RTT_vprintf(0, fmt, &args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
#elif PRINTF_BUFFER_SIZE == 0 // Use standard library formatting with character-wise output
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Static functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
static int _putchar(int x, __printf_tag_ptr ctx) {
|
||||
(void)ctx;
|
||||
SEGGER_RTT_Write(0, (char *)&x, 1);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions, printf
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* printf()
|
||||
*
|
||||
* Function description
|
||||
* print a formatted string character-wise, using RTT and standard
|
||||
* library formatting.
|
||||
*/
|
||||
int printf(const char *fmt, ...) {
|
||||
int n;
|
||||
va_list args;
|
||||
__printf_t iod;
|
||||
|
||||
va_start(args, fmt);
|
||||
iod.string = 0;
|
||||
iod.maxchars = INT_MAX;
|
||||
iod.output_fn = _putchar;
|
||||
SEGGER_RTT_LOCK();
|
||||
n = __vfprintf(&iod, fmt, args);
|
||||
SEGGER_RTT_UNLOCK();
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
#else // Use standard library formatting with static buffer
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions, printf
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* printf()
|
||||
*
|
||||
* Function description
|
||||
* print a formatted string using RTT and standard library formatting.
|
||||
*/
|
||||
int printf(const char *fmt,...) {
|
||||
int n;
|
||||
char aBuffer[PRINTF_BUFFER_SIZE];
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
n = vsnprintf(aBuffer, sizeof(aBuffer), fmt, args);
|
||||
if (n > (int)sizeof(aBuffer)) {
|
||||
SEGGER_RTT_Write(0, aBuffer, sizeof(aBuffer));
|
||||
} else if (n > 0) {
|
||||
SEGGER_RTT_Write(0, aBuffer, n);
|
||||
}
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
/*********************************************************************
|
||||
*
|
||||
* puts()
|
||||
*
|
||||
* Function description
|
||||
* print a string using RTT.
|
||||
*/
|
||||
int puts(const char *s) {
|
||||
return SEGGER_RTT_WriteString(0, s);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* __putchar()
|
||||
*
|
||||
* Function description
|
||||
* Write one character via RTT.
|
||||
*/
|
||||
int __putchar(int x, __printf_tag_ptr ctx) {
|
||||
(void)ctx;
|
||||
SEGGER_RTT_Write(0, (char *)&x, 1);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* __getchar()
|
||||
*
|
||||
* Function description
|
||||
* Wait for and get a character via RTT.
|
||||
*/
|
||||
int __getchar() {
|
||||
return SEGGER_RTT_WaitKey();
|
||||
}
|
||||
|
||||
#endif
|
||||
/****** End Of File *************************************************/
|
||||
+1
-1
Submodule lib/nrfx updated: 096e770ee4...7a4c9d946c.
@@ -119,11 +119,23 @@ __STATIC_INLINE void apply_config(nrf_drv_uart_t const * p_instance, nrf_drv_uar
|
||||
nrf_gpio_cfg_input(p_config->pselrxd, NRF_GPIO_PIN_NOPULL);
|
||||
}
|
||||
|
||||
nrf_uarte_config_t uarte_cfg =
|
||||
{
|
||||
.hwfc = (nrf_uarte_hwfc_t) p_config->hwfc,
|
||||
.parity = (nrf_uarte_parity_t) p_config->parity
|
||||
};
|
||||
|
||||
nrf_uart_config_t uart_cfg =
|
||||
{
|
||||
.hwfc = (nrf_uart_hwfc_t) p_config->hwfc,
|
||||
.parity = (nrf_uart_parity_t) p_config->parity
|
||||
};
|
||||
|
||||
CODE_FOR_UARTE
|
||||
(
|
||||
nrf_uarte_baudrate_set(p_instance->reg.p_uarte, (nrf_uarte_baudrate_t)p_config->baudrate);
|
||||
nrf_uarte_configure(p_instance->reg.p_uarte, (nrf_uarte_parity_t)p_config->parity,
|
||||
(nrf_uarte_hwfc_t)p_config->hwfc);
|
||||
// nrf_uarte_configure(p_instance->reg.p_uarte, (nrf_uarte_parity_t)p_config->parity, (nrf_uarte_hwfc_t)p_config->hwfc);
|
||||
nrf_uarte_configure(p_instance->reg.p_uarte, &uarte_cfg);
|
||||
nrf_uarte_txrx_pins_set(p_instance->reg.p_uarte, p_config->pseltxd, p_config->pselrxd);
|
||||
if (p_config->hwfc == NRF_UART_HWFC_ENABLED)
|
||||
{
|
||||
@@ -142,7 +154,8 @@ __STATIC_INLINE void apply_config(nrf_drv_uart_t const * p_instance, nrf_drv_uar
|
||||
CODE_FOR_UART
|
||||
(
|
||||
nrf_uart_baudrate_set(p_instance->reg.p_uart, p_config->baudrate);
|
||||
nrf_uart_configure(p_instance->reg.p_uart, p_config->parity, p_config->hwfc);
|
||||
// nrf_uart_configure(p_instance->reg.p_uart, p_config->parity, p_config->hwfc);
|
||||
nrf_uart_configure(p_instance->reg.p_uart, &uart_cfg);
|
||||
nrf_uart_txrx_pins_set(p_instance->reg.p_uart, p_config->pseltxd, p_config->pselrxd);
|
||||
if (p_config->hwfc == NRF_UART_HWFC_ENABLED)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
#include "app_uart.h"
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
// nRF has native usb peripheral
|
||||
#ifdef NRF_USBD
|
||||
#include "tusb.h"
|
||||
#endif
|
||||
|
||||
@@ -121,13 +122,17 @@ static uint32_t send_tx_byte_end(void);
|
||||
*/
|
||||
uint32_t (*send_tx_byte) (void) = send_tx_byte_default;
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
static uint32_t serial_put(char ch)
|
||||
{
|
||||
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
|
||||
}
|
||||
#ifdef NRF_USBD
|
||||
|
||||
static uint32_t serial_put(char ch)
|
||||
{
|
||||
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
#else
|
||||
#define serial_put app_uart_put
|
||||
|
||||
#define serial_put app_uart_put
|
||||
|
||||
#endif
|
||||
|
||||
static uint32_t send_tx_byte_end(void)
|
||||
@@ -345,7 +350,7 @@ static bool rx_buffer_overflowed(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
|
||||
static uint32_t slip_uart_open(void)
|
||||
{
|
||||
@@ -441,7 +446,8 @@ uint32_t hci_slip_open()
|
||||
uint32_t hci_slip_close()
|
||||
{
|
||||
m_current_state = SLIP_OFF;
|
||||
#ifdef NRF52840_XXAA
|
||||
|
||||
#ifdef NRF_USBD
|
||||
return NRF_SUCCESS;
|
||||
#else
|
||||
uint32_t err_code = app_uart_close();
|
||||
|
||||
@@ -39,10 +39,8 @@
|
||||
*/
|
||||
#include "app_util_platform.h"
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
/* Global nvic state instance, required by nrf_nvic.h */
|
||||
nrf_nvic_state_t nrf_nvic_state;
|
||||
#endif
|
||||
|
||||
static uint32_t m_in_critical_region = 0;
|
||||
|
||||
|
||||
@@ -52,10 +52,8 @@
|
||||
#include <stdint.h>
|
||||
#include "compiler_abstraction.h"
|
||||
#include "nrf.h"
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_nvic.h"
|
||||
#endif
|
||||
#include "nrf_assert.h"
|
||||
#include "app_error.h"
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
#include <stddef.h>
|
||||
#include "sdk_common.h"
|
||||
|
||||
#define MAX_DFU_PKT_LEN 20 /**< Maximum length (in bytes) of the DFU Packet characteristic. */
|
||||
#define PKT_START_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Start DFU Request. */
|
||||
#define PKT_INIT_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Init DFU Request. */
|
||||
#define PKT_RCPT_NOTIF_REQ_LEN 3 /**< Length (in bytes) of the Packet Receipt Notification Request. */
|
||||
#define MAX_PKTS_RCPT_NOTIF_LEN 6 /**< Maximum length (in bytes) of the Packets Receipt Notification. */
|
||||
#define MAX_RESPONSE_LEN 7 /**< Maximum length (in bytes) of the response to a Control Point command. */
|
||||
#define MAX_NOTIF_BUFFER_LEN MAX(MAX_PKTS_RCPT_NOTIF_LEN, MAX_RESPONSE_LEN) /**< Maximum length (in bytes) of the buffer needed by DFU Service while sending notifications to peer. */
|
||||
#define MAX_DFU_PKT_LEN (BLEGATT_ATT_MTU_MAX - 3) /**< Maximum length (in bytes) of the DFU Packet characteristic. */
|
||||
#define PKT_START_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Start DFU Request. */
|
||||
#define PKT_INIT_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Init DFU Request. */
|
||||
#define PKT_RCPT_NOTIF_REQ_LEN 3 /**< Length (in bytes) of the Packet Receipt Notification Request. */
|
||||
#define MAX_PKTS_RCPT_NOTIF_LEN 6 /**< Maximum length (in bytes) of the Packets Receipt Notification. */
|
||||
#define MAX_RESPONSE_LEN 7 /**< Maximum length (in bytes) of the response to a Control Point command. */
|
||||
#define MAX_NOTIF_BUFFER_LEN MAX(MAX_PKTS_RCPT_NOTIF_LEN, MAX_RESPONSE_LEN) /**< Maximum length (in bytes) of the buffer needed by DFU Service while sending notifications to peer. */
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -57,7 +57,8 @@ static uint32_t dfu_pkt_char_add(ble_dfu_t * const p_dfu)
|
||||
|
||||
memset(&char_md, 0, sizeof(char_md));
|
||||
|
||||
char_md.char_props.write_wo_resp = 1;
|
||||
char_md.char_props.write = 1; // For those improved apps that can take advantage of ACK
|
||||
char_md.char_props.write_wo_resp = 1; // Nordic IOS DFU app REQUIRES Write Without Response */
|
||||
char_md.p_char_user_desc = NULL;
|
||||
char_md.p_char_pf = NULL;
|
||||
char_md.p_user_desc_md = NULL;
|
||||
@@ -463,7 +464,7 @@ uint32_t ble_dfu_init(ble_dfu_t * p_dfu, ble_dfu_init_t * p_dfu_init)
|
||||
|
||||
p_dfu->conn_handle = BLE_CONN_HANDLE_INVALID;
|
||||
|
||||
ble_uuid_t service_uuid;
|
||||
ble_uuid_t service_uuid = {0};
|
||||
uint32_t err_code;
|
||||
|
||||
const ble_uuid128_t base_uuid128 =
|
||||
@@ -555,29 +556,35 @@ uint32_t ble_dfu_bytes_rcvd_report(ble_dfu_t * p_dfu, uint32_t num_of_firmware_b
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
ble_gatts_hvx_params_t hvx_params;
|
||||
uint16_t index = 0;
|
||||
uint32_t err_code;
|
||||
do {
|
||||
|
||||
// Encode the Op Code.
|
||||
m_notif_buffer[index++] = OP_CODE_RESPONSE;
|
||||
ble_gatts_hvx_params_t hvx_params;
|
||||
uint16_t index = 0;
|
||||
|
||||
// Encode the Op Code.
|
||||
m_notif_buffer[index++] = OP_CODE_RESPONSE;
|
||||
|
||||
// Encode the Reqest Op Code.
|
||||
m_notif_buffer[index++] = OP_CODE_IMAGE_SIZE_REQ;
|
||||
|
||||
// Encode the Response Value.
|
||||
m_notif_buffer[index++] = (uint8_t)BLE_DFU_RESP_VAL_SUCCESS;
|
||||
|
||||
index += uint32_encode(num_of_firmware_bytes_rcvd, &m_notif_buffer[index]);
|
||||
|
||||
memset(&hvx_params, 0, sizeof(hvx_params));
|
||||
|
||||
hvx_params.handle = p_dfu->dfu_ctrl_pt_handles.value_handle;
|
||||
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
|
||||
hvx_params.offset = 0;
|
||||
hvx_params.p_len = &index;
|
||||
hvx_params.p_data = m_notif_buffer;
|
||||
|
||||
err_code = sd_ble_gatts_hvx(p_dfu->conn_handle, &hvx_params);
|
||||
} while (err_code == NRF_ERROR_RESOURCES);
|
||||
|
||||
// Encode the Reqest Op Code.
|
||||
m_notif_buffer[index++] = OP_CODE_IMAGE_SIZE_REQ;
|
||||
|
||||
// Encode the Response Value.
|
||||
m_notif_buffer[index++] = (uint8_t)BLE_DFU_RESP_VAL_SUCCESS;
|
||||
|
||||
index += uint32_encode(num_of_firmware_bytes_rcvd, &m_notif_buffer[index]);
|
||||
|
||||
memset(&hvx_params, 0, sizeof(hvx_params));
|
||||
|
||||
hvx_params.handle = p_dfu->dfu_ctrl_pt_handles.value_handle;
|
||||
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
|
||||
hvx_params.offset = 0;
|
||||
hvx_params.p_len = &index;
|
||||
hvx_params.p_data = m_notif_buffer;
|
||||
|
||||
return sd_ble_gatts_hvx(p_dfu->conn_handle, &hvx_params);
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
@@ -593,22 +600,28 @@ uint32_t ble_dfu_pkts_rcpt_notify(ble_dfu_t * p_dfu, uint32_t num_of_firmware_by
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
ble_gatts_hvx_params_t hvx_params;
|
||||
uint16_t index = 0;
|
||||
uint32_t err_code;
|
||||
do {
|
||||
|
||||
m_notif_buffer[index++] = OP_CODE_PKT_RCPT_NOTIF;
|
||||
ble_gatts_hvx_params_t hvx_params;
|
||||
uint16_t index = 0;
|
||||
|
||||
m_notif_buffer[index++] = OP_CODE_PKT_RCPT_NOTIF;
|
||||
|
||||
index += uint32_encode(num_of_firmware_bytes_rcvd, &m_notif_buffer[index]);
|
||||
|
||||
memset(&hvx_params, 0, sizeof(hvx_params));
|
||||
|
||||
hvx_params.handle = p_dfu->dfu_ctrl_pt_handles.value_handle;
|
||||
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
|
||||
hvx_params.offset = 0;
|
||||
hvx_params.p_len = &index;
|
||||
hvx_params.p_data = m_notif_buffer;
|
||||
|
||||
index += uint32_encode(num_of_firmware_bytes_rcvd, &m_notif_buffer[index]);
|
||||
err_code = sd_ble_gatts_hvx(p_dfu->conn_handle, &hvx_params);
|
||||
} while (err_code == NRF_ERROR_RESOURCES);
|
||||
|
||||
memset(&hvx_params, 0, sizeof(hvx_params));
|
||||
|
||||
hvx_params.handle = p_dfu->dfu_ctrl_pt_handles.value_handle;
|
||||
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
|
||||
hvx_params.offset = 0;
|
||||
hvx_params.p_len = &index;
|
||||
hvx_params.p_data = m_notif_buffer;
|
||||
|
||||
return sd_ble_gatts_hvx(p_dfu->conn_handle, &hvx_params);
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
@@ -626,24 +639,30 @@ uint32_t ble_dfu_response_send(ble_dfu_t * p_dfu,
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
ble_gatts_hvx_params_t hvx_params;
|
||||
uint16_t index = 0;
|
||||
uint32_t err_code;
|
||||
do {
|
||||
|
||||
m_notif_buffer[index++] = OP_CODE_RESPONSE;
|
||||
ble_gatts_hvx_params_t hvx_params;
|
||||
uint16_t index = 0;
|
||||
|
||||
m_notif_buffer[index++] = OP_CODE_RESPONSE;
|
||||
|
||||
// Encode the Request Op code
|
||||
m_notif_buffer[index++] = (uint8_t)dfu_proc;
|
||||
|
||||
// Encode the Response Value.
|
||||
m_notif_buffer[index++] = (uint8_t)resp_val;
|
||||
|
||||
memset(&hvx_params, 0, sizeof(hvx_params));
|
||||
|
||||
hvx_params.handle = p_dfu->dfu_ctrl_pt_handles.value_handle;
|
||||
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
|
||||
hvx_params.offset = 0;
|
||||
hvx_params.p_len = &index;
|
||||
hvx_params.p_data = m_notif_buffer;
|
||||
|
||||
err_code = sd_ble_gatts_hvx(p_dfu->conn_handle, &hvx_params);
|
||||
} while (err_code == NRF_ERROR_RESOURCES);
|
||||
|
||||
// Encode the Request Op code
|
||||
m_notif_buffer[index++] = (uint8_t)dfu_proc;
|
||||
|
||||
// Encode the Response Value.
|
||||
m_notif_buffer[index++] = (uint8_t)resp_val;
|
||||
|
||||
memset(&hvx_params, 0, sizeof(hvx_params));
|
||||
|
||||
hvx_params.handle = p_dfu->dfu_ctrl_pt_handles.value_handle;
|
||||
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
|
||||
hvx_params.offset = 0;
|
||||
hvx_params.p_len = &index;
|
||||
hvx_params.p_data = m_notif_buffer;
|
||||
|
||||
return sd_ble_gatts_hvx(p_dfu->conn_handle, &hvx_params);
|
||||
return err_code;
|
||||
}
|
||||
@@ -32,15 +32,18 @@
|
||||
static uint16_t service_handle;
|
||||
static ble_gatts_char_handles_t manufact_name_handles;
|
||||
static ble_gatts_char_handles_t model_num_handles;
|
||||
static ble_gatts_char_handles_t fw_rev_handles;
|
||||
static ble_gatts_char_handles_t pnp_id_handles;
|
||||
|
||||
#if 0
|
||||
static ble_gatts_char_handles_t serial_num_handles;
|
||||
static ble_gatts_char_handles_t hw_rev_handles;
|
||||
static ble_gatts_char_handles_t fw_rev_handles;
|
||||
static ble_gatts_char_handles_t sw_rev_handles;
|
||||
static ble_gatts_char_handles_t sys_id_handles;
|
||||
static ble_gatts_char_handles_t reg_cert_data_list_handles;
|
||||
static ble_gatts_char_handles_t pnp_id_handles;
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/**@brief Function for encoding a System ID.
|
||||
*
|
||||
* @param[out] p_encoded_buffer Buffer where the encoded data will be written.
|
||||
@@ -61,6 +64,7 @@ static void sys_id_encode(uint8_t * p_encoded_buffer, const ble_dis_sys_id_t * p
|
||||
p_encoded_buffer[6] = (p_sys_id->organizationally_unique_id & 0x00FF00) >> 8;
|
||||
p_encoded_buffer[7] = (p_sys_id->organizationally_unique_id & 0xFF0000) >> 16;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**@brief Function for encoding a PnP ID.
|
||||
@@ -182,6 +186,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (p_dis_init->serial_num_str.length > 0)
|
||||
{
|
||||
err_code = char_add(BLE_UUID_SERIAL_NUMBER_STRING_CHAR,
|
||||
@@ -206,6 +212,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_dis_init->fw_rev_str.length > 0)
|
||||
{
|
||||
err_code = char_add(BLE_UUID_FIRMWARE_REVISION_STRING_CHAR,
|
||||
@@ -218,6 +226,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (p_dis_init->sw_rev_str.length > 0)
|
||||
{
|
||||
err_code = char_add(BLE_UUID_SOFTWARE_REVISION_STRING_CHAR,
|
||||
@@ -230,6 +240,7 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_dis_init->p_sys_id != NULL)
|
||||
{
|
||||
uint8_t encoded_sys_id[BLE_DIS_SYS_ID_LEN];
|
||||
@@ -257,6 +268,8 @@ uint32_t ble_dis_init(const ble_dis_init_t * p_dis_init)
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_dis_init->p_pnp_id != NULL)
|
||||
{
|
||||
uint8_t encoded_pnp_id[BLE_DIS_PNP_ID_LEN];
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
#define INVALID_OPCODE 0x00 /**< Invalid op code identifier. */
|
||||
|
||||
#ifdef NRF51
|
||||
#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF51. */
|
||||
#elif defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF52. */
|
||||
#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF51. */
|
||||
#elif defined(NRF52_SERIES)
|
||||
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF52. */
|
||||
#else
|
||||
#error No target defined
|
||||
#error No target defined
|
||||
#endif
|
||||
|
||||
|
||||
@@ -280,6 +280,10 @@ static void app_notify(uint32_t result, cmd_queue_element_t * p_elem)
|
||||
*/
|
||||
void pstorage_sys_event_handler(uint32_t sys_evt)
|
||||
{
|
||||
// Do not bother processing events we are not interested in
|
||||
if (sys_evt != NRF_EVT_FLASH_OPERATION_SUCCESS &&
|
||||
sys_evt != NRF_EVT_FLASH_OPERATION_ERROR) return;
|
||||
|
||||
uint32_t retval = NRF_SUCCESS;
|
||||
|
||||
// The event shall only be processed if requested by this module.
|
||||
@@ -339,6 +343,7 @@ void pstorage_sys_event_handler(uint32_t sys_evt)
|
||||
* @brief Function for processing of commands and issuing flash access request to the SoftDevice.
|
||||
*
|
||||
* @return The return value received from SoftDevice.
|
||||
* @remark This function is only called when m_cmd_queue.flash_access == false
|
||||
*/
|
||||
static uint32_t cmd_process(void)
|
||||
{
|
||||
@@ -352,6 +357,9 @@ static uint32_t cmd_process(void)
|
||||
|
||||
storage_addr = p_cmd->storage_addr.block_id;
|
||||
|
||||
// Let's assume we will do a flash access
|
||||
m_cmd_queue.flash_access = true;
|
||||
|
||||
switch (p_cmd->op_code)
|
||||
{
|
||||
case PSTORAGE_STORE_OP_CODE:
|
||||
@@ -396,9 +404,10 @@ static uint32_t cmd_process(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (retval == NRF_SUCCESS)
|
||||
// An error means we will not do it
|
||||
if (retval != NRF_SUCCESS)
|
||||
{
|
||||
m_cmd_queue.flash_access = true;
|
||||
m_cmd_queue.flash_access = false;
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
@@ -32,21 +32,10 @@
|
||||
|
||||
#include "boards.h"
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
#include "tusb.h"
|
||||
#endif
|
||||
|
||||
#define APP_TIMER_PRESCALER 0
|
||||
|
||||
#define IRQ_ENABLED 0x01 /**< Field identifying if an interrupt is enabled. */
|
||||
|
||||
/**< Maximum number of interrupts available. */
|
||||
#if defined(NRF52832_XXAA)
|
||||
#define MAX_NUMBER_INTERRUPTS 39
|
||||
#elif defined(NRF52840_XXAA)
|
||||
#define MAX_NUMBER_INTERRUPTS 48
|
||||
#endif
|
||||
|
||||
/**@brief Enumeration for specifying current bootloader status.
|
||||
*/
|
||||
typedef enum
|
||||
@@ -55,11 +44,13 @@ typedef enum
|
||||
BOOTLOADER_SETTINGS_SAVING, /**< Bootloader status for indicating that saving of bootloader settings is in progress. */
|
||||
BOOTLOADER_COMPLETE, /**< Bootloader status for indicating that all operations for the update procedure has completed and it is safe to reset the system. */
|
||||
BOOTLOADER_TIMEOUT, /**< Bootloader status field for indicating that a timeout has occured and current update process should be aborted. */
|
||||
BOOTLOADER_RESET, /**< Bootloader status field for indicating that a reset has been requested and current update process should be aborted. */
|
||||
BOOTLOADER_SYS_RESET, /**< Bootloader status field for indicating that a reset has been requested and current update process should be aborted. */
|
||||
BOOTLOADER_RESET_TO_SELF, /**< Bootloader status field for indicating that a reset has been requested and current update process should be aborted and the bootloader must be reentered. */
|
||||
} bootloader_status_t;
|
||||
|
||||
static pstorage_handle_t m_bootsettings_handle; /**< Pstorage handle to use for registration and identifying the bootloader module on subsequent calls to the pstorage module for load and store of bootloader setting in flash. */
|
||||
static bootloader_status_t m_update_status; /**< Current update status for the bootloader module to ensure correct behaviour when updating settings and when update completes. */
|
||||
static bool m_cancel_timeout_on_usb; /**< If set the timeout is cancelled when USB is enumerated. Otherwise, the timeout is only cancelled when DFU update is started. */
|
||||
|
||||
APP_TIMER_DEF( _dfu_startup_timer );
|
||||
volatile bool dfu_startup_packet_received = false;
|
||||
@@ -90,7 +81,15 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
|
||||
*/
|
||||
static void dfu_startup_timer_handler(void * p_context)
|
||||
{
|
||||
// No packets are received within timeout, terminal and DFU mode
|
||||
#ifdef NRF_USBD
|
||||
if (m_cancel_timeout_on_usb && tud_mounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// nRF52832 forced DFU on startup
|
||||
// No packets are received within timeout, exit DFU mode
|
||||
// dfu_startup_packet_received is set by process_dfu_packet() in dfu_transport_serial.c
|
||||
if (!dfu_startup_packet_received)
|
||||
{
|
||||
@@ -118,67 +117,70 @@ static void wait_for_events(void)
|
||||
// APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Feed all Watchdog just in case application enable it
|
||||
// WDT cannot be disabled once started. It even last through soft reset (NVIC Reset)
|
||||
if ( nrf_wdt_started() )
|
||||
// WDT cannot be disabled once started. It even last through NVIC soft reset
|
||||
if ( nrf_wdt_started(NRF_WDT) )
|
||||
{
|
||||
for (uint8_t i=0; i<8; i++) nrf_wdt_reload_request_set(i);
|
||||
for (uint8_t i=0; i<8; i++) nrf_wdt_reload_request_set(NRF_WDT, i);
|
||||
}
|
||||
|
||||
// Event received. Process it from the scheduler.
|
||||
app_sched_execute();
|
||||
|
||||
#ifdef NRF52840_XXAA
|
||||
#ifdef NRF_USBD
|
||||
// skip if usb is not inited ( e.g OTA / finializing sd/bootloader )
|
||||
extern bool usb_inited(void);
|
||||
if ( usb_inited() )
|
||||
if ( tusb_inited() )
|
||||
{
|
||||
tusb_task();
|
||||
tud_task();
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((m_update_status == BOOTLOADER_COMPLETE) ||
|
||||
(m_update_status == BOOTLOADER_TIMEOUT) ||
|
||||
(m_update_status == BOOTLOADER_RESET) )
|
||||
(m_update_status == BOOTLOADER_SYS_RESET) ||
|
||||
(m_update_status == BOOTLOADER_RESET_TO_SELF))
|
||||
{
|
||||
// When update has completed or a timeout/reset occured we will return.
|
||||
// When update has completed or a timeout/reset occurred we will return.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool bootloader_app_is_valid(uint32_t app_addr)
|
||||
bool bootloader_app_is_valid(void)
|
||||
{
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
bool success = false;
|
||||
uint32_t const app_addr = DFU_BANK_0_REGION_START;
|
||||
|
||||
// There exists an application in CODE region 1.
|
||||
if (*((uint32_t *)app_addr) == EMPTY_FLASH_MASK)
|
||||
bootloader_settings_t const *p_bootloader_settings;
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
enum { EMPTY_FLASH = 0xFFFFFFFFUL };
|
||||
|
||||
// Application is invalid if first 2 words are all 0xFFFFFFF
|
||||
if ( *((uint32_t *)app_addr ) == EMPTY_FLASH &&
|
||||
*((uint32_t *)(app_addr+4)) == EMPTY_FLASH )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// The application in CODE region 1 is flagged as valid during update.
|
||||
if ( p_bootloader_settings->bank_0 == BANK_VALID_APP )
|
||||
{
|
||||
uint16_t image_crc = 0;
|
||||
|
||||
// A stored crc value of 0 indicates that CRC checking is not used.
|
||||
if ( p_bootloader_settings->bank_0_crc != 0 )
|
||||
{
|
||||
return false;
|
||||
image_crc = crc16_compute((uint8_t*) app_addr,
|
||||
p_bootloader_settings->bank_0_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
success = (image_crc == p_bootloader_settings->bank_0_crc);
|
||||
}
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
// The application in CODE region 1 is flagged as valid during update.
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_APP)
|
||||
{
|
||||
uint16_t image_crc = 0;
|
||||
|
||||
// A stored crc value of 0 indicates that CRC checking is not used.
|
||||
if (p_bootloader_settings->bank_0_crc != 0)
|
||||
{
|
||||
image_crc = crc16_compute((uint8_t *)DFU_BANK_0_REGION_START,
|
||||
p_bootloader_settings->bank_0_size,
|
||||
NULL);
|
||||
}
|
||||
|
||||
success = (image_crc == p_bootloader_settings->bank_0_crc);
|
||||
}
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,16 +188,42 @@ static void bootloader_settings_save(bootloader_settings_t * p_settings)
|
||||
{
|
||||
if ( is_ota() )
|
||||
{
|
||||
uint32_t err_code = pstorage_clear(&m_bootsettings_handle, sizeof(bootloader_settings_t));
|
||||
uint32_t err_code;
|
||||
while(1) {
|
||||
err_code = pstorage_clear(&m_bootsettings_handle, sizeof(bootloader_settings_t));
|
||||
if (err_code != NRF_ERROR_NO_MEM) {
|
||||
break;
|
||||
}
|
||||
// This means the write/erase queue of commands was completely full - Should not
|
||||
// happen, but better safe than sorry, wait until space becomes available -
|
||||
// the pstorage event handler is only run from the main loop, and we are also
|
||||
// running from a BLE event on the main loop: This means if we wait here, the FLASH
|
||||
// completion events will never be handled (will be queued by app_scheduler, but
|
||||
// not handled, and that means this wait will never end... So, process SOC events
|
||||
// from the SD (but NOT BLE events!) - This will free entries on the pstorage queue
|
||||
// as soon as operations are complete, allowing this op to be queued
|
||||
while (NRF_ERROR_NOT_FOUND != proc_soc()) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = pstorage_store(&m_bootsettings_handle, (uint8_t *) p_settings, sizeof(bootloader_settings_t), 0);
|
||||
while(1) {
|
||||
err_code = pstorage_store(&m_bootsettings_handle, (uint8_t *) p_settings, sizeof(bootloader_settings_t), 0);
|
||||
if (err_code != NRF_ERROR_NO_MEM) {
|
||||
break;
|
||||
}
|
||||
// No space, wait until an entry in the queue is freed
|
||||
while (NRF_ERROR_NOT_FOUND != proc_soc()) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_nvmc_page_erase(BOOTLOADER_SETTINGS_ADDRESS);
|
||||
nrf_nvmc_write_words(BOOTLOADER_SETTINGS_ADDRESS, (uint32_t *) p_settings, sizeof(bootloader_settings_t) / 4);
|
||||
nrfx_nvmc_page_erase(BOOTLOADER_SETTINGS_ADDRESS);
|
||||
nrfx_nvmc_words_write(BOOTLOADER_SETTINGS_ADDRESS, (uint32_t *) p_settings, sizeof(bootloader_settings_t) / 4);
|
||||
|
||||
pstorage_callback_handler(&m_bootsettings_handle, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_settings, sizeof(bootloader_settings_t));
|
||||
}
|
||||
@@ -207,194 +235,203 @@ void bootloader_dfu_update_process(dfu_update_status_t update_status)
|
||||
__attribute__((aligned(4))) static bootloader_settings_t settings;
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
|
||||
if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_APP;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_COMPLETE)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.sd_size + update_status.bl_size + update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_SD;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
settings.sd_image_start = update_status.sd_image_start;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_BOOT_COMPLETE)
|
||||
{
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
settings.bank_1 = BANK_VALID_BOOT;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_SWAPPED)
|
||||
{
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_APP;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_COMPLETE)
|
||||
{
|
||||
settings.bank_0_crc = update_status.app_crc;
|
||||
settings.bank_0_size = update_status.sd_size +
|
||||
update_status.bl_size +
|
||||
update_status.app_size;
|
||||
settings.bank_0 = BANK_VALID_SD;
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
settings.sd_image_start = update_status.sd_image_start;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_BOOT_COMPLETE)
|
||||
{
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
settings.bank_1 = BANK_VALID_BOOT;
|
||||
settings.sd_image_size = update_status.sd_size;
|
||||
settings.bl_image_size = update_status.bl_size;
|
||||
settings.app_image_size = update_status.app_size;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_UPDATE_SD_SWAPPED)
|
||||
{
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD)
|
||||
{
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
}
|
||||
// This handles cases where SoftDevice was not updated, hence bank0 keeps its settings.
|
||||
else
|
||||
{
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
}
|
||||
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = 0;
|
||||
settings.bl_image_size = 0;
|
||||
settings.app_image_size = 0;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_TIMEOUT)
|
||||
{
|
||||
// Timeout has occurred. Close the connection with the DFU Controller.
|
||||
uint32_t err_code;
|
||||
if ( is_ota() )
|
||||
{
|
||||
err_code = dfu_transport_ble_close();
|
||||
}else
|
||||
{
|
||||
err_code = dfu_transport_serial_close();
|
||||
}
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
m_update_status = BOOTLOADER_TIMEOUT;
|
||||
}
|
||||
else if (update_status.status_code == DFU_BANK_0_ERASED)
|
||||
{
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
settings.bank_1 = p_bootloader_settings->bank_1;
|
||||
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_RESET)
|
||||
{
|
||||
m_update_status = BOOTLOADER_RESET;
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
}
|
||||
// This handles cases where SoftDevice was not updated, hence bank0 keeps its settings.
|
||||
else
|
||||
{
|
||||
// No implementation needed.
|
||||
settings.bank_0 = p_bootloader_settings->bank_0;
|
||||
settings.bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
settings.bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
}
|
||||
|
||||
settings.bank_1 = BANK_INVALID_APP;
|
||||
settings.sd_image_size = 0;
|
||||
settings.bl_image_size = 0;
|
||||
settings.app_image_size = 0;
|
||||
|
||||
m_update_status = BOOTLOADER_SETTINGS_SAVING;
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_TIMEOUT)
|
||||
{
|
||||
// Timeout has occurred. Close the connection with the DFU Controller.
|
||||
uint32_t err_code;
|
||||
if ( is_ota() )
|
||||
{
|
||||
err_code = dfu_transport_ble_close();
|
||||
}else
|
||||
{
|
||||
err_code = dfu_transport_serial_close();
|
||||
}
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
m_update_status = BOOTLOADER_TIMEOUT;
|
||||
}
|
||||
else if (update_status.status_code == DFU_BANK_0_ERASED)
|
||||
{
|
||||
settings.bank_0_crc = 0;
|
||||
settings.bank_0_size = 0;
|
||||
settings.bank_0 = BANK_INVALID_APP;
|
||||
settings.bank_1 = p_bootloader_settings->bank_1;
|
||||
|
||||
bootloader_settings_save(&settings);
|
||||
}
|
||||
else if (update_status.status_code == DFU_RESET)
|
||||
{
|
||||
m_update_status =
|
||||
(update_status.restart_into_bootloader == false ? BOOTLOADER_SYS_RESET : BOOTLOADER_RESET_TO_SELF);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No implementation needed.
|
||||
}
|
||||
}
|
||||
|
||||
bool bootloader_must_reset_to_self(void)
|
||||
{
|
||||
return m_update_status == BOOTLOADER_RESET_TO_SELF;
|
||||
}
|
||||
|
||||
uint32_t bootloader_init(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
pstorage_module_param_t storage_params = {.cb = pstorage_callback_handler};
|
||||
uint32_t err_code;
|
||||
pstorage_module_param_t storage_params = {.cb = pstorage_callback_handler};
|
||||
|
||||
err_code = pstorage_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
err_code = pstorage_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
m_bootsettings_handle.block_id = BOOTLOADER_SETTINGS_ADDRESS;
|
||||
err_code = pstorage_register(&storage_params, &m_bootsettings_handle);
|
||||
m_bootsettings_handle.block_id = BOOTLOADER_SETTINGS_ADDRESS;
|
||||
err_code = pstorage_register(&storage_params, &m_bootsettings_handle);
|
||||
|
||||
return err_code;
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms)
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout_on_usb)
|
||||
{
|
||||
uint32_t err_code;
|
||||
uint32_t err_code;
|
||||
|
||||
// Clear swap if banked update is used.
|
||||
err_code = dfu_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
m_cancel_timeout_on_usb = cancel_timeout_on_usb && !ota;
|
||||
|
||||
if ( ota )
|
||||
// Clear swap if banked update is used.
|
||||
err_code = dfu_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
if ( ota )
|
||||
{
|
||||
err_code = dfu_transport_ble_update_start();
|
||||
}else
|
||||
{
|
||||
// DFU mode with timeout can be
|
||||
// - Forced startup DFU for nRF52832 or
|
||||
// - Makecode single tap reset but no enumerated (battery power)
|
||||
if ( timeout_ms )
|
||||
{
|
||||
err_code = dfu_transport_ble_update_start();
|
||||
}else
|
||||
{
|
||||
// timeout_ms > 0 is forced startup DFU
|
||||
if ( timeout_ms )
|
||||
{
|
||||
dfu_startup_packet_received = false;
|
||||
dfu_startup_packet_received = false;
|
||||
|
||||
app_timer_create(&_dfu_startup_timer, APP_TIMER_MODE_SINGLE_SHOT, dfu_startup_timer_handler);
|
||||
app_timer_start(_dfu_startup_timer, APP_TIMER_TICKS(timeout_ms), NULL);
|
||||
}
|
||||
|
||||
err_code = dfu_transport_serial_update_start();
|
||||
app_timer_create(&_dfu_startup_timer, APP_TIMER_MODE_SINGLE_SHOT, dfu_startup_timer_handler);
|
||||
app_timer_start(_dfu_startup_timer, APP_TIMER_TICKS(timeout_ms), NULL);
|
||||
}
|
||||
|
||||
wait_for_events();
|
||||
err_code = dfu_transport_serial_update_start();
|
||||
}
|
||||
|
||||
return err_code;
|
||||
wait_for_events();
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for disabling all interrupts before jumping from bootloader to application.
|
||||
*/
|
||||
static void interrupts_disable(void)
|
||||
void bootloader_app_start(void)
|
||||
{
|
||||
uint32_t interrupt_setting_mask;
|
||||
uint32_t irq = 0; // We start from first interrupt, i.e. interrupt 0.
|
||||
|
||||
// Fetch the current interrupt settings.
|
||||
interrupt_setting_mask = NVIC->ISER[0];
|
||||
|
||||
for (; irq < MAX_NUMBER_INTERRUPTS; irq++)
|
||||
{
|
||||
if (interrupt_setting_mask & (IRQ_ENABLED << irq))
|
||||
{
|
||||
// The interrupt was enabled, and hence disable it.
|
||||
NVIC_DisableIRQ((IRQn_Type)irq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bootloader_app_start(uint32_t app_addr)
|
||||
{
|
||||
// If the applications CRC has been checked and passed, the magic number will be written and we
|
||||
// can start the application safely.
|
||||
APP_ERROR_CHECK ( sd_softdevice_disable() );
|
||||
|
||||
interrupts_disable();
|
||||
|
||||
#if 0 // may need set forward irq
|
||||
sd_mbr_command_t command =
|
||||
{
|
||||
.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
|
||||
.params.irq_forward_address_set.address = MBR_SIZE,
|
||||
};
|
||||
|
||||
sd_mbr_command(&command);
|
||||
// Disable all interrupts
|
||||
NVIC->ICER[0]=0xFFFFFFFF;
|
||||
NVIC->ICPR[0]=0xFFFFFFFF;
|
||||
#if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
|
||||
NVIC->ICER[1]=0xFFFFFFFF;
|
||||
NVIC->ICPR[1]=0xFFFFFFFF;
|
||||
#endif
|
||||
|
||||
APP_ERROR_CHECK( sd_softdevice_vector_table_base_set(CODE_REGION_1_START) );
|
||||
uint32_t fwd_ret;
|
||||
uint32_t app_addr;
|
||||
|
||||
bootloader_util_app_start(CODE_REGION_1_START);
|
||||
if ( is_sd_existed() )
|
||||
{
|
||||
PRINTF("SoftDevice exist\r\n");
|
||||
// App starts after SoftDevice
|
||||
app_addr = SD_SIZE_GET(MBR_SIZE);
|
||||
fwd_ret = sd_softdevice_vector_table_base_set(app_addr);
|
||||
}else
|
||||
{
|
||||
PRINTF("SoftDevice not exist\r\n");
|
||||
|
||||
// App starts right after MBR
|
||||
app_addr = MBR_SIZE;
|
||||
sd_mbr_command_t command =
|
||||
{
|
||||
.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
|
||||
.params.irq_forward_address_set.address = app_addr,
|
||||
};
|
||||
|
||||
fwd_ret = sd_mbr_command(&command);
|
||||
}
|
||||
|
||||
// unlikely failed to forward vector table, manually set forward address
|
||||
if ( fwd_ret != NRF_SUCCESS )
|
||||
{
|
||||
PRINT_HEX(fwd_ret);
|
||||
|
||||
// MBR use first 4-bytes of SRAM to store foward address
|
||||
*(uint32_t *)(0x20000000) = app_addr;
|
||||
}
|
||||
|
||||
// jump to app
|
||||
bootloader_util_app_start(app_addr);
|
||||
}
|
||||
|
||||
|
||||
@@ -402,54 +439,55 @@ bool bootloader_dfu_sd_in_progress(void)
|
||||
{
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD ||
|
||||
p_bootloader_settings->bank_1 == BANK_VALID_BOOT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (p_bootloader_settings->bank_0 == BANK_VALID_SD ||
|
||||
p_bootloader_settings->bank_1 == BANK_VALID_BOOT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_sd_update_continue(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
uint32_t err_code;
|
||||
|
||||
if ((dfu_sd_image_validate() == NRF_SUCCESS) &&
|
||||
(dfu_bl_image_validate() == NRF_SUCCESS))
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
if ((dfu_sd_image_validate() == NRF_SUCCESS) &&
|
||||
(dfu_bl_image_validate() == NRF_SUCCESS))
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
// Ensure that flash operations are not executed within the first 100 ms seconds to allow
|
||||
// a debugger to be attached.
|
||||
NRFX_DELAY_MS(100);
|
||||
// Ensure that flash operations are not executed within the first 100 ms seconds to allow
|
||||
// a debugger to be attached.
|
||||
NRFX_DELAY_MS(100);
|
||||
|
||||
err_code = dfu_sd_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
err_code = dfu_sd_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = dfu_sd_image_validate();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
err_code = dfu_sd_image_validate();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
err_code = dfu_bl_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
err_code = dfu_bl_image_swap();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
return err_code;
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_sd_update_finalize(void)
|
||||
{
|
||||
dfu_update_status_t update_status = {DFU_UPDATE_SD_SWAPPED, };
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
update_status.status_code = DFU_UPDATE_SD_SWAPPED;
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
bootloader_dfu_update_process(update_status);
|
||||
|
||||
wait_for_events();
|
||||
wait_for_events();
|
||||
|
||||
return NRF_SUCCESS;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -457,14 +495,14 @@ void bootloader_settings_get(bootloader_settings_t * const p_settings)
|
||||
{
|
||||
bootloader_settings_t const * p_bootloader_settings;
|
||||
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
bootloader_util_settings_get(&p_bootloader_settings);
|
||||
|
||||
p_settings->bank_0 = p_bootloader_settings->bank_0;
|
||||
p_settings->bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
p_settings->bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
p_settings->bank_1 = p_bootloader_settings->bank_1;
|
||||
p_settings->sd_image_size = p_bootloader_settings->sd_image_size;
|
||||
p_settings->bl_image_size = p_bootloader_settings->bl_image_size;
|
||||
p_settings->app_image_size = p_bootloader_settings->app_image_size;
|
||||
p_settings->sd_image_start = p_bootloader_settings->sd_image_start;
|
||||
p_settings->bank_0 = p_bootloader_settings->bank_0;
|
||||
p_settings->bank_0_crc = p_bootloader_settings->bank_0_crc;
|
||||
p_settings->bank_0_size = p_bootloader_settings->bank_0_size;
|
||||
p_settings->bank_1 = p_bootloader_settings->bank_1;
|
||||
p_settings->sd_image_size = p_bootloader_settings->sd_image_size;
|
||||
p_settings->bl_image_size = p_bootloader_settings->bl_image_size;
|
||||
p_settings->app_image_size = p_bootloader_settings->app_image_size;
|
||||
p_settings->sd_image_start = p_bootloader_settings->sd_image_start;
|
||||
}
|
||||
@@ -32,20 +32,24 @@
|
||||
*/
|
||||
uint32_t bootloader_init(void);
|
||||
|
||||
/**@brief Function to check if bootloader must be reentered after a reset
|
||||
* @details: This function can only be called after bootloader_dfu_start returns
|
||||
* @retval true If device must reboot to the bootloader
|
||||
* @retval false If device must reboot to the application, if possible
|
||||
*/
|
||||
bool bootloader_must_reset_to_self(void);
|
||||
|
||||
/**@brief Function for validating application region in flash.
|
||||
*
|
||||
* @param[in] app_addr Address to the region in flash where the application is stored.
|
||||
*
|
||||
* @retval true If Application region is valid.
|
||||
* @retval false If Application region is not valid.
|
||||
*/
|
||||
bool bootloader_app_is_valid(uint32_t app_addr);
|
||||
bool bootloader_app_is_valid(void);
|
||||
|
||||
/**@brief Function for starting the Device Firmware Update.
|
||||
*
|
||||
* @retval NRF_SUCCESS If new application image was successfully transferred.
|
||||
*/
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms);
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout_on_usb);
|
||||
|
||||
/**@brief Function for exiting bootloader and booting into application.
|
||||
*
|
||||
@@ -55,7 +59,7 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms);
|
||||
*
|
||||
* @param[in] app_addr Address to the region where the application is stored.
|
||||
*/
|
||||
void bootloader_app_start(uint32_t app_addr);
|
||||
void bootloader_app_start(void);
|
||||
|
||||
/**@brief Function for retrieving the bootloader settings.
|
||||
*
|
||||
@@ -92,6 +96,11 @@ uint32_t bootloader_dfu_sd_update_continue(void);
|
||||
*/
|
||||
uint32_t bootloader_dfu_sd_update_finalize(void);
|
||||
|
||||
|
||||
void bootloader_mbr_addrs_populate(void);
|
||||
|
||||
extern uint32_t proc_soc(void);
|
||||
|
||||
#endif // BOOTLOADER_H__
|
||||
|
||||
/**@} */
|
||||
@@ -13,45 +13,23 @@
|
||||
#include "bootloader_settings.h"
|
||||
#include <stdint.h>
|
||||
#include <dfu_types.h>
|
||||
#include "nrfx_nvmc.h"
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
/**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__attribute__ ((section(".bootloaderSettings")))
|
||||
uint8_t m_boot_settings[CODE_PAGE_SIZE];
|
||||
|
||||
uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS))) __attribute__((used)); /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START; /**< This variable makes the linker script write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
/**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
__attribute__ ((section(".uicrBootStartAddress")))
|
||||
volatile uint32_t m_uicr_bootloader_start_address = BOOTLOADER_REGION_START;
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
|
||||
uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__ ((section(".bootloaderSettings"))); /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
volatile uint32_t m_uicr_bootloader_start_address __attribute__ ((section(".uicrBootStartAddress"))) = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
|
||||
__no_init uint8_t m_boot_settings[CODE_PAGE_SIZE] @ BOOTLOADER_SETTINGS_ADDRESS; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__root const uint32_t m_uicr_bootloader_start_address @ NRF_UICR_BOOT_START_ADDRESS = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
#if defined ( __CC_ARM )
|
||||
|
||||
uint8_t m_mbr_params_page[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS))) __attribute__((used)); /**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
uint32_t m_uicr_mbr_params_page_address __attribute__((at(NRF_UICR_MBR_PARAMS_PAGE_ADDRESS)))
|
||||
= BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
|
||||
|
||||
#elif defined (__GNUC__ )
|
||||
|
||||
uint8_t m_mbr_params_page[CODE_PAGE_SIZE] __attribute__ ((section(".mbrParamsPage"))); /**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
volatile uint32_t m_uicr_mbr_params_page_address __attribute__ ((section(".uicrMbrParamsPageAddress")))
|
||||
= BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
|
||||
|
||||
#elif defined (__ICCARM__ )
|
||||
|
||||
__no_init uint8_t m_mbr_params_page[CODE_PAGE_SIZE] @ BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__root const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
|
||||
|
||||
#endif
|
||||
#endif // defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
/**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
|
||||
__attribute__ ((section(".mbrParamsPage")))
|
||||
uint8_t m_mbr_params_page[CODE_PAGE_SIZE];
|
||||
|
||||
/**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
|
||||
__attribute__ ((section(".uicrMbrParamsPageAddress")))
|
||||
volatile uint32_t m_uicr_mbr_params_page_address = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS;
|
||||
|
||||
void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings)
|
||||
{
|
||||
@@ -61,3 +39,23 @@ void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_s
|
||||
|
||||
*pp_bootloader_settings = p_bootloader_settings;
|
||||
}
|
||||
|
||||
void bootloader_mbr_addrs_populate(void)
|
||||
{
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 12)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
if (*(const uint32_t *)MBR_BOOTLOADER_ADDR == 0xFFFFFFFF)
|
||||
{
|
||||
nrfx_nvmc_word_write(MBR_BOOTLOADER_ADDR, BOOTLOADER_REGION_START);
|
||||
}
|
||||
|
||||
if (*(const uint32_t *)MBR_PARAM_PAGE_ADDR == 0xFFFFFFFF)
|
||||
{
|
||||
nrfx_nvmc_word_write(MBR_PARAM_PAGE_ADDR, BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS);
|
||||
}
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 12)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
@@ -32,6 +32,12 @@
|
||||
#if defined ( __CC_ARM )
|
||||
__asm static void bootloader_util_reset(uint32_t start_addr)
|
||||
{
|
||||
MOVS R5, #0x00 ; R5 = 0
|
||||
MSR CONTROL, R5 ; Clear CONTROL
|
||||
MSR PRIMASK, R5 ; Clear PRIMASK
|
||||
MSR BASEPRI, R5 ; Clear BASEPRI
|
||||
MSR FAULTMASK, R5 ; Clear FAULTMASK
|
||||
|
||||
LDR R5, [R0] ; Get App initial MSP for bootloader.
|
||||
MSR MSP, R5 ; Set the main stack pointer to the applications MSP.
|
||||
LDR R0, [R0, #0x04] ; Load Reset handler into R0. This will be first argument to branch instruction (BX).
|
||||
@@ -69,6 +75,12 @@ static inline void bootloader_util_reset (uint32_t start_addr) __attribute__ ((o
|
||||
static inline void bootloader_util_reset(uint32_t start_addr)
|
||||
{
|
||||
__asm volatile(
|
||||
"movs r5, #0x00\t\n" // R5 = 0
|
||||
"msr control, r5\t\n" // Clear CONTROL
|
||||
"msr primask, r5\t\n" // Clear PRIMASK
|
||||
"msr basepri, r5\t\n" // Clear BASEPRI
|
||||
"msr faultmask, r5\t\n" // Clear FAULTMASK
|
||||
|
||||
"ldr r0, [%0]\t\n" // Get App initial MSP for bootloader.
|
||||
"msr msp, r0\t\n" // Set the main stack pointer to the applications MSP.
|
||||
"ldr r0, [%0, #0x04]\t\n" // Load Reset handler into R0.
|
||||
@@ -108,7 +120,13 @@ static inline void bootloader_util_reset(uint32_t start_addr)
|
||||
#elif defined ( __ICCARM__ )
|
||||
static inline void bootloader_util_reset(uint32_t start_addr)
|
||||
{
|
||||
asm("ldr r5, [%0]\n" // Get App initial MSP for bootloader.
|
||||
asm("movs r5, #0x00\n" // R5 = 0
|
||||
"msr control, r5\n" // Clear CONTROL
|
||||
"msr primask, r5\n" // Clear PRIMASK
|
||||
"msr basepri, r5\n" // Clear BASEPRI
|
||||
"msr faultmask, r5\n" // Clear FAULTMASK
|
||||
|
||||
"ldr r5, [%0]\n" // Get App initial MSP for bootloader.
|
||||
"msr msp, r5\n" // Set the main stack pointer to the applications MSP.
|
||||
"ldr r0, [%0, #0x04]\n" // Load Reset handler into R0.
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ typedef enum
|
||||
DFU_STATE_WAIT_4_ACTIVATE /**< State for: waiting for dfu_image_activate(). */
|
||||
} dfu_state_t;
|
||||
|
||||
#define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */
|
||||
#define DFU_TIMEOUT_INTERVAL APP_TIMER_TICKS(300000) /**< DFU timeout interval in units of timer ticks. */
|
||||
#define DFU_TIMEOUT_INTERVAL APP_TIMER_TICKS(360000) /**< DFU timeout interval in milliseconds. */
|
||||
|
||||
#define IS_UPDATING_SD(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_SD) /**< Macro for determining if a SoftDevice update is ongoing. */
|
||||
#define IS_UPDATING_BL(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_BL) /**< Macro for determining if a Bootloader update is ongoing. */
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -31,7 +31,7 @@ static dfu_state_t m_dfu_state; /**< Current DFU
|
||||
static uint32_t m_image_size; /**< Size of the image that will be transmitted. */
|
||||
|
||||
static dfu_start_packet_t m_start_packet; /**< Start packet received for this update procedure. Contains update mode and image sizes information to be used for image transfer. */
|
||||
static uint8_t m_init_packet[64]; /**< Init packet, can hold CRC, Hash, Signed Hash and similar, for image validation, integrety check and authorization checking. */
|
||||
static uint8_t m_init_packet[128]; /**< Init packet, can hold CRC, Hash, Signed Hash and similar, for image validation, integrety check and authorization checking. */
|
||||
static uint8_t m_init_packet_length; /**< Length of init packet received. */
|
||||
static uint16_t m_image_crc; /**< Calculated CRC of the image received. */
|
||||
|
||||
@@ -132,31 +132,33 @@ static uint32_t dfu_timer_restart(void)
|
||||
*/
|
||||
static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
{
|
||||
mp_storage_handle_active = &m_storage_handle_app;
|
||||
mp_storage_handle_active = &m_storage_handle_app;
|
||||
|
||||
// Doing a SoftDevice update thus current application must be cleared to ensure enough space
|
||||
// for new SoftDevice.
|
||||
m_dfu_state = DFU_STATE_PREPARING;
|
||||
// Doing a SoftDevice update thus current application must be cleared to ensure enough space
|
||||
// for new SoftDevice.
|
||||
m_dfu_state = DFU_STATE_PREPARING;
|
||||
|
||||
if ( is_ota() )
|
||||
{
|
||||
uint32_t err_code;
|
||||
err_code = pstorage_clear(&m_storage_handle_app, m_image_size);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t page_count = m_image_size / CODE_PAGE_SIZE;
|
||||
if ( m_image_size % CODE_PAGE_SIZE ) page_count++;
|
||||
|
||||
for ( uint32_t i = 0; i < page_count; i++ )
|
||||
if ( is_ota() )
|
||||
{
|
||||
nrf_nvmc_page_erase(DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE);
|
||||
uint32_t err_code;
|
||||
while(1) {
|
||||
err_code = pstorage_clear(&m_storage_handle_app, m_image_size);
|
||||
if (err_code != NRF_ERROR_NO_MEM)
|
||||
break;
|
||||
// No space, wait until an entry in the queue is freed
|
||||
while (NRF_ERROR_NOT_FOUND != proc_soc()) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_nrf5x_erase(DFU_BANK_0_REGION_START, m_image_size);
|
||||
|
||||
// simulate complete call
|
||||
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
|
||||
}
|
||||
// invoke complete callback
|
||||
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +166,8 @@ static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
*/
|
||||
static void dfu_cleared_func_app(void)
|
||||
{
|
||||
dfu_update_status_t update_status = {DFU_BANK_0_ERASED, };
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
update_status.status_code = DFU_BANK_0_ERASED;
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
@@ -179,14 +182,14 @@ static void dfu_cleared_func_app(void)
|
||||
uint32_t offset_calculate(uint32_t sd_image_size)
|
||||
{
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
||||
if (m_start_packet.sd_image_size > DFU_BANK_0_REGION_START)
|
||||
{
|
||||
uint32_t page_mask = (CODE_PAGE_SIZE - 1);
|
||||
uint32_t diff = m_start_packet.sd_image_size - DFU_BANK_0_REGION_START;
|
||||
|
||||
|
||||
offset = diff & ~page_mask;
|
||||
|
||||
|
||||
// Align offset to next page if image size is not page sized.
|
||||
if ((diff & page_mask) > 0)
|
||||
{
|
||||
@@ -232,8 +235,7 @@ static uint32_t dfu_activate_sd(void)
|
||||
*/
|
||||
static uint32_t dfu_activate_app(void)
|
||||
{
|
||||
uint32_t err_code = NRF_SUCCESS;
|
||||
dfu_update_status_t update_status;
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
|
||||
memset(&update_status, 0, sizeof(dfu_update_status_t ));
|
||||
update_status.status_code = DFU_UPDATE_APP_COMPLETE;
|
||||
@@ -242,7 +244,7 @@ static uint32_t dfu_activate_app(void)
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
|
||||
return err_code;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +258,7 @@ static uint32_t dfu_activate_app(void)
|
||||
*/
|
||||
static uint32_t dfu_activate_bl(void)
|
||||
{
|
||||
dfu_update_status_t update_status;
|
||||
dfu_update_status_t update_status = {0};
|
||||
|
||||
update_status.status_code = DFU_UPDATE_BOOT_COMPLETE;
|
||||
update_status.app_crc = m_image_crc;
|
||||
@@ -322,7 +324,7 @@ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
// - SoftDevice
|
||||
// - Bootloader
|
||||
// - SoftDevice with Bootloader
|
||||
if (IS_UPDATING_APP(m_start_packet) &&
|
||||
if (IS_UPDATING_APP(m_start_packet) &&
|
||||
(IS_UPDATING_SD(m_start_packet) || IS_UPDATING_BL(m_start_packet)))
|
||||
{
|
||||
// App update is only supported independently.
|
||||
@@ -339,7 +341,7 @@ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
|
||||
m_image_size = m_start_packet.sd_image_size + m_start_packet.bl_image_size +
|
||||
m_start_packet.app_image_size;
|
||||
|
||||
|
||||
if (m_start_packet.bl_image_size > DFU_BL_IMAGE_MAX_SIZE)
|
||||
{
|
||||
return NRF_ERROR_DATA_SIZE;
|
||||
@@ -351,7 +353,7 @@ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
}
|
||||
m_functions.prepare = dfu_prepare_func_app_erase;
|
||||
m_functions.cleared = dfu_cleared_func_app;
|
||||
|
||||
|
||||
if (IS_UPDATING_SD(m_start_packet))
|
||||
{
|
||||
m_functions.activate = dfu_activate_sd;
|
||||
@@ -365,22 +367,15 @@ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
m_functions.activate = dfu_activate_app;
|
||||
}
|
||||
|
||||
switch (m_dfu_state)
|
||||
{
|
||||
case DFU_STATE_IDLE:
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
m_functions.prepare(m_image_size);
|
||||
if ( DFU_STATE_IDLE != m_dfu_state ) return NRF_ERROR_INVALID_STATE;
|
||||
|
||||
break;
|
||||
// Valid peer activity detected. Hence restart the DFU timer.
|
||||
err_code = dfu_timer_restart();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
default:
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
m_functions.prepare(m_image_size);
|
||||
|
||||
return err_code;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -428,13 +423,21 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
|
||||
if ( is_ota() )
|
||||
{
|
||||
err_code = pstorage_store(mp_storage_handle_active, (uint8_t *)p_data, data_length, m_data_received);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
while(1) {
|
||||
err_code = pstorage_store(mp_storage_handle_active, (uint8_t *)p_data, data_length, m_data_received);
|
||||
if (err_code != NRF_ERROR_NO_MEM)
|
||||
break;
|
||||
// No space, wait until an entry in the queue is freed
|
||||
while (NRF_ERROR_NOT_FOUND != proc_soc()) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
VERIFY_SUCCESS(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_nrf5x_write(DFU_BANK_0_REGION_START + m_data_received, p_data, data_length, false);
|
||||
pstorage_callback_handler(mp_storage_handle_active, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_data, data_length);
|
||||
flash_nrf5x_write(DFU_BANK_0_REGION_START + m_data_received, p_data, data_length, false);
|
||||
pstorage_callback_handler(mp_storage_handle_active, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_data, data_length);
|
||||
}
|
||||
|
||||
m_data_received += data_length;
|
||||
@@ -446,10 +449,10 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !is_ota() ) flash_nrf5x_flush(false);
|
||||
if ( !is_ota() ) flash_nrf5x_flush(false);
|
||||
|
||||
// The entire image has been received. Return NRF_SUCCESS.
|
||||
err_code = NRF_SUCCESS;
|
||||
// The entire image has been received. Return NRF_SUCCESS.
|
||||
err_code = NRF_SUCCESS;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -465,14 +468,14 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
uint32_t dfu_init_pkt_complete(void)
|
||||
{
|
||||
uint32_t err_code = NRF_ERROR_INVALID_STATE;
|
||||
|
||||
|
||||
// DFU initialization has been done and a start packet has been received.
|
||||
if (IMAGE_WRITE_IN_PROGRESS())
|
||||
{
|
||||
// Image write is already in progress. Cannot handle an init packet now.
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
if (m_dfu_state == DFU_STATE_RX_INIT_PKT)
|
||||
{
|
||||
err_code = dfu_init_prevalidate(m_init_packet, m_init_packet_length, m_start_packet.dfu_update_mode);
|
||||
@@ -498,7 +501,8 @@ uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
{
|
||||
case DFU_STATE_RDY:
|
||||
m_dfu_state = DFU_STATE_RX_INIT_PKT;
|
||||
// When receiving init packet in state ready just update and fall through this case.
|
||||
// When receiving init packet in state ready just update and fall through this case.
|
||||
/* FALLTHRU */
|
||||
|
||||
case DFU_STATE_RX_INIT_PKT:
|
||||
// DFU initialization has been done and a start packet has been received.
|
||||
@@ -526,11 +530,10 @@ uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
|
||||
default:
|
||||
// Either the start packet was not received or dfu_init function was not called before.
|
||||
err_code = NRF_ERROR_INVALID_STATE;
|
||||
break;
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
return err_code;
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -600,10 +603,18 @@ uint32_t dfu_image_activate()
|
||||
|
||||
void dfu_reset(void)
|
||||
{
|
||||
dfu_update_status_t update_status;
|
||||
dfu_update_status_t update_status = { 0 };
|
||||
|
||||
update_status.status_code = DFU_RESET;
|
||||
|
||||
// If we are still receiving packets, and we are expecting more of them,
|
||||
// and we receive the RESET command, this means the DFU app is trying
|
||||
// to interrupt and recover a failed previous attempt of FLASHing a new
|
||||
// application. Make sure to reboot into DFU mode instead of starting
|
||||
// a previously stored application (specially valid for double bank
|
||||
// bootloaders
|
||||
update_status.restart_into_bootloader = (m_dfu_state == DFU_STATE_RX_DATA_PKT && m_data_received != m_image_size);
|
||||
|
||||
bootloader_dfu_update_process(update_status);
|
||||
}
|
||||
|
||||
@@ -634,13 +645,13 @@ static uint32_t dfu_copy_sd(uint32_t * src, uint32_t * dst, uint32_t len)
|
||||
}
|
||||
|
||||
|
||||
static uint32_t dfu_sd_img_block_swap(uint32_t * src,
|
||||
uint32_t * dst,
|
||||
uint32_t len,
|
||||
static uint32_t dfu_sd_img_block_swap(uint32_t * src,
|
||||
uint32_t * dst,
|
||||
uint32_t len,
|
||||
uint32_t block_size)
|
||||
{
|
||||
// It is neccesarry to swap the new SoftDevice in 3 rounds to ensure correct copy of data
|
||||
// and verifucation of data in case power reset occurs during write to flash.
|
||||
// and verification of data in case power reset occurs during write to flash.
|
||||
// To ensure the robustness of swapping the images are compared backwards till start of
|
||||
// image swap. If the back is identical everything is swapped.
|
||||
uint32_t err_code = dfu_compare_block(src, dst, len);
|
||||
@@ -651,9 +662,9 @@ static uint32_t dfu_sd_img_block_swap(uint32_t * src,
|
||||
|
||||
if ((uint32_t)dst > SOFTDEVICE_REGION_START)
|
||||
{
|
||||
err_code = dfu_sd_img_block_swap((uint32_t *)((uint32_t)src - block_size),
|
||||
(uint32_t *)((uint32_t)dst - block_size),
|
||||
block_size,
|
||||
err_code = dfu_sd_img_block_swap((uint32_t *)((uint32_t)src - block_size),
|
||||
(uint32_t *)((uint32_t)dst - block_size),
|
||||
block_size,
|
||||
block_size);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
}
|
||||
@@ -675,37 +686,37 @@ uint32_t dfu_sd_image_swap(void)
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if ((SOFTDEVICE_REGION_START + boot_settings.sd_image_size) > boot_settings.sd_image_start)
|
||||
{
|
||||
uint32_t err_code;
|
||||
uint32_t sd_start = SOFTDEVICE_REGION_START;
|
||||
uint32_t block_size = (boot_settings.sd_image_start - sd_start) / 2;
|
||||
|
||||
|
||||
/* ##### FIX START ##### */
|
||||
block_size &= ~(uint32_t)(CODE_PAGE_SIZE - 1);
|
||||
/* ##### FIX END ##### */
|
||||
|
||||
block_size &= ~(uint32_t)(CODE_PAGE_SIZE - 1);
|
||||
/* ##### FIX END ##### */
|
||||
|
||||
uint32_t image_end = boot_settings.sd_image_start + boot_settings.sd_image_size;
|
||||
|
||||
uint32_t img_block_start = boot_settings.sd_image_start + 2 * block_size;
|
||||
uint32_t sd_block_start = sd_start + 2 * block_size;
|
||||
|
||||
|
||||
if (SD_SIZE_GET(MBR_SIZE) < boot_settings.sd_image_size)
|
||||
{
|
||||
// This will clear a page thus ensuring the old image is invalidated before swapping.
|
||||
err_code = dfu_copy_sd((uint32_t *)(sd_start + block_size),
|
||||
(uint32_t *)(sd_start + block_size),
|
||||
err_code = dfu_copy_sd((uint32_t *)(sd_start + block_size),
|
||||
(uint32_t *)(sd_start + block_size),
|
||||
sizeof(uint32_t));
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
err_code = dfu_copy_sd((uint32_t *)sd_start, (uint32_t *)sd_start, sizeof(uint32_t));
|
||||
VERIFY_SUCCESS(err_code);
|
||||
}
|
||||
|
||||
return dfu_sd_img_block_swap((uint32_t *)img_block_start,
|
||||
(uint32_t *)sd_block_start,
|
||||
image_end - img_block_start,
|
||||
|
||||
return dfu_sd_img_block_swap((uint32_t *)img_block_start,
|
||||
(uint32_t *)sd_block_start,
|
||||
image_end - img_block_start,
|
||||
block_size);
|
||||
}
|
||||
else
|
||||
@@ -713,7 +724,7 @@ uint32_t dfu_sd_image_swap(void)
|
||||
if (boot_settings.sd_image_size != 0)
|
||||
{
|
||||
return dfu_copy_sd((uint32_t *)boot_settings.sd_image_start,
|
||||
(uint32_t *)SOFTDEVICE_REGION_START,
|
||||
(uint32_t *)SOFTDEVICE_REGION_START,
|
||||
boot_settings.sd_image_size);
|
||||
}
|
||||
}
|
||||
@@ -733,7 +744,7 @@ uint32_t dfu_bl_image_swap(void)
|
||||
{
|
||||
uint32_t bl_image_start = (bootloader_settings.sd_image_size == 0) ?
|
||||
DFU_BANK_0_REGION_START :
|
||||
bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_size;
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COPY_BL;
|
||||
@@ -745,27 +756,54 @@ uint32_t dfu_bl_image_swap(void)
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint32_t dfu_bl_image_validate(void)
|
||||
{
|
||||
bootloader_settings_t bootloader_settings;
|
||||
sd_mbr_command_t sd_mbr_cmd;
|
||||
|
||||
sd_mbr_command_t sd_mbr_cmd_1;
|
||||
sd_mbr_command_t sd_mbr_cmd_2;
|
||||
|
||||
bootloader_settings_get(&bootloader_settings);
|
||||
|
||||
if (bootloader_settings.bl_image_size != 0)
|
||||
{
|
||||
uint32_t bl_image_start = (bootloader_settings.sd_image_size == 0) ?
|
||||
/*
|
||||
* The problem with updating the bootloader from a dual to single bank bootloader is that the new
|
||||
* bootloader expects the firmware image to be at the start of BANK 0, while it's actually loaded
|
||||
* to BANK1 by the old bootloader. After the update the new single bank bootloader verifies that
|
||||
* the image was correctly written to flash by comparing itself with the firmware image that it
|
||||
* expects to be located in BANK0. Since the actual firmware image is in BANK 1 this check will
|
||||
* fail and the new bootloader updates itself with whatever data located in BANK0 using the MBR.
|
||||
|
||||
* The fix is to modify the dfu_bl_image_validate() function in dfu_single_bank.c run verification
|
||||
* on both addresses (BANK0 and BANK1)
|
||||
*/
|
||||
uint32_t bl_image_start_1 = (bootloader_settings.sd_image_size == 0) ?
|
||||
DFU_BANK_0_REGION_START :
|
||||
bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_size;
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COMPARE;
|
||||
sd_mbr_cmd.params.compare.ptr1 = (uint32_t *)BOOTLOADER_REGION_START;
|
||||
sd_mbr_cmd.params.compare.ptr2 = (uint32_t *)(bl_image_start);
|
||||
sd_mbr_cmd.params.compare.len = bootloader_settings.bl_image_size / sizeof(uint32_t);
|
||||
sd_mbr_cmd_1.command = SD_MBR_COMMAND_COMPARE;
|
||||
sd_mbr_cmd_1.params.compare.ptr1 = (uint32_t *)BOOTLOADER_REGION_START;
|
||||
sd_mbr_cmd_1.params.compare.ptr2 = (uint32_t *)(bl_image_start_1);
|
||||
sd_mbr_cmd_1.params.compare.len = bootloader_settings.bl_image_size / sizeof(uint32_t);
|
||||
|
||||
return sd_mbr_command(&sd_mbr_cmd);
|
||||
uint32_t err_code = sd_mbr_command(&sd_mbr_cmd_1);
|
||||
if (err_code == NRF_SUCCESS) {
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t bl_image_start_2 = (bootloader_settings.sd_image_size == 0) ?
|
||||
DFU_BANK_1_REGION_START :
|
||||
bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_size;
|
||||
|
||||
sd_mbr_cmd_2.command = SD_MBR_COMMAND_COMPARE;
|
||||
sd_mbr_cmd_2.params.compare.ptr1 = (uint32_t *)BOOTLOADER_REGION_START;
|
||||
sd_mbr_cmd_2.params.compare.ptr2 = (uint32_t *)(bl_image_start_2);
|
||||
sd_mbr_cmd_2.params.compare.len = bootloader_settings.bl_image_size / sizeof(uint32_t);
|
||||
|
||||
return sd_mbr_command(&sd_mbr_cmd_2);
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
@@ -782,14 +820,18 @@ uint32_t dfu_sd_image_validate(void)
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if ((SOFTDEVICE_REGION_START + bootloader_settings.sd_image_size) > bootloader_settings.sd_image_start)
|
||||
{
|
||||
uint32_t sd_start = SOFTDEVICE_REGION_START;
|
||||
uint32_t block_size = (bootloader_settings.sd_image_start - sd_start) / 2;
|
||||
uint32_t image_end = bootloader_settings.sd_image_start +
|
||||
uint32_t image_end = bootloader_settings.sd_image_start +
|
||||
bootloader_settings.sd_image_size;
|
||||
|
||||
/* ##### FIX START ##### */
|
||||
block_size &= ~(uint32_t)(CODE_PAGE_SIZE - 1);
|
||||
/* ##### FIX END ##### */
|
||||
|
||||
uint32_t img_block_start = bootloader_settings.sd_image_start + 2 * block_size;
|
||||
uint32_t sd_block_start = sd_start + 2 * block_size;
|
||||
|
||||
@@ -798,12 +840,12 @@ uint32_t dfu_sd_image_validate(void)
|
||||
return NRF_ERROR_NULL;
|
||||
}
|
||||
|
||||
return dfu_sd_img_block_swap((uint32_t *)img_block_start,
|
||||
(uint32_t *)sd_block_start,
|
||||
image_end - img_block_start,
|
||||
return dfu_sd_img_block_swap((uint32_t *)img_block_start,
|
||||
(uint32_t *)sd_block_start,
|
||||
image_end - img_block_start,
|
||||
block_size);
|
||||
}
|
||||
|
||||
|
||||
sd_mbr_cmd.command = SD_MBR_COMMAND_COMPARE;
|
||||
sd_mbr_cmd.params.compare.ptr1 = (uint32_t *)SOFTDEVICE_REGION_START;
|
||||
sd_mbr_cmd.params.compare.ptr2 = (uint32_t *)bootloader_settings.sd_image_start;
|
||||
|
||||
@@ -35,11 +35,6 @@
|
||||
#include "nrf_delay.h"
|
||||
#include "sdk_common.h"
|
||||
|
||||
|
||||
#define BLEGAP_EVENT_LENGTH 6
|
||||
#define BLEGATT_ATT_MTU_MAX 247
|
||||
enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
|
||||
#define DFU_REV_MAJOR 0x00 /** DFU Major revision number to be exposed. */
|
||||
#define DFU_REV_MINOR 0x08 /** DFU Minor revision number to be exposed. */
|
||||
#define DFU_REVISION ((DFU_REV_MAJOR << 8) | DFU_REV_MINOR) /** DFU Revision number to be exposed. Combined of major and minor versions. */
|
||||
@@ -47,18 +42,19 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
#define BLE_HANDLE_MAX 0xFFFF /**< Max handle value is BLE. */
|
||||
|
||||
// limit of 8 chars
|
||||
#ifndef DEVICE_NAME
|
||||
#define DEVICE_NAME "AdaDFU" /**< Name of device. Will be included in the advertising data. */
|
||||
#endif
|
||||
|
||||
#define MIN_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(10, UNIT_1_25_MS)) /**< Minimum acceptable connection interval (11.25 milliseconds). */
|
||||
#define MIN_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(15, UNIT_1_25_MS)) /**< Minimum acceptable connection interval (11.25 milliseconds). */
|
||||
#define MAX_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(30, UNIT_1_25_MS)) /**< Maximum acceptable connection interval (15 milliseconds). */
|
||||
#define SLAVE_LATENCY 0 /**< Slave latency. */
|
||||
#define CONN_SUP_TIMEOUT (4 * 100) /**< Connection supervisory timeout (4 seconds). */
|
||||
|
||||
#define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */
|
||||
#define SLAVE_LATENCY 4 /**< Slave latency. */
|
||||
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(8000, UNIT_10_MS) /**< Connection supervisory timeout (4 seconds). */
|
||||
#define SPEEDUP_FLASH_WRITES 1 /**< Speedup FLASH writes by changing Softdevice local latency */
|
||||
|
||||
#define APP_ADV_INTERVAL MSEC_TO_UNITS(25, UNIT_0_625_MS) /**< The advertising interval (25 ms.). */
|
||||
#define APP_ADV_TIMEOUT BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising timeout in units of seconds. This is set to @ref BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED so that the advertisement is done as long as there there is a call to @ref dfu_transport_close function.*/
|
||||
#define APP_DIRECTED_ADV_TIMEOUT 50 /**< number of direct advertisement (each lasting 1.28seconds). */
|
||||
#define APP_DIRECTED_ADV_TIMEOUT 50 /**< number of direct advertisement (each lasting 1.28seconds). */
|
||||
#define PEER_ADDRESS_TYPE_INVALID 0xFF /**< Value indicating that no valid peer address exists. This will be the case when a private resolvable address is used in which case there is no address available but instead an IRK is present. */
|
||||
#define PEER_ADDRESS_TYPE_INVALID 0xFF /**< Value indicating that no valid peer address exists. This will be the case when a private resolvable address is used in which case there is no address available but instead an IRK is present. */
|
||||
|
||||
@@ -77,8 +73,9 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
|
||||
#define IS_CONNECTED() (m_conn_handle != BLE_CONN_HANDLE_INVALID) /**< Macro to determine if the device is in connected state. */
|
||||
|
||||
#define APP_FEATURE_NOT_SUPPORTED BLE_GATT_STATUS_ATTERR_APP_BEGIN + 2 /**< Reply when unsupported features are requested. */
|
||||
#define SD_IMAGE_SIZE_OFFSET 0 /**< Offset in start packet for the size information for SoftDevice. */
|
||||
#define APP_FEATURE_NOT_SUPPORTED \
|
||||
(BLE_GATT_STATUS_ATTERR_APP_BEGIN + 2) /**< Reply when unsupported features are requested. */
|
||||
#define SD_IMAGE_SIZE_OFFSET 0 /**< Offset in start packet for the size information for SoftDevice. */
|
||||
#define BL_IMAGE_SIZE_OFFSET 4 /**< Offset in start packet for the size information for bootloader. */
|
||||
#define APP_IMAGE_SIZE_OFFSET 8 /**< Offset in start packet for the size information for application. */
|
||||
|
||||
@@ -150,6 +147,7 @@ static uint32_t service_change_indicate()
|
||||
|
||||
err_code = sd_ble_gatts_service_changed(m_conn_handle, DFU_SERVICE_HANDLE, BLE_HANDLE_MAX);
|
||||
if ((err_code == BLE_ERROR_INVALID_CONN_HANDLE) ||
|
||||
(err_code == BLE_ERROR_INVALID_ATTR_HANDLE) ||
|
||||
(err_code == NRF_ERROR_INVALID_STATE) ||
|
||||
(err_code == NRF_ERROR_BUSY))
|
||||
{
|
||||
@@ -209,7 +207,35 @@ static ble_dfu_resp_val_t nrf_err_code_translate(uint32_t err_c
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SPEEDUP_FLASH_WRITES
|
||||
static void prioritize_ble_over_flash_writes(void) {
|
||||
// We set the local latency to 0: That will revert latency to the negotiated one with the host.
|
||||
// That will increase throughput to the maximum possible
|
||||
ble_opt_t opt;
|
||||
varclr(&opt);
|
||||
opt.gap_opt.local_conn_latency.conn_handle = m_conn_handle; /**< Connection Handle */
|
||||
opt.gap_opt.local_conn_latency.requested_latency = 0; /**< Requested local connection latency. */
|
||||
opt.gap_opt.local_conn_latency.p_actual_latency =
|
||||
NULL; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
|
||||
sd_ble_opt_set(BLE_GAP_OPT_LOCAL_CONN_LATENCY, &opt);
|
||||
}
|
||||
|
||||
static void prioritize_flash_writes_over_ble(void) {
|
||||
// We set the local latency to the maximum possible: That will make FLASH writes faster, as BLE comms will
|
||||
// be delayed (even losing RXd packets, but this is the same as a poor connection and will be handled by
|
||||
// the protocol itself)
|
||||
ble_opt_t opt;
|
||||
varclr(&opt);
|
||||
opt.gap_opt.local_conn_latency.conn_handle = m_conn_handle; /**< Connection Handle */
|
||||
opt.gap_opt.local_conn_latency.requested_latency = 50; /**< Requested local connection latency. */
|
||||
opt.gap_opt.local_conn_latency.p_actual_latency =
|
||||
NULL; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
|
||||
sd_ble_opt_set(BLE_GAP_OPT_LOCAL_CONN_LATENCY, &opt);
|
||||
}
|
||||
#else
|
||||
#define prioritize_ble_over_flash_writes()
|
||||
#define prioritize_flash_writes_over_ble()
|
||||
#endif
|
||||
/**@brief Function for handling the callback events from the dfu module.
|
||||
* Callbacks are expected when \ref dfu_data_pkt_handle has been executed.
|
||||
*
|
||||
@@ -227,6 +253,9 @@ static void dfu_cb_handler(uint32_t packet, uint32_t result, uint8_t * p_data)
|
||||
case DATA_PACKET:
|
||||
if (result != NRF_SUCCESS)
|
||||
{
|
||||
// Restore latency to the negotiated one
|
||||
prioritize_ble_over_flash_writes();
|
||||
|
||||
// Disconnect from peer.
|
||||
if (IS_CONNECTED())
|
||||
{
|
||||
@@ -243,6 +272,9 @@ static void dfu_cb_handler(uint32_t packet, uint32_t result, uint8_t * p_data)
|
||||
// If the callback matches final data packet received then the peer is notified.
|
||||
if (mp_final_packet == p_data)
|
||||
{
|
||||
// Restore latency to the negotiated one
|
||||
prioritize_ble_over_flash_writes();
|
||||
|
||||
// Notify the DFU Controller about the success of the procedure.
|
||||
err_code = ble_dfu_response_send(&m_dfu,
|
||||
BLE_DFU_RECEIVE_APP_PROCEDURE,
|
||||
@@ -253,6 +285,10 @@ static void dfu_cb_handler(uint32_t packet, uint32_t result, uint8_t * p_data)
|
||||
break;
|
||||
|
||||
case START_PACKET:
|
||||
|
||||
// Restore latency to the negotiated one
|
||||
prioritize_ble_over_flash_writes();
|
||||
|
||||
// Translate the err_code returned by the above function to DFU Response Value.
|
||||
resp_val = nrf_err_code_translate(result, BLE_DFU_START_PROCEDURE);
|
||||
|
||||
@@ -325,9 +361,15 @@ static void start_data_process(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
|
||||
start_packet.bl_image_size = uint32_decode(p_length_data + BL_IMAGE_SIZE_OFFSET);
|
||||
start_packet.app_image_size = uint32_decode(p_length_data + APP_IMAGE_SIZE_OFFSET);
|
||||
|
||||
// Prioritize FLASH writes over BLE comms
|
||||
prioritize_flash_writes_over_ble();
|
||||
|
||||
err_code = dfu_start_pkt_handle(&update_packet);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
// Prioritize BLE over flash writes
|
||||
prioritize_ble_over_flash_writes();
|
||||
|
||||
// Translate the err_code returned by the above function to DFU Response Value.
|
||||
ble_dfu_resp_val_t resp_val;
|
||||
|
||||
@@ -736,11 +778,30 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
uint32_t err_code;
|
||||
ble_gatts_rw_authorize_reply_params_t auth_reply;
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
extern void print_ble_event(uint16_t evt_id);
|
||||
print_ble_event(p_ble_evt->header.evt_id);
|
||||
#endif
|
||||
|
||||
switch (p_ble_evt->header.evt_id)
|
||||
{
|
||||
case BLE_GAP_EVT_CONNECTED:
|
||||
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
|
||||
m_is_advertising = false;
|
||||
{
|
||||
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
|
||||
m_is_advertising = false;
|
||||
|
||||
// Force changing the slave latency to try to improve transfer throughput (bandwidth)
|
||||
// But Android and IOS will override it with their minimum supported value
|
||||
ble_gap_conn_params_t p_conn_params;
|
||||
p_conn_params.min_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.min_conn_interval;
|
||||
p_conn_params.max_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval;
|
||||
p_conn_params.slave_latency = SLAVE_LATENCY;
|
||||
p_conn_params.conn_sup_timeout = p_ble_evt->evt.gap_evt.params.connected.conn_params.conn_sup_timeout;
|
||||
|
||||
err_code = sd_ble_gap_conn_param_update(m_conn_handle, &p_conn_params);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_DISCONNECTED:
|
||||
@@ -770,6 +831,9 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_CONN_PARAM_UPDATE:
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
|
||||
{
|
||||
ble_gap_sec_keyset_t keys;
|
||||
@@ -885,9 +949,23 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
APP_ERROR_CHECK( sd_ble_gap_data_length_update(m_conn_handle, NULL, NULL) );
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
|
||||
{
|
||||
// Tell SoftDevice to choose PHY automatically
|
||||
ble_gap_phys_t phy = { BLE_GAP_PHY_AUTO, BLE_GAP_PHY_AUTO };
|
||||
(void) sd_ble_gap_phy_update(m_conn_handle, &phy);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
|
||||
{
|
||||
uint16_t att_mtu = MIN(p_ble_evt->evt.gatts_evt.params.exchange_mtu_request.client_rx_mtu, BLEGATT_ATT_MTU_MAX);
|
||||
|
||||
// Round it to a multiple of 4 plus 3 bytes, as we need data packets to be multiple of 4 bytes
|
||||
att_mtu &= 0xFFFCU;
|
||||
att_mtu |= 3;
|
||||
|
||||
PRINTF("GAP ATT MTU is changed to %d\r\n", att_mtu);
|
||||
APP_ERROR_CHECK( sd_ble_gatts_exchange_mtu_reply(m_conn_handle, att_mtu) );
|
||||
}
|
||||
break;
|
||||
@@ -953,7 +1031,7 @@ static void service_error_handler(uint32_t nrf_error)
|
||||
}
|
||||
|
||||
|
||||
static void ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, char * p_ascii)
|
||||
static void ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, const char * p_ascii)
|
||||
{
|
||||
p_utf8->length = (uint16_t)strlen(p_ascii);
|
||||
p_utf8->p_str = (uint8_t *)p_ascii;
|
||||
@@ -980,20 +1058,9 @@ static void services_init(void)
|
||||
ble_dis_init_t dis_init;
|
||||
memset(&dis_init, 0, sizeof(dis_init));
|
||||
|
||||
ascii_to_utf8(&dis_init.manufact_name_str, DIS_MANUFACTURER);
|
||||
ascii_to_utf8(&dis_init.model_num_str, DIS_MODEL);
|
||||
|
||||
uint32_t const sd_id = SD_ID_GET(MBR_SIZE);
|
||||
uint32_t const sd_version = SD_VERSION_GET(MBR_SIZE);
|
||||
|
||||
uint32_t const ver1 = sd_version / 1000000;
|
||||
uint32_t const ver2 = (sd_version % 1000000)/1000;
|
||||
uint32_t const ver3 = sd_version % 1000;
|
||||
|
||||
char fw_str[30+1];
|
||||
sprintf(fw_str, "s%ld %ld.%ld.%ld r%ld", sd_id, ver1, ver2, ver3, MK_BOOTLOADER_VERSION & 0xFFUL);
|
||||
|
||||
ascii_to_utf8(&dis_init.fw_rev_str, fw_str);
|
||||
ascii_to_utf8(&dis_init.manufact_name_str, BLEDIS_MANUFACTURER);
|
||||
ascii_to_utf8(&dis_init.model_num_str, BLEDIS_MODEL);
|
||||
ascii_to_utf8(&dis_init.fw_rev_str, BLEDIS_FW_VERSION);
|
||||
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm);
|
||||
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm);
|
||||
@@ -1080,3 +1147,114 @@ uint32_t dfu_transport_ble_close()
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
|
||||
#if 0
|
||||
typedef struct
|
||||
{
|
||||
uint32_t key;
|
||||
void const * data;
|
||||
}lookup_entry_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count;
|
||||
lookup_entry_t const* items;
|
||||
} lookup_table_t;
|
||||
|
||||
void const * lookup_find(lookup_table_t const* p_table, uint32_t key)
|
||||
{
|
||||
for(uint16_t i=0; i<p_table->count; i++)
|
||||
{
|
||||
if (p_table->items[i].key == key) return p_table->items[i].data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BLE Event String
|
||||
*------------------------------------------------------------------*/
|
||||
static lookup_entry_t const _strevt_lookup[] =
|
||||
{
|
||||
// BLE common: 0x01
|
||||
{ .key = BLE_EVT_USER_MEM_REQUEST , .data= "BLE_EVT_USER_MEM_REQUEST" },
|
||||
{ .key = BLE_EVT_USER_MEM_RELEASE , .data= "BLE_EVT_USER_MEM_RELEASE" },
|
||||
|
||||
// BLE Gap: 0x10
|
||||
{ .key = BLE_GAP_EVT_CONNECTED , .data= "BLE_GAP_EVT_CONNECTED" },
|
||||
{ .key = BLE_GAP_EVT_DISCONNECTED , .data= "BLE_GAP_EVT_DISCONNECTED" },
|
||||
{ .key = BLE_GAP_EVT_CONN_PARAM_UPDATE , .data= "BLE_GAP_EVT_CONN_PARAM_UPDATE" },
|
||||
{ .key = BLE_GAP_EVT_SEC_PARAMS_REQUEST , .data= "BLE_GAP_EVT_SEC_PARAMS_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_SEC_INFO_REQUEST , .data= "BLE_GAP_EVT_SEC_INFO_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_PASSKEY_DISPLAY , .data= "BLE_GAP_EVT_PASSKEY_DISPLAY" },
|
||||
{ .key = BLE_GAP_EVT_KEY_PRESSED , .data= "BLE_GAP_EVT_KEY_PRESSED" },
|
||||
{ .key = BLE_GAP_EVT_AUTH_KEY_REQUEST , .data= "BLE_GAP_EVT_AUTH_KEY_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_LESC_DHKEY_REQUEST , .data= "BLE_GAP_EVT_LESC_DHKEY_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_AUTH_STATUS , .data= "BLE_GAP_EVT_AUTH_STATUS" },
|
||||
{ .key = BLE_GAP_EVT_CONN_SEC_UPDATE , .data= "BLE_GAP_EVT_CONN_SEC_UPDATE" },
|
||||
{ .key = BLE_GAP_EVT_TIMEOUT , .data= "BLE_GAP_EVT_TIMEOUT" },
|
||||
{ .key = BLE_GAP_EVT_RSSI_CHANGED , .data= "BLE_GAP_EVT_RSSI_CHANGED" },
|
||||
{ .key = BLE_GAP_EVT_ADV_REPORT , .data= "BLE_GAP_EVT_ADV_REPORT" },
|
||||
{ .key = BLE_GAP_EVT_SEC_REQUEST , .data= "BLE_GAP_EVT_SEC_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST , .data= "BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_SCAN_REQ_REPORT , .data= "BLE_GAP_EVT_SCAN_REQ_REPORT" },
|
||||
{ .key = BLE_GAP_EVT_PHY_UPDATE_REQUEST , .data= "BLE_GAP_EVT_PHY_UPDATE_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_PHY_UPDATE , .data= "BLE_GAP_EVT_PHY_UPDATE" },
|
||||
{ .key = BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST , .data= "BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST" },
|
||||
{ .key = BLE_GAP_EVT_DATA_LENGTH_UPDATE , .data= "BLE_GAP_EVT_DATA_LENGTH_UPDATE" },
|
||||
{ .key = BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT , .data= "BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT" },
|
||||
{ .key = BLE_GAP_EVT_ADV_SET_TERMINATED , .data= "BLE_GAP_EVT_ADV_SET_TERMINATED" },
|
||||
|
||||
// BLE Gattc: 0x30
|
||||
{ .key = BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP , .data= "BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_REL_DISC_RSP , .data= "BLE_GATTC_EVT_REL_DISC_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_CHAR_DISC_RSP , .data= "BLE_GATTC_EVT_CHAR_DISC_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_DESC_DISC_RSP , .data= "BLE_GATTC_EVT_DESC_DISC_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_ATTR_INFO_DISC_RSP , .data= "BLE_GATTC_EVT_ATTR_INFO_DISC_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP , .data= "BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_READ_RSP , .data= "BLE_GATTC_EVT_READ_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_CHAR_VALS_READ_RSP , .data= "BLE_GATTC_EVT_CHAR_VALS_READ_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_WRITE_RSP , .data= "BLE_GATTC_EVT_WRITE_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_HVX , .data= "BLE_GATTC_EVT_HVX" },
|
||||
{ .key = BLE_GATTC_EVT_EXCHANGE_MTU_RSP , .data= "BLE_GATTC_EVT_EXCHANGE_MTU_RSP" },
|
||||
{ .key = BLE_GATTC_EVT_TIMEOUT , .data= "BLE_GATTC_EVT_TIMEOUT" },
|
||||
{ .key = BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE , .data= "BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE" },
|
||||
|
||||
// BLE Gatts: 0x50
|
||||
{ .key = BLE_GATTS_EVT_WRITE , .data= "BLE_GATTS_EVT_WRITE" },
|
||||
{ .key = BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST , .data= "BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST" },
|
||||
{ .key = BLE_GATTS_EVT_SYS_ATTR_MISSING , .data= "BLE_GATTS_EVT_SYS_ATTR_MISSING" },
|
||||
{ .key = BLE_GATTS_EVT_HVC , .data= "BLE_GATTS_EVT_HVC" },
|
||||
{ .key = BLE_GATTS_EVT_SC_CONFIRM , .data= "BLE_GATTS_EVT_SC_CONFIRM" },
|
||||
{ .key = BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST , .data= "BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST" },
|
||||
{ .key = BLE_GATTS_EVT_TIMEOUT , .data= "BLE_GATTS_EVT_TIMEOUT" },
|
||||
{ .key = BLE_GATTS_EVT_HVN_TX_COMPLETE , .data= "BLE_GATTS_EVT_HVN_TX_COMPLETE" },
|
||||
};
|
||||
|
||||
lookup_table_t const _strevt_table =
|
||||
{
|
||||
.count = arrcount(_strevt_lookup),
|
||||
.items = _strevt_lookup
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void print_ble_event(uint16_t evt_id)
|
||||
{
|
||||
// const char * str = (const char *) lookup_find(&_strevt_table, evt_id);
|
||||
const char * str = NULL;
|
||||
PRINTF("BLE event: ");
|
||||
if ( str == NULL )
|
||||
{
|
||||
PRINTF("0x%04X", evt_id);
|
||||
}else
|
||||
{
|
||||
PRINTF(str);
|
||||
}
|
||||
PRINTF("\r\n");
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -201,55 +201,55 @@ static void process_dfu_packet(void * p_event_data, uint16_t event_size)
|
||||
extern bool dfu_startup_packet_received;
|
||||
dfu_startup_packet_received = true;
|
||||
|
||||
while (false == DATA_QUEUE_EMPTY())
|
||||
while (false == DATA_QUEUE_EMPTY())
|
||||
{
|
||||
// Fetch the element to be processed.
|
||||
for (index = 0; index < MAX_BUFFERS ; index++)
|
||||
{
|
||||
// Fetch the element to be processed.
|
||||
for (index = 0; index < MAX_BUFFERS ; index++)
|
||||
packet = &m_data_queue.data_packet[index];
|
||||
if (INVALID_PACKET != packet->packet_type)
|
||||
{
|
||||
packet = &m_data_queue.data_packet[index];
|
||||
if (INVALID_PACKET != packet->packet_type)
|
||||
switch (DATA_QUEUE_ELEMENT_GET_PTYPE(index))
|
||||
{
|
||||
switch (DATA_QUEUE_ELEMENT_GET_PTYPE(index))
|
||||
{
|
||||
case DATA_PACKET:
|
||||
(void)dfu_data_pkt_handle(packet);
|
||||
break;
|
||||
case DATA_PACKET:
|
||||
(void)dfu_data_pkt_handle(packet);
|
||||
break;
|
||||
|
||||
case START_PACKET:
|
||||
packet->params.start_packet =
|
||||
(dfu_start_packet_t*)packet->params.data_packet.p_data_packet;
|
||||
retval = dfu_start_pkt_handle(packet);
|
||||
APP_ERROR_CHECK(retval);
|
||||
break;
|
||||
case START_PACKET:
|
||||
packet->params.start_packet =
|
||||
(dfu_start_packet_t*)packet->params.data_packet.p_data_packet;
|
||||
retval = dfu_start_pkt_handle(packet);
|
||||
APP_ERROR_CHECK(retval);
|
||||
break;
|
||||
|
||||
case INIT_PACKET:
|
||||
(void)dfu_init_pkt_handle(packet);
|
||||
retval = dfu_init_pkt_complete();
|
||||
APP_ERROR_CHECK(retval);
|
||||
case INIT_PACKET:
|
||||
(void)dfu_init_pkt_handle(packet);
|
||||
retval = dfu_init_pkt_complete();
|
||||
APP_ERROR_CHECK(retval);
|
||||
|
||||
led_state(STATE_WRITING_STARTED);
|
||||
break;
|
||||
led_state(STATE_WRITING_STARTED);
|
||||
break;
|
||||
|
||||
case STOP_DATA_PACKET:
|
||||
(void)dfu_image_validate();
|
||||
(void)dfu_image_activate();
|
||||
case STOP_DATA_PACKET:
|
||||
(void)dfu_image_validate();
|
||||
(void)dfu_image_activate();
|
||||
|
||||
led_state(STATE_WRITING_FINISHED);
|
||||
led_state(STATE_WRITING_FINISHED);
|
||||
|
||||
// Break the loop by returning.
|
||||
return;
|
||||
// Break the loop by returning.
|
||||
return;
|
||||
|
||||
default:
|
||||
// No implementation needed.
|
||||
break;
|
||||
}
|
||||
|
||||
// Free the processed element.
|
||||
retval = data_queue_element_free(index);
|
||||
APP_ERROR_CHECK(retval);
|
||||
default:
|
||||
// No implementation needed.
|
||||
break;
|
||||
}
|
||||
|
||||
// Free the processed element.
|
||||
retval = data_queue_element_free(index);
|
||||
APP_ERROR_CHECK(retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,61 +24,61 @@
|
||||
#define DFU_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf_sdm.h"
|
||||
#include "nrf_mbr.h"
|
||||
#include "nrf.h"
|
||||
#include "app_util.h"
|
||||
|
||||
#ifndef SD_MAGIC_NUMBER
|
||||
#define SD_MAGIC_NUMBER 0x51B1E5DB
|
||||
#endif
|
||||
|
||||
static inline bool is_sd_existed(void)
|
||||
{
|
||||
return *((uint32_t*)(SOFTDEVICE_INFO_STRUCT_ADDRESS+4)) == SD_MAGIC_NUMBER;
|
||||
}
|
||||
|
||||
#define NRF_UICR_BOOT_START_ADDRESS (NRF_UICR_BASE + 0x14) /**< Register where the bootloader start address is stored in the UICR register. */
|
||||
|
||||
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
#define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18) /**< Register where the mbr params page is stored in the UICR register. (Only in use in nRF52 MBR).*/
|
||||
#endif
|
||||
|
||||
#define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
||||
// Application address is either after MBR or SD (if existed)
|
||||
#define CODE_REGION_1_START (is_sd_existed() ? SD_SIZE_GET(MBR_SIZE) : MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
||||
|
||||
#define SOFTDEVICE_REGION_START MBR_SIZE /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
|
||||
|
||||
|
||||
#if defined(NRF52832_XXAA)
|
||||
|
||||
#define BOOTLOADER_REGION_START 0x00074000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
|
||||
|
||||
#if defined(NRF52832_XXAA) || defined(NRF52833_XXAA)
|
||||
// Flash = 512 KB, allow to be defined in debug mode
|
||||
#ifndef BOOTLOADER_REGION_START
|
||||
#define BOOTLOADER_REGION_START 0x00074000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#endif
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
|
||||
#elif defined(NRF52840_XXAA)
|
||||
|
||||
// Increase bootloader size to application data region for easy debugging
|
||||
#ifdef DEBUG_SIZE_EXPAND
|
||||
#define BOOTLOADER_REGION_START (0x000F4000 - CODE_PAGE_SIZE*7)
|
||||
#define DFU_APP_DATA_RESERVED 0
|
||||
#else
|
||||
#define BOOTLOADER_REGION_START 0x000F4000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#endif
|
||||
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
|
||||
// Flash = 1024 KB, allow to be defined in debug mode
|
||||
#ifndef BOOTLOADER_REGION_START
|
||||
#define BOOTLOADER_REGION_START 0x000F4000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||
#endif
|
||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
|
||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
|
||||
|
||||
#else
|
||||
|
||||
#error No target defined
|
||||
|
||||
#error No target defined
|
||||
#endif
|
||||
|
||||
#define DFU_REGION_TOTAL_SIZE (BOOTLOADER_REGION_START - CODE_REGION_1_START) /**< Total size of the region between SD and Bootloader. */
|
||||
|
||||
#ifndef DFU_APP_DATA_RESERVED
|
||||
#define DFU_APP_DATA_RESERVED CODE_PAGE_SIZE*7 /**< Size of Application Data that must be preserved between application updates. This value must be a multiple of page size. Page size is 0x400 (1024d) bytes, thus this value must be 0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, etc. */
|
||||
#error "DFU_APP_DATA_RESERVED is not defined"
|
||||
#endif
|
||||
|
||||
#define DFU_IMAGE_MAX_SIZE_FULL (DFU_REGION_TOTAL_SIZE - DFU_APP_DATA_RESERVED) /**< Maximum size of an application, excluding save data from the application. */
|
||||
|
||||
#define DFU_IMAGE_MAX_SIZE_BANKED (((DFU_IMAGE_MAX_SIZE_FULL) - \
|
||||
(DFU_IMAGE_MAX_SIZE_FULL % (2 * CODE_PAGE_SIZE)))/2) /**< Maximum size of an application, excluding save data from the application. */
|
||||
|
||||
#define DFU_BL_IMAGE_MAX_SIZE (BOOTLOADER_SETTINGS_ADDRESS - BOOTLOADER_REGION_START) /**< Maximum size of a bootloader, excluding save data from the current bootloader. */
|
||||
|
||||
#define DFU_BL_IMAGE_MAX_SIZE (BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS - BOOTLOADER_REGION_START) /**< Maximum size of a bootloader, excluding save data from the current bootloader. */
|
||||
#define DFU_BANK_0_REGION_START CODE_REGION_1_START /**< Bank 0 region start. */
|
||||
#define DFU_BANK_1_REGION_START (DFU_BANK_0_REGION_START + DFU_IMAGE_MAX_SIZE_BANKED) /**< Bank 1 region start. */
|
||||
|
||||
@@ -141,7 +141,8 @@ typedef enum
|
||||
DFU_UPDATE_BOOT_COMPLETE, /**< Status update complete.*/
|
||||
DFU_BANK_0_ERASED, /**< Status bank 0 erased.*/
|
||||
DFU_TIMEOUT, /**< Status timeout.*/
|
||||
DFU_RESET /**< Status Reset to indicate current update procedure has been aborted and system should reset. */
|
||||
DFU_RESET, /**< Status Reset to indicate current update procedure has been aborted and system should reset. */
|
||||
DFU_UF2_BOOTLOADER_COMPLETE
|
||||
} dfu_update_status_code_t;
|
||||
|
||||
/**@brief Structure holding DFU complete event.
|
||||
@@ -154,6 +155,7 @@ typedef struct
|
||||
uint32_t bl_size; /**< Size of the recieved BootLoader. */
|
||||
uint32_t app_size; /**< Size of the recieved Application. */
|
||||
uint32_t sd_image_start; /**< Location in flash where the received SoftDevice image is stored. */
|
||||
bool restart_into_bootloader; /**< If the chip must be reset and must reenter bootloader mode. */
|
||||
} dfu_update_status_t;
|
||||
|
||||
/**@brief Update complete handler type. */
|
||||
|
||||
+49
-22
@@ -64,9 +64,22 @@ extern "C" {
|
||||
#define MBR_PAGE_SIZE_IN_WORDS (1024)
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash.
|
||||
This is the offset where the first byte of the SoftDevice hex file is written.*/
|
||||
This is the offset where the first byte of the SoftDevice hex file is written. */
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @brief Location (in the flash memory) of the bootloader address. */
|
||||
#define MBR_BOOTLOADER_ADDR (0xFF8)
|
||||
|
||||
/** @brief Location (in UICR) of the bootloader address. */
|
||||
#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0]))
|
||||
|
||||
/** @brief Location (in the flash memory) of the address of the MBR parameter page. */
|
||||
#define MBR_PARAM_PAGE_ADDR (0xFFC)
|
||||
|
||||
/** @brief Location (in UICR) of the address of the MBR parameter page. */
|
||||
#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1]))
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
@@ -129,24 +142,29 @@ typedef struct
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
*
|
||||
* With this command, destination of BootLoader is always the address written in
|
||||
* NRF_UICR->BOOTADDR.
|
||||
* The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to
|
||||
* the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* Destination is erased by this function.
|
||||
* The bootloader destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This function will use PROTENSET to protect the flash that is not intended to be written.
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* On success, this function will not return. It will start the new BootLoader from reset-vector as normal.
|
||||
* This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is
|
||||
* not intended to be written.
|
||||
*
|
||||
* On success, this function will not return. It will start the new bootloader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info)
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
|
||||
uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
@@ -155,15 +173,22 @@ typedef struct
|
||||
* Once this function has been called, this address is where the MBR will start to forward
|
||||
* interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding this function should be called with @ref address set to 0. The
|
||||
* MBR will then start forwarding interrupts to the address in NFR_UICR->BOOTADDR or to the
|
||||
* SoftDevice if the BOOTADDR is not set.
|
||||
* To restore default forwarding, this function should be called with @ref address set to 0. If a
|
||||
* bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will
|
||||
* be forwarded to the SoftDevice.
|
||||
*
|
||||
* The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or
|
||||
* @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* On success, this function will not return. It will reset the device.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info)
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -212,19 +237,21 @@ typedef struct
|
||||
*
|
||||
* The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires
|
||||
* parameters to be retained by the MBR when resetting the IC. This is done in a separate flash
|
||||
* page provided by the application. The UICR register UICR.NRFFW[1] must be set to an address
|
||||
* corresponding to a page in the application flash space. This page will be cleared by the MBR and
|
||||
* used to store the command before reset. When the UICR.NRFFW[1] field is set the page it refers
|
||||
* to must not be used by the application. If the UICR.NRFFW[1] is set to 0xFFFFFFFF (the default)
|
||||
* MBR commands which use flash will be unavailable and return @ref NRF_ERROR_NO_MEM.
|
||||
* page. The location of the flash page should be provided by the application in either
|
||||
* @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR
|
||||
* will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to
|
||||
* store the command before reset. When an address is specified, the page it refers to must not be
|
||||
* used by the application. If no address is provided by the application, i.e. both
|
||||
* @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use
|
||||
* flash will be unavailable and return @ref NRF_ERROR_NO_MEM.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
* @note For return values, see ::sd_mbr_command_copy_sd_t, ::sd_mbr_command_copy_bl_t,
|
||||
* ::sd_mbr_command_compare_t, ::sd_mbr_command_vector_table_base_set_t,
|
||||
* ::sd_mbr_command_irq_forward_address_set_t
|
||||
* @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t,
|
||||
* ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t,
|
||||
* ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t
|
||||
*
|
||||
* @retval ::NRF_ERROR_NO_MEM if UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF).
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given.
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NRF_SVC__
|
||||
#define NRF_SVC__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Supervisor call declaration.
|
||||
*
|
||||
* A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception.
|
||||
* The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice.
|
||||
*
|
||||
* @param[in] number The SVC number to be used.
|
||||
* @param[in] return_type The return type of the SVC function.
|
||||
* @param[in] signature Function signature. The function can have at most four arguments.
|
||||
*/
|
||||
|
||||
#ifdef SVCALL_AS_NORMAL_FUNCTION
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#else
|
||||
|
||||
#ifndef SVCALL
|
||||
#if defined (__CC_ARM)
|
||||
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
|
||||
#elif defined (__GNUC__)
|
||||
#ifdef __cplusplus
|
||||
#define GCC_CAST_CPP (uint16_t)
|
||||
#else
|
||||
#define GCC_CAST_CPP
|
||||
#endif
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
|
||||
__attribute__((naked)) \
|
||||
__attribute__((unused)) \
|
||||
static return_type signature \
|
||||
{ \
|
||||
__asm( \
|
||||
"svc %0\n" \
|
||||
"bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \
|
||||
); \
|
||||
} \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
|
||||
#elif defined (__ICCARM__)
|
||||
#define PRAGMA(x) _Pragma(#x)
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
PRAGMA(swi_number = (number)) \
|
||||
__swi return_type signature;
|
||||
#else
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#endif
|
||||
#endif // SVCALL
|
||||
|
||||
#endif // SVCALL_AS_NORMAL_FUNCTION
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_SVC__
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2007 - 2018, Nordic Semiconductor ASA
|
||||
Copyright (c) 2007 - 2019, Nordic Semiconductor ASA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -0,0 +1,179 @@
|
||||
:020000040000FA
|
||||
:1000000000040020810A000015070000610A0000BA
|
||||
:100010001F07000029070000330700000000000050
|
||||
:10002000000000000000000000000000A50A000021
|
||||
:100030003D070000000000004707000051070000D6
|
||||
:100040005B070000650700006F07000079070000EC
|
||||
:10005000830700008D07000097070000A10700003C
|
||||
:10006000AB070000B5070000BF070000C90700008C
|
||||
:10007000D3070000DD070000E7070000F1070000DC
|
||||
:10008000FB070000050800000F0800001908000029
|
||||
:10009000230800002D080000370800004108000078
|
||||
:1000A0004B080000550800005F08000069080000C8
|
||||
:1000B000730800007D080000870800009108000018
|
||||
:1000C0009B080000A5080000AF080000B908000068
|
||||
:1000D000C3080000CD080000D7080000E1080000B8
|
||||
:1000E000EB080000F5080000FF0800000909000007
|
||||
:1000F000130900001D090000270900003109000054
|
||||
:100100003B0900001FB500F003F88DE80F001FBD8C
|
||||
:1001100000F0ACBC40F6FC7108684FF01022401CA7
|
||||
:1001200008D00868401C09D00868401C04D0086842
|
||||
:1001300000F037BA9069F5E79069F9E7704770B554
|
||||
:100140000B46010B184400F6FF70040B4FF0805073
|
||||
:100150000022090303692403406943431D1B104621
|
||||
:1001600000F048FA29462046BDE8704000F042BA47
|
||||
:10017000F0B54FF6FF734FF4B4751A466E1E11E0DA
|
||||
:10018000A94201D3344600E00C46091B30F8027B3B
|
||||
:10019000641E3B441A44F9D19CB204EB134394B25D
|
||||
:1001A00004EB12420029EBD198B200EB134002EBB2
|
||||
:1001B000124140EA0140F0BDF34992B00446D1E952
|
||||
:1001C0000001CDE91001FF224021684600F0F4FB58
|
||||
:1001D00094E80F008DE80F00684610A902E004C8FB
|
||||
:1001E00041F8042D8842FAD110216846FFF7C0FF7C
|
||||
:1001F0001090AA208DF8440000F099F9FFF78AFFCB
|
||||
:1002000040F6FC7420684FF01025401C0FD0206889
|
||||
:1002100010226946803000F078F92068401C08D030
|
||||
:100220002068082210A900F070F900F061F9A869AF
|
||||
:10023000EEE7A869F5E74FF080500369406940F6A2
|
||||
:10024000FC71434308684FF01022401C06D0086838
|
||||
:1002500000F58050834203D2092070479069F7E788
|
||||
:100260000868401C04D00868401C03D00020704778
|
||||
:100270009069F9E70420704770B504460068C34DE3
|
||||
:10028000072876D2DFE800F033041929631E250021
|
||||
:10029000D4E9026564682946304600F062F92A46CE
|
||||
:1002A0002146304600F031F9AA002146304600F0E0
|
||||
:1002B00057FB002800D0032070BD00F009FC4FF46C
|
||||
:1002C000805007E0201D00F040F90028F4D100F034
|
||||
:1002D000FFFB60682860002070BD241D94E80700C3
|
||||
:1002E000920000F03DFB0028F6D00E2070BDFFF715
|
||||
:1002F000A2FF0028FAD1D4E901034FF0805100EBAE
|
||||
:10030000830208694D69684382420ED840F6F8704E
|
||||
:1003100005684FF010226D1C09D0056805EB8305B8
|
||||
:100320000B6949694B439D4203D9092070BD55694A
|
||||
:10033000F4E70168491C03D00068401C02D003E0C8
|
||||
:100340005069FAE70F2070BD2046FFF735FFFFF731
|
||||
:1003500072FF0028F7D1201D00F0F7F80028F2D135
|
||||
:1003600060680028F0D100F0E2F8FFF7D3FE00F05B
|
||||
:10037000BFF8072070BD10B50C46182802D0012028
|
||||
:10038000086010BD2068FFF777FF206010BD41684E
|
||||
:10039000054609B1012700E0002740F6F8742068FF
|
||||
:1003A0004FF01026401C2BD02068AA68920000F065
|
||||
:1003B000D7FA38B3A86881002068401C27D020688D
|
||||
:1003C000FFF7BDFED7B12068401C22D026684FF051
|
||||
:1003D0008050AC686D68016942695143A9420DD9EA
|
||||
:1003E000016940694143A14208D92146304600F0E5
|
||||
:1003F000B8F822462946304600F087F800F078F831
|
||||
:100400007069D2E700F093F8FFF784FEF6E77069B1
|
||||
:10041000D6E77669DBE740F6FC7420684FF01026DB
|
||||
:10042000401C23D02068401C0CD02068401C1FD0EA
|
||||
:100430002568206805F18005401C1BD027683879A5
|
||||
:10044000AA2819D040F6F8700168491C42D001680A
|
||||
:10045000491C45D00168491C3ED001680968491C07
|
||||
:100460003ED00168491C39D000683EE0B069DAE747
|
||||
:10047000B569DEE7B769E2E710212846FFF778FEA5
|
||||
:100480003968814222D12068401C05D0D4F8001080
|
||||
:1004900001F18002C03107E0B169F9E730B108CA63
|
||||
:1004A00051F8040D984201D1012000E000208A4259
|
||||
:1004B000F4D158B1286810B1042803D0FEE72846CB
|
||||
:1004C000FFF765FF3149686808600EE0FFF722FE1C
|
||||
:1004D00000F00EF87169BBE77169BFE7706904E06D
|
||||
:1004E0004FF480500168491C01D000F0CBFAFEE7C0
|
||||
:1004F000BFF34F8F26480168264A01F4E06111439B
|
||||
:100500000160BFF34F8F00BFFDE72DE9F0411746B3
|
||||
:100510000D460646002406E03046296800F054F8EF
|
||||
:10052000641C2D1D361DBC42F6D3BDE8F08140F69B
|
||||
:10053000FC700168491C04D0D0F800004FF48051D1
|
||||
:10054000FDE54FF010208069F8E74FF080510A690F
|
||||
:10055000496900684A43824201D810207047002050
|
||||
:10056000704770B50C4605464FF4806608E0284693
|
||||
:1005700000F017F8B44205D3A4F5806405F5805562
|
||||
:10058000002CF4D170BD0000F40A0000000000202F
|
||||
:100590000CED00E00400FA05144801680029FCD0C5
|
||||
:1005A0007047134A0221116010490B68002BFCD0E0
|
||||
:1005B0000F4B1B1D186008680028FCD0002010603D
|
||||
:1005C00008680028FCD07047094B10B501221A605A
|
||||
:1005D000064A1468002CFCD0016010680028FCD08A
|
||||
:1005E0000020186010680028FCD010BD00E4014015
|
||||
:1005F00004E5014070B50C46054600F073F810B9EB
|
||||
:1006000000F07EF828B121462846BDE8704000F091
|
||||
:1006100007B821462846BDE8704000F037B8000012
|
||||
:100620007FB5002200920192029203920A0B000B06
|
||||
:100630006946012302440AE0440900F01F0651F80C
|
||||
:10064000245003FA06F6354341F82450401C8242F8
|
||||
:10065000F2D80D490868009A10430860081D016827
|
||||
:10066000019A1143016000F03DF800280AD00649C4
|
||||
:1006700010310868029A10430860091D0868039A3F
|
||||
:10068000104308607FBD00000006004030B50F4CED
|
||||
:10069000002200BF04EB0213D3F800582DB9D3F8A1
|
||||
:1006A000045815B9D3F808581DB1521C082AF1D3C3
|
||||
:1006B00030BD082AFCD204EB0212C2F80008C3F8CD
|
||||
:1006C00004180220C3F8080830BD000000E0014013
|
||||
:1006D0004FF08050D0F83001082801D0002070473A
|
||||
:1006E000012070474FF08050D0F83011062905D016
|
||||
:1006F000D0F83001401C01D0002070470120704725
|
||||
:100700004FF08050D0F830010A2801D00020704707
|
||||
:100710000120704708208F490968095808471020B0
|
||||
:100720008C4909680958084714208A4909680958FA
|
||||
:100730000847182087490968095808473020854923
|
||||
:100740000968095808473820824909680958084744
|
||||
:100750003C20804909680958084740207D490968BC
|
||||
:100760000958084744207B49096809580847482028
|
||||
:1007700078490968095808474C207649096809589A
|
||||
:10078000084750207349096809580847542071499F
|
||||
:1007900009680958084758206E49096809580847E8
|
||||
:1007A0005C206C4909680958084760206949096854
|
||||
:1007B00009580847642067490968095808476820AC
|
||||
:1007C00064490968095808476C2062490968095852
|
||||
:1007D000084770205F4909680958084774205D4937
|
||||
:1007E00009680958084778205A490968095808478C
|
||||
:1007F0007C205849096809580847802055490968EC
|
||||
:10080000095808478420534909680958084788202F
|
||||
:1008100050490968095808478C204E490968095809
|
||||
:10082000084790204B4909680958084794204949CE
|
||||
:10083000096809580847982046490968095808472F
|
||||
:100840009C204449096809580847A0204149096883
|
||||
:1008500009580847A4203F49096809580847A820B3
|
||||
:100860003C49096809580847AC203A4909680958C1
|
||||
:100870000847B0203749096809580847B420354966
|
||||
:10088000096809580847B8203249096809580847D3
|
||||
:10089000BC203049096809580847C0202D4909681B
|
||||
:1008A00009580847C4202B49096809580847C82037
|
||||
:1008B0002849096809580847CC2026490968095879
|
||||
:1008C0000847D0202349096809580847D4202149FE
|
||||
:1008D000096809580847D8201E4909680958084777
|
||||
:1008E000DC201C49096809580847E02019490968B3
|
||||
:1008F00009580847E4201749096809580847E820BB
|
||||
:100900001449096809580847EC2012490968095830
|
||||
:100910000847F0200F49096809580847F4200D4995
|
||||
:10092000096809580847F8200A490968095808471A
|
||||
:10093000FC2008490968095808475FF48070054998
|
||||
:10094000096809580847000003480449024A034B54
|
||||
:100950007047000000000020000B0000000B0000AA
|
||||
:1009600040EA010310B59B070FD1042A0DD310C82C
|
||||
:1009700008C9121F9C42F8D020BA19BA884201D97E
|
||||
:10098000012010BD4FF0FF3010BD1AB1D30703D0C6
|
||||
:10099000521C07E0002010BD10F8013B11F8014B7C
|
||||
:1009A0001B1B07D110F8013B11F8014B1B1B01D198
|
||||
:1009B000921EF1D1184610BD02F0FF0343EA032254
|
||||
:1009C00042EA024200F005B87047704770474FF0A6
|
||||
:1009D00000020429C0F0128010F0030C00F01B800C
|
||||
:1009E000CCF1040CBCF1020F18BF00F8012BA8BF1A
|
||||
:1009F00020F8022BA1EB0C0100F00DB85FEAC17CDE
|
||||
:100A000024BF00F8012B00F8012B48BF00F8012B90
|
||||
:100A100070474FF0000200B51346944696462039C1
|
||||
:100A200022BFA0E80C50A0E80C50B1F12001BFF4A7
|
||||
:100A3000F7AF090728BFA0E80C5048BF0CC05DF80D
|
||||
:100A400004EB890028BF40F8042B08BF704748BF5B
|
||||
:100A500020F8022B11F0804F18BF00F8012B7047CF
|
||||
:100A6000014B1B68DB6818470000002009480A4951
|
||||
:100A70007047FFF7FBFFFFF745FB00BD20BFFDE719
|
||||
:100A8000064B1847064A1060016881F308884068E1
|
||||
:100A900000470000000B0000000B000017040000DE
|
||||
:100AA000000000201EF0040F0CBFEFF30881EFF3ED
|
||||
:100AB0000981886902380078182803D100E0000015
|
||||
:100AC000074A1047074A12682C3212681047000084
|
||||
:100AD00000B5054B1B68054A9B58984700BD0000B0
|
||||
:100AE0007703000000000020F00A0000040000006E
|
||||
:100AF000001000000000000000FFFFFF0090D00386
|
||||
:0400000500000A816C
|
||||
:00000001FF
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Binary file not shown.
+18
@@ -123,6 +123,7 @@ enum BLE_COMMON_OPTS
|
||||
BLE_COMMON_OPT_PA_LNA = BLE_OPT_BASE + 0, /**< PA and LNA options */
|
||||
BLE_COMMON_OPT_CONN_EVT_EXT = BLE_OPT_BASE + 1, /**< Extended connection events option */
|
||||
BLE_COMMON_OPT_EXTENDED_RC_CAL = BLE_OPT_BASE + 2, /**< Extended RC calibration option */
|
||||
BLE_COMMON_OPT_ADV_SCHED_CFG = BLE_OPT_BASE + 3, /**< Advertiser role scheduling configuration option */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
@@ -146,6 +147,12 @@ enum BLE_COMMON_OPTS
|
||||
offsetof(ble_evt_t, evt.gattc_evt.params.prim_srvc_disc_rsp.services) + ((ATT_MTU) - 1) / 4 * sizeof(ble_gattc_service_t) \
|
||||
)
|
||||
|
||||
/** @defgroup ADV_SCHED_CFG Advertiser Role Scheduling Configuration
|
||||
* @{ */
|
||||
#define ADV_SCHED_CFG_DEFAULT 0 /**< Default advertiser role scheduling configuration. */
|
||||
#define ADV_SCHED_CFG_IMPROVED 1 /**< Improved advertiser role scheduling configuration in which the housekeeping time is reduced. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_USER_MEM_TYPES User Memory Types
|
||||
* @{ */
|
||||
#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
|
||||
@@ -303,12 +310,23 @@ typedef struct
|
||||
uint8_t enable : 1; /**< Enable extended RC calibration, enabled by default. */
|
||||
} ble_common_opt_extended_rc_cal_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration of BLE advertiser role scheduling.
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sched_cfg; /**< See @ref ADV_SCHED_CFG. */
|
||||
} ble_common_opt_adv_sched_cfg_t;
|
||||
|
||||
/**@brief Option structure for common options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */
|
||||
ble_common_opt_conn_evt_ext_t conn_evt_ext; /**< Parameters for enabling extended connection events. */
|
||||
ble_common_opt_extended_rc_cal_t extended_rc_cal; /**< Parameters for enabling extended RC calibration. */
|
||||
ble_common_opt_adv_sched_cfg_t adv_sched_cfg; /**< Parameters for configuring advertiser role scheduling. */
|
||||
} ble_common_opt_t;
|
||||
|
||||
/**@brief Common BLE Option type, wrapping the module specific options. */
|
||||
File renamed without changes.
+7
-2
@@ -876,8 +876,10 @@ typedef struct
|
||||
the bitfield indicates the PHYs the scanner will use for scanning
|
||||
on primary advertising channels. The scanner will accept
|
||||
@ref BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs.
|
||||
- When used with @ref sd_ble_gap_connect, the
|
||||
bitfield indicates the PHYs on where a connection may be initiated.
|
||||
- When used with @ref sd_ble_gap_connect, the bitfield indicates
|
||||
the PHYs the initiator will use for scanning on primary advertising
|
||||
channels. The initiator will accept connections initiated on either
|
||||
of the @ref BLE_GAP_PHYS_SUPPORTED PHYs.
|
||||
If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS,
|
||||
the primary scan PHY is @ref BLE_GAP_PHY_1MBPS.
|
||||
If scan_phys also contains @ref BLE_GAP_PHY_CODED, the primary scan
|
||||
@@ -2610,6 +2612,9 @@ SVCALL(SD_BLE_GAP_PHY_UPDATE, uint32_t, sd_ble_gap_phy_update(uint16_t conn_hand
|
||||
* @note If the application uses @ref BLE_GAP_DATA_LENGTH_AUTO for one or more members of
|
||||
* p_dl_params, the SoftDevice will choose the highest value supported in current
|
||||
* configuration and connection parameters.
|
||||
* @note If the link PHY is Coded, the SoftDevice will ensure that the MaxTxTime and/or MaxRxTime
|
||||
* used in the Data Length Update procedure is at least 2704 us. Otherwise, MaxTxTime and
|
||||
* MaxRxTime will be limited to maximum 2120 us.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_dl_params Pointer to local parameters to be used in Data Length Update
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+268
-242
@@ -1,242 +1,268 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE (0x18)
|
||||
|
||||
/**@brief Page size in words. */
|
||||
#define MBR_PAGE_SIZE_IN_WORDS (1024)
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash.
|
||||
This is the offset where the first byte of the SoftDevice hex file is written.*/
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
SD_MBR_COMMAND_RESERVED,
|
||||
SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
*
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the BPROT registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/
|
||||
} sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory. */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory. */
|
||||
uint32_t len; /**< Number of 32 bit words to compare.*/
|
||||
} sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
*
|
||||
* With this command, destination of BootLoader is always the address written in
|
||||
* NRF_UICR->BOOTADDR.
|
||||
*
|
||||
* Destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This function will use the flash protect peripheral (BPROT or ACL) to protect the flash that is
|
||||
* not intended to be written.
|
||||
*
|
||||
* On success, this function will not return. It will start the new BootLoader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Change the address the MBR starts after a reset
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward
|
||||
* interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding this function should be called with @ref address set to 0. The
|
||||
* MBR will then start forwarding interrupts to the address in NFR_UICR->BOOTADDR or to the
|
||||
* SoftDevice if the BOOTADDR is not set.
|
||||
*
|
||||
* On success, this function will not return. It will reset the device.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not
|
||||
* change where the MBR starts after reset.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_irq_forward_address_set_t;
|
||||
|
||||
/**@brief Input structure containing data used when calling ::sd_mbr_command
|
||||
*
|
||||
* Depending on what command value that is set, the corresponding params value type must also be
|
||||
* set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command
|
||||
* @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/
|
||||
sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/
|
||||
} params; /**< Command parameters. */
|
||||
} sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader.
|
||||
*
|
||||
* The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires
|
||||
* parameters to be retained by the MBR when resetting the IC. This is done in a separate flash
|
||||
* page provided by the application. The UICR register UICR.NRFFW[1] must be set to an address
|
||||
* corresponding to a page in the application flash space. This page will be cleared by the MBR and
|
||||
* used to store the command before reset. When the UICR.NRFFW[1] field is set the page it refers
|
||||
* to must not be used by the application. If the UICR.NRFFW[1] is set to 0xFFFFFFFF (the default)
|
||||
* MBR commands which use flash will be unavailable and return @ref NRF_ERROR_NO_MEM.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
* @note For return values, see ::sd_mbr_command_copy_sd_t, ::sd_mbr_command_copy_bl_t,
|
||||
* ::sd_mbr_command_compare_t, ::sd_mbr_command_vector_table_base_set_t,
|
||||
* ::sd_mbr_command_irq_forward_address_set_t
|
||||
*
|
||||
* @retval ::NRF_ERROR_NO_MEM if UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF).
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given.
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE (0x18)
|
||||
|
||||
/**@brief Page size in words. */
|
||||
#define MBR_PAGE_SIZE_IN_WORDS (1024)
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash.
|
||||
This is the offset where the first byte of the SoftDevice hex file is written. */
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @brief Location (in the flash memory) of the bootloader address. */
|
||||
#define MBR_BOOTLOADER_ADDR (0xFF8)
|
||||
|
||||
/** @brief Location (in UICR) of the bootloader address. */
|
||||
#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0]))
|
||||
|
||||
/** @brief Location (in the flash memory) of the address of the MBR parameter page. */
|
||||
#define MBR_PARAM_PAGE_ADDR (0xFFC)
|
||||
|
||||
/** @brief Location (in UICR) of the address of the MBR parameter page. */
|
||||
#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1]))
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
SD_MBR_COMMAND_RESERVED,
|
||||
SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
*
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the BPROT registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/
|
||||
} sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory. */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory. */
|
||||
uint32_t len; /**< Number of 32 bit words to compare.*/
|
||||
} sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
*
|
||||
* The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to
|
||||
* the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* The bootloader destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is
|
||||
* not intended to be written.
|
||||
*
|
||||
* On success, this function will not return. It will start the new bootloader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Change the address the MBR starts after a reset
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward
|
||||
* interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding, this function should be called with @ref address set to 0. If a
|
||||
* bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will
|
||||
* be forwarded to the SoftDevice.
|
||||
*
|
||||
* The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or
|
||||
* @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* On success, this function will not return. It will reset the device.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not
|
||||
* change where the MBR starts after reset.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_irq_forward_address_set_t;
|
||||
|
||||
/**@brief Input structure containing data used when calling ::sd_mbr_command
|
||||
*
|
||||
* Depending on what command value that is set, the corresponding params value type must also be
|
||||
* set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command
|
||||
* @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/
|
||||
sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/
|
||||
} params; /**< Command parameters. */
|
||||
} sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader.
|
||||
*
|
||||
* The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires
|
||||
* parameters to be retained by the MBR when resetting the IC. This is done in a separate flash
|
||||
* page. The location of the flash page should be provided by the application in either
|
||||
* @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR
|
||||
* will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to
|
||||
* store the command before reset. When an address is specified, the page it refers to must not be
|
||||
* used by the application. If no address is provided by the application, i.e. both
|
||||
* @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use
|
||||
* flash will be unavailable and return @ref NRF_ERROR_NO_MEM.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
* @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t,
|
||||
* ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t,
|
||||
* ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t
|
||||
*
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given.
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -73,7 +73,7 @@ extern "C" {
|
||||
#define SD_MINOR_VERSION (1)
|
||||
|
||||
/** @brief The bugfix version for the SoftDevice binary distributed with this header file. */
|
||||
#define SD_BUGFIX_VERSION (0)
|
||||
#define SD_BUGFIX_VERSION (1)
|
||||
|
||||
/** @brief The SoftDevice variant of this firmware. */
|
||||
#define SD_VARIANT_ID 140
|
||||
File renamed without changes.
File renamed without changes.
+35
-35
@@ -1,35 +1,35 @@
|
||||
Copyright (c) 2007 - 2018, Nordic Semiconductor ASA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form, except as embedded into a Nordic
|
||||
Semiconductor ASA integrated circuit in a product or a software update for
|
||||
such product, must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
4. This software, with or without modification, must only be used with a
|
||||
Nordic Semiconductor ASA integrated circuit.
|
||||
|
||||
5. Any software provided in binary form under this license must not be reverse
|
||||
engineered, decompiled, modified and/or disassembled.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Copyright (c) 2007 - 2020, Nordic Semiconductor ASA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form, except as embedded into a Nordic
|
||||
Semiconductor ASA integrated circuit in a product or a software update for
|
||||
such product, must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
4. This software, with or without modification, must only be used with a
|
||||
Nordic Semiconductor ASA integrated circuit.
|
||||
|
||||
5. Any software provided in binary form under this license must not be reverse
|
||||
engineered, decompiled, modified and/or disassembled.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
File diff suppressed because it is too large.
Load diff
+30
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -89,8 +89,9 @@ enum BLE_COMMON_SVCS
|
||||
*/
|
||||
enum BLE_COMMON_EVTS
|
||||
{
|
||||
BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE + 0, /**< User Memory request. @ref ble_evt_user_mem_request_t */
|
||||
BLE_EVT_USER_MEM_RELEASE = BLE_EVT_BASE + 1, /**< User Memory release. @ref ble_evt_user_mem_release_t */
|
||||
BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE + 0, /**< User Memory request. See @ref ble_evt_user_mem_request_t
|
||||
\n Reply with @ref sd_ble_user_mem_reply. */
|
||||
BLE_EVT_USER_MEM_RELEASE = BLE_EVT_BASE + 1, /**< User Memory release. See @ref ble_evt_user_mem_release_t */
|
||||
};
|
||||
|
||||
/**@brief BLE Connection Configuration IDs.
|
||||
@@ -316,6 +317,7 @@ typedef union
|
||||
{
|
||||
ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */
|
||||
ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */
|
||||
ble_gattc_opt_t gattc_opt; /**< GATTC option, opt_id in @ref BLE_GATTC_OPTS series. */
|
||||
} ble_opt_t;
|
||||
|
||||
/**@brief BLE connection configuration type, wrapping the module specific configurations, set with
|
||||
@@ -388,6 +390,21 @@ typedef union
|
||||
* application RAM region (APP_RAM_BASE). On return, this will
|
||||
* contain the minimum start address of the application RAM region
|
||||
* required by the SoftDevice for this configuration.
|
||||
* @warning After this call, the SoftDevice may generate several events. The list of events provided
|
||||
* below require the application to initiate a SoftDevice API call. The corresponding API call
|
||||
* is referenced in the event documentation.
|
||||
* If the application fails to do so, the BLE connection may timeout, or the SoftDevice may stop
|
||||
* communicating with the peer device.
|
||||
* - @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST
|
||||
* - @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST
|
||||
* - @ref BLE_GAP_EVT_PHY_UPDATE_REQUEST
|
||||
* - @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST
|
||||
* - @ref BLE_GAP_EVT_SEC_INFO_REQUEST
|
||||
* - @ref BLE_GAP_EVT_SEC_REQUEST
|
||||
* - @ref BLE_GAP_EVT_AUTH_KEY_REQUEST
|
||||
* - @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST
|
||||
* - @ref BLE_EVT_USER_MEM_REQUEST
|
||||
* - @ref BLE_L2CAP_EVT_CH_SETUP_REQUEST
|
||||
*
|
||||
* @note The memory requirement for a specific configuration will not increase between SoftDevices
|
||||
* with the same major version number.
|
||||
@@ -521,31 +538,30 @@ SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_v
|
||||
|
||||
|
||||
/**@brief Remove a Vendor Specific base UUID.
|
||||
*
|
||||
* @details This call removes a Vendor Specific base UUID that has been added with @ref sd_ble_uuid_vs_add. This function allows
|
||||
*
|
||||
* @details This call removes a Vendor Specific base UUID. This function allows
|
||||
* the application to reuse memory allocated for Vendor Specific base UUIDs.
|
||||
*
|
||||
* @note Currently this function can only be called with a p_uuid_type set to @ref BLE_UUID_TYPE_UNKNOWN or the last added UUID type.
|
||||
*
|
||||
* @param[in] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t::type corresponds to the UUID type that
|
||||
* shall be removed. If the type is set to @ref BLE_UUID_TYPE_UNKNOWN, or the pointer is NULL, the last
|
||||
* Vendor Specific base UUID will be removed.
|
||||
* @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponds to the UUID type that was
|
||||
* removed. If function returns with a failure, it contains the last type that is in use by the ATT Server.
|
||||
* @param[inout] p_uuid_type Pointer to a uint8_t where its value matches the UUID type in @ref ble_uuid_t::type to be removed.
|
||||
* If the type is set to @ref BLE_UUID_TYPE_UNKNOWN, or the pointer is NULL, the last Vendor Specific
|
||||
* base UUID will be removed. If the function returns successfully, the UUID type that was removed will
|
||||
* be written back to @p p_uuid_type. If function returns with a failure, it contains the last type that
|
||||
* is in use by the ATT Server.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully removed the Vendor Specific base UUID.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If p_uuid_type is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM If p_uuid_type points to a non-valid UUID type.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If the Vendor Specific base UUID is in use by the ATT Server.
|
||||
*/
|
||||
|
||||
SVCALL(SD_BLE_UUID_VS_REMOVE, uint32_t, sd_ble_uuid_vs_remove(uint8_t *p_uuid_type));
|
||||
|
||||
|
||||
/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
|
||||
*
|
||||
* @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
|
||||
* to the corresponding ones in each entry of the table of Vendor Specific base UUIDs populated with @ref sd_ble_uuid_vs_add
|
||||
* to the corresponding ones in each entry of the table of Vendor Specific base UUIDs
|
||||
* to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
|
||||
* relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
|
||||
*
|
||||
@@ -620,12 +636,8 @@ SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_hand
|
||||
*
|
||||
* @details This call allows the application to set the value of an option.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
|
||||
* @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS, @ref BLE_GAP_OPTS, and @ref BLE_GATTC_OPTS.
|
||||
* @param[in] p_opt Pointer to a @ref ble_opt_t structure containing the option value.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option set successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
+262
-74
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -64,46 +64,49 @@ extern "C" {
|
||||
*/
|
||||
enum BLE_GAP_SVCS
|
||||
{
|
||||
SD_BLE_GAP_ADDR_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */
|
||||
SD_BLE_GAP_ADDR_GET = BLE_GAP_SVC_BASE + 1, /**< Get own Bluetooth Address. */
|
||||
SD_BLE_GAP_WHITELIST_SET = BLE_GAP_SVC_BASE + 2, /**< Set active whitelist. */
|
||||
SD_BLE_GAP_DEVICE_IDENTITIES_SET = BLE_GAP_SVC_BASE + 3, /**< Set device identity list. */
|
||||
SD_BLE_GAP_PRIVACY_SET = BLE_GAP_SVC_BASE + 4, /**< Set Privacy settings*/
|
||||
SD_BLE_GAP_PRIVACY_GET = BLE_GAP_SVC_BASE + 5, /**< Get Privacy settings*/
|
||||
SD_BLE_GAP_ADV_SET_CONFIGURE = BLE_GAP_SVC_BASE + 6, /**< Configure an advertising set. */
|
||||
SD_BLE_GAP_ADV_START = BLE_GAP_SVC_BASE + 7, /**< Start Advertising. */
|
||||
SD_BLE_GAP_ADV_STOP = BLE_GAP_SVC_BASE + 8, /**< Stop Advertising. */
|
||||
SD_BLE_GAP_CONN_PARAM_UPDATE = BLE_GAP_SVC_BASE + 9, /**< Connection Parameter Update. */
|
||||
SD_BLE_GAP_DISCONNECT = BLE_GAP_SVC_BASE + 10, /**< Disconnect. */
|
||||
SD_BLE_GAP_TX_POWER_SET = BLE_GAP_SVC_BASE + 11, /**< Set TX Power. */
|
||||
SD_BLE_GAP_APPEARANCE_SET = BLE_GAP_SVC_BASE + 12, /**< Set Appearance. */
|
||||
SD_BLE_GAP_APPEARANCE_GET = BLE_GAP_SVC_BASE + 13, /**< Get Appearance. */
|
||||
SD_BLE_GAP_PPCP_SET = BLE_GAP_SVC_BASE + 14, /**< Set PPCP. */
|
||||
SD_BLE_GAP_PPCP_GET = BLE_GAP_SVC_BASE + 15, /**< Get PPCP. */
|
||||
SD_BLE_GAP_DEVICE_NAME_SET = BLE_GAP_SVC_BASE + 16, /**< Set Device Name. */
|
||||
SD_BLE_GAP_DEVICE_NAME_GET = BLE_GAP_SVC_BASE + 17, /**< Get Device Name. */
|
||||
SD_BLE_GAP_AUTHENTICATE = BLE_GAP_SVC_BASE + 18, /**< Initiate Pairing/Bonding. */
|
||||
SD_BLE_GAP_SEC_PARAMS_REPLY = BLE_GAP_SVC_BASE + 19, /**< Reply with Security Parameters. */
|
||||
SD_BLE_GAP_AUTH_KEY_REPLY = BLE_GAP_SVC_BASE + 20, /**< Reply with an authentication key. */
|
||||
SD_BLE_GAP_LESC_DHKEY_REPLY = BLE_GAP_SVC_BASE + 21, /**< Reply with an LE Secure Connections DHKey. */
|
||||
SD_BLE_GAP_KEYPRESS_NOTIFY = BLE_GAP_SVC_BASE + 22, /**< Notify of a keypress during an authentication procedure. */
|
||||
SD_BLE_GAP_LESC_OOB_DATA_GET = BLE_GAP_SVC_BASE + 23, /**< Get the local LE Secure Connections OOB data. */
|
||||
SD_BLE_GAP_LESC_OOB_DATA_SET = BLE_GAP_SVC_BASE + 24, /**< Set the remote LE Secure Connections OOB data. */
|
||||
SD_BLE_GAP_ENCRYPT = BLE_GAP_SVC_BASE + 25, /**< Initiate encryption procedure. */
|
||||
SD_BLE_GAP_SEC_INFO_REPLY = BLE_GAP_SVC_BASE + 26, /**< Reply with Security Information. */
|
||||
SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 27, /**< Obtain connection security level. */
|
||||
SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 28, /**< Start reporting of changes in RSSI. */
|
||||
SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 29, /**< Stop reporting of changes in RSSI. */
|
||||
SD_BLE_GAP_SCAN_START = BLE_GAP_SVC_BASE + 30, /**< Start Scanning. */
|
||||
SD_BLE_GAP_SCAN_STOP = BLE_GAP_SVC_BASE + 31, /**< Stop Scanning. */
|
||||
SD_BLE_GAP_CONNECT = BLE_GAP_SVC_BASE + 32, /**< Connect. */
|
||||
SD_BLE_GAP_CONNECT_CANCEL = BLE_GAP_SVC_BASE + 33, /**< Cancel ongoing connection procedure. */
|
||||
SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 34, /**< Get the last RSSI sample. */
|
||||
SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 35, /**< Initiate or respond to a PHY Update Procedure. */
|
||||
SD_BLE_GAP_DATA_LENGTH_UPDATE = BLE_GAP_SVC_BASE + 36, /**< Initiate or respond to a Data Length Update Procedure. */
|
||||
SD_BLE_GAP_QOS_CHANNEL_SURVEY_START = BLE_GAP_SVC_BASE + 37, /**< Start Quality of Service (QoS) channel survey module. */
|
||||
SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP = BLE_GAP_SVC_BASE + 38, /**< Stop Quality of Service (QoS) channel survey module. */
|
||||
SD_BLE_GAP_ADV_ADDR_GET = BLE_GAP_SVC_BASE + 39, /**< Get the Address used on air while Advertising. */
|
||||
SD_BLE_GAP_ADDR_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */
|
||||
SD_BLE_GAP_ADDR_GET = BLE_GAP_SVC_BASE + 1, /**< Get own Bluetooth Address. */
|
||||
SD_BLE_GAP_WHITELIST_SET = BLE_GAP_SVC_BASE + 2, /**< Set active whitelist. */
|
||||
SD_BLE_GAP_DEVICE_IDENTITIES_SET = BLE_GAP_SVC_BASE + 3, /**< Set device identity list. */
|
||||
SD_BLE_GAP_PRIVACY_SET = BLE_GAP_SVC_BASE + 4, /**< Set Privacy settings*/
|
||||
SD_BLE_GAP_PRIVACY_GET = BLE_GAP_SVC_BASE + 5, /**< Get Privacy settings*/
|
||||
SD_BLE_GAP_ADV_SET_CONFIGURE = BLE_GAP_SVC_BASE + 6, /**< Configure an advertising set. */
|
||||
SD_BLE_GAP_ADV_START = BLE_GAP_SVC_BASE + 7, /**< Start Advertising. */
|
||||
SD_BLE_GAP_ADV_STOP = BLE_GAP_SVC_BASE + 8, /**< Stop Advertising. */
|
||||
SD_BLE_GAP_CONN_PARAM_UPDATE = BLE_GAP_SVC_BASE + 9, /**< Connection Parameter Update. */
|
||||
SD_BLE_GAP_DISCONNECT = BLE_GAP_SVC_BASE + 10, /**< Disconnect. */
|
||||
SD_BLE_GAP_TX_POWER_SET = BLE_GAP_SVC_BASE + 11, /**< Set TX Power. */
|
||||
SD_BLE_GAP_APPEARANCE_SET = BLE_GAP_SVC_BASE + 12, /**< Set Appearance. */
|
||||
SD_BLE_GAP_APPEARANCE_GET = BLE_GAP_SVC_BASE + 13, /**< Get Appearance. */
|
||||
SD_BLE_GAP_PPCP_SET = BLE_GAP_SVC_BASE + 14, /**< Set PPCP. */
|
||||
SD_BLE_GAP_PPCP_GET = BLE_GAP_SVC_BASE + 15, /**< Get PPCP. */
|
||||
SD_BLE_GAP_DEVICE_NAME_SET = BLE_GAP_SVC_BASE + 16, /**< Set Device Name. */
|
||||
SD_BLE_GAP_DEVICE_NAME_GET = BLE_GAP_SVC_BASE + 17, /**< Get Device Name. */
|
||||
SD_BLE_GAP_AUTHENTICATE = BLE_GAP_SVC_BASE + 18, /**< Initiate Pairing/Bonding. */
|
||||
SD_BLE_GAP_SEC_PARAMS_REPLY = BLE_GAP_SVC_BASE + 19, /**< Reply with Security Parameters. */
|
||||
SD_BLE_GAP_AUTH_KEY_REPLY = BLE_GAP_SVC_BASE + 20, /**< Reply with an authentication key. */
|
||||
SD_BLE_GAP_LESC_DHKEY_REPLY = BLE_GAP_SVC_BASE + 21, /**< Reply with an LE Secure Connections DHKey. */
|
||||
SD_BLE_GAP_KEYPRESS_NOTIFY = BLE_GAP_SVC_BASE + 22, /**< Notify of a keypress during an authentication procedure. */
|
||||
SD_BLE_GAP_LESC_OOB_DATA_GET = BLE_GAP_SVC_BASE + 23, /**< Get the local LE Secure Connections OOB data. */
|
||||
SD_BLE_GAP_LESC_OOB_DATA_SET = BLE_GAP_SVC_BASE + 24, /**< Set the remote LE Secure Connections OOB data. */
|
||||
SD_BLE_GAP_ENCRYPT = BLE_GAP_SVC_BASE + 25, /**< Initiate encryption procedure. */
|
||||
SD_BLE_GAP_SEC_INFO_REPLY = BLE_GAP_SVC_BASE + 26, /**< Reply with Security Information. */
|
||||
SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 27, /**< Obtain connection security level. */
|
||||
SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 28, /**< Start reporting of changes in RSSI. */
|
||||
SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 29, /**< Stop reporting of changes in RSSI. */
|
||||
SD_BLE_GAP_SCAN_START = BLE_GAP_SVC_BASE + 30, /**< Start Scanning. */
|
||||
SD_BLE_GAP_SCAN_STOP = BLE_GAP_SVC_BASE + 31, /**< Stop Scanning. */
|
||||
SD_BLE_GAP_CONNECT = BLE_GAP_SVC_BASE + 32, /**< Connect. */
|
||||
SD_BLE_GAP_CONNECT_CANCEL = BLE_GAP_SVC_BASE + 33, /**< Cancel ongoing connection procedure. */
|
||||
SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 34, /**< Get the last RSSI sample. */
|
||||
SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 35, /**< Initiate or respond to a PHY Update Procedure. */
|
||||
SD_BLE_GAP_DATA_LENGTH_UPDATE = BLE_GAP_SVC_BASE + 36, /**< Initiate or respond to a Data Length Update Procedure. */
|
||||
SD_BLE_GAP_QOS_CHANNEL_SURVEY_START = BLE_GAP_SVC_BASE + 37, /**< Start Quality of Service (QoS) channel survey module. */
|
||||
SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP = BLE_GAP_SVC_BASE + 38, /**< Stop Quality of Service (QoS) channel survey module. */
|
||||
SD_BLE_GAP_ADV_ADDR_GET = BLE_GAP_SVC_BASE + 39, /**< Get the Address used on air while Advertising. */
|
||||
SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET = BLE_GAP_SVC_BASE + 40, /**< Get the next connection event counter. */
|
||||
SD_BLE_GAP_CONN_EVT_TRIGGER_START = BLE_GAP_SVC_BASE + 41, /** Start triggering a given task on connection event start. */
|
||||
SD_BLE_GAP_CONN_EVT_TRIGGER_STOP = BLE_GAP_SVC_BASE + 42, /** Stop triggering the task configured using @ref sd_ble_gap_conn_evt_trigger_start. */
|
||||
};
|
||||
|
||||
/**@brief GAP Event IDs.
|
||||
@@ -125,12 +128,14 @@ enum BLE_GAP_EVTS
|
||||
BLE_GAP_EVT_TIMEOUT = BLE_GAP_EVT_BASE + 11, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */
|
||||
BLE_GAP_EVT_RSSI_CHANGED = BLE_GAP_EVT_BASE + 12, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */
|
||||
BLE_GAP_EVT_ADV_REPORT = BLE_GAP_EVT_BASE + 13, /**< Advertising report. \n See @ref ble_gap_evt_adv_report_t. */
|
||||
BLE_GAP_EVT_SEC_REQUEST = BLE_GAP_EVT_BASE + 14, /**< Security Request. \n See @ref ble_gap_evt_sec_request_t. */
|
||||
BLE_GAP_EVT_SEC_REQUEST = BLE_GAP_EVT_BASE + 14, /**< Security Request. \n Reply with @ref sd_ble_gap_authenticate
|
||||
\n or with @ref sd_ble_gap_encrypt if required security information is available
|
||||
. \n See @ref ble_gap_evt_sec_request_t. */
|
||||
BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 15, /**< Connection Parameter Update Request. \n Reply with @ref sd_ble_gap_conn_param_update. \n See @ref ble_gap_evt_conn_param_update_request_t. */
|
||||
BLE_GAP_EVT_SCAN_REQ_REPORT = BLE_GAP_EVT_BASE + 16, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */
|
||||
BLE_GAP_EVT_PHY_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 17, /**< PHY Update Request. \n Reply with @ref sd_ble_gap_phy_update. \n See @ref ble_gap_evt_phy_update_request_t. */
|
||||
BLE_GAP_EVT_PHY_UPDATE = BLE_GAP_EVT_BASE + 18, /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */
|
||||
BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 19, /**< Data Length Update Request. \n Reply with @ref sd_ble_gap_data_length_update.\n See @ref ble_gap_evt_data_length_update_request_t. */
|
||||
BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 19, /**< Data Length Update Request. \n Reply with @ref sd_ble_gap_data_length_update. \n See @ref ble_gap_evt_data_length_update_request_t. */
|
||||
BLE_GAP_EVT_DATA_LENGTH_UPDATE = BLE_GAP_EVT_BASE + 20, /**< LL Data Channel PDU payload length updated. \n See @ref ble_gap_evt_data_length_update_t. */
|
||||
BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT = BLE_GAP_EVT_BASE + 21, /**< Channel survey report. \n See @ref ble_gap_evt_qos_channel_survey_report_t. */
|
||||
BLE_GAP_EVT_ADV_SET_TERMINATED = BLE_GAP_EVT_BASE + 22, /**< Advertising set terminated. \n See @ref ble_gap_evt_adv_set_terminated_t. */
|
||||
@@ -155,8 +160,12 @@ enum BLE_GAP_OPTS
|
||||
*/
|
||||
enum BLE_GAP_CFGS
|
||||
{
|
||||
BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */
|
||||
BLE_GAP_CFG_DEVICE_NAME = BLE_GAP_CFG_BASE + 1, /**< Device name configuration. */
|
||||
BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */
|
||||
BLE_GAP_CFG_DEVICE_NAME = BLE_GAP_CFG_BASE + 1, /**< Device name configuration. */
|
||||
BLE_GAP_CFG_PPCP_INCL_CONFIG = BLE_GAP_CFG_BASE + 2, /**< Peripheral Preferred Connection Parameters characteristic
|
||||
inclusion configuration. */
|
||||
BLE_GAP_CFG_CAR_INCL_CONFIG = BLE_GAP_CFG_BASE + 3, /**< Central Address Resolution characteristic
|
||||
inclusion configuration. */
|
||||
};
|
||||
|
||||
/**@brief GAP TX Power roles.
|
||||
@@ -546,7 +555,7 @@ enum BLE_GAP_TX_POWER_ROLES
|
||||
#define BLE_GAP_PHY_NOT_SET 0xFF /**< PHY is not configured. */
|
||||
|
||||
/**@brief Supported PHYs in connections, for scanning, and for advertising. */
|
||||
#define BLE_GAP_PHYS_SUPPORTED (BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS) /**< All PHYs except @ref BLE_GAP_PHY_CODED are supported. */
|
||||
#define BLE_GAP_PHYS_SUPPORTED (BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS | BLE_GAP_PHY_CODED) /**< All PHYs are supported. */
|
||||
|
||||
/**@} */
|
||||
|
||||
@@ -606,6 +615,7 @@ enum BLE_GAP_TX_POWER_ROLES
|
||||
/**@defgroup BLE_GAP_EVENT_LENGTH GAP event length defines.
|
||||
* @{ */
|
||||
#define BLE_GAP_EVENT_LENGTH_MIN (2) /**< Minimum event length, in 1.25 ms units. */
|
||||
#define BLE_GAP_EVENT_LENGTH_CODED_PHY_MIN (6) /**< The shortest event length in 1.25 ms units supporting LE Coded PHY. */
|
||||
#define BLE_GAP_EVENT_LENGTH_DEFAULT (3) /**< Default event length, in 1.25 ms units. */
|
||||
/**@} */
|
||||
|
||||
@@ -645,6 +655,41 @@ enum BLE_GAP_TX_POWER_ROLES
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GAP_CHAR_INCL_CONFIG GAP Characteristic inclusion configurations
|
||||
* @{
|
||||
*/
|
||||
#define BLE_GAP_CHAR_INCL_CONFIG_INCLUDE (0) /**< Include the characteristic in the Attribute Table */
|
||||
#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITH_SPACE (1) /**< Do not include the characteristic in the Attribute table.
|
||||
The SoftDevice will reserve the attribute handles
|
||||
which are otherwise used for this characteristic.
|
||||
By reserving the attribute handles it will be possible
|
||||
to upgrade the SoftDevice without changing handle of the
|
||||
Service Changed characteristic. */
|
||||
#define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE (2) /**< Do not include the characteristic in the Attribute table.
|
||||
The SoftDevice will not reserve the attribute handles
|
||||
which are otherwise used for this characteristic. */
|
||||
/**@} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GAP_CHAR_INCL_CONFIG_DEFAULTS Characteristic inclusion default values
|
||||
* @{ */
|
||||
#define BLE_GAP_PPCP_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */
|
||||
#define BLE_GAP_CAR_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */
|
||||
/**@} */
|
||||
|
||||
/** @defgroup BLE_GAP_SLAVE_LATENCY Slave latency configuration options
|
||||
* @{ */
|
||||
#define BLE_GAP_SLAVE_LATENCY_ENABLE (0) /**< Slave latency is enabled. When slave latency is enabled,
|
||||
the slave will wake up every time it has data to send,
|
||||
and/or every slave latency number of connection events. */
|
||||
#define BLE_GAP_SLAVE_LATENCY_DISABLE (1) /**< Disable slave latency. The slave will wake up every connection event
|
||||
regardless of the requested slave latency.
|
||||
This option consumes the most power. */
|
||||
#define BLE_GAP_SLAVE_LATENCY_WAIT_FOR_ACK (2) /**< The slave will wake up every connection event if it has not received
|
||||
an ACK from the master for at least slave latency events. This
|
||||
configuration may increase the power consumption in environments
|
||||
with a lot of radio activity. */
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup BLE_GAP_STRUCTURES Structures
|
||||
* @{ */
|
||||
@@ -797,13 +842,14 @@ typedef struct
|
||||
uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising channel packets
|
||||
are transmitted. If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS
|
||||
will be used.
|
||||
The only supported value by this SoftDevice is @ref BLE_GAP_PHY_1MBPS. */
|
||||
Valid values are @ref BLE_GAP_PHY_1MBPS and @ref BLE_GAP_PHY_CODED.
|
||||
@note The primary_phy shall indicate @ref BLE_GAP_PHY_1MBPS if
|
||||
@ref ble_gap_adv_properties_t::type is not an extended advertising type. */
|
||||
uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising channel packets
|
||||
are transmitted.
|
||||
If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS will be used.
|
||||
Valid values are
|
||||
@ref BLE_GAP_PHY_1MBPS and @ref BLE_GAP_PHY_2MBPS. @ref BLE_GAP_PHY_CODED
|
||||
is not supported by this SoftDevice.
|
||||
@ref BLE_GAP_PHY_1MBPS, @ref BLE_GAP_PHY_2MBPS, and @ref BLE_GAP_PHY_CODED.
|
||||
If @ref ble_gap_adv_properties_t::type is an extended advertising type
|
||||
and connectable, this is the PHY that will be used to establish a
|
||||
connection and send AUX_ADV_IND packets on.
|
||||
@@ -874,12 +920,21 @@ typedef struct
|
||||
the bitfield indicates the PHYs the scanner will use for scanning
|
||||
on primary advertising channels. The scanner will accept
|
||||
@ref BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs.
|
||||
- When used with @ref sd_ble_gap_connect, the
|
||||
bitfield indicates the PHYs on where a connection may be initiated.
|
||||
- When used with @ref sd_ble_gap_connect, the bitfield indicates
|
||||
the PHYs the initiator will use for scanning on primary advertising
|
||||
channels. The initiator will accept connections initiated on either
|
||||
of the @ref BLE_GAP_PHYS_SUPPORTED PHYs.
|
||||
If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS,
|
||||
the primary scan PHY is @ref BLE_GAP_PHY_1MBPS. */
|
||||
the primary scan PHY is @ref BLE_GAP_PHY_1MBPS.
|
||||
If scan_phys also contains @ref BLE_GAP_PHY_CODED, the primary scan
|
||||
PHY will also contain @ref BLE_GAP_PHY_CODED. If the only scan PHY is
|
||||
@ref BLE_GAP_PHY_CODED, the primary scan PHY is
|
||||
@ref BLE_GAP_PHY_CODED only. */
|
||||
uint16_t interval; /**< Scan interval in 625 us units. @sa BLE_GAP_SCAN_INTERVALS. */
|
||||
uint16_t window; /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW. */
|
||||
uint16_t window; /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW.
|
||||
If scan_phys contains both @ref BLE_GAP_PHY_1MBPS and
|
||||
@ref BLE_GAP_PHY_CODED interval shall be larger than or
|
||||
equal to twice the scan window. */
|
||||
uint16_t timeout; /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */
|
||||
ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels.
|
||||
At least one of the primary channels, that is channel index 37-39, must be
|
||||
@@ -1202,7 +1257,8 @@ typedef struct
|
||||
/**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */
|
||||
typedef struct
|
||||
{
|
||||
int8_t rssi; /**< Received Signal Strength Indication in dBm. */
|
||||
int8_t rssi; /**< Received Signal Strength Indication in dBm.
|
||||
@note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */
|
||||
uint8_t ch_index; /**< Data Channel Index on which the Signal Strength is measured (0-36). */
|
||||
} ble_gap_evt_rssi_changed_t;
|
||||
|
||||
@@ -1251,7 +1307,8 @@ typedef struct
|
||||
This field is set to @ref BLE_GAP_POWER_LEVEL_INVALID if the
|
||||
last received packet did not contain the Tx Power field.
|
||||
@note TX Power is only included in extended advertising packets. */
|
||||
int8_t rssi; /**< Received Signal Strength Indication in dBm of the last packet received. */
|
||||
int8_t rssi; /**< Received Signal Strength Indication in dBm of the last packet received.
|
||||
@note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */
|
||||
uint8_t ch_index; /**< Channel Index on which the last advertising packet is received (0-39). */
|
||||
uint8_t set_id; /**< Set ID of the received advertising data. Set ID is not present
|
||||
if set to @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */
|
||||
@@ -1289,7 +1346,8 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
uint8_t adv_handle; /**< Advertising handle for the advertising set which received the Scan Request */
|
||||
int8_t rssi; /**< Received Signal Strength Indication in dBm. */
|
||||
int8_t rssi; /**< Received Signal Strength Indication in dBm.
|
||||
@note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */
|
||||
ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1
|
||||
and the address is the device's identity address. */
|
||||
} ble_gap_evt_scan_req_report_t;
|
||||
@@ -1301,7 +1359,10 @@ typedef struct
|
||||
ble_gap_data_length_params_t peer_params; /**< Peer data length parameters. */
|
||||
} ble_gap_evt_data_length_update_request_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE. */
|
||||
/**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE.
|
||||
*
|
||||
* @note This event may also be raised after a PHY Update procedure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_gap_data_length_params_t effective_params; /**< The effective data length parameters. */
|
||||
@@ -1431,11 +1492,31 @@ typedef struct
|
||||
} ble_gap_cfg_device_name_t;
|
||||
|
||||
|
||||
/**@brief Peripheral Preferred Connection Parameters include configuration parameters, set with @ref sd_ble_cfg_set. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t include_cfg; /**< Inclusion configuration of the Peripheral Preferred Connection Parameters characteristic.
|
||||
See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_PPCP_INCL_CONFIG_DEFAULT. */
|
||||
} ble_gap_cfg_ppcp_incl_cfg_t;
|
||||
|
||||
|
||||
/**@brief Central Address Resolution include configuration parameters, set with @ref sd_ble_cfg_set. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t include_cfg; /**< Inclusion configuration of the Central Address Resolution characteristic.
|
||||
See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_CAR_INCL_CONFIG_DEFAULT. */
|
||||
} ble_gap_cfg_car_incl_cfg_t;
|
||||
|
||||
|
||||
/**@brief Configuration structure for GAP configurations. */
|
||||
typedef union
|
||||
{
|
||||
ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */
|
||||
ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */
|
||||
ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */
|
||||
ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */
|
||||
ble_gap_cfg_ppcp_incl_cfg_t ppcp_include_cfg; /**< Peripheral Preferred Connection Parameters characteristic include
|
||||
configuration, cfg_id is @ref BLE_GAP_CFG_PPCP_INCL_CONFIG. */
|
||||
ble_gap_cfg_car_incl_cfg_t car_include_cfg; /**< Central Address Resolution characteristic include configuration,
|
||||
cfg_id is @ref BLE_GAP_CFG_CAR_INCL_CONFIG. */
|
||||
} ble_gap_cfg_t;
|
||||
|
||||
|
||||
@@ -1513,10 +1594,14 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle */
|
||||
uint8_t disable : 1; /**< Set to 1 to disable slave latency. Set to 0 enable it again.*/
|
||||
uint8_t disable; /**< For allowed values see @ref BLE_GAP_SLAVE_LATENCY */
|
||||
} ble_gap_opt_slave_latency_disable_t;
|
||||
|
||||
/**@brief Passkey Option.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @details Structure containing the passkey to be used during pairing. This can be used with @ref
|
||||
* sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication
|
||||
@@ -1589,8 +1674,22 @@ typedef union
|
||||
ble_gap_opt_auth_payload_timeout_t auth_payload_timeout; /**< Parameters for the authenticated payload timeout option.*/
|
||||
ble_gap_opt_slave_latency_disable_t slave_latency_disable; /**< Parameters for the Disable slave latency option */
|
||||
} ble_gap_opt_t;
|
||||
/**@} */
|
||||
|
||||
/**@brief Connection event triggering parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ppi_ch_id; /**< PPI channel to use. This channel should be regarded as reserved until
|
||||
connection event PPI task triggering is stopped.
|
||||
The PPI channel ID can not be one of the PPI channels reserved by
|
||||
the SoftDevice. See @ref NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK. */
|
||||
uint32_t task_endpoint; /**< Task Endpoint to trigger. */
|
||||
uint16_t conn_evt_counter_start; /**< The connection event on which the task triggering should start. */
|
||||
uint16_t period_in_events; /**< Trigger period. Valid range is [1, 32767].
|
||||
If the device is in slave role and slave latency is enabled,
|
||||
this parameter should be set to a multiple of (slave latency + 1)
|
||||
to ensure low power operation. */
|
||||
} ble_gap_conn_event_trigger_t;
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup BLE_GAP_FUNCTIONS Functions
|
||||
* @{ */
|
||||
@@ -1652,7 +1751,7 @@ SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Address successfully retrieved.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found.
|
||||
* @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE The advertising set is currently not advertising.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_ADV_ADDR_GET, uint32_t, sd_ble_gap_adv_addr_get(uint8_t adv_handle, ble_gap_addr_t *p_addr));
|
||||
@@ -1733,6 +1832,10 @@ SVCALL(SD_BLE_GAP_DEVICE_IDENTITIES_SET, uint32_t, sd_ble_gap_device_identities_
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR The pointer to privacy settings is NULL or invalid.
|
||||
* Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Out of range parameters are provided.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED The SoftDevice does not support privacy if the Central Address Resolution
|
||||
characteristic is not configured to be included and the SoftDevice is configured
|
||||
to support central roles.
|
||||
See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising, scanning
|
||||
* or creating a connection.
|
||||
*/
|
||||
@@ -1804,6 +1907,9 @@ SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint
|
||||
*
|
||||
* @note Only one advertiser may be active at any time.
|
||||
*
|
||||
* @note If privacy is enabled, the advertiser's private address will be refreshed when this function is called.
|
||||
* See @ref sd_ble_gap_privacy_set().
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.}
|
||||
* @event{@ref BLE_GAP_EVT_ADV_SET_TERMINATED, Advertising set has terminated.}
|
||||
@@ -1824,7 +1930,10 @@ SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The BLE stack has started advertising.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE adv_handle is not configured or already advertising.
|
||||
* @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached; connectable advertiser cannot be started.
|
||||
* @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration
|
||||
* tag has been reached; connectable advertiser cannot be started.
|
||||
* To increase the number of available connections,
|
||||
* use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP.
|
||||
* @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. Configure a new adveriting handle with @ref sd_ble_gap_adv_set_configure.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied:
|
||||
@@ -1839,7 +1948,6 @@ SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint
|
||||
* - p_adv_params is configured with connectable advertising, but the event_length parameter
|
||||
* associated with conn_cfg_tag is too small to be able to establish a connection on
|
||||
* the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag));
|
||||
|
||||
@@ -1934,7 +2042,9 @@ SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_hand
|
||||
* - For all other roles handle is ignored.
|
||||
* @param[in] tx_power Radio transmit power in dBm (see note for accepted values).
|
||||
*
|
||||
* @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm.
|
||||
* @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm.
|
||||
* In addition, on some chips following values are supported: +2dBm, +5dBm, +6dBm, +7dBm and +8dBm.
|
||||
* Setting these values on a chip that does not support them will result in undefined behaviour.
|
||||
* @note The initiator will have the same transmit power as the scanner.
|
||||
* @note When a connection is created it will inherit the transmit power from the initiator or
|
||||
* advertiser leading to the connection.
|
||||
@@ -1974,6 +2084,8 @@ SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t *
|
||||
* @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table,
|
||||
see @ref ble_gap_cfg_ppcp_incl_cfg_t.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params));
|
||||
|
||||
@@ -1984,6 +2096,8 @@ SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table,
|
||||
see @ref ble_gap_cfg_ppcp_incl_cfg_t.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params));
|
||||
|
||||
@@ -2070,6 +2184,10 @@ SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t
|
||||
* @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
|
||||
* Distribution of own Identity Information is only supported if the Central
|
||||
* Address Resolution characteristic is configured to be included or
|
||||
* the Softdevice is configured to support peripheral roles only.
|
||||
* See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t.
|
||||
* @retval ::NRF_ERROR_TIMEOUT A SMP timeout has occurred, and further SMP operations on this link is prohibited.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params));
|
||||
@@ -2081,7 +2199,7 @@ SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_
|
||||
* @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
|
||||
*
|
||||
* @events
|
||||
* @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
|
||||
* @event{This function is used during authentication procedures, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
|
||||
* @endevents
|
||||
*
|
||||
* @mscs
|
||||
@@ -2130,6 +2248,10 @@ SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Security parameters has not been requested.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
|
||||
* Distribution of own Identity Information is only supported if the Central
|
||||
* Address Resolution characteristic is configured to be included or
|
||||
* the Softdevice is configured to support peripheral roles only.
|
||||
* See @ref ble_gap_cfg_car_incl_cfg_t and @ref ble_gap_cfg_role_count_t.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const *p_sec_params, ble_gap_sec_keyset_t const *p_sec_keyset));
|
||||
|
||||
@@ -2327,8 +2449,8 @@ SVCALL(SD_BLE_GAP_ENCRYPT, uint32_t, sd_ble_gap_encrypt(uint16_t conn_handle, bl
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
|
||||
* - No link has been established.
|
||||
* - No @ref BLE_GAP_EVT_SEC_REQUEST pending.
|
||||
* - LE long term key requested command not allowed.
|
||||
* - No @ref BLE_GAP_EVT_SEC_INFO_REQUEST pending.
|
||||
* - Encryption information provided by the app without being requested. See @ref ble_gap_evt_sec_info_request_t::enc_info.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const *p_enc_info, ble_gap_irk_t const *p_id_info, ble_gap_sign_info_t const *p_sign_info));
|
||||
@@ -2395,6 +2517,7 @@ SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle
|
||||
*
|
||||
* @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND
|
||||
* will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start.
|
||||
* @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement.
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
|
||||
* @endmscs
|
||||
@@ -2461,7 +2584,6 @@ SVCALL(SD_BLE_GAP_RSSI_GET, uint32_t, sd_ble_gap_rssi_get(uint16_t conn_handle,
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH The provided buffer length is invalid. See @ref BLE_GAP_SCAN_BUFFER_MIN.
|
||||
* @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available.
|
||||
* Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_SCAN_START, uint32_t, sd_ble_gap_scan_start(ble_gap_scan_params_t const *p_scan_params, ble_data_t const * p_adv_report_buffer));
|
||||
|
||||
@@ -2514,14 +2636,15 @@ SVCALL(SD_BLE_GAP_SCAN_STOP, uint32_t, sd_ble_gap_scan_stop(void));
|
||||
* @retval ::NRF_ERROR_INVALID_STATE The SoftDevice is in an invalid state to perform this operation. This may be due to an
|
||||
* existing locally initiated connect procedure, which must complete before initiating again.
|
||||
* @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Peer address.
|
||||
* @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached.
|
||||
* @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration tag has been reached.
|
||||
* To increase the number of available connections,
|
||||
* use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP.
|
||||
* @retval ::NRF_ERROR_RESOURCES Either:
|
||||
* - Not enough BLE role slots available.
|
||||
* Stop one or more currently active roles (Central, Peripheral or Observer) and try again.
|
||||
* - The event_length parameter associated with conn_cfg_tag is too small to be able to
|
||||
* establish a connection on the selected @ref ble_gap_scan_params_t::scan_phys.
|
||||
* Use @ref sd_ble_cfg_set to increase the event length.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_CONNECT, uint32_t, sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params, uint8_t conn_cfg_tag));
|
||||
|
||||
@@ -2561,12 +2684,12 @@ SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void));
|
||||
* @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to
|
||||
* @ref BLE_HCI_UNSUPPORTED_REMOTE_FEATURE.
|
||||
*
|
||||
* If the PHY procedure was rejected by the peer due to a procedure collision, the status
|
||||
* If the PHY Update procedure was rejected by the peer due to a procedure collision, the status
|
||||
* will be @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or
|
||||
* @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION.
|
||||
* If the peer responds to the PHY Update procedure with invalid parameters, the status
|
||||
* will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS.
|
||||
* If the PHY procedure was rejected by the peer for a different reason, the status will
|
||||
* If the PHY Update procedure was rejected by the peer for a different reason, the status will
|
||||
* contain the reason as specified by the peer.
|
||||
*
|
||||
* @events
|
||||
@@ -2585,8 +2708,10 @@ SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void));
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE No link has been established.
|
||||
* @retval ::NRF_ERROR_RESOURCES The connection event length configured for this link is not sufficient for the combination of
|
||||
* @ref ble_gap_phys_t::tx_phys, @ref ble_gap_phys_t::rx_phys, and @ref ble_gap_data_length_params_t.
|
||||
* The connection event length is configured with @ref BLE_CONN_CFG_GAP using @ref sd_ble_cfg_set.
|
||||
* @retval ::NRF_ERROR_BUSY Procedure is already in progress or not allowed at this time. Process pending events and wait for the pending procedure to complete and retry.
|
||||
*
|
||||
*/
|
||||
@@ -2598,6 +2723,9 @@ SVCALL(SD_BLE_GAP_PHY_UPDATE, uint32_t, sd_ble_gap_phy_update(uint16_t conn_hand
|
||||
* @note If the application uses @ref BLE_GAP_DATA_LENGTH_AUTO for one or more members of
|
||||
* p_dl_params, the SoftDevice will choose the highest value supported in current
|
||||
* configuration and connection parameters.
|
||||
* @note If the link PHY is Coded, the SoftDevice will ensure that the MaxTxTime and/or MaxRxTime
|
||||
* used in the Data Length Update procedure is at least 2704 us. Otherwise, MaxTxTime and
|
||||
* MaxRxTime will be limited to maximum 2120 us.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_dl_params Pointer to local parameters to be used in Data Length Update
|
||||
@@ -2660,6 +2788,9 @@ SVCALL(SD_BLE_GAP_DATA_LENGTH_UPDATE, uint32_t, sd_ble_gap_data_length_update(ui
|
||||
SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START, uint32_t, sd_ble_gap_qos_channel_survey_start(uint32_t interval_us));
|
||||
|
||||
/**@brief Stop the Quality of Service (QoS) channel survey module.
|
||||
*
|
||||
* @note The SoftDevice may generate one @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT event after this
|
||||
* function is called.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The module is successfully stopped.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Trying to stop the module when it is not running.
|
||||
@@ -2667,6 +2798,63 @@ SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START, uint32_t, sd_ble_gap_qos_channel_sur
|
||||
SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP, uint32_t, sd_ble_gap_qos_channel_survey_stop(void));
|
||||
|
||||
|
||||
/**@brief Obtain the next connection event counter value.
|
||||
*
|
||||
* @details The connection event counter is initialized to zero on the first connection event. The value is incremented
|
||||
* by one for each connection event. For more information see Bluetooth Core Specification v5.0, Vol 6, Part B,
|
||||
* Section 4.5.1.
|
||||
*
|
||||
* @note The connection event counter obtained through this API will be outdated if this API is called
|
||||
* at the same time as the connection event counter is incremented.
|
||||
*
|
||||
* @note This API will always return the last connection event counter + 1.
|
||||
* The actual connection event may be multiple connection events later if:
|
||||
* - Slave latency is enabled and there is no data to transmit or receive.
|
||||
* - Another role is scheduled with a higher priority at the same time as the next connection event.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[out] p_counter Pointer to the variable where the next connection event counter will be written.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The connection event counter was successfully retrieved.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET, uint32_t, sd_ble_gap_next_conn_evt_counter_get(uint16_t conn_handle, uint16_t * p_counter));
|
||||
|
||||
|
||||
/**@brief Start triggering a given task on connection event start.
|
||||
*
|
||||
* @details When enabled, this feature will trigger a PPI task at the start of connection events.
|
||||
* The application can configure the SoftDevice to trigger every N connection events starting from
|
||||
* a given connection event counter. See also @ref ble_gap_conn_event_trigger_t.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_params Connection event trigger parameters.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Success.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter supplied. See @ref ble_gap_conn_event_trigger_t.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Either:
|
||||
* - Trying to start connection event triggering when it is already ongoing.
|
||||
* - @ref ble_gap_conn_event_trigger_t::conn_evt_counter_start is in the past.
|
||||
* Use @ref sd_ble_gap_next_conn_evt_counter_get to find a new value
|
||||
to be used as ble_gap_conn_event_trigger_t::conn_evt_counter_start.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_CONN_EVT_TRIGGER_START, uint32_t, sd_ble_gap_conn_evt_trigger_start(uint16_t conn_handle, ble_gap_conn_event_trigger_t const * p_params));
|
||||
|
||||
|
||||
/**@brief Stop triggering the task configured using @ref sd_ble_gap_conn_evt_trigger_start.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Success.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Trying to stop connection event triggering when it is not enabled.
|
||||
*/
|
||||
SVCALL(SD_BLE_GAP_CONN_EVT_TRIGGER_STOP, uint32_t, sd_ble_gap_conn_evt_trigger_stop(uint16_t conn_handle));
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -121,7 +121,7 @@ extern "C" {
|
||||
#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Insufficient resources. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
|
||||
+47
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 - 2017, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -97,6 +97,14 @@ enum BLE_GATTC_EVTS
|
||||
BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE /**< Write without Response transmission complete. \n See @ref ble_gattc_evt_write_cmd_tx_complete_t. */
|
||||
};
|
||||
|
||||
/**@brief GATTC Option IDs.
|
||||
* IDs that uniquely identify a GATTC option.
|
||||
*/
|
||||
enum BLE_GATTC_OPTS
|
||||
{
|
||||
BLE_GATTC_OPT_UUID_DISC = BLE_GATTC_OPT_BASE, /**< UUID discovery. @ref ble_gattc_opt_uuid_disc_t */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_DEFINES Defines
|
||||
@@ -344,6 +352,40 @@ typedef struct
|
||||
ble_gattc_evt_write_cmd_tx_complete_t write_cmd_tx_complete; /**< Write without Response transmission complete Event Parameters. */
|
||||
} params; /**< Event Parameters. @note Only valid if @ref gatt_status == @ref BLE_GATT_STATUS_SUCCESS. */
|
||||
} ble_gattc_evt_t;
|
||||
|
||||
/**@brief UUID discovery option.
|
||||
*
|
||||
* @details Used with @ref sd_ble_opt_set to enable and disable automatic insertion of discovered 128-bit UUIDs to the
|
||||
* Vendor Specific UUID table. Disabled by default.
|
||||
* - When disabled, if a procedure initiated by
|
||||
* @ref sd_ble_gattc_primary_services_discover,
|
||||
* @ref sd_ble_gattc_relationships_discover,
|
||||
* @ref sd_ble_gattc_characteristics_discover,
|
||||
* @ref sd_ble_gattc_descriptors_discover
|
||||
* finds a 128-bit UUID which was not added by @ref sd_ble_uuid_vs_add, @ref ble_uuid_t::type will be set
|
||||
* to @ref BLE_UUID_TYPE_UNKNOWN in the corresponding event.
|
||||
* - When enabled, all found 128-bit UUIDs will be automatically added. The application can use
|
||||
* @ref sd_ble_uuid_encode to retrieve the 128-bit UUID from @ref ble_uuid_t received in the corresponding
|
||||
* event. If the total number of Vendor Specific UUIDs exceeds the table capacity, @ref ble_uuid_t::type will
|
||||
* be set to @ref BLE_UUID_TYPE_UNKNOWN in the corresponding event.
|
||||
* See also @ref ble_common_cfg_vs_uuid_t, @ref sd_ble_uuid_vs_remove.
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Set successfully.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t auto_add_vs_enable : 1; /**< Set to 1 to enable (or 0 to disable) automatic insertion of discovered 128-bit UUIDs. */
|
||||
} ble_gattc_opt_uuid_disc_t;
|
||||
|
||||
/**@brief Option structure for GATTC options. */
|
||||
typedef union
|
||||
{
|
||||
ble_gattc_opt_uuid_disc_t uuid_disc; /**< Parameters for the UUID discovery option. */
|
||||
} ble_gattc_opt_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_FUNCTIONS Functions
|
||||
@@ -353,9 +395,7 @@ typedef struct
|
||||
*
|
||||
* @details This function initiates or resumes a Primary Service discovery procedure, starting from the supplied handle.
|
||||
* If the last service has not been reached, this function must be called again with an updated start handle value to continue the search.
|
||||
*
|
||||
* @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
* See also @ref ble_gattc_opt_uuid_disc_t.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP}
|
||||
@@ -383,6 +423,7 @@ SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_se
|
||||
*
|
||||
* @details This function initiates or resumes the Find Included Services sub-procedure. If the last included service has not been reached,
|
||||
* this must be called again with an updated handle range to continue the search.
|
||||
* See also @ref ble_gattc_opt_uuid_disc_t.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_REL_DISC_RSP}
|
||||
@@ -410,9 +451,7 @@ SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships
|
||||
*
|
||||
* @details This function initiates or resumes a Characteristic discovery procedure. If the last Characteristic has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
* See also @ref ble_gattc_opt_uuid_disc_t.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_CHAR_DISC_RSP}
|
||||
@@ -439,6 +478,7 @@ SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteris
|
||||
*
|
||||
* @details This function initiates or resumes a Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
* See also @ref ble_gattc_opt_uuid_disc_t.
|
||||
*
|
||||
* @events
|
||||
* @event{@ref BLE_GATTC_EVT_DESC_DISC_RSP}
|
||||
+19
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -106,6 +106,7 @@ enum BLE_GATTS_CFGS
|
||||
{
|
||||
BLE_GATTS_CFG_SERVICE_CHANGED = BLE_GATTS_CFG_BASE, /**< Service changed configuration. */
|
||||
BLE_GATTS_CFG_ATTR_TAB_SIZE, /**< Attribute table size configuration. */
|
||||
BLE_GATTS_CFG_SERVICE_CHANGED_CCCD_PERM, /**< Service changed CCCD permission configuration. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
@@ -321,6 +322,22 @@ typedef struct
|
||||
uint8_t service_changed : 1; /**< If 1, include the Service Changed characteristic in the Attribute Table. Default is @ref BLE_GATTS_SERVICE_CHANGED_DEFAULT. */
|
||||
} ble_gatts_cfg_service_changed_t;
|
||||
|
||||
/**@brief Service Changed CCCD permission configuration parameters, set with @ref sd_ble_cfg_set.
|
||||
*
|
||||
* @note @ref ble_gatts_attr_md_t::vlen is ignored and should be set to 0.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
|
||||
* - @ref ble_gatts_attr_md_t::write_perm is out of range.
|
||||
* - @ref ble_gatts_attr_md_t::write_perm is @ref BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS, that is not allowed by the Bluetooth Specification.
|
||||
* - wrong @ref ble_gatts_attr_md_t::read_perm, only @ref BLE_GAP_CONN_SEC_MODE_SET_OPEN is allowed by the Bluetooth Specification.
|
||||
* - wrong @ref ble_gatts_attr_md_t::vloc, only @ref BLE_GATTS_VLOC_STACK is allowed.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Security Mode 2 not supported
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_gatts_attr_md_t perm; /**< Permission for Service Changed CCCD. Default is @ref BLE_GAP_CONN_SEC_MODE_SET_OPEN, no authorization. */
|
||||
} ble_gatts_cfg_service_changed_cccd_perm_t;
|
||||
|
||||
/**@brief Attribute table size configuration parameters, set with @ref sd_ble_cfg_set.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true:
|
||||
@@ -337,6 +354,7 @@ typedef struct
|
||||
typedef union
|
||||
{
|
||||
ble_gatts_cfg_service_changed_t service_changed; /**< Include service changed characteristic, cfg_id is @ref BLE_GATTS_CFG_SERVICE_CHANGED. */
|
||||
ble_gatts_cfg_service_changed_cccd_perm_t service_changed_cccd_perm; /**< Service changed CCCD permission, cfg_id is @ref BLE_GATTS_CFG_SERVICE_CHANGED_CCCD_PERM. */
|
||||
ble_gatts_cfg_attr_tab_size_t attr_tab_size; /**< Attribute table size, cfg_id is @ref BLE_GATTS_CFG_ATTR_TAB_SIZE. */
|
||||
} ble_gatts_cfg_t;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -95,6 +95,7 @@ enum BLE_L2CAP_SVCS
|
||||
enum BLE_L2CAP_EVTS
|
||||
{
|
||||
BLE_L2CAP_EVT_CH_SETUP_REQUEST = BLE_L2CAP_EVT_BASE + 0, /**< L2CAP Channel Setup Request event.
|
||||
\n Reply with @ref sd_ble_l2cap_ch_setup.
|
||||
\n See @ref ble_l2cap_evt_ch_setup_request_t. */
|
||||
BLE_L2CAP_EVT_CH_SETUP_REFUSED = BLE_L2CAP_EVT_BASE + 1, /**< L2CAP Channel Setup Refused event.
|
||||
\n See @ref ble_l2cap_evt_ch_setup_refused_t. */
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE (0x18)
|
||||
|
||||
/**@brief Page size in words. */
|
||||
#define MBR_PAGE_SIZE_IN_WORDS (1024)
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash.
|
||||
This is the offset where the first byte of the SoftDevice hex file is written. */
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @brief Location (in the flash memory) of the bootloader address. */
|
||||
#define MBR_BOOTLOADER_ADDR (0xFF8)
|
||||
|
||||
/** @brief Location (in UICR) of the bootloader address. */
|
||||
#define MBR_UICR_BOOTLOADER_ADDR (&(NRF_UICR->NRFFW[0]))
|
||||
|
||||
/** @brief Location (in the flash memory) of the address of the MBR parameter page. */
|
||||
#define MBR_PARAM_PAGE_ADDR (0xFFC)
|
||||
|
||||
/** @brief Location (in UICR) of the address of the MBR parameter page. */
|
||||
#define MBR_UICR_PARAM_PAGE_ADDR (&(NRF_UICR->NRFFW[1]))
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see ::sd_mbr_command_copy_bl_t*/
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD. Does not require any parameters in ::sd_mbr_command_t params.*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset. @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
SD_MBR_COMMAND_RESERVED,
|
||||
SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address. @see ::sd_mbr_command_irq_forward_address_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
*
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the BPROT registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/
|
||||
} sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory. */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory. */
|
||||
uint32_t len; /**< Number of 32 bit words to compare.*/
|
||||
} sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
*
|
||||
* The MBR assumes that either @ref MBR_BOOTLOADER_ADDR or @ref MBR_UICR_BOOTLOADER_ADDR is set to
|
||||
* the address where the bootloader will be copied. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* The bootloader destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* This command will use the flash protect peripheral (BPROT or ACL) to protect the flash that is
|
||||
* not intended to be written.
|
||||
*
|
||||
* On success, this function will not return. It will start the new bootloader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if the bootloader address is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Change the address the MBR starts after a reset
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward
|
||||
* interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding, this function should be called with @ref address set to 0. If a
|
||||
* bootloader is present, interrupts will be forwarded to the bootloader. If not, interrupts will
|
||||
* be forwarded to the SoftDevice.
|
||||
*
|
||||
* The location of a bootloader can be specified in @ref MBR_BOOTLOADER_ADDR or
|
||||
* @ref MBR_UICR_BOOTLOADER_ADDR. If both addresses are set, the MBR will prioritize
|
||||
* @ref MBR_BOOTLOADER_ADDR.
|
||||
*
|
||||
* This command requires that @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR is set,
|
||||
* see @ref sd_mbr_command.
|
||||
*
|
||||
* On success, this function will not return. It will reset the device.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page is provided. See @ref sd_mbr_command.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not
|
||||
* change where the MBR starts after reset.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_irq_forward_address_set_t;
|
||||
|
||||
/**@brief Input structure containing data used when calling ::sd_mbr_command
|
||||
*
|
||||
* Depending on what command value that is set, the corresponding params value type must also be
|
||||
* set. See @ref NRF_MBR_COMMANDS for command types and corresponding params value type. If command
|
||||
* @ref SD_MBR_COMMAND_INIT_SD is set, it is not necessary to set any values under params.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< Type of command to be issued. See @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/
|
||||
sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/
|
||||
} params; /**< Command parameters. */
|
||||
} sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader.
|
||||
*
|
||||
* The @ref SD_MBR_COMMAND_COPY_BL and @ref SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires
|
||||
* parameters to be retained by the MBR when resetting the IC. This is done in a separate flash
|
||||
* page. The location of the flash page should be provided by the application in either
|
||||
* @ref MBR_PARAM_PAGE_ADDR or @ref MBR_UICR_PARAM_PAGE_ADDR. If both addresses are set, the MBR
|
||||
* will prioritize @ref MBR_PARAM_PAGE_ADDR. This page will be cleared by the MBR and is used to
|
||||
* store the command before reset. When an address is specified, the page it refers to must not be
|
||||
* used by the application. If no address is provided by the application, i.e. both
|
||||
* @ref MBR_PARAM_PAGE_ADDR and @ref MBR_UICR_PARAM_PAGE_ADDR is 0xFFFFFFFF, MBR commands which use
|
||||
* flash will be unavailable and return @ref NRF_ERROR_NO_MEM.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
* @note For a complete set of return values, see ::sd_mbr_command_copy_sd_t,
|
||||
* ::sd_mbr_command_copy_bl_t, ::sd_mbr_command_compare_t,
|
||||
* ::sd_mbr_command_vector_table_base_set_t, ::sd_mbr_command_irq_forward_address_set_t
|
||||
*
|
||||
* @retval ::NRF_ERROR_NO_MEM No MBR parameter page provided
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM if an invalid command is given.
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
+9
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -67,16 +67,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief The major version for the SoftDevice binary distributed with this header file. */
|
||||
#define SD_MAJOR_VERSION (6)
|
||||
#define SD_MAJOR_VERSION (7)
|
||||
|
||||
/** @brief The minor version for the SoftDevice binary distributed with this header file. */
|
||||
#define SD_MINOR_VERSION (1)
|
||||
#define SD_MINOR_VERSION (3)
|
||||
|
||||
/** @brief The bugfix version for the SoftDevice binary distributed with this header file. */
|
||||
#define SD_BUGFIX_VERSION (0)
|
||||
|
||||
/** @brief The SoftDevice variant of this firmware. */
|
||||
#define SD_VARIANT_ID 132
|
||||
#define SD_VARIANT_ID 140
|
||||
|
||||
/** @brief The full version number for the SoftDevice binary this header file was distributed
|
||||
* with, as a decimal number in the form Mmmmbbb, where:
|
||||
@@ -141,7 +141,7 @@ the start of the SoftDevice (without MBR)*/
|
||||
* Add @ref MBR_SIZE to find the first available flash address when the SoftDevice is installed
|
||||
* just above the MBR (the usual case).
|
||||
*/
|
||||
#define SD_FLASH_SIZE 0x25000
|
||||
#define SD_FLASH_SIZE 0x26000
|
||||
|
||||
/** @brief Defines a macro for retrieving the actual FWID value from a given base address. Use
|
||||
* @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual
|
||||
@@ -274,6 +274,10 @@ typedef struct
|
||||
* perform a reset, using e.g. CMSIS NVIC_SystemReset().
|
||||
* If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset().
|
||||
*
|
||||
* @note It is recommended to either perform a reset in the fault handler or to let the SoftDevice reset the device.
|
||||
* Otherwise SoC peripherals may behave in an undefined way. For example, the RADIO peripherial may
|
||||
* continously transmit packets.
|
||||
*
|
||||
* @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
+113
-40
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -71,10 +71,10 @@ extern "C" {
|
||||
#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
|
||||
|
||||
/**@brief The maximum processing time to handle a timeslot extension. */
|
||||
#define NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US (17)
|
||||
#define NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US (20)
|
||||
|
||||
/**@brief The latest time before the end of a timeslot the timeslot can be extended. */
|
||||
#define NRF_RADIO_MIN_EXTENSION_MARGIN_US (79)
|
||||
#define NRF_RADIO_MIN_EXTENSION_MARGIN_US (82)
|
||||
|
||||
#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */
|
||||
#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */
|
||||
@@ -117,12 +117,6 @@ extern "C" {
|
||||
| (1U << 31) \
|
||||
))
|
||||
|
||||
/**@brief Mask of PPI channels available to the application when the SoftDevice is disabled. */
|
||||
#define NRF_SOC_APP_PPI_CHANNELS_SD_DISABLED_MSK (~NRF_SOC_SD_PPI_CHANNELS_SD_DISABLED_MSK)
|
||||
|
||||
/**@brief Mask of PPI channels available to the application when the SoftDevice is enabled. */
|
||||
#define NRF_SOC_APP_PPI_CHANNELS_SD_ENABLED_MSK (~NRF_SOC_SD_PPI_CHANNELS_SD_ENABLED_MSK)
|
||||
|
||||
/**@brief Mask of PPI groups reserved by the SoftDevice when the SoftDevice is disabled. */
|
||||
#define NRF_SOC_SD_PPI_GROUPS_SD_DISABLED_MSK ((uint32_t)(0))
|
||||
|
||||
@@ -132,12 +126,6 @@ extern "C" {
|
||||
| (1U << 5) \
|
||||
))
|
||||
|
||||
/**@brief Mask of PPI groups available to the application when the SoftDevice is disabled. */
|
||||
#define NRF_SOC_APP_PPI_GROUPS_SD_DISABLED_MSK (~NRF_SOC_SD_PPI_GROUPS_SD_DISABLED_MSK)
|
||||
|
||||
/**@brief Mask of PPI groups available to the application when the SoftDevice is enabled. */
|
||||
#define NRF_SOC_APP_PPI_GROUPS_SD_ENABLED_MSK (~NRF_SOC_SD_PPI_GROUPS_SD_ENABLED_MSK)
|
||||
|
||||
/**@} */
|
||||
|
||||
/**@addtogroup NRF_SOC_ENUMS Enumerations
|
||||
@@ -156,7 +144,6 @@ enum NRF_SOC_SVCS
|
||||
SD_PPI_GROUP_GET = SOC_SVC_BASE + 7,
|
||||
SD_FLASH_PAGE_ERASE = SOC_SVC_BASE + 8,
|
||||
SD_FLASH_WRITE = SOC_SVC_BASE + 9,
|
||||
SD_FLASH_PROTECT = SOC_SVC_BASE + 10,
|
||||
SD_PROTECTED_REGISTER_WRITE = SOC_SVC_BASE + 11,
|
||||
SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
|
||||
SD_MUTEX_ACQUIRE = SOC_SVC_BASE_NOT_AVAILABLE + 1,
|
||||
@@ -170,6 +157,7 @@ enum NRF_SOC_SVCS
|
||||
SD_POWER_RESET_REASON_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 9,
|
||||
SD_POWER_POF_ENABLE = SOC_SVC_BASE_NOT_AVAILABLE + 10,
|
||||
SD_POWER_POF_THRESHOLD_SET = SOC_SVC_BASE_NOT_AVAILABLE + 11,
|
||||
SD_POWER_POF_THRESHOLDVDDH_SET = SOC_SVC_BASE_NOT_AVAILABLE + 12,
|
||||
SD_POWER_RAM_POWER_SET = SOC_SVC_BASE_NOT_AVAILABLE + 13,
|
||||
SD_POWER_RAM_POWER_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 14,
|
||||
SD_POWER_RAM_POWER_GET = SOC_SVC_BASE_NOT_AVAILABLE + 15,
|
||||
@@ -177,6 +165,7 @@ enum NRF_SOC_SVCS
|
||||
SD_POWER_GPREGRET_CLR = SOC_SVC_BASE_NOT_AVAILABLE + 17,
|
||||
SD_POWER_GPREGRET_GET = SOC_SVC_BASE_NOT_AVAILABLE + 18,
|
||||
SD_POWER_DCDC_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 19,
|
||||
SD_POWER_DCDC0_MODE_SET = SOC_SVC_BASE_NOT_AVAILABLE + 20,
|
||||
SD_APP_EVT_WAIT = SOC_SVC_BASE_NOT_AVAILABLE + 21,
|
||||
SD_CLOCK_HFCLK_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 22,
|
||||
SD_CLOCK_HFCLK_RELEASE = SOC_SVC_BASE_NOT_AVAILABLE + 23,
|
||||
@@ -189,6 +178,10 @@ enum NRF_SOC_SVCS
|
||||
SD_RADIO_REQUEST = SOC_SVC_BASE_NOT_AVAILABLE + 30,
|
||||
SD_EVT_GET = SOC_SVC_BASE_NOT_AVAILABLE + 31,
|
||||
SD_TEMP_GET = SOC_SVC_BASE_NOT_AVAILABLE + 32,
|
||||
SD_POWER_USBPWRRDY_ENABLE = SOC_SVC_BASE_NOT_AVAILABLE + 33,
|
||||
SD_POWER_USBDETECTED_ENABLE = SOC_SVC_BASE_NOT_AVAILABLE + 34,
|
||||
SD_POWER_USBREMOVED_ENABLE = SOC_SVC_BASE_NOT_AVAILABLE + 35,
|
||||
SD_POWER_USBREGSTATUS_GET = SOC_SVC_BASE_NOT_AVAILABLE + 36,
|
||||
SVC_SOC_LAST = SOC_SVC_BASE_NOT_AVAILABLE + 37
|
||||
};
|
||||
|
||||
@@ -224,6 +217,26 @@ enum NRF_POWER_THRESHOLDS
|
||||
NRF_POWER_THRESHOLD_V28 /**< 2.8 Volts power failure threshold. */
|
||||
};
|
||||
|
||||
/**@brief Power failure thresholds for high voltage */
|
||||
enum NRF_POWER_THRESHOLDVDDHS
|
||||
{
|
||||
NRF_POWER_THRESHOLDVDDH_V27, /**< 2.7 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V28, /**< 2.8 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V29, /**< 2.9 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V30, /**< 3.0 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V31, /**< 3.1 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V32, /**< 3.2 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V33, /**< 3.3 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V34, /**< 3.4 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V35, /**< 3.5 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V36, /**< 3.6 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V37, /**< 3.7 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V38, /**< 3.8 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V39, /**< 3.9 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V40, /**< 4.0 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V41, /**< 4.1 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLDVDDH_V42 /**< 4.2 Volts power failure threshold. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief DC/DC converter modes. */
|
||||
@@ -326,6 +339,9 @@ enum NRF_SOC_EVTS
|
||||
NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio timeslot signal callback handler return was invalid. */
|
||||
NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio timeslot session is idle. */
|
||||
NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio timeslot session is closed. */
|
||||
NRF_EVT_POWER_USB_POWER_READY, /**< Event indicating that a USB 3.3 V supply is ready. */
|
||||
NRF_EVT_POWER_USB_DETECTED, /**< Event indicating that voltage supply is detected on VBUS. */
|
||||
NRF_EVT_POWER_USB_REMOVED, /**< Event indicating that voltage supply is removed from VBUS. */
|
||||
NRF_EVT_NUMBER_OF_EVTS
|
||||
};
|
||||
|
||||
@@ -520,9 +536,60 @@ SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
|
||||
|
||||
/**@brief Enables or disables the USB power ready event.
|
||||
*
|
||||
* Enabling this will give a SoftDevice event (NRF_EVT_POWER_USB_POWER_READY) when a USB 3.3 V supply is ready.
|
||||
* The event can be retrieved with sd_evt_get();
|
||||
*
|
||||
* @param[in] usbpwrrdy_enable True if the power ready event should be enabled, false if it should be disabled.
|
||||
*
|
||||
* @note Calling this function on a chip without USBD peripheral will result in undefined behaviour.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_USBPWRRDY_ENABLE, uint32_t, sd_power_usbpwrrdy_enable(uint8_t usbpwrrdy_enable));
|
||||
|
||||
/**@brief Enables or disables the power USB-detected event.
|
||||
*
|
||||
* Enabling this will give a SoftDevice event (NRF_EVT_POWER_USB_DETECTED) when a voltage supply is detected on VBUS.
|
||||
* The event can be retrieved with sd_evt_get();
|
||||
*
|
||||
* @param[in] usbdetected_enable True if the power ready event should be enabled, false if it should be disabled.
|
||||
*
|
||||
* @note Calling this function on a chip without USBD peripheral will result in undefined behaviour.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_USBDETECTED_ENABLE, uint32_t, sd_power_usbdetected_enable(uint8_t usbdetected_enable));
|
||||
|
||||
/**@brief Enables or disables the power USB-removed event.
|
||||
*
|
||||
* Enabling this will give a SoftDevice event (NRF_EVT_POWER_USB_REMOVED) when a voltage supply is removed from VBUS.
|
||||
* The event can be retrieved with sd_evt_get();
|
||||
*
|
||||
* @param[in] usbremoved_enable True if the power ready event should be enabled, false if it should be disabled.
|
||||
*
|
||||
* @note Calling this function on a chip without USBD peripheral will result in undefined behaviour.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_USBREMOVED_ENABLE, uint32_t, sd_power_usbremoved_enable(uint8_t usbremoved_enable));
|
||||
|
||||
/**@brief Get USB supply status register content.
|
||||
*
|
||||
* @param[out] usbregstatus The content of USBREGSTATUS register.
|
||||
*
|
||||
* @note Calling this function on a chip without USBD peripheral will result in undefined behaviour.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_USBREGSTATUS_GET, uint32_t, sd_power_usbregstatus_get(uint32_t * usbregstatus));
|
||||
|
||||
/**@brief Sets the power failure comparator threshold value.
|
||||
*
|
||||
* @note: Power failure comparator threshold setting. This setting applies both for normal voltage
|
||||
* mode (supply connected to both VDD and VDDH) and high voltage mode (supply connected to
|
||||
* VDDH only).
|
||||
*
|
||||
* @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDS.
|
||||
*
|
||||
@@ -531,6 +598,18 @@ SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(uint8_t threshold));
|
||||
|
||||
/**@brief Sets the power failure comparator threshold value for high voltage.
|
||||
*
|
||||
* @note: Power failure comparator threshold setting for high voltage mode (supply connected to
|
||||
* VDDH only). This setting does not apply for normal voltage mode (supply connected to both
|
||||
* VDD and VDDH).
|
||||
*
|
||||
* @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDVDDHS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The power failure threshold was set.
|
||||
* @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown.
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_THRESHOLDVDDH_SET, uint32_t, sd_power_pof_thresholdvddh_set(uint8_t threshold));
|
||||
|
||||
/**@brief Writes the NRF_POWER->RAM[index].POWERSET register.
|
||||
*
|
||||
@@ -586,7 +665,7 @@ SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_id, uint32_t *p_gpregret));
|
||||
|
||||
/**@brief Enable or disable the DC/DC regulator.
|
||||
/**@brief Enable or disable the DC/DC regulator for the regulator stage 1 (REG1).
|
||||
*
|
||||
* @param[in] dcdc_mode The mode of the DCDC, see @ref NRF_POWER_DCDC_MODES.
|
||||
*
|
||||
@@ -595,6 +674,16 @@ SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_
|
||||
*/
|
||||
SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(uint8_t dcdc_mode));
|
||||
|
||||
/**@brief Enable or disable the DC/DC regulator for the regulator stage 0 (REG0).
|
||||
*
|
||||
* For more details on the REG0 stage, please see product specification.
|
||||
*
|
||||
* @param[in] dcdc_mode The mode of the DCDC0, see @ref NRF_POWER_DCDC_MODES.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM The dcdc_mode is invalid.
|
||||
*/
|
||||
SVCALL(SD_POWER_DCDC0_MODE_SET, uint32_t, sd_power_dcdc0_mode_set(uint8_t dcdc_mode));
|
||||
|
||||
/**@brief Request the high frequency crystal oscillator.
|
||||
*
|
||||
@@ -887,27 +976,6 @@ SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * p_dst, uint32_t const
|
||||
SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
|
||||
|
||||
|
||||
/**@brief Flash Protection set
|
||||
*
|
||||
* Commands to set the flash protection configuration registers.
|
||||
This sets the CONFIGx registers of the BPROT peripheral.
|
||||
*
|
||||
* @note Not all parameters are valid for all products. Some bits in each parameter may not be
|
||||
* valid for your product. Please refer your Product Specification for more details.
|
||||
*
|
||||
* @note To read the values read them directly. They are only write-protected.
|
||||
*
|
||||
* @note It is possible to use @ref sd_protected_register_write instead of this function.
|
||||
*
|
||||
* @param[in] block_cfg0 Value to be written to the configuration register.
|
||||
* @param[in] block_cfg1 Value to be written to the configuration register.
|
||||
* @param[in] block_cfg2 Value to be written to the configuration register.
|
||||
* @param[in] block_cfg3 Value to be written to the configuration register.
|
||||
*
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED Non-zero value supplied to one or more of the unsupported parameters.
|
||||
* @retval ::NRF_SUCCESS Values successfully written to configuration registers.
|
||||
*/
|
||||
SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3));
|
||||
|
||||
/**@brief Opens a session for radio timeslot requests.
|
||||
*
|
||||
@@ -969,7 +1037,12 @@ SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_
|
||||
*
|
||||
* @param[in] p_request Pointer to the request parameters.
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Either:
|
||||
* - The session is not open.
|
||||
* - The session is not IDLE.
|
||||
* - This is the first request and its type is not @ref NRF_RADIO_REQ_TYPE_EARLIEST.
|
||||
* - The request type was set to @ref NRF_RADIO_REQ_TYPE_NORMAL after a
|
||||
* @ref NRF_RADIO_REQ_TYPE_EARLIEST request was blocked.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
@@ -981,7 +1054,7 @@ SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_
|
||||
* This function writes to a register that is write-protected by the SoftDevice. Please refer to your
|
||||
* SoftDevice Specification for more details about which registers that are protected by SoftDevice.
|
||||
* This function can write to the following protected peripheral:
|
||||
* - BPROT
|
||||
* - ACL
|
||||
*
|
||||
* @note Protected registers may be read directly.
|
||||
* @note Register that are write-once will return @ref NRF_SUCCESS on second set, even the value in
|
||||
+11
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
|
||||
* Copyright (c) Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -45,6 +45,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Supervisor call declaration.
|
||||
*
|
||||
* A call to a function marked with @ref SVCALL, will trigger a Supervisor Call (SVC) Exception.
|
||||
* The SVCs with SVC numbers 0x00-0x0F are forwared to the application. All other SVCs are handled by the SoftDevice.
|
||||
*
|
||||
* @param[in] number The SVC number to be used.
|
||||
* @param[in] return_type The return type of the SVC function.
|
||||
* @param[in] signature Function signature. The function can have at most four arguments.
|
||||
*/
|
||||
|
||||
#ifdef SVCALL_AS_NORMAL_FUNCTION
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#else
|
||||
@@ -0,0 +1,35 @@
|
||||
Copyright (c) 2007 - 2020, Nordic Semiconductor ASA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form, except as embedded into a Nordic
|
||||
Semiconductor ASA integrated circuit in a product or a software update for
|
||||
such product, must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
4. This software, with or without modification, must only be used with a
|
||||
Nordic Semiconductor ASA integrated circuit.
|
||||
|
||||
5. Any software provided in binary form under this license must not be reverse
|
||||
engineered, decompiled, modified and/or disassembled.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,23 @@
|
||||
## Working with SoftDevice S340
|
||||
|
||||
The SoftDevice S340 is closed-source, not publicly available and is only distributed by Garmin Canada Inc.
|
||||
|
||||
In order to be able to download the required ANT+ capable SoftDevice and place SoftDevice S340 v7.0.1 files here. You need to register an 'ANT+ Adopter' account at [thisisant.com](https://www.thisisant.com/register/). After around one business day you will receive access to the resources there. Then do the following steps:
|
||||
- Download the SoftDevice S340 v7.0.1 [(here)](https://www.thisisant.com/developer/components/nrf52832#tab_protocol_stacks_tab) and extract its contents
|
||||
- Under `lib/softdevice` in this repository there is a folder called `s340_nrf52_7.0.1`
|
||||
- Copy the API folder `ANT_s340_nrf52_7.0.1.API`, the license agreement `License_Agreement_ANT_Softdevice_rev3_3.pdf` and the hex file `ANT_s340_nrf52_7.0.1.hex` from the extracted contents to it
|
||||
- Rename the API folder to `s340_nrf52_7.0.1_API`
|
||||
- Rename the hex file to `s340_nrf52_7.0.1_softdevice.hex`
|
||||
- Check `lib/softdevice/s340_nrf52_7.0.1_API/include/nrf_sdm.h` on line 191 to get an *evaluation key* for the ANT SoftDevice which can later be used for the `ANT_LICENSE_KEY` parameter
|
||||
- **VERY IMPORTANT:** You MUST obtain a valid commercial license key BEFORE releasing a product to market that uses the ANT SoftDevice!
|
||||
|
||||
To use the SoftDevice S340 with an existing board the `SD_NAME`, `SD_VERSION` and `ANT_LICENSE_KEY` parameters can just be passed to the command line of the `make` command, e.g.:
|
||||
```
|
||||
make BOARD=xiao_nrf52840_ble_sense SD_NAME=s340 SD_VERSION=7.0.1 ANT_LICENSE_KEY=<YOUR_LICENSE_KEY_OR_EVALUATION_KEY> all
|
||||
```
|
||||
|
||||
To add or modify a board with an ANT+ capable SoftDevice S340 the `SD_VERSION` and `SD_NAME` parameters in the corresponding `board.mk` file have to be set:
|
||||
```
|
||||
SD_VERSION = 7.0.1
|
||||
SD_NAME = s340
|
||||
```
|
||||
Submodule
+1
Submodule lib/tinycrypt added at cf24c907a6.
+1
-1
Submodule lib/tinyusb updated: a1c596490a...9775e76910.
Submodule
+1
Submodule lib/uf2 added at b19ac9ad61.
@@ -1,7 +1,7 @@
|
||||
/* Linker script to configure memory regions. */
|
||||
|
||||
SEARCH_DIR(.)
|
||||
GROUP(-lgcc -lc -lnosys)
|
||||
/*GROUP(-lgcc -lc -lnosys)*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
@@ -11,28 +11,27 @@ MEMORY
|
||||
* those values do not match. The check is performed in main.c, see
|
||||
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
|
||||
*/
|
||||
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0xA000 /* 40 KB */
|
||||
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x7E000, LENGTH = 0x1000
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x7F000, LENGTH = 0x1000
|
||||
|
||||
/** RAM Region for bootloader. */
|
||||
RAM (rwx) : ORIGIN = 0x20003000, LENGTH = 0x20007F7C-0x20003000
|
||||
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20010000-0x20008000
|
||||
|
||||
/* Location for double reset detection, no init */
|
||||
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
|
||||
|
||||
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
|
||||
* from application to bootloader when using buttonluss DFU OTA.
|
||||
*/
|
||||
* from application to bootloader when using buttonless DFU OTA. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000
|
||||
|
||||
|
||||
/** Location in UICR where bootloader start address is stored. */
|
||||
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000
|
||||
|
||||
/** Location in UICR where mbr params page address is stored. */
|
||||
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* Linker script to configure memory regions. */
|
||||
|
||||
SEARCH_DIR(.)
|
||||
/*GROUP(-lgcc -lc -lnosys)*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/** Flash start address for the bootloader. This setting will also be stored in UICR to allow the
|
||||
* MBR to init the bootloader when starting the system. This value must correspond to
|
||||
* BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if
|
||||
* those values do not match. The check is performed in main.c, see
|
||||
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
|
||||
*/
|
||||
FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000-2K /* 38 KB */
|
||||
|
||||
BOOTLOADER_CONFIG (r): ORIGIN = 0x7E000 - 2K, LENGTH = 2K
|
||||
|
||||
/** Location of mbr params page in flash. */
|
||||
MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000
|
||||
|
||||
/** Location of bootloader setting in flash. */
|
||||
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000
|
||||
|
||||
|
||||
|
||||
/** RAM Region for bootloader. */
|
||||
/* Avoid conflict with NOINIT for OTA bond sharing */
|
||||
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20020000-0x20008000
|
||||
|
||||
/* Location for double reset detection, no init */
|
||||
DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04
|
||||
|
||||
/** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
|
||||
* from application to bootloader when using buttonless DFU OTA. */
|
||||
NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80
|
||||
|
||||
|
||||
|
||||
/** Location in UICR where bootloader start address is stored. */
|
||||
UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
|
||||
|
||||
/** Location in UICR where mbr params page address is stored. */
|
||||
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fs_data_out ALIGN(4):
|
||||
{
|
||||
PROVIDE( __start_fs_data = .);
|
||||
KEEP(*(fs_data))
|
||||
PROVIDE( __stop_fs_data = .);
|
||||
} = 0
|
||||
|
||||
.bootloaderConfig :
|
||||
{
|
||||
KEEP(*(.bootloaderConfig))
|
||||
} > BOOTLOADER_CONFIG
|
||||
|
||||
/* Place the bootloader settings page in flash. */
|
||||
.bootloaderSettings(NOLOAD) :
|
||||
{
|
||||
|
||||
} > BOOTLOADER_SETTINGS
|
||||
|
||||
/* Write the bootloader address in UICR. */
|
||||
.uicrBootStartAddress :
|
||||
{
|
||||
KEEP(*(.uicrBootStartAddress))
|
||||
} > UICR_BOOTLOADER
|
||||
|
||||
/* Place the mbr params page in flash. */
|
||||
.mbrParamsPage(NOLOAD) :
|
||||
{
|
||||
|
||||
} > MBR_PARAMS_PAGE
|
||||
|
||||
/* Write the bootloader address in UICR. */
|
||||
.uicrMbrParamsPageAddress :
|
||||
{
|
||||
KEEP(*(.uicrMbrParamsPageAddress))
|
||||
} > UICR_MBR_PARAM_PAGE
|
||||
|
||||
.dbl_reset(NOLOAD) :
|
||||
{
|
||||
|
||||
} > DBL_RESET
|
||||
|
||||
/* No init RAM section in bootloader. Used for bond information exchange. */
|
||||
.noinit(NOLOAD) :
|
||||
{
|
||||
|
||||
} > NOINIT
|
||||
|
||||
/* other placements follow here... */
|
||||
}
|
||||
|
||||
INCLUDE "nrf_common.ld"
|
||||
Loaded 100 of 342 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user