Compare commits

...
133 Commits
Author SHA1 Message Date
Ha Thach c67f0bcf0f Merge pull request #374 from piotrmalek/master
Improve bootloader version parsing from GIT_VERSION
2026-05-21 13:23:49 +07:00
hathach dc42c2a7c0 update cmake version as well 2026-05-21 11:49:01 +07:00
hathach 4b0fc1c504 Merge branch 'master' into fork/piotrmalek/master 2026-05-21 11:38:10 +07:00
Ha Thach 00dba18703 Merge pull request #390 from jesuslg123/auto-reboot-on-usb-disconnected
Exit bootloader and jump to app when USB is disconnected
2026-05-21 11:35:24 +07:00
hathachandClaude Opus 4.7 2f272950fc dfu_transport_serial: normalize new lines to CRLF
PR introduced LF on the new #include and the activity_mark call inside an
otherwise-CRLF file, leaving it mixed-EOL. Convert those lines back to CRLF
to match the rest of the file.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 22:38:07 +07:00
hathach 64f1b70922 usb tud_mount_cb() to set m_usb_was_mounted 2026-05-20 18:07:12 +07:00
Ha Thach b3ac920e82 Merge pull request #396 from adafruit/skip-app-valid-for-debugger-flash
validate app presence more robustly, allow debugger flashing e.g witjlink without flashing the setting page
2026-05-15 11:22:42 +07:00
hathach 67105f8db3 validate app presence more robustly, allow debugger flashing e.g with jlink without flashing the setting page 2026-05-15 10:56:06 +07:00
Ha Thach 48a149ffcb Merge pull request #393 from adafruit/add-agents-md
update AGENTS.md
2026-03-19 10:43:34 +07:00
hathach ac086326fe restrict GitHub Actions to master branch and add workflow_dispatch trigger 2026-03-19 10:34:52 +07:00
hathach 545fc0534d update AGENTS.md 2026-03-19 10:32:02 +07:00
jesuslg123 1f17efd611 Revert unwanted change 2026-03-08 22:35:48 +01:00
jesuslg123 96c57447c6 Ignore files 2026-03-08 21:20:18 +01:00
jesuslg123 57ce8b2e93 When in bootloader mode and USB is disconnected the system now jumpt to app state to avoid leave the device stuck on bootloader 2026-03-08 21:20:03 +01:00
Ha Thach 8023c1e6a0 Merge pull request #384 from ejtagle/master
Use ACL to protect MBR and Bootloader against accidental FLASH overwrites by the user application
2026-02-25 10:12:54 +07:00
Ha Thach a32baf561b Merge pull request #387 from mestrode/master
Seeed Xiao BLE boards: enable 2nd LED
2026-02-23 16:02:18 +07:00
mestrode dd816e511a Seeed Xiao BLE boards: enable 2nd LED 2026-02-16 17:32:07 +01:00
Eduardo José Tagle 2d889d35d5 Merge branch 'adafruit:master' into master 2026-02-04 12:07:14 -03:00
hathach c2ae4183aa minor 2026-02-03 20:38:21 +07:00
hathach 48cfda2a29 check page size alignment for address as well 2026-02-03 19:01:45 +07:00
hathach 8c45bf843c - always enable flash protect
- clean up code
- add illustrated memory layout for quick ref
2026-02-03 18:47:04 +07:00
hathach c3282f4c0a Merge branch 'master' into fork/piotrmalek/master
# Conflicts:
#	Makefile
2026-02-03 14:46:18 +07:00
Ha Thach 6180d8a26b Merge pull request #381 from ReFil/gcc-15-fixes
fix: Fix build errors on GCC15
2026-02-03 14:17:16 +07:00
hathach 6b24be5f69 - add GCC diagnostic ignored "-Warray-bounds" to affected code
- correct usage of __has_attribute(nonstring) and rename to ATTR_NOSTRING
2026-02-03 14:14:08 +07:00
Eduardo José Tagle 3714bb727d Merge branch 'adafruit:master' into master 2026-02-02 20:10:09 -03:00
Eduardo José Tagle c61f330c1d Merge branch 'master' of https://github.com/ejtagle/Adafruit_nRF52_Bootloader 2026-02-02 14:28:35 -03:00
Eduardo José Tagle 1307fe7f57 Enable FLASH overwrite protection from user applications for MBR and bootloader 2026-02-02 14:28:12 -03:00
Ha Thach ede0f06e03 Merge pull request #378 from ambraglow/master
Add support for Syldra development board
2026-02-02 19:36:46 +07:00
hathach cef2651b0d correct uf2 board id 2026-02-02 19:14:56 +07:00
hathach 5bb68e6125 sync master 2026-02-02 19:12:21 +07:00
hathach 1069753842 Merge branch 'master' into fork/ambraglow/master 2026-02-02 19:11:14 +07:00
Ha Thach 5a11529409 Merge pull request #383 from adafruit/refactor-button
Refactor button
2026-02-02 17:55:34 +07:00
hathach a6f668ece4 clean up 2026-02-02 17:33:14 +07:00
hathach 7cf6787810 Merge branch 'master' into refactor-button
# Conflicts:
#	src/boards/nice_nano/board.h
2026-02-02 16:52:32 +07:00
hathach 29173a4de1 rename BUTTON_FRESET to BUTTON_DFU_OTA
change board.d BUTTON_1/2 directly to BUTTON_DFU and BUTTON_DFU_OTA
2026-02-02 16:49:26 +07:00
Ha Thach 583d67b30d Merge pull request #377 from ejtagle/master
Try to gracefully handle FLASH operations queue becoming full, instead of silently failing and allow OTA DFU process to be recoverable, in case of a communication error in the DUAL_BANK configuration
2026-02-02 15:52:52 +07:00
hathach a76d419c34 minor clean up 2026-02-02 14:30:32 +07:00
Eduardo José TagleandCopilot e6da12ab45 Update Makefile
Yes, the '-D' was missing

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-31 16:23:36 -03:00
Eduardo José Tagle 4d1ca56d0a nice!nano board has no buttons 2026-01-31 16:20:36 -03:00
Eduardo José Tagle e8ffbd019a Allow using an external LNA/PA to increase BLE range 2026-01-31 16:19:57 -03:00
Eduardo José Tagle d0f13ea1fe Made sure to clear pending interrupts and exceptions before jumping to the user application. Was rarely causing locks 2026-01-31 16:17:22 -03:00
hathach cb30e6f172 update board and supported_boards.md 2026-01-31 11:52:15 +07:00
Eduardo José Tagle 87b8354d1f Allow defaulting to OTA DFU instead of Serial/UF2 DFU (turned off by default) 2026-01-30 13:09:24 -03:00
Willow Herring d435d66921 fix: Fix build errors on GCC15 2026-01-28 18:55:22 +00:00
Eduardo José Tagle 3249f41dd9 In case a RESET command is received in the middle of a OTA DFU, reboot to bootloader to allow the DFU app to recover previously interrupted transfers, instead of reverting to the last working firmware and launching it 2026-01-27 22:41:20 -03:00
ambraglow da75a5443f Add support for Syldra development board 2026-01-27 17:08:45 +01:00
Eduardo José Tagle 6770e15527 Merge branch 'adafruit:master' into master 2026-01-26 14:38:12 -03:00
hathach 210c6f4a40 add AGENTs.md, remove unused BUTTONS_NUMBER 2026-01-26 18:17:14 +07:00
Ha Thach 30c734971e Merge pull request #376 from adafruit/pr/1
Make User Button DFU/FRESET optional
2026-01-26 17:35:04 +07:00
hathach 794aef2053 clean up 2026-01-26 17:27:57 +07:00
hathach 698bfa2c09 Merge branch 'master' into fork/SeeedJP/pr/1
# Conflicts:
#	src/boards/boards.c
#	src/main.c
2026-01-26 16:27:01 +07:00
Eduardo José Tagle c9dd183d4d Merge branch 'adafruit:master' into master 2026-01-26 01:33:20 -03:00
Eduardo José Tagle 29dd14ee46 Merged improvements 2026-01-26 00:49:52 -03:00
Eduardo José Tagle e1ea1c6dd1 Wait until FLASH operation queue has enough available room, instead of silently dropping operations 2026-01-26 00:44:54 -03:00
Ha Thach 78540d604f Merge pull request #375 from ejtagle/master
Huge improvement in stability,reliability and speed, restored dual_bank support and signed firmware verification
2026-01-23 14:35:43 +07:00
hathach 3c4470889b minor clean up and fix dfu_bl_image_validate() return nrf error code 2026-01-23 14:30:58 +07:00
Ha ThachandCopilot 3e87e07921 fix typo
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-21 09:06:12 +07:00
Eduardo José Tagle 827edd212b Bumped SLAVE_LATENCY to 4. Does not make any difference in our tests, but https://stackoverflow.com/questions/32588325/ios-bluetooth-le-code-6-the-connection-has-timed-out-unexpectedly suggests this is the best to solve the ConnectionTimedOutUnexpectedly on IOS 2026-01-15 19:14:41 -03:00
Eduardo José Tagle 16477539d9 Fix autodetection of workarounds for GCC 12.x 13.x and 14.x under Windows 2026-01-15 15:43:59 -03:00
Eduardo José Tagle 6b5158a682 Removed redundant call to verify if the supplied public key is valid 2026-01-15 15:31:16 -03:00
Eduardo José Tagle 0623a20120 Fixed compilation 2026-01-15 02:51:01 -03:00
Eduardo José Tagle 33070836f9 Add missing tinycrypt dependency 2026-01-15 02:38:13 -03:00
Eduardo José Tagle 01290c728b Improved documentation on dual bank and signed bootloader 2026-01-15 02:35:05 -03:00
Eduardo José Tagle c8af92c4d8 Implement signed firmware verification: If enabled (Disabled by default), the bootloader will reject and not flash any firmware that is not digitally signed with the proper key 2026-01-15 01:53:57 -03:00
Eduardo José Tagle f20bfe9f63 Add DUAL_BANK functionality (disabled by default, can be enabled passing DUAL_BANK=1 to the Makefile in the make command line 2026-01-15 01:40:51 -03:00
Eduardo José Tagle d8c27bb7fd If there is no application in FLASH, or flash was corrupted, make sure to restart in DFU mode 2026-01-15 01:31:36 -03:00
Eduardo José Tagle 88eab38a6c Allow flashing of a SINGLE BANK bootloader after a DUAL BANKED bootloader was installed. Without this patch, the SINGLE BANK bootloader will end in a continuous loop and no recovery without a JTAG programmer is possible 2026-01-15 01:26:03 -03:00
Eduardo José Tagle 450ce3b3c6 Definitions for DUAL BANKED firmware updates (storing 2 copies of the firmware, so if a firmware update fails, the bootloader can revert to the previously working firmware) 2026-01-15 01:22:12 -03:00
Eduardo José Tagle efe383d090 Add DFU mode exit timeout of 3 minutes. If the user enters DFU mode BUT does nothing, in about 3 minutes, the bootloader will exit and start executing the user application 2026-01-15 01:19:15 -03:00
Eduardo José Tagle ca46deb0a2 Factor out FLASH erase procedure (non OTA), fix FLASH write procedure (non OTA), use them instead of repeating code 2026-01-15 01:14:50 -03:00
Eduardo José Tagle d28c2e0871 Enable negotiation of MTU sizes above 20. This will significatively increase DFU write speed 2026-01-15 01:03:53 -03:00
Eduardo José Tagle 36422ba612 Speedup FLASH writes by temporarily increasing BLE stack local latency 2026-01-15 00:46:27 -03:00
Eduardo José Tagle 04d029a5bd Allow overriding device name in DFU mode 2026-01-15 00:43:27 -03:00
Eduardo José Tagle b5ddc1879e Fix improper processing of Flash WRITE/ERASE completion notifications that was causing the DFU firmware update to sometimes crash 2026-01-15 00:41:16 -03:00
Eduardo José Tagle 2910556adc Wait until notification queue has enough room so no notifications of completed operations to the DFU app are lost 2026-01-15 00:36:14 -03:00
Eduardo José Tagle f5ab453f75 Allow BLE characteristics to support both WriteWithoutResponse (for compatibility with Nordic DFU apps) and WriteWithResponse (for improved reliability) 2026-01-15 00:31:39 -03:00
Piotr Małek 951a93abb4 Improve bootloader version parsing from GIT_VERSION 2026-01-14 11:32:04 +01:00
Ha Thach 0147d71e73 Merge pull request #372 from adafruit/update-buildsystem
Update buildsystem
2025-12-19 23:20:30 +07:00
hathach 24768bcd9a clean up 2025-12-19 22:55:38 +07:00
hathach 859a721b41 remove git submodules from uf2 version 2025-12-19 18:11:08 +07:00
hathach d7e4a2572a update cmake build 2025-12-19 17:25:24 +07:00
hathach 4493a352cb add board.cmake 2025-12-19 16:42:31 +07:00
Ha Thach c4b2c5039f Merge pull request #366 from JuergenLeber/master
feat: finalize SoftDevice S340 support
2025-12-04 17:19:12 +07:00
Ha Thach a766738509 Merge pull request #367 from tomaszduda23/master
fix boot loop due to wrong value read from REGOUT0
2025-12-04 17:17:45 +07:00
Tomasz Duda 6250be4bf1 fix boot loop due to wrong value read from REGOUT0 2025-11-11 21:50:29 +01:00
Jürgen Leber 4ca93c5139 feat: adjust documentation for builds with SoftDevice S340 2025-10-27 21:05:08 +01:00
Jürgen Leber fa1caccd67 feat: add ANT_LICENSE_KEY handling for SoftDevice S340 2025-10-27 20:57:29 +01:00
Ha Thach 6a9a6a3e6d Merge pull request #359 from JuergenLeber/add-sd-s340-support
feat: add support for SoftDevice S340
2025-06-30 17:54:31 +07:00
hathach 31c3081668 update makefile/cmake for softdevice macro. Remove the _s340 filter in ci 2025-06-30 17:32:49 +07:00
hathach d475f25154 Merge branch 'master' into fork/JuergenLeber/add-sd-s340-support
# Conflicts:
#	README.md
2025-06-30 16:14:29 +07:00
Ha Thach 4bce0cc1f2 Merge pull request #358 from JuergenLeber/repair-debug-build
fix: repair build with DEBUG=1 option
2025-06-30 14:31:04 +07:00
Ha Thach b1e088396a Merge pull request #347 from OmarEMbed/master
Adding Omnimo-nRF52840 board
2025-06-30 14:29:50 +07:00
Ha Thach df983b53c7 Merge pull request #357 from JuergenLeber/minor-updates-and-fixes
chore: update uf2 submodule and fix a small typo
2025-06-30 11:28:32 +07:00
Ha Thach 0e98348d96 Merge pull request #354 from andreaskurz/askz/fix-cmake-build
fix: CMake build producing too large binaries
2025-06-30 10:50:43 +07:00
hathach 70da7d88f4 set CMAKE_BUILD_TYPE to MinSizeRel if not defined instead of forcing -Os
add CONFIG_GPIO_AS_PINRESET
2025-06-30 10:45:38 +07:00
JuergenLeber 3182f6036d fix: remove -lnosys option for debug linker scripts as it conflicts with RTT printf retarget 2025-06-10 19:10:53 +02:00
JuergenLeber de9a9b79f4 refactor: deduplicate code for disabling SD 2025-06-10 19:05:21 +02:00
JuergenLeber b8544f5c8c feat: add SD S340 support for nRF52840 and nRF52833 2025-06-10 19:05:21 +02:00
JuergenLeber 00b5e72496 fix: fix small typo 2025-06-10 18:58:34 +02:00
JuergenLeber 389e5b004d chore: update uf2 submodule to latest 2025-06-10 18:58:34 +02:00
Andreas Kurz ddcb2dba8c chore: add documentation for CMake
In this repository CMake and Make co-exists. Unfortunately there was no
documentation on how to properly use CMake so this is a starting point.

Signed-off-by: Andreas Kurz <info@akurz.net>
2025-05-09 10:31:05 +02:00
Andreas Kurz 73020f3567 fix: add size optimization
This flag is also present in the Makefile and optimises the resulting binary for the size of the binary. Without that flag the flash consumption would be too high to fit inside the allocated space.

Signed-off-by: Andreas Kurz <info@akurz.net>
2025-05-09 10:17:09 +02:00
Ha Thach a48e944f0b Merge pull request #353 from andreaskurz/askz/fix-array-subscript
fix: array subscript 0 outside array bounds
2025-05-05 17:06:44 +07:00
Andreas Kurz c83fa9fc2b fix: array subscript 0 outside array bounds
This will also add version 14.x of the compiler to apply additional CLFAGS.

 #339

Signed-off-by: Andreas Kurz <info@akurz.net>
2025-05-04 20:59:12 +02:00
OmarEMbed 8970125e51 Update board.h 2025-02-16 14:00:12 +01:00
OmarEMbed 22224cef7b Add files via upload 2025-02-16 11:04:50 +01:00
Ha Thach 4329614a8f Merge pull request #343 from chibiegg/board_MBN52832DK
Add support Murata MBN52832DK board
2025-02-07 17:04:16 +07:00
Ha Thach bd12455029 Merge pull request #344 from fanoush/fix-regout0-bootloop
fix reboot loop - set REGOUT0 only when value is erased to default
2025-02-07 17:03:06 +07:00
Ha Thach 3a2708b30a Merge pull request #342 from pdcook/master
Add support for nRFMicro
2024-12-25 16:14:00 +07:00
fanoush fb557b2af9 set REGOUT0 only when value is erased to default
this fixes reboot loop when REGOUT0 is explicitly set to different value that cannot be rewritten by clearing bits in flash
2024-11-16 10:28:42 +01:00
chibiegg 7f2b127506 Add support Murata MBN52832DK board 2024-11-05 14:05:57 +09:00
Patrick Cook 5a96435322 commit correct file for nRFMicro 2024-09-11 23:19:40 -04:00
Patrick Cook f3b3a0de40 reduced number of chars, updated potential PID 2024-09-08 18:31:25 -04:00
Patrick Cook 6940c5b73e rename promicro->nrfmicro 2024-09-08 18:29:19 -04:00
Patrick Cook 4786a4a251 fixed board-id to conform to standards 2024-09-08 17:14:35 -04:00
Patrick Cook 9027359cec add support for promicro/supermini nrf52 boards 2024-09-08 17:11:05 -04:00
Ha Thach eefbe6bda9 Merge pull request #337 from adafruit/support-itsybitsy-dotstar
support itsybitsy dotstar led
2024-07-19 13:06:13 +07:00
hathach ab74be4811 correct itsybitsy dotstar 2024-07-19 13:02:31 +07:00
Ha Thach 488711a9b3 Merge pull request #336 from markbirss/master
Add support for Seeed T1000-E boards
2024-07-12 20:22:34 +07:00
Mark Trevor Birss 91fc6735e9 Update board.h 2024-07-12 12:34:49 +02:00
Mark Trevor Birss 6b62aacdc9 Update board.h 2024-07-12 09:20:53 +02:00
Mark Trevor Birss 4f747e416b Update board.h 2024-07-12 09:02:34 +02:00
Mark Trevor Birss 155dedb048 Add files via upload 2024-07-12 08:55:57 +02:00
Ha Thach 29ca3ebfab Merge pull request #332 from adafruit/bump-feather833-sd
remove feather 833 specific SD_VERSION
2024-06-05 17:45:15 +07:00
hathach 4e700d4904 bump feather 833 SD to 7.3.0 2024-06-05 17:42:13 +07:00
Ha Thach 8473ff6f35 Merge pull request #331 from adafruit/minor-update
Minor update
2024-06-05 17:38:36 +07:00
hathach 5f99d530ff revert fetch-depth 0 2024-06-05 17:34:56 +07:00
hathach c5150ccf02 update PR template 2024-06-05 17:32:51 +07:00
hathach 438a08e0ac change PID of argon,boron,xenon, pca10056 to 0x00DA (allocated by Adafruit), previously these shared with feather nrf52840
change PID of pca10100 to 0x00D8 (allocated by Adafruit)
2024-06-05 17:30:27 +07:00
hathach 2d68ec56e3 default SD version to 7.3.0 for 833, 6.1.1 for 840 and 832
some cmake rename
2024-06-05 17:29:26 +07:00
Ha Thach 836c8dcc76 Merge pull request #329 from adafruit/ci-auto-matrix
use script to set board matrix
2024-05-09 21:40:35 +07:00
hathach 9e25f4ac0a use script to set board matrix 2024-05-09 20:40:04 +07:00
Takashi Matsuoka a5bf0bad6e Support for no button 2023-02-02 17:24:35 +09:00
169 changed files with 4918 additions and 27442 deletions

No files matched your search

+99
View File
@@ -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
...
-2
View File
@@ -3,10 +3,8 @@
*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
- [ ] Please provide related links (*eg. Issue which will be closed by this Pull Request*)
- [ ] If you are adding an new boards, please make sure
- [ ] Provide link to your allocated VID/PID if applicable
- [ ] Add your board to [action ci](/.github/workflows) in correct workflow and alphabet order for release binary
- [ ] `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.*
+24 -55
View File
@@ -1,74 +1,43 @@
name: Build
on:
workflow_dispatch:
pull_request:
push:
repository_dispatch:
branches: [ master ]
release:
types:
- created
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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:
# Adafruit Boards
- 'circuitplayground_nrf52840'
- 'clue_nrf52840'
- 'feather_nrf52832'
- 'feather_nrf52833_express'
- 'feather_nrf52840_express'
- 'feather_nrf52840_sense'
- 'feather_nrf52840_sense_tft'
- 'itsybitsy_nrf52840_express'
- 'metro_nrf52840_express'
- 'ledglasses_nrf52840'
# Other Makers (Alphabetical order)
- 'adm_b_nrf52840_1'
- 'ae_bl652_bo'
- 'aramcon_badge_2019'
- 'aramcon2_badge'
- 'arcade_feather_nrf52840_express'
- 'arduino_nano_33_ble'
- 'bast_ble'
- 'bluemicro_nrf52833'
- 'bluemicro_nrf52840'
- 'challenger_840_ble'
- 'ebyte_e104_bt5032a'
- 'ebyte_e73_tbb'
- 'electronut_labs_papyr'
- 'ikigaisense_vita'
- 'm60_keyboard'
- 'mdk_nrf52840_dongle'
- 'mikoto'
- 'nice_nano'
- 'nrf52840_bboard'
- 'nRF52840_connect_kit'
- 'nrf52840_m2'
- 'ohs2020_badge'
- 'particle_argon'
- 'particle_boron'
- 'particle_xenon'
- 'pca10056'
- 'pca10059'
- 'pca10100'
- 'pitaya_go'
- 'raytac_mdbt50q_db_40'
- 'raytac_mdbt50q_rx'
- 'sparkfun_nrf52840_micromod'
- 'waveshare_nrf52840_eval'
- 'xiao_nrf52840_ble'
- 'xiao_nrf52840_ble_sense'
board: ${{ fromJSON(needs.set-matrix.outputs.matrix) }}
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Checkout Code
uses: actions/checkout@v4
with:
+4
View File
@@ -56,6 +56,7 @@ dkms.conf
segger/Output
_build/
cmake-build-*/
bin/
*.emSession
*.jlink
@@ -65,3 +66,6 @@ TAGS
.DS_Store
Makefile.user
# Exclude all SoftDevice S340 files
lib/softdevice/s340*
+3
View File
@@ -8,3 +8,6 @@
path = lib/uf2
url = https://github.com/microsoft/uf2.git
[submodule "lib/tinycrypt"]
path = lib/tinycrypt
url = https://github.com/intel/tinycrypt
+102
View File
@@ -0,0 +1,102 @@
# Agent Instructions
This file provides guidance to AI agents when working with code in this repository.
## Project Overview
CDC/DFU/UF2 bootloader for Nordic nRF52 microcontrollers (nRF52832, nRF52833, nRF52840). Supports DFU over Serial, BLE OTA, and USB mass storage (UF2). Runs on 60+ boards.
## Style
Follow the repo `.clang-format` when making changes.
## Build / Verify
Default board: `feather_nrf52840_express`. Always verify changes against both boards:
- `feather_nrf52840_express` (nRF52840)
- `feather_nrf52832` (nRF52832)
### CMake (preferred)
```bash
cmake -S . -B cmake-build-feather_nrf52840_express -DBOARD=feather_nrf52840_express
cmake --build cmake-build-feather_nrf52840_express
cmake -S . -B cmake-build-feather_nrf52832 -DBOARD=feather_nrf52832
cmake --build cmake-build-feather_nrf52832
```
### Make (alternate)
```bash
make BOARD=feather_nrf52840_express all
make BOARD=feather_nrf52832 all
```
### Flashing
```bash
make BOARD={board} flash # Flash via JLink
make BOARD={board} flash-dfu # Flash via Serial/CDC DFU
make BOARD={board} flash-sd # Flash SoftDevice only
```
### Build all boards
```bash
python3 tools/build_all.py
```
## Architecture
### MCU Variants and SoftDevices
- **nrf52** (nRF52832): UART-only bootloader, default SoftDevice s132 v6.1.1
- **nrf52833**: USB support, default SoftDevice s140 v7.3.0
- **nrf52840**: Full USB + OTA, default SoftDevice s140 v6.1.1
- Boards may override `SD_NAME`/`SD_VERSION` in their `board.mk`
### Key Source Structure
- `src/main.c` — Bootloader entry point, DFU mode detection, LED/button init
- `src/dfu_init.c` — DFU packet validation, CRC/signature verification
- `src/dfu_ble_svc.c` — BLE DFU service
- `src/flash_nrf5x.c` — Flash memory operations
- `src/boards/boards.c` — Board abstraction (LED control, buttons, timing)
- `src/usb/` — USB stack (nRF52833/nRF52840): CDC serial, MSC storage, UF2 handler
- `src/usb/uf2/ghostfat.c` — Virtual FAT filesystem for UF2 drag-and-drop
### Board Definition System
Each board lives in `src/boards/{board_name}/` with:
- `board.h` — Pin definitions, LED/button assignments, USB VID/PID, UF2 metadata
- `board.mk` — Makefile variable `MCU_SUB_VARIANT` (nrf52, nrf52833, or nrf52840)
- `board.cmake` — CMake variable `MCU_VARIANT`
- `pinconfig.c` — CF2 bootloader configuration (flash/RAM size, UF2 family ID)
### Memory Layout (linker scripts in `linker/`)
- Bootloader occupies ~38KB near end of flash (e.g., 0xF4000–0xFD800 on nRF52840)
- No heap (`__HEAP_SIZE=0`), static allocation only
- Special sections: double-reset detection word, bond info for OTA, MBR params, bootloader settings
### Submodules (`lib/`)
- `tinyusb` — USB device stack
- `nrfx` — Nordic HAL drivers
- `uf2` — UF2 format tools
- `tinycrypt` — Crypto (only when `SIGNED_FW=1`)
- `sdk/`, `sdk11/` — Nordic SDK libraries
- `softdevice/` — Precompiled Bluetooth stack binaries
### Compile-Time Feature Flags
- `SIGNED_FW` — Require signed firmware (disables UF2 unless `FORCE_UF2=1`)
- `DUALBANK_FW` — Dual-bank updates
- `DEFAULT_TO_OTA_DFU` — Default to BLE OTA instead of serial DFU
- `DEBUG` — Enable RTT debugging, larger bootloader region
## PR Review Checklist
- **VID/PID assignment**: When a PR adds or modifies a board, verify `USB_DESC_VID`/`USB_DESC_UF2_PID` in `board.h`. New boards should use unique values. The Adafruit VID `0x239A` is reserved for Adafruit-allocated boards; third-party boards must use their own VID. Some legacy boards intentionally share a VID/PID with a reference board (see `// Shared VID/PID with ...` comments) — these are pending cleanup, not a template for new boards.
## CI
GitHub Actions (`.github/workflows/githubci.yml`) builds all boards in parallel using a matrix generated from `src/boards/` directory names. On release, artifacts (zip, hex, uf2) are uploaded as release assets.
## Required Toolchain
- `arm-none-eabi-gcc` (tested with 12.3.1)
- Python 3 with: `adafruit-nrfutil`, `intelhex`
- `nrfjprog` (for JLink flashing)
+212 -159
View File
@@ -1,14 +1,11 @@
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 ()
if (NOT DEFINED TOOLCHAIN)
set(TOOLCHAIN gcc)
endif ()
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/src/boards/${BOARD}/board.cmake)
@@ -21,15 +18,22 @@ else ()
set(JLINK_DEVICE ${MCU_VARIANT}_xxaa)
endif ()
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/arm_gcc.cmake)
project(Adafruit_nRF52_Bootloader C ASM)
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)
set(NRFX ${CMAKE_CURRENT_LIST_DIR}/lib/nrfx)
set(SDK11 ${CMAKE_CURRENT_LIST_DIR}/lib/sdk11/components)
set(SDK ${CMAKE_CURRENT_LIST_DIR}/lib/sdk/components)
set(SOFTDEVICE ${CMAKE_CURRENT_LIST_DIR}/lib/softdevice)
set(TUSB ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
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)
@@ -37,17 +41,13 @@ set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c)
#-------------------
# Bootloader
#-------------------
set(CMAKE_EXECUTABLE_SUFFIX .elf)
add_executable(bootloader)
# SD_VERSION can be overwritten by board.cmake
if(NOT DEFINED SD_VERSION)
set(SD_VERSION 6.1.1)
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
endif ()
set(MBR_HEX ${SOFTDEVICE}/mbr/hex/mbr_nrf52_2.4.1_mbr.hex)
target_sources(bootloader PUBLIC
project(Adafruit_nRF52_Bootloader C ASM)
set(CMAKE_EXECUTABLE_SUFFIX .elf)
add_executable(bootloader
# src
src/dfu_ble_svc.c
src/dfu_init.c
@@ -57,95 +57,99 @@ target_sources(bootloader PUBLIC
src/images.c
src/boards/boards.c
# nrfx
${NRFX}/drivers/src/nrfx_power.c
${NRFX}/drivers/src/nrfx_nvmc.c
${NRFX}/mdk/system_${MCU_VARIANT}.c
${NRFX_DIR}/drivers/src/nrfx_power.c
${NRFX_DIR}/drivers/src/nrfx_nvmc.c
${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c
# sdk 11
${SDK11}/libraries/bootloader_dfu/bootloader.c
${SDK11}/libraries/bootloader_dfu/bootloader_settings.c
${SDK11}/libraries/bootloader_dfu/bootloader_util.c
${SDK11}/libraries/bootloader_dfu/dfu_transport_serial.c
${SDK11}/libraries/bootloader_dfu/dfu_transport_ble.c
${SDK11}/libraries/bootloader_dfu/dfu_single_bank.c
${SDK11}/ble/ble_services/ble_dfu/ble_dfu.c
${SDK11}/ble/ble_services/ble_dis/ble_dis.c
${SDK11}/drivers_nrf/pstorage/pstorage_raw.c
${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}/libraries/timer/app_timer.c
${SDK}/libraries/scheduler/app_scheduler.c
${SDK}/libraries/util/app_error.c
${SDK}/libraries/util/app_util_platform.c
${SDK}/libraries/crc16/crc16.c
${SDK}/libraries/hci/hci_mem_pool.c
${SDK}/libraries/hci/hci_slip.c
${SDK}/libraries/hci/hci_transport.c
${SDK}/libraries/util/nrf_assert.c
# ASM
${NRFX}/mdk/gcc_startup_${MCU_VARIANT}.S
${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
${TUSB}
${TINYUSB_DIR}
# nrfx
${NRFX}
${NRFX}/mdk
${NRFX}/hal
${NRFX}/drivers/include
${NRFX}/drivers/src
${NRFX_DIR}
${NRFX_DIR}/mdk
${NRFX_DIR}/hal
${NRFX_DIR}/drivers/include
${NRFX_DIR}/drivers/src
# sdk 11 for cdc/ble dfu
${SDK11}/libraries/bootloader_dfu
${SDK11}/libraries/bootloader_dfu/hci_transport
${SDK11}/drivers_nrf/pstorage
${SDK11}/ble/common
${SDK11}/ble/ble_services/ble_dfu
${SDK11}/ble/ble_services/ble_dis
${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}/libraries/timer
${SDK}/libraries/scheduler
${SDK}/libraries/crc16
${SDK}/libraries/util
${SDK}/libraries/hci/config
${SDK}/libraries/hci
${SDK}/libraries/uart
${SDK}/drivers_nrf/delay
${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}/mbr/headers
${SOFTDEVICE_DIR}/mbr/headers
)
# Debug option
# Debug linker file
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
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_debug.ld)
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 ()
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}.ld)
endif ()
target_link_options(bootloader PUBLIC
"LINKER:--script=${LD_FILE}"
-L${NRFX}/mdk
-L${NRFX_DIR}/mdk
-nostartfiles
--specs=nosys.specs --specs=nano.specs
)
target_compile_options(bootloader PUBLIC
@@ -171,8 +175,32 @@ target_compile_options(bootloader PUBLIC
)
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)
@@ -181,14 +209,14 @@ endif ()
if (MCU_VARIANT STREQUAL "nrf52")
# UART transport
target_sources(bootloader PUBLIC
${SDK}/libraries/uart/app_uart.c
${SDK}/drivers_nrf/uart/nrf_drv_uart.c
${SDK}/drivers_nrf/common/nrf_drv_common.c
${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}/libraries/util
${SDK}/drivers_nrf/common
${SDK}/drivers_nrf/uart
${SDK11_DIR}/libraries/util
${SDK_DIR}/drivers_nrf/common
${SDK_DIR}/drivers_nrf/uart
)
else ()
# USB transport
@@ -199,13 +227,13 @@ else ()
src/usb/usb_desc.c
src/usb/uf2/ghostfat.c
# TinyUSB
${TUSB}/portable/nordic/nrf5x/dcd_nrf5x.c
${TUSB}/common/tusb_fifo.c
${TUSB}/device/usbd.c
${TUSB}/device/usbd_control.c
${TUSB}/class/cdc/cdc_device.c
${TUSB}/class/msc/msc_device.c
${TUSB}/tusb.c
${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 ()
@@ -213,94 +241,106 @@ 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
S132
)
target_include_directories(bootloader PUBLIC
${SOFTDEVICE}/s132_nrf52_6.1.1/s132_nrf52_6.1.1_API/include
)
target_compile_definitions(bootloader PUBLIC NRF52 NRF52832_XXAA)
elseif (MCU_VARIANT STREQUAL "nrf52833")
set(SD_NAME s140)
set(DFU_DEV_REV 52833)
set(DFU_APP_DATA_RESERVED 7*4096)
target_compile_definitions(bootloader PUBLIC
NRF52833_XXAA
S140
)
target_include_directories(bootloader PUBLIC
${SOFTDEVICE}/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include
)
target_compile_definitions(bootloader PUBLIC NRF52833_XXAA)
if (NOT DEFINED SD_NAME)
set(SD_NAME s140)
endif ()
elseif (MCU_VARIANT STREQUAL "nrf52840")
set(SD_NAME s140)
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
S140
)
target_include_directories(bootloader PUBLIC
${SOFTDEVICE}/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include
)
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}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex)
set(SD_HEX ${SOFTDEVICE_DIR}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
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)
execute_process(COMMAND bash "-c" "git submodule status | cut -d\" \" -f3,4 | paste -s -d\" \" -"
OUTPUT_VARIABLE GIT_SUBMODULE_VERSIONS
)
string(STRIP ${GIT_SUBMODULE_VERSIONS} GIT_SUBMODULE_VERSIONS)
string(REPLACE ../ "" GIT_SUBMODULE_VERSIONS ${GIT_SUBMODULE_VERSIONS})
string(REPLACE lib/ "" GIT_SUBMODULE_VERSIONS ${GIT_SUBMODULE_VERSIONS})
# Extract semantic version numbers (MAJOR.MINOR.PATCH) from GIT_VERSION.
# Supports tags like:
# v1.2.3
# 1.2.3
# 1.2.3-147-gd71abcd
# If the version string does not match MAJOR.MINOR.PATCH, defaults to 0.0.0.
if(GIT_VERSION MATCHES "^v?([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(RELEASE_VERSION_MAJOR ${CMAKE_MATCH_1})
set(RELEASE_VERSION_MINOR ${CMAKE_MATCH_2})
set(RELEASE_VERSION_PATCH ${CMAKE_MATCH_3})
else()
set(RELEASE_VERSION_MAJOR 0)
set(RELEASE_VERSION_MINOR 0)
set(RELEASE_VERSION_PATCH 0)
endif()
math(EXPR MK_BOOTLOADER_VERSION "((${RELEASE_VERSION_MAJOR} << 16) | (${RELEASE_VERSION_MINOR} << 8) | ${RELEASE_VERSION_PATCH})")
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 GIT_SUBMODULE_VERSIONS MK_BOOTLOADER_VERSION)
cmake_print_variables(GIT_VERSION MK_BOOTLOADER_VERSION)
target_compile_definitions(bootloader PUBLIC
UF2_VERSION_BASE="${GIT_VERSION}"
UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS}"
UF2_VERSION="${GIT_VERSION}"
BLEDIS_FW_VERSION="${GIT_VERSION} ${SD_NAME} ${SD_VERSION}"
MK_BOOTLOADER_VERSION=${MK_BOOTLOADER_VERSION}
)
#----------------------------------
# Post build
#----------------------------------
# run size after build
add_custom_command(TARGET bootloader POST_BUILD
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:bootloader>
)
# Add bin/hex output
add_custom_command(TARGET bootloader POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.bin
@@ -312,12 +352,11 @@ add_custom_command(TARGET bootloader POST_BUILD
#----------------------------------
# Flashing target
#----------------------------------
if (NOT DEFINED NRFJPROG)
set(NRFJPROG nrfjprog)
endif()
add_custom_target(flash-jlink
add_custom_target(flash-bootloader
DEPENDS bootloader
COMMAND ${NRFJPROG} --program $<TARGET_FILE:bootloader> --verify --sectoranduicrerase -f nrf52 --reset
)
@@ -328,13 +367,27 @@ add_custom_target(flash-uf2
)
add_custom_target(flash-sd
COMMAND ${NRFJPROG} --program ${SD_HEX} --verify --sectorerase -f nrf52 --reset
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 --reset
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
# )
+116 -44
View File
@@ -1,24 +1,40 @@
#------------------------------------------------------------------------------
# CONFIGURE
# - SDK_PATH : path to SDK directory
# - SDK_PATH : path to SDK directory
#
# - SD_NAME : e.g s132, s140
# - SD_VERSION : SoftDevice version e.g 6.0.0
# - SD_HEX : to bootloader hex binary
# - 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)
# SD_VERSION can be overwritten by board.mk
ifndef SD_VERSION
SD_VERSION = 6.1.1
ifeq ($(MCU_SUB_VARIANT),nrf52833)
SD_VERSION = 7.3.0
else
SD_VERSION = 6.1.1
endif
endif
SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
@@ -26,6 +42,15 @@ SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
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)
NULL_DEVICE = NUL
else
NULL_DEVICE = /dev/null
endif
# linker by MCU eg. nrf52840.ld
ifeq ($(DEBUG), 1)
LD_FILE = linker/$(MCU_SUB_VARIANT)_debug.ld
@@ -34,7 +59,6 @@ else
endif
GIT_VERSION := $(shell git describe --dirty --always --tags)
GIT_SUBMODULE_VERSIONS := $(shell git submodule status | cut -d" " -f3,4 | paste -s -d" " -)
# compiled file name
OUT_NAME = $(BOARD)_bootloader-$(GIT_VERSION)
@@ -42,6 +66,8 @@ 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
#------------------------------------------------------------------------------
@@ -89,46 +115,45 @@ endif
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'
#---------------------------------
# Select the board to build
#---------------------------------
# Note: whitespace is not allowed in the filenames... it WILL break this part of the script
BOARD_LIST = $(sort $(filter-out boards.h boards.c,$(notdir $(wildcard src/boards/*))))
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
$(info You must provide a BOARD parameter with 'BOARD='. Supported boards are:)
$(foreach b,$(BOARD_LIST),$(info - $(b)))
$(error Invalid BOARD specified)
endif
# Build directory
BUILD = _build/build-$(BOARD)
BIN = _bin/$(BOARD)
# Board specific
-include src/boards/$(BOARD)/board.mk
# 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
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
DFU_APP_DATA_RESERVED=7*4096
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
SD_NAME = s140
CFLAGS += -DNRF52833_XXAA
DFU_DEV_REV = 52833
CFLAGS += -DNRF52833_XXAA -DS140
DFU_APP_DATA_RESERVED=7*4096
ifndef SD_NAME
SD_NAME = s140
endif
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
SD_NAME = s140
CFLAGS += -DNRF52840_XXAA
DFU_DEV_REV = 52840
CFLAGS += -DNRF52840_XXAA -DS140
# 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
#------------------------------------------------------------------------------
@@ -142,6 +167,15 @@ C_SRC += \
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
@@ -156,7 +190,11 @@ 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
@@ -190,10 +228,10 @@ C_SRC += src/boards/$(BOARD)/pinconfig.c
# USB Application ( MSC + UF2 )
C_SRC += \
src/usb/msc_uf2.c \
src/usb/usb_desc.c \
src/usb/usb.c \
src/usb/uf2/ghostfat.c
src/usb/msc_uf2.c \
src/usb/uf2/ghostfat.c \
src/usb/usb.c
# TinyUSB stack
C_SRC += \
@@ -204,9 +242,9 @@ C_SRC += \
$(TUSB_PATH)/class/cdc/cdc_device.c \
$(TUSB_PATH)/class/msc/msc_device.c \
$(TUSB_PATH)/tusb.c
endif
#------------------------------------------------------------------------------
# Assembly Files
#------------------------------------------------------------------------------
@@ -225,6 +263,11 @@ IPATH += \
src/usb \
$(TUSB_PATH)
ifeq ($(SIGNED_FW), 1)
IPATH += \
$(TCRYPT_PATH)/include
endif
# nrfx
IPATH += \
$(NRFX_PATH) \
@@ -316,12 +359,42 @@ ifneq ($(USE_NFCT),yes)
endif
CFLAGS += -DSOFTDEVICE_PRESENT
CFLAGS += -DUF2_VERSION_BASE='"$(GIT_VERSION)"'
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS)"'
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION)"'
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
_VER = $(subst ., ,$(word 1, $(subst -, ,$(GIT_VERSION))))
CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)) << 8) + $(word 3,$(_VER))'
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
# Extract semantic version numbers (MAJOR.MINOR.PATCH) from GIT_VERSION.
# Supports tags like:
# v1.2.3
# 1.2.3
# 1.2.3-147-gd71abcd
# If the version string does not match MAJOR.MINOR.PATCH, defaults to 0.0.0.
_VER3 := $(shell echo "$(GIT_VERSION)" | sed -E 's/^v?([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 \2 \3/; t; s/.*/0 0 0/')
# Split extracted version into individual numeric components
_VER_MAJ := $(word 1,$(_VER3))
_VER_MIN := $(word 2,$(_VER3))
_VER_PAT := $(word 3,$(_VER3))
# Pack MAJOR.MINOR.PATCH into a single 32-bit integer:
# [31:16] MAJOR
# [15:8] MINOR
# [7:0] PATCH
# This value is stored in the bootloader version register and must be a valid C integer constant.
CFLAGS += -DMK_BOOTLOADER_VERSION='((($(_VER_MAJ)<<16)|($(_VER_MIN)<<8)|($(_VER_PAT))))'
# Debug option use RTT for printf
ifeq ($(DEBUG), 1)
@@ -341,12 +414,6 @@ endif
CFLAGS += -DDFU_APP_DATA_RESERVED=$(DFU_APP_DATA_RESERVED)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
# Fixes for gcc version 12 and 13.
ifneq (,$(filter 12.% 13.%,$(shell $(CC) -dumpversion 2>/dev/null)))
CFLAGS += --param=min-pagesize=0
endif
#------------------------------------------------------------------------------
# Linker Flags
#------------------------------------------------------------------------------
@@ -438,17 +505,17 @@ $(BUILD)/$(OUT_NAME).hex: $(BUILD)/$(OUT_NAME).out
# Hex file with mbr (still no SD)
$(BUILD)/$(OUT_NAME)_nosd.hex: $(BUILD)/$(OUT_NAME).hex
@echo Create $(notdir $@)
@python3 tools/hexmerge.py --overlap=replace -o $@ $< $(MBR_HEX)
@$(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 $@)
@python3 lib/uf2/utils/uf2conv.py -f 0xd663823c -c -o $@ $^
$(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 $@)
@python3 tools/hexmerge.py -o $@ $< $(SD_HEX)
@$(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
@@ -496,12 +563,17 @@ flash-mbr:
@echo Flashing: $(MBR_HEX)
$(call FLASH_NOUICR_CMD,$(MBR_HEX))
# 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 $<
# 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
# flash skip crc magic ( app valid = 0x0001, crc = 0x0000 )
#flash-skip-crc:
# nrfjprog --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f nrf52
+102 -7
View File
@@ -24,14 +24,21 @@ Officially supported boards are:
- Adafruit Metro nRF52840 Express
- [Raytac MDBT50Q-RX Dongle](https://www.adafruit.com/product/5199)
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](/src/boards).
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
@@ -101,7 +108,7 @@ Pre-builtin binaries are available on GitHub [releases](https://github.com/adafr
Note: The bootloader can be downgraded. Since the binary release is a merged version of
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.
@@ -114,14 +121,20 @@ You must have have a J-Link available to "unbrick" your device.
### Build:
Firstly clone this repo with following commands
Firstly clone this repo including its submodules with following command:
```
git clone --recurse-submodules https://github.com/adafruit/Adafruit_nRF52_Bootloader
```
For git versions before `2.13.0` you have to do that manually:
```
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
cd Adafruit_nRF52_Bootloader
git submodule update --init
```
#### Build using `make`
Then build it with `make BOARD={board} all`, for example:
```
@@ -131,12 +144,43 @@ 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:
@@ -169,6 +213,57 @@ 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
#### `arm-none-eabi-gcc`: No such file or directory
@@ -176,7 +271,7 @@ make BOARD=feather_nrf52840_express flash-mbr
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
@@ -185,7 +280,7 @@ make: *** [_build/main.o] Error 127
... 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
make CROSS_COMPILE=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- BOARD=feather_nrf52832 all
```
For other compile errors, check the gcc version with `arm-none-eabi-gcc --version` to insure it is at least 9.x.
+6 -23
View File
@@ -1,23 +1,6 @@
if (TOOLCHAIN STREQUAL "gcc")
set(TOOLCHAIN_COMMON_FLAGS
-mthumb
-mcpu=cortex-m4
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
)
if (NOT DEFINED FREERTOS_PORT)
set(FREERTOS_PORT GCC_ARM_CM4F CACHE INTERNAL "")
endif ()
elseif (TOOLCHAIN STREQUAL "iar")
set(TOOLCHAIN_COMMON_FLAGS
--cpu cortex-m4
--fpu VFPv4
)
if (NOT DEFINED FREERTOS_PORT)
set(FREERTOS_PORT IAR_ARM_CM4F CACHE INTERNAL "")
endif ()
endif ()
set(TOOLCHAIN_COMMON_FLAGS
-mthumb
-mcpu=cortex-m4
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
)
+7 -15
View File
@@ -3,10 +3,7 @@ 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_SIZE "arm-none-eabi-size" CACHE FILEPATH "")
set(CMAKE_OBJCOPY "arm-none-eabi-objcopy" CACHE FILEPATH "")
set(CMAKE_OBJDUMP "arm-none-eabi-objdump" CACHE FILEPATH "")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
@@ -16,9 +13,6 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# pass TOOLCHAIN_CPU to
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
# enable all possible warnings for building examples
@@ -27,6 +21,7 @@ list(APPEND TOOLCHAIN_COMMON_FLAGS
-ffunction-sections
-fsingle-precision-constant
-fno-strict-aliasing
-g
)
set(TOOLCHAIN_EXE_LINKER_FLAGS
@@ -35,12 +30,9 @@ set(TOOLCHAIN_EXE_LINKER_FLAGS
#-Wl,--cref
)
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
# 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)
# try_compile is cmake test compiling its own example,
# pass -nostdlib to skip stdlib linking
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
if (IS_IN_TRY_COMPILE)
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
endif ()
set(CMAKE_C_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS} ${TOOLCHAIN_C_FLAGS}")
set(CMAKE_ASM_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS} ${TOOLCHAIN_ASM_FLAGS}")
-17
View File
@@ -1,17 +0,0 @@
include(CMakePrintHelpers)
# join the toolchain flags into a single string
list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
foreach (LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_FLAGS_INIT ${TOOLCHAIN_COMMON_FLAGS})
#cmake_print_variables(CMAKE_${LANG}_FLAGS_INIT)
# optimization flags for LOG, LOGGER ?
#set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-Os")
#set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
endforeach ()
# Linker
list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)
@@ -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;
@@ -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;
}
@@ -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;
@@ -44,15 +44,38 @@ 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. */
static bool m_usb_was_mounted; /**< Tracks whether the USB DFU session was ever enumerated so we can exit when cable is later removed. */
static bool m_startup_dfu_has_activity; /**< Tracks whether any valid serial or UF2 update traffic has started. */
APP_TIMER_DEF( _dfu_startup_timer );
volatile bool dfu_startup_packet_received = false;
static void bootloader_timeout_startup_dfu(void)
{
if (!m_startup_dfu_has_activity)
{
dfu_update_status_t update_status;
update_status.status_code = DFU_TIMEOUT;
bootloader_dfu_update_process(update_status);
}
}
void bootloader_dfu_activity_mark(void)
{
m_startup_dfu_has_activity = true;
}
void bootloader_mark_usb_mounted(void)
{
m_usb_was_mounted = true;
}
/**@brief Function for handling callbacks from pstorage module.
*
@@ -81,22 +104,17 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
static void dfu_startup_timer_handler(void * p_context)
{
#ifdef NRF_USBD
if (m_cancel_timeout_on_usb && tud_mounted())
// If host enumerated the device, keep waiting — m_usb_was_mounted was set
// by tud_mount_cb() and the unplug path in wait_for_events() will handle exit.
if (m_cancel_timeout_on_usb && m_usb_was_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)
{
dfu_update_status_t update_status;
update_status.status_code = DFU_TIMEOUT;
bootloader_dfu_update_process(update_status);
}
// No update activity is received within timeout, exit DFU mode
bootloader_timeout_startup_dfu();
}
/**@brief Function for waiting for events.
@@ -132,13 +150,22 @@ static void wait_for_events(void)
tud_task();
tud_cdc_write_flush();
}
// Exit startup DFU once USB was actually unplugged (VBUS gone), not on a
// host-side re-enumeration or temporary unmount.
if (m_cancel_timeout_on_usb && m_usb_was_mounted &&
!(NRF_POWER->USBREGSTATUS & POWER_USBREGSTATUS_VBUSDETECT_Msk))
{
bootloader_timeout_startup_dfu();
}
#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;
}
}
@@ -147,23 +174,22 @@ static void wait_for_events(void)
bool bootloader_app_is_valid(void)
{
bool success = false;
uint32_t const app_addr = DFU_BANK_0_REGION_START;
bootloader_settings_t const *p_bootloader_settings;
bootloader_util_settings_get(&p_bootloader_settings);
uint32_t const sp_addr = *((uint32_t*)app_addr);
uint32_t const reset_addr = *((uint32_t*)(app_addr + 4));
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 )
if (sp_addr == EMPTY_FLASH && reset_addr == 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 )
bootloader_settings_t const * p_bootloader_settings;
bootloader_util_settings_get(&p_bootloader_settings);
// Primary path: a prior DFU flagged bank 0 as valid.
if (p_bootloader_settings->bank_0 == BANK_VALID_APP)
{
uint16_t image_crc = 0;
@@ -175,10 +201,26 @@ bool bootloader_app_is_valid(void)
NULL);
}
success = (image_crc == p_bootloader_settings->bank_0_crc);
return (image_crc == p_bootloader_settings->bank_0_crc);
}
return success;
// Fallback for debugger-flashed apps: settings page is erased (bank_0 = 0xFFFF)
// but an app may still have been written to bank 0 directly. Accept it if its
// Cortex-M vector table is plausible: initial SP within RAM, reset vector
// within app flash region with the Thumb bit set. The SP upper bound is
// inclusive because the empty-descending stack initializes one past RAM end.
if (p_bootloader_settings->bank_0 == 0xFFFF)
{
uint32_t const ram_start = 0x20000000UL;
uint32_t const ram_end = ram_start + (NRF_FICR->INFO.RAM << 10u);
bool const sp_valid = (sp_addr >= ram_start) && (sp_addr <= ram_end) && ((sp_addr & 3U) == 0);
bool const reset_in_app = (reset_addr & 1U) &&
(reset_addr >= app_addr) &&
(reset_addr < BOOTLOADER_REGION_START);
return sp_valid && reset_in_app;
}
return false;
}
@@ -186,10 +228,36 @@ 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
@@ -296,7 +364,8 @@ void bootloader_dfu_update_process(dfu_update_status_t update_status)
}
else if (update_status.status_code == DFU_RESET)
{
m_update_status = BOOTLOADER_RESET;
m_update_status =
(update_status.restart_into_bootloader == false ? BOOTLOADER_SYS_RESET : BOOTLOADER_RESET_TO_SELF);
}
else
{
@@ -304,6 +373,10 @@ void bootloader_dfu_update_process(dfu_update_status_t update_status)
}
}
bool bootloader_must_reset_to_self(void)
{
return m_update_status == BOOTLOADER_RESET_TO_SELF;
}
uint32_t bootloader_init(void)
{
@@ -325,6 +398,8 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout
uint32_t err_code;
m_cancel_timeout_on_usb = cancel_timeout_on_usb && !ota;
m_usb_was_mounted = false;
m_startup_dfu_has_activity = false;
// Clear swap if banked update is used.
err_code = dfu_init();
@@ -340,8 +415,6 @@ uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout
// - Makecode single tap reset but no enumerated (battery power)
if ( timeout_ms )
{
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);
}
@@ -32,6 +32,13 @@
*/
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.
* @retval true If Application region is valid.
* @retval false If Application region is not valid.
@@ -67,6 +74,20 @@ void bootloader_settings_get(bootloader_settings_t * const p_settings);
*/
void bootloader_dfu_update_process(dfu_update_status_t update_status);
/**@brief Mark that startup DFU has received valid update activity.
*
* @details This suppresses the startup timeout or USB unplug fallback that is only
* meant for the "entered bootloader, but never started an update" case.
*/
void bootloader_dfu_activity_mark(void);
/**@brief Mark that the USB DFU session was enumerated by a host.
*
* @details Called from tud_mount_cb(). Enables the USB-unplug exit path in
* wait_for_events(), which exits startup DFU once VBUS is removed.
*/
void bootloader_mark_usb_mounted(void);
/**@brief Function getting state of SoftDevice update in progress.
* After a successfull SoftDevice transfer the system restarts in orderto disable SoftDevice
* and complete the update.
@@ -92,6 +113,8 @@ uint32_t bootloader_dfu_sd_update_finalize(void);
void bootloader_mbr_addrs_populate(void);
extern uint32_t proc_soc(void);
#endif // BOOTLOADER_H__
/**@} */
@@ -40,15 +40,22 @@ 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 (*(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);
}
}
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
}
@@ -11,9 +11,12 @@
*/
#include "bootloader_util.h"
#include <stdint.h>
#include <string.h>
#include "dfu_types.h"
#include "nrf_peripherals.h"
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
/**
* @brief Function for aborting current application/bootloader jump to to other app/bootloader.
@@ -32,6 +35,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 +78,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 +123,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.
@@ -146,8 +167,76 @@ static inline void bootloader_util_reset(uint32_t start_addr)
#error Compiler not supported.
#endif
// protect flash region from write access
static uint32_t bootloader_util_flash_protect(uint32_t address, uint32_t size) {
if ((size & (CODE_PAGE_SIZE - 1)) || (address & (CODE_PAGE_SIZE - 1)) || (address > BOOTLOADER_SETTINGS_ADDRESS)) {
return NRF_ERROR_INVALID_PARAM;
}
void bootloader_util_app_start(uint32_t start_addr)
{
bootloader_util_reset(start_addr);
#if defined(ACL_PRESENT)
// Protect using ACL.
static uint32_t acl_instance = 0;
volatile ACL_ACL_Type *p_acl;
const uint32_t mask = (ACL_ACL_PERM_WRITE_Disable << ACL_ACL_PERM_WRITE_Pos);
do {
if (acl_instance >= ACL_REGIONS_COUNT) {
return NRF_ERROR_NO_MEM;
}
p_acl = &NRF_ACL->ACL[acl_instance];
p_acl->ADDR = address;
p_acl->SIZE = size;
p_acl->PERM = mask;
acl_instance++;
} while (p_acl->ADDR != address || p_acl->SIZE != size ||
p_acl->PERM != mask); // Check whether the acl_instance has been used before.
#elif defined(BPROT_PRESENT)
// Protect using BPROT. BPROT does not support read protection.
uint32_t pagenum_start = address / CODE_PAGE_SIZE;
uint32_t pagenum_end = pagenum_start + ((size - 1) / CODE_PAGE_SIZE);
for (uint32_t i = pagenum_start; i <= pagenum_end; i++) {
uint32_t config_index = i / 32;
uint32_t mask = (1 << (i - config_index * 32));
switch (config_index) {
case 0:
NRF_BPROT->CONFIG0 = mask;
break;
case 1:
NRF_BPROT->CONFIG1 = mask;
break;
#if BPROT_REGIONS_NUM > 64
case 2:
NRF_BPROT->CONFIG2 = mask;
break;
case 3:
NRF_BPROT->CONFIG3 = mask;
break;
#endif
}
}
#endif
return NRF_SUCCESS;
}
void bootloader_util_app_start(uint32_t start_addr) {
// Protect MBR against user writes
bootloader_util_flash_protect(0, MBR_SIZE);
// Size of the bootloader flash area to protect (Bootloader + MBR params + Bootloader settings)
const uint32_t area_size = BOOTLOADER_SETTINGS_ADDRESS + CODE_PAGE_SIZE - BOOTLOADER_REGION_START;
// Protect bootloader code and params pages against user writes
bootloader_util_flash_protect(BOOTLOADER_REGION_START, area_size);
// Jump to user application
bootloader_util_reset(start_addr);
}
@@ -40,6 +40,8 @@ typedef enum
DFU_STATE_WAIT_4_ACTIVATE /**< State for: waiting for dfu_image_activate(). */
} dfu_state_t;
#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. */
#define IS_UPDATING_APP(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_APP) /**< Macro for determining if a Application update is ongoing. */
@@ -0,0 +1,947 @@
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
#include <stddef.h>
#include "dfu.h"
#include <dfu_types.h>
#include "dfu_bank_internal.h"
#include "nrf.h"
#include "nrf_sdm.h"
#include "app_error.h"
#include "app_timer.h"
#include "bootloader.h"
#include "bootloader_types.h"
#include "pstorage.h"
#include "nrf_mbr.h"
#include "dfu_init.h"
#include "sdk_common.h"
static dfu_state_t m_dfu_state; /**< Current DFU state. */
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[128]; /**< Init packet, can hold CRC, Hash, Signed Hash and similar, for image validation, integrity 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. */
APP_TIMER_DEF(m_dfu_timer_id); /**< Application timer id. */
static bool m_dfu_timed_out = false; /**< Boolean flag value for tracking DFU timer timeout state. */
static pstorage_handle_t m_storage_handle_swap; /**< Pstorage handle for the swap area (bank 1). Bank used when updating an application or bootloader without SoftDevice. */
static pstorage_handle_t m_storage_handle_app; /**< Pstorage handle for the application area (bank 0). Bank used when updating a SoftDevice w/wo bootloader. Handle also used when swapping received application from bank 1 to bank 0. */
static pstorage_handle_t * mp_storage_handle_active; /**< Pointer to the pstorage handle for the active bank for receiving of data packets. */
static dfu_callback_t m_data_pkt_cb; /**< Callback from DFU Bank module for notification of asynchronous operation such as flash prepare. */
static dfu_bank_func_t m_functions; /**< Structure holding operations for the selected update process. */
/**@brief Function for handling callbacks from pstorage module.
*
* @details Handles pstorage results for clear and storage operation. For detailed description of
* the parameters provided with the callback, please refer to \ref pstorage_ntf_cb_t.
*/
static void pstorage_callback_handler(pstorage_handle_t * p_handle,
uint8_t op_code,
uint32_t result,
uint8_t * p_data,
uint32_t data_len)
{
switch (op_code)
{
case PSTORAGE_STORE_OP_CODE:
if ((m_dfu_state == DFU_STATE_RX_DATA_PKT) && (m_data_pkt_cb != NULL))
{
m_data_pkt_cb(DATA_PACKET, result, p_data);
}
break;
case PSTORAGE_CLEAR_OP_CODE:
if (m_dfu_state == DFU_STATE_PREPARING)
{
m_functions.cleared();
m_dfu_state = DFU_STATE_RDY;
if (m_data_pkt_cb != NULL)
{
m_data_pkt_cb(START_PACKET, result, p_data);
}
}
break;
default:
break;
}
APP_ERROR_CHECK(result);
}
/**@brief Function for handling the DFU timeout.
*
* @param[in] p_context The timeout context.
*/
static void dfu_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
dfu_update_status_t update_status = {0};
m_dfu_timed_out = true;
update_status.status_code = DFU_TIMEOUT;
bootloader_dfu_update_process(update_status);
}
/**@brief Function for restarting the DFU Timer.
*
* @details This function will stop and restart the DFU timer. This function will be called by the
* functions handling any DFU packet received from the peer that is transferring a firmware
* image.
*/
static uint32_t dfu_timer_restart(void)
{
if (m_dfu_timed_out)
{
// The DFU timer had already timed out.
return NRF_ERROR_INVALID_STATE;
}
uint32_t err_code = app_timer_stop(m_dfu_timer_id);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);
return err_code;
}
/**@brief Function for preparing of flash before receiving SoftDevice image.
*
* @details This function will erase current application area to ensure sufficient amount of
* storage for the SoftDevice image. Upon erase complete a callback will be done.
* See \ref dfu_bank_prepare_t for further details.
*/
static void dfu_prepare_func_app_erase(uint32_t image_size)
{
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;
if ( is_ota() )
{
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);
// invoke complete callback
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
}
}
/**@brief Function for preparing swap before receiving application or bootloader image.
*
* @details This function will erase current swap area to ensure flash is ready for storage of the
* Application or Bootloader image. Upon erase complete a callback will be done.
* See \ref dfu_bank_prepare_t for further details.
*/
static void dfu_prepare_func_swap_erase(uint32_t image_size)
{
mp_storage_handle_active = &m_storage_handle_swap;
m_dfu_state = DFU_STATE_PREPARING;
if ( is_ota() )
{
uint32_t err_code;
while(1) {
err_code = pstorage_clear(&m_storage_handle_swap, 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_1_REGION_START, image_size);
// invoke complete callback
pstorage_callback_handler(&m_storage_handle_swap, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
}
}
/**@brief Function for handling behaviour when clear operation has completed.
*/
static void dfu_cleared_func_swap(void)
{
// Do nothing.
}
/**@brief Function for handling behaviour when clear operation has completed.
*/
static void dfu_cleared_func_app(void)
{
dfu_update_status_t update_status = { 0 };
update_status.status_code = DFU_BANK_0_ERASED;
bootloader_dfu_update_process(update_status);
}
/**@brief Function for calculating storage offset for receiving SoftDevice image.
*
* @details When a new SoftDevice is received it will be temporary stored in flash before moved to
* address 0x0. In order to successfully validate transfer and relocation it is important
* that temporary image and final installed image does not overlap hence an offset must
* be calculated in case new image is larger than currently installed SoftDevice.
*/
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)
{
offset += CODE_PAGE_SIZE;
}
}
return offset;
}
/**@brief Function for activating received SoftDevice image.
*
* @note This function will not move the SoftDevice image.
* The bootloader settings will be marked as SoftDevice update complete and the swapping of
* current SoftDevice will occur after system reset.
*
* @return NRF_SUCCESS on success.
*/
static uint32_t dfu_activate_sd(void)
{
dfu_update_status_t update_status = {0};
update_status.status_code = DFU_UPDATE_SD_COMPLETE;
update_status.app_crc = m_image_crc;
update_status.sd_image_start = DFU_BANK_0_REGION_START;
update_status.sd_size = m_start_packet.sd_image_size;
update_status.bl_size = m_start_packet.bl_image_size;
update_status.app_size = m_start_packet.app_image_size;
bootloader_dfu_update_process(update_status);
return NRF_SUCCESS;
}
/**@brief Function for activating received Application image.
*
* @details This function will move the received application image from swap (bank 1) to
* application area (bank 0).
*
* @return NRF_SUCCESS on success. Error code otherwise.
*/
static uint32_t dfu_activate_app(void)
{
uint32_t err_code = NRF_SUCCESS;
// Erase BANK 0.
if ( is_ota() )
{
while(1) {
err_code = pstorage_clear(&m_storage_handle_app, m_start_packet.app_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);
while(1) {
err_code = pstorage_store(&m_storage_handle_app,
(uint8_t *)m_storage_handle_swap.block_id,
m_start_packet.app_image_size,
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
}
}
VERIFY_SUCCESS(err_code);
}
else
{
flash_nrf5x_erase(DFU_BANK_0_REGION_START, m_start_packet.app_image_size);
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
flash_nrf5x_write(DFU_BANK_0_REGION_START, (uint8_t *)DFU_BANK_1_REGION_START, m_start_packet.app_image_size, false);
flash_nrf5x_flush(false);
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) DFU_BANK_1_REGION_START, m_start_packet.app_image_size);
}
if (err_code == NRF_SUCCESS)
{
dfu_update_status_t update_status = { 0 };
memset(&update_status, 0, sizeof(dfu_update_status_t ));
update_status.status_code = DFU_UPDATE_APP_COMPLETE;
update_status.app_crc = m_image_crc;
update_status.app_size = m_start_packet.app_image_size;
bootloader_dfu_update_process(update_status);
}
return err_code;
}
/**@brief Function for activating received Bootloader image.
*
* @note This function will not move the bootloader image.
* The bootloader settings will be marked as Bootloader update complete and the swapping of
* current bootloader will occur after system reset.
*
* @return NRF_SUCCESS on success.
*/
static uint32_t dfu_activate_bl(void)
{
dfu_update_status_t update_status = {0};
update_status.status_code = DFU_UPDATE_BOOT_COMPLETE;
update_status.app_crc = m_image_crc;
update_status.sd_size = m_start_packet.sd_image_size;
update_status.bl_size = m_start_packet.bl_image_size;
update_status.app_size = m_start_packet.app_image_size;
bootloader_dfu_update_process(update_status);
return NRF_SUCCESS;
}
uint32_t dfu_init(void)
{
uint32_t err_code;
pstorage_module_param_t storage_module_param = {.cb = pstorage_callback_handler};
m_init_packet_length = 0;
m_image_crc = 0;
err_code = pstorage_register(&storage_module_param, &m_storage_handle_app);
if (err_code != NRF_SUCCESS)
{
m_dfu_state = DFU_STATE_INIT_ERROR;
return err_code;
}
m_storage_handle_app.block_id = DFU_BANK_0_REGION_START;
m_storage_handle_swap = m_storage_handle_app;
m_storage_handle_swap.block_id = DFU_BANK_1_REGION_START;
// Create the timer to monitor the activity by the peer doing the firmware update.
err_code = app_timer_create(&m_dfu_timer_id,
APP_TIMER_MODE_SINGLE_SHOT,
dfu_timeout_handler);
APP_ERROR_CHECK(err_code);
// Start the DFU timer.
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);
m_data_received = 0;
m_dfu_state = DFU_STATE_IDLE;
return NRF_SUCCESS;
}
void dfu_register_callback(dfu_callback_t callback_handler)
{
m_data_pkt_cb = callback_handler;
}
uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
{
uint32_t err_code;
m_start_packet = *(p_packet->params.start_packet);
// Check that the requested update procedure is supported.
// Currently the following combinations are allowed:
// - Application
// - SoftDevice
// - Bootloader
// - SoftDevice with Bootloader
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.
return NRF_ERROR_NOT_SUPPORTED;
}
if (!(IS_WORD_SIZED(m_start_packet.sd_image_size) &&
IS_WORD_SIZED(m_start_packet.bl_image_size) &&
IS_WORD_SIZED(m_start_packet.app_image_size)))
{
// Image_sizes are not a multiple of 4 (word size).
return NRF_ERROR_NOT_SUPPORTED;
}
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;
}
if (IS_UPDATING_SD(m_start_packet))
{
if (m_image_size > (DFU_IMAGE_MAX_SIZE_FULL))
{
return NRF_ERROR_DATA_SIZE;
}
m_functions.prepare = dfu_prepare_func_app_erase;
m_functions.cleared = dfu_cleared_func_app;
m_functions.activate = dfu_activate_sd;
}
else
{
if (m_image_size > DFU_IMAGE_MAX_SIZE_BANKED)
{
return NRF_ERROR_DATA_SIZE;
}
m_functions.prepare = dfu_prepare_func_swap_erase;
m_functions.cleared = dfu_cleared_func_swap;
if (IS_UPDATING_BL(m_start_packet))
{
m_functions.activate = dfu_activate_bl;
}
else
{
m_functions.activate = dfu_activate_app;
}
}
if ( DFU_STATE_IDLE != m_dfu_state )
return NRF_ERROR_INVALID_STATE;
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
VERIFY_SUCCESS(err_code);
m_functions.prepare(m_image_size);
return NRF_SUCCESS;
}
uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
{
uint32_t data_length;
uint32_t err_code;
uint32_t * p_data;
VERIFY_PARAM_NOT_NULL(p_packet);
// Check pointer alignment.
if (!is_word_aligned(p_packet->params.data_packet.p_data_packet))
{
// The p_data_packet is not word aligned address.
return NRF_ERROR_INVALID_ADDR;
}
switch (m_dfu_state)
{
case DFU_STATE_RDY:
case DFU_STATE_RX_INIT_PKT:
return NRF_ERROR_INVALID_STATE;
case DFU_STATE_RX_DATA_PKT:
data_length = p_packet->params.data_packet.packet_length * sizeof(uint32_t);
if ((m_data_received + data_length) > m_image_size)
{
// The caller is trying to write more bytes into the flash than the size provided to
// the dfu_image_size_set function. This is treated as a serious error condition and
// an unrecoverable one. Hence point the variable mp_app_write_address to the top of
// the flash area. This will ensure that all future application data packet writes
// will be blocked because of the above check.
m_data_received = 0xFFFFFFFF;
return NRF_ERROR_DATA_SIZE;
}
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
VERIFY_SUCCESS(err_code);
p_data = (uint32_t *)p_packet->params.data_packet.p_data_packet;
if ( is_ota() )
{
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(
(mp_storage_handle_active == &m_storage_handle_app
? DFU_BANK_0_REGION_START
: DFU_BANK_1_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;
if (m_data_received != m_image_size)
{
// The entire image is not received yet. More data is expected.
err_code = NRF_ERROR_INVALID_LENGTH;
}
else
{
if ( !is_ota() ) flash_nrf5x_flush(false);
// The entire image has been received. Return NRF_SUCCESS.
err_code = NRF_SUCCESS;
}
break;
default:
err_code = NRF_ERROR_INVALID_STATE;
break;
}
return err_code;
}
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);
if (err_code == NRF_SUCCESS)
{
m_dfu_state = DFU_STATE_RX_DATA_PKT;
}
else
{
m_init_packet_length = 0;
}
}
return err_code;
}
uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
{
uint32_t err_code = NRF_SUCCESS;
uint32_t length;
switch (m_dfu_state)
{
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.
/* FALLTHRU */
case DFU_STATE_RX_INIT_PKT:
// 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;
}
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
VERIFY_SUCCESS(err_code);
length = p_packet->params.data_packet.packet_length * sizeof(uint32_t);
if ((m_init_packet_length + length) > sizeof(m_init_packet))
{
return NRF_ERROR_INVALID_LENGTH;
}
memcpy(&m_init_packet[m_init_packet_length],
&p_packet->params.data_packet.p_data_packet[0],
length);
m_init_packet_length += length;
break;
default:
// Either the start packet was not received or dfu_init function was not called before.
return NRF_ERROR_INVALID_STATE;
}
return NRF_SUCCESS;
}
uint32_t dfu_image_validate()
{
uint32_t err_code;
switch (m_dfu_state)
{
case DFU_STATE_RX_DATA_PKT:
// Check if the application image write has finished.
if (m_data_received != m_image_size)
{
// Image not yet fully transferred by the peer or the peer has attempted to write
// too much data. Hence the validation should fail.
err_code = NRF_ERROR_INVALID_STATE;
}
else
{
m_dfu_state = DFU_STATE_VALIDATE;
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
if (err_code == NRF_SUCCESS)
{
err_code = dfu_init_postvalidate((uint8_t *)mp_storage_handle_active->block_id,
m_image_size);
VERIFY_SUCCESS(err_code);
m_dfu_state = DFU_STATE_WAIT_4_ACTIVATE;
}
}
break;
default:
err_code = NRF_ERROR_INVALID_STATE;
break;
}
return err_code;
}
uint32_t dfu_image_activate()
{
uint32_t err_code;
switch (m_dfu_state)
{
case DFU_STATE_WAIT_4_ACTIVATE:
// Stop the DFU Timer because the peer activity need not be monitored any longer.
err_code = app_timer_stop(m_dfu_timer_id);
APP_ERROR_CHECK(err_code);
err_code = m_functions.activate();
break;
default:
err_code = NRF_ERROR_INVALID_STATE;
break;
}
return err_code;
}
void dfu_reset(void)
{
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);
}
static uint32_t dfu_compare_block(uint32_t * ptr1, uint32_t * ptr2, uint32_t len)
{
sd_mbr_command_t sd_mbr_cmd;
sd_mbr_cmd.command = SD_MBR_COMMAND_COMPARE;
sd_mbr_cmd.params.compare.ptr1 = ptr1;
sd_mbr_cmd.params.compare.ptr2 = ptr2;
sd_mbr_cmd.params.compare.len = len / sizeof(uint32_t);
return sd_mbr_command(&sd_mbr_cmd);
}
static uint32_t dfu_copy_sd(uint32_t * src, uint32_t * dst, uint32_t len)
{
sd_mbr_command_t sd_mbr_cmd;
sd_mbr_cmd.command = SD_MBR_COMMAND_COPY_SD;
sd_mbr_cmd.params.copy_sd.src = src;
sd_mbr_cmd.params.copy_sd.dst = dst;
sd_mbr_cmd.params.copy_sd.len = len / sizeof(uint32_t);
return sd_mbr_command(&sd_mbr_cmd);
}
static uint32_t dfu_sd_img_block_swap(uint32_t * src,
uint32_t * dst,
uint32_t len,
uint32_t block_size)
{
// It is necessary to swap the new SoftDevice in 3 rounds to ensure correct copy of data
// 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);
if (err_code == NRF_SUCCESS)
{
return err_code;
}
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,
block_size);
VERIFY_SUCCESS(err_code);
}
err_code = dfu_copy_sd(src, dst, len);
VERIFY_SUCCESS(err_code);
return dfu_compare_block(src, dst, len);
}
uint32_t dfu_sd_image_swap(void)
{
bootloader_settings_t boot_settings;
bootloader_settings_get(&boot_settings);
if (boot_settings.sd_image_size == 0)
{
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 ##### */
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),
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,
block_size);
}
else
{
if (boot_settings.sd_image_size != 0)
{
return dfu_copy_sd((uint32_t *)boot_settings.sd_image_start,
(uint32_t *)SOFTDEVICE_REGION_START,
boot_settings.sd_image_size);
}
}
return NRF_SUCCESS;
}
uint32_t dfu_bl_image_swap(void)
{
bootloader_settings_t bootloader_settings;
sd_mbr_command_t sd_mbr_cmd;
bootloader_settings_get(&bootloader_settings);
if (bootloader_settings.bl_image_size != 0)
{
uint32_t bl_image_start = (bootloader_settings.sd_image_size == 0) ?
DFU_BANK_1_REGION_START :
bootloader_settings.sd_image_start +
bootloader_settings.sd_image_size;
sd_mbr_cmd.command = SD_MBR_COMMAND_COPY_BL;
sd_mbr_cmd.params.copy_bl.bl_src = (uint32_t *)(bl_image_start);
sd_mbr_cmd.params.copy_bl.bl_len = bootloader_settings.bl_image_size / sizeof(uint32_t);
return sd_mbr_command(&sd_mbr_cmd);
}
return NRF_SUCCESS;
}
uint32_t dfu_bl_image_validate(void)
{
bootloader_settings_t bootloader_settings;
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_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_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);
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;
}
uint32_t dfu_sd_image_validate(void)
{
bootloader_settings_t bootloader_settings;
sd_mbr_command_t sd_mbr_cmd;
bootloader_settings_get(&bootloader_settings);
if (bootloader_settings.sd_image_size == 0)
{
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 +
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;
if (SD_SIZE_GET(MBR_SIZE) < bootloader_settings.sd_image_size)
{
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,
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;
sd_mbr_cmd.params.compare.len = bootloader_settings.sd_image_size / sizeof(uint32_t);
return sd_mbr_command(&sd_mbr_cmd);
}
@@ -31,10 +31,13 @@ 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. */
APP_TIMER_DEF(m_dfu_timer_id); /**< Application timer id. */
static bool m_dfu_timed_out = false; /**< Boolean flag value for tracking DFU timer timeout state. */
static pstorage_handle_t m_storage_handle_app; /**< Pstorage handle for the application area (bank 0). Bank used when updating a SoftDevice w/wo bootloader. Handle also used when swapping received application from bank 1 to bank 0. */
static pstorage_handle_t * mp_storage_handle_active; /**< Pointer to the pstorage handle for the active bank for receiving of data packets. */
@@ -80,6 +83,47 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
APP_ERROR_CHECK(result);
}
/**@brief Function for handling the DFU timeout.
*
* @param[in] p_context The timeout context.
*/
static void dfu_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
dfu_update_status_t update_status;
m_dfu_timed_out = true;
update_status.status_code = DFU_TIMEOUT;
bootloader_dfu_update_process(update_status);
}
/**@brief Function for restarting the DFU Timer.
*
* @details This function will stop and restart the DFU timer. This function will be called by the
* functions handling any DFU packet received from the peer that is transferring a firmware
* image.
*/
static uint32_t dfu_timer_restart(void)
{
if (m_dfu_timed_out)
{
// The DFU timer had already timed out.
return NRF_ERROR_INVALID_STATE;
}
uint32_t err_code = app_timer_stop(m_dfu_timer_id);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);
return err_code;
}
/**@brief Function for preparing of flash before receiving SoftDevice image.
*
* @details This function will erase current application area to ensure sufficient amount of
@@ -88,31 +132,33 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
*/
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 = pstorage_clear(&m_storage_handle_app, m_image_size);
APP_ERROR_CHECK(err_code);
}
else
{
uint32_t const page_count = NRFX_CEIL_DIV(m_image_size, CODE_PAGE_SIZE);
for ( uint32_t i = 0; i < page_count; i++ )
if ( is_ota() )
{
uint32_t const addr = DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE;
PRINTF("Erase 0x%08lX\r\n", addr);
nrfx_nvmc_page_erase(addr);
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);
// invoke complete callback
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);
}
}
@@ -136,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)
{
@@ -189,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;
@@ -199,7 +244,7 @@ static uint32_t dfu_activate_app(void)
bootloader_dfu_update_process(update_status);
return err_code;
return NRF_SUCCESS;
}
@@ -213,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;
@@ -244,6 +289,16 @@ uint32_t dfu_init(void)
m_storage_handle_app.block_id = DFU_BANK_0_REGION_START;
// Create the timer to monitor the activity by the peer doing the firmware update.
err_code = app_timer_create(&m_dfu_timer_id,
APP_TIMER_MODE_SINGLE_SHOT,
dfu_timeout_handler);
APP_ERROR_CHECK(err_code);
// Start the DFU timer.
err_code = app_timer_start(m_dfu_timer_id, DFU_TIMEOUT_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);
m_data_received = 0;
m_dfu_state = DFU_STATE_IDLE;
@@ -259,6 +314,8 @@ void dfu_register_callback(dfu_callback_t callback_handler)
uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
{
uint32_t err_code;
m_start_packet = *(p_packet->params.start_packet);
// Check that the requested update procedure is supported.
@@ -267,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.
@@ -284,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;
@@ -296,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;
@@ -312,6 +369,10 @@ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
if ( DFU_STATE_IDLE != m_dfu_state ) return NRF_ERROR_INVALID_STATE;
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
VERIFY_SUCCESS(err_code);
m_functions.prepare(m_image_size);
return NRF_SUCCESS;
@@ -354,17 +415,29 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
return NRF_ERROR_DATA_SIZE;
}
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
VERIFY_SUCCESS(err_code);
p_data = (uint32_t *)p_packet->params.data_packet.p_data_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;
@@ -376,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;
@@ -395,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);
@@ -421,6 +494,7 @@ uint32_t dfu_init_pkt_complete(void)
uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
{
uint32_t err_code = NRF_SUCCESS;
uint32_t length;
switch (m_dfu_state)
@@ -438,6 +512,10 @@ uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
return NRF_ERROR_INVALID_STATE;
}
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
VERIFY_SUCCESS(err_code);
length = p_packet->params.data_packet.packet_length * sizeof(uint32_t);
if ((m_init_packet_length + length) > sizeof(m_init_packet))
{
@@ -477,9 +555,16 @@ uint32_t dfu_image_validate()
{
m_dfu_state = DFU_STATE_VALIDATE;
err_code = dfu_init_postvalidate((uint8_t *)mp_storage_handle_active->block_id, m_image_size);
VERIFY_SUCCESS(err_code);
m_dfu_state = DFU_STATE_WAIT_4_ACTIVATE;
// Valid peer activity detected. Hence restart the DFU timer.
err_code = dfu_timer_restart();
if (err_code == NRF_SUCCESS)
{
err_code = dfu_init_postvalidate((uint8_t *)mp_storage_handle_active->block_id,
m_image_size);
VERIFY_SUCCESS(err_code);
m_dfu_state = DFU_STATE_WAIT_4_ACTIVATE;
}
}
break;
@@ -499,6 +584,11 @@ uint32_t dfu_image_activate()
switch (m_dfu_state)
{
case DFU_STATE_WAIT_4_ACTIVATE:
// Stop the DFU Timer because the peer activity need not be monitored any longer.
err_code = app_timer_stop(m_dfu_timer_id);
APP_ERROR_CHECK(err_code);
err_code = m_functions.activate();
break;
@@ -513,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);
}
@@ -547,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);
@@ -564,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);
}
@@ -588,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
@@ -626,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);
}
}
@@ -646,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;
@@ -658,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;
}
@@ -695,17 +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 ##### */
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;
@@ -714,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 23
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,16 +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 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. */
@@ -75,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. */
@@ -208,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.
*
@@ -226,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())
{
@@ -242,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,
@@ -252,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);
@@ -324,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;
@@ -743,8 +786,22 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
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:
@@ -774,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;
@@ -900,6 +960,11 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
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) );
}
@@ -12,6 +12,7 @@
#include "dfu_transport.h"
#include <stddef.h>
#include "bootloader.h"
#include "dfu.h"
#include <dfu_types.h>
#include "app_error.h"
@@ -197,9 +198,8 @@ static void process_dfu_packet(void * p_event_data, uint16_t event_size)
uint32_t index;
dfu_update_packet_t * packet;
// Adafruit modification for startup dfu
extern bool dfu_startup_packet_received;
dfu_startup_packet_received = true;
// Mark that startup DFU has transitioned into a real update flow.
bootloader_dfu_activity_mark();
while (false == DATA_QUEUE_EMPTY())
{
@@ -20,10 +20,42 @@
* @brief Device Firmware Update module type and definitions.
*/
/*
* Flash layout (nrf52840, see linker/nrf52840.ld):
*
* -------------------------
* | Bootloader Settings |
* | 4 KB |
* |-------------------------| 0xFF000 BOOTLOADER_SETTINGS_ADDRESS
* | MBR Params Page |
* | 4 KB |
* |-------------------------| 0xFE000
* | Bootloader Config |
* | 2 KB |
* |-------------------------| 0xFD800
* | Bootloader |
* | 38 KB |
* |-------------------------| 0xF4000 BOOTLOADER_REGION_START
* | App Data Reserved |
* | 40 KB |
* |-------------------------| 0xEA000
* | Application |
* | Single/ Dual Bank |
* | |
* |-------------------------| CODE_REGION_1_START
* | SoftDevice |
* | 0x26000 (optional) |
* |-------------------------| 0x01000
* | MBR |
* | 4 KB |
* ------------------------- 0x00000
*/
#ifndef DFU_TYPES_H__
#define DFU_TYPES_H__
#include <stdint.h>
#include <stdbool.h>
#include "nrf_sdm.h"
#include "nrf_mbr.h"
#include "nrf.h"
@@ -74,8 +106,12 @@ static inline bool is_sd_existed(void)
#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_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. */
#define EMPTY_FLASH_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */
@@ -150,6 +186,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. */
+23
View File
@@ -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/uf2 updated: adbb8c7260...b19ac9ad61.
+1 -5
View File
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
/*GROUP(-lgcc -lc -lnosys)*/
MEMORY
{
@@ -19,8 +19,6 @@ MEMORY
/** Location of bootloader setting in flash. */
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x7F000, LENGTH = 0x1000
/** RAM Region for bootloader. */
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20010000-0x20008000
@@ -30,8 +28,6 @@ MEMORY
/** 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
+1 -1
View File
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
/*GROUP(-lgcc -lc -lnosys)*/
MEMORY
{
+1 -1
View File
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
/*GROUP(-lgcc -lc)*/
MEMORY
{
+2 -7
View File
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
/*GROUP(-lgcc -lc -lnosys)*/
MEMORY
{
@@ -21,8 +21,6 @@ MEMORY
/** Location of bootloader setting in flash. */
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000
/** RAM Region for bootloader. */
/* Avoid conflict with NOINIT for OTA bond sharing */
RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20040000-0x20008000
@@ -33,9 +31,7 @@ MEMORY
/** 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
@@ -91,7 +87,6 @@ SECTIONS
{
} > NOINIT
/* other placements follow here... */
}
+1 -1
View File
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
/*GROUP(-lgcc -lc)*/
MEMORY
{
+1 -1
View File
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
/*GROUP(-lgcc -lc)*/
MEMORY
{
-363
View File
@@ -1,363 +0,0 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="Adafruit_nRF52_Bootloader" target="8" version="2">
<project Name="Adafruit_nRF52_Bootloader">
<configuration
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_endian="Little"
arm_fp_abi="Hard"
arm_fpu_type="FPv4-SP-D16"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="ROM;0x00000000;0x00100000;RAM;0x20000000;0x00040000"
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="nRF52840_xxAA"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;NO_VTOR_CONFIG;MK_BOOTLOADER_VERSION=0x00020A;CONFIG_GPIO_AS_PINRESET;CONFIG_NFCT_PINS_AS_GPIOS;SOFTDEVICE_PRESENT;UF2_VERSION=&quot;Segger&quot;;BLEDIS_FW_VERSION=&quot;Segger&quot;;DFU_APP_DATA_RESERVED=7*4096;CFG_DEBUG"
c_user_include_directories=".;../src/;../src/usb;../src/boards;../src/cmsis/include;$(tusbDir);$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(nrfxDir)/drivers/src;$(sdDir)/include;$(sdDir)/include/nrf52;$(sdk11Dir)/drivers_nrf/pstorage;$(sdk11Dir)/ble/common/;$(sdk11Dir)/ble/ble_services/ble_dfu;$(sdk11Dir)/ble/ble_services/ble_dis;$(sdk11Dir)/libraries/bootloader_dfu;$(sdk11Dir)/libraries/bootloader_dfu/hci_transport;$(sdk11Dir)/libraries/util;$(sdkDir)/toolchain/cmsis/include;$(sdkDir)/device;$(sdkDir)/toolchain;$(sdkDir)/drivers_nrf/hal;$(sdkDir)/drivers_nrf/systick;$(sdkDir)/drivers_nrf/uart;$(sdkDir)/drivers_nrf/usbd;$(sdkDir)/drivers_nrf/common;$(sdkDir)/drivers_nrf/delay;$(sdkDir)/drivers_nrf/power;$(sdkDir)/drivers_nrf/clock;$(sdkDir)/libraries/util;$(sdkDir)/libraries/timer;$(sdkDir)/libraries/scheduler;$(sdkDir)/libraries/crc16;$(sdkDir)/libraries/util;$(sdkDir)/libraries/hci/config;$(sdkDir)/libraries/uart;$(sdkDir)/libraries/hci;$(sdkDir)/external/fprintf;$(sdkDir)/libraries/strerror;$(sdkDir)/libraries/atomic;$(sdkDir)/libraries/balloc;$(sdkDir)/libraries/experimental_log/src;$(sdkDir)/libraries/experimental_log;$(sdkDir)/libraries/experimental_section_vars;$(sdkDir)/libraries/experimental_memobj"
debug_initial_breakpoint_set_option="Never"
debug_register_definition_file="$(ProjectDir)/nrf52840_Registers.xml"
debug_target_connection="J-Link"
gcc_enable_all_warnings="No"
gcc_entry_point="Reset_Handler"
gcc_optimization_level="Debug"
linker_memory_map_file="$(ProjectDir)/nRF52840_xxAA_MemoryMap.xml"
linker_printf_width_precision_supported="Yes"
linker_section_placement_file="$(ProjectDir)/flash_placement.xml"
macros="DeviceHeaderFile=$(PackagesDir)/nRF/CMSIS/Device/Include/nrf.h;DeviceLibraryIdentifier=M4lf;DeviceSystemFile=$(PackagesDir)/nRF/CMSIS/Device/Source/system_nrf52840.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/ses_nrf52840_Vectors.s;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash;sdkDir=../lib/sdk/components;sdk11Dir=../lib/sdk11/components;sdDir=../lib/softdevice/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API;tusbDir=../lib/tinyusb/src;nrfxDir=../lib/nrfx"
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
target_script_file="$(ProjectDir)/nRF_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder Name="RTT Files">
<file file_name="SEGGER_RTT.c" />
<file file_name="SEGGER_RTT.h" />
<file file_name="SEGGER_RTT_Conf.h" />
<file file_name="SEGGER_RTT_SES.c" />
</folder>
<folder Name="Script Files">
<file file_name="nRF_Target.js">
<configuration Name="Common" file_type="Reset Script" />
</file>
</folder>
<folder Name="System Files">
<file file_name="thumb_crt0.s" />
<file file_name="flash_placement.xml" />
<file file_name="nRF52840_xxAA_MemoryMap.xml" />
<file file_name="nRF52832_xxAA_MemoryMap.xml" />
</folder>
<configuration Name="Debug Single" gcc_optimization_level="Debug" />
<configuration
Name="Release Single"
gcc_optimization_level="Optimize For Size" />
<folder Name="lib">
<folder
Name="sdk"
exclude=""
filter="*.h;*.c"
path="../lib/sdk"
recurse="Yes" />
<folder Name="sdk11">
<folder Name="components">
<folder Name="ble">
<folder Name="ble_services">
<folder Name="ble_dfu">
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c" />
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.h" />
</folder>
<folder Name="ble_dis">
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dis/ble_dis.c" />
<file file_name="../lib/sdk11/components/ble/ble_services/ble_dis/ble_dis.h" />
</folder>
</folder>
<folder Name="common">
<file file_name="../lib/sdk11/components/ble/common/ble_srv_common.h" />
</folder>
</folder>
<folder Name="drivers_nrf">
<folder Name="pstorage">
<file file_name="../lib/sdk11/components/drivers_nrf/pstorage/pstorage.h" />
<file file_name="../lib/sdk11/components/drivers_nrf/pstorage/pstorage_raw.c" />
</folder>
</folder>
<folder Name="libraries">
<folder Name="bootloader_dfu">
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader.c" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_types.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_util.c" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/bootloader_util.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_bank_internal.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_ble_svc.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_ble_svc_internal.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_init.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_transport.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_serial.c" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_types.h" />
<folder Name="ble_transport">
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h" />
</folder>
<folder Name="hci_transport">
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_mem_pool_internal.h" />
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_transport_config.h" />
</folder>
<file file_name="../lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c" />
</folder>
<folder Name="util">
<file file_name="../lib/sdk11/components/libraries/util/nrf_log.h" />
</folder>
</folder>
</folder>
</folder>
<folder Name="tinyusb">
<folder Name="src">
<file file_name="../lib/tinyusb/src/tusb.c" />
<file file_name="../lib/tinyusb/src/tusb.h" />
<file file_name="../lib/tinyusb/src/tusb_hal.h" />
<file file_name="../lib/tinyusb/src/tusb_option.h" />
<folder Name="class">
<folder Name="cdc">
<file file_name="../lib/tinyusb/src/class/cdc/cdc.h" />
<file file_name="../lib/tinyusb/src/class/cdc/cdc_device.c" />
<file file_name="../lib/tinyusb/src/class/cdc/cdc_device.h" />
</folder>
<folder Name="hid">
<file file_name="../lib/tinyusb/src/class/hid/hid.h" />
<file file_name="../lib/tinyusb/src/class/hid/hid_device.c" />
<file file_name="../lib/tinyusb/src/class/hid/hid_device.h" />
</folder>
<folder Name="msc">
<file file_name="../lib/tinyusb/src/class/msc/msc.h" />
<file file_name="../lib/tinyusb/src/class/msc/msc_device.c" />
<file file_name="../lib/tinyusb/src/class/msc/msc_device.h" />
</folder>
</folder>
<folder Name="common">
<file file_name="../lib/tinyusb/src/common/binary.h" />
<file file_name="../lib/tinyusb/src/common/timeout_timer.h" />
<file file_name="../lib/tinyusb/src/common/tusb_common.h" />
<file file_name="../lib/tinyusb/src/common/tusb_compiler.h" />
<file file_name="../lib/tinyusb/src/common/tusb_error.h" />
<file file_name="../lib/tinyusb/src/common/tusb_fifo.c" />
<file file_name="../lib/tinyusb/src/common/tusb_fifo.h" />
<file file_name="../lib/tinyusb/src/common/tusb_types.h" />
<file file_name="../lib/tinyusb/src/common/tusb_verify.h" />
<folder Name="compiler">
<file file_name="../lib/tinyusb/src/common/compiler/tusb_compiler_gcc.h" />
<file file_name="../lib/tinyusb/src/common/compiler/tusb_compiler_iar.h" />
</folder>
</folder>
<folder Name="device">
<file file_name="../lib/tinyusb/src/device/dcd.h" />
<file file_name="../lib/tinyusb/src/device/usbd.c" />
<file file_name="../lib/tinyusb/src/device/usbd.h" />
<file file_name="../lib/tinyusb/src/device/usbd_pvt.h" />
<file file_name="../lib/tinyusb/src/device/usbd_control.c" />
</folder>
<folder Name="osal">
<file file_name="../lib/tinyusb/src/osal/osal.h" />
<file file_name="../lib/tinyusb/src/osal/osal_none.h" />
</folder>
<folder Name="portable">
<folder Name="nordic">
<folder Name="nrf5x">
<file file_name="../lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c" />
</folder>
</folder>
</folder>
</folder>
<configuration Name="Feather52832" build_exclude_from_build="Yes" />
</folder>
<folder Name="nrfx">
<file file_name="../lib/nrfx/nrfx.h" />
<folder Name="drivers">
<file file_name="../lib/nrfx/drivers/nrfx_common.h" />
<file file_name="../lib/nrfx/drivers/nrfx_errors.h" />
<folder Name="include">
<file file_name="../lib/nrfx/drivers/include/nrf_bitmask.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_adc.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_clock.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_comp.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_gpiote.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_i2s.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_lpcomp.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_pdm.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_power.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_power_clock.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_ppi.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_pwm.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_qdec.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_qspi.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_rng.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_rtc.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_saadc.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_spi.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_spim.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_spis.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_swi.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_systick.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_timer.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_twi.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_twim.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_twis.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_uart.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_uarte.h" />
<file file_name="../lib/nrfx/drivers/include/nrfx_wdt.h" />
</folder>
<folder Name="src">
<file file_name="../lib/nrfx/drivers/src/nrfx_power.c" />
<file file_name="../lib/nrfx/drivers/src/nrfx_nvmc.c" />
</folder>
</folder>
<folder Name="hal">
<file file_name="../lib/nrfx/hal/nrf_adc.h" />
<file file_name="../lib/nrfx/hal/nrf_ccm.h" />
<file file_name="../lib/nrfx/hal/nrf_clock.h" />
<file file_name="../lib/nrfx/hal/nrf_comp.h" />
<file file_name="../lib/nrfx/hal/nrf_ecb.h" />
<file file_name="../lib/nrfx/hal/nrf_egu.h" />
<file file_name="../lib/nrfx/hal/nrf_gpio.h" />
<file file_name="../lib/nrfx/hal/nrf_gpiote.h" />
<file file_name="../lib/nrfx/hal/nrf_i2s.h" />
<file file_name="../lib/nrfx/hal/nrf_lpcomp.h" />
<file file_name="../lib/nrfx/hal/nrf_nvmc.h" />
<file file_name="../lib/nrfx/hal/nrf_pdm.h" />
<file file_name="../lib/nrfx/hal/nrf_power.h" />
<file file_name="../lib/nrfx/hal/nrf_ppi.h" />
<file file_name="../lib/nrfx/hal/nrf_pwm.h" />
<file file_name="../lib/nrfx/hal/nrf_qdec.h" />
<file file_name="../lib/nrfx/hal/nrf_qspi.h" />
<file file_name="../lib/nrfx/hal/nrf_radio.h" />
<file file_name="../lib/nrfx/hal/nrf_rng.h" />
<file file_name="../lib/nrfx/hal/nrf_rtc.h" />
<file file_name="../lib/nrfx/hal/nrf_saadc.h" />
<file file_name="../lib/nrfx/hal/nrf_spi.h" />
<file file_name="../lib/nrfx/hal/nrf_spim.h" />
<file file_name="../lib/nrfx/hal/nrf_spis.h" />
<file file_name="../lib/nrfx/hal/nrf_systick.h" />
<file file_name="../lib/nrfx/hal/nrf_temp.h" />
<file file_name="../lib/nrfx/hal/nrf_timer.h" />
<file file_name="../lib/nrfx/hal/nrf_twi.h" />
<file file_name="../lib/nrfx/hal/nrf_twim.h" />
<file file_name="../lib/nrfx/hal/nrf_twis.h" />
<file file_name="../lib/nrfx/hal/nrf_uart.h" />
<file file_name="../lib/nrfx/hal/nrf_uarte.h" />
<file file_name="../lib/nrfx/hal/nrf_usbd.h" />
<file file_name="../lib/nrfx/hal/nrf_wdt.h" />
</folder>
<folder Name="mdk">
<file file_name="../lib/nrfx/mdk/compiler_abstraction.h" />
<file file_name="../lib/nrfx/mdk/nrf.h" />
<file file_name="../lib/nrfx/mdk/nrf52.h" />
<file file_name="../lib/nrfx/mdk/nrf52832_peripherals.h" />
<file file_name="../lib/nrfx/mdk/nrf52840.h" />
<file file_name="../lib/nrfx/mdk/nrf52840_bitfields.h" />
<file file_name="../lib/nrfx/mdk/nrf52840_peripherals.h" />
<file file_name="../lib/nrfx/mdk/nrf52_bitfields.h" />
<file file_name="../lib/nrfx/mdk/nrf_peripherals.h" />
<file file_name="../lib/nrfx/mdk/ses_startup_nrf52.s">
<configuration
Name="Feather52840 Size++"
build_exclude_from_build="Yes" />
<configuration
Name="Feather52840"
build_exclude_from_build="Yes" />
</file>
<file file_name="../lib/nrfx/mdk/ses_startup_nrf52840.s">
<configuration
Name="Feather52840 Size++"
build_exclude_from_build="No" />
<configuration
Name="Feather52832"
build_exclude_from_build="Yes" />
</file>
<file file_name="../lib/nrfx/mdk/ses_startup_nrf_common.s">
<configuration
Name="Feather52840 Size++"
build_exclude_from_build="No" />
</file>
<file file_name="../lib/nrfx/mdk/startup_config.h" />
<file file_name="../lib/nrfx/mdk/system_nrf52.c">
<configuration
Name="Feather52840 Size++"
build_exclude_from_build="Yes" />
<configuration
Name="Feather52840"
build_exclude_from_build="Yes" />
</file>
<file file_name="../lib/nrfx/mdk/system_nrf52.h" />
<file file_name="../lib/nrfx/mdk/system_nrf52840.c">
<configuration
Name="Feather52832"
build_exclude_from_build="Yes" />
</file>
<file file_name="../lib/nrfx/mdk/system_nrf52840.h" />
</folder>
<folder Name="soc">
<file file_name="../lib/nrfx/soc/nrfx_coredep.h" />
<file file_name="../lib/nrfx/soc/nrfx_irqs.h" />
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf51.h" />
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf52810.h" />
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf52832.h" />
<file file_name="../lib/nrfx/soc/nrfx_irqs_nrf52840.h" />
</folder>
</folder>
</folder>
<configuration
Name="Feather52840"
c_preprocessor_definitions="NRF52840_XXAA;S140"
c_user_include_directories="../src/boards/feather_nrf52840_express"
gcc_optimization_level="Debug"
linker_memory_map_file="nRF52840_xxAA_MemoryMap.xml" />
<configuration
Name="Feather52832"
c_preprocessor_definitions="NRF52832_XXAA;S132"
c_user_include_directories="../src/boards/feather_nrf52832"
gcc_optimization_level="Debug"
linker_memory_map_file="nRF52832_xxAA_MemoryMap.xml" />
<folder Name="src">
<folder Name="boards">
<folder Name="feather_nrf52840_express">
<file file_name="../src/boards/feather_nrf52840_express/board.h" />
<file file_name="../src/boards/feather_nrf52840_express/pinconfig.c" />
</folder>
<file file_name="../src/boards/boards.c" />
<file file_name="../src/boards/boards.h" />
</folder>
<folder
Name="cmsis"
exclude=""
filter="*.c;*.h"
path="../src/cmsis"
recurse="Yes" />
<file file_name="../src/dfu_ble_svc.c" />
<file file_name="../src/dfu_init.c" />
<file file_name="../src/flash_nrf5x.c" />
<file file_name="../src/flash_nrf5x.h" />
<file file_name="../src/main.c" />
<file file_name="../src/nrfx_config.h" />
<file file_name="../src/nrfx_glue.h" />
<file file_name="../src/pstorage_platform.h" />
<file file_name="../src/sdk_config.h" />
<folder
Name="usb"
exclude=""
filter="*.c;*.h"
path="../src/usb"
recurse="Yes" />
</folder>
</project>
<configuration Name="Feather52840" />
<configuration Name="Feather52832" />
</solution>
-1329
View File
File diff suppressed because it is too large. Load diff
-234
View File
@@ -1,234 +0,0 @@
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* 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. *
* *
* 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. *
* *
**********************************************************************
* *
* RTT version: 5.12e *
* *
**********************************************************************
---------------------------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.
----------------------------------------------------------------------
*/
#ifndef SEGGER_RTT_H
#define SEGGER_RTT_H
#include "SEGGER_RTT_Conf.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);
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_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_WriteString (unsigned BufferIndex, const char* s);
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
//
// Function macro for performance optimization
//
#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
/*********************************************************************
*
* RTT "Terminal" API functions
*
**********************************************************************
*/
int SEGGER_RTT_SetTerminal (char TerminalId);
int SEGGER_RTT_TerminalOut (char TerminalId, const char* s);
/*********************************************************************
*
* RTT printf functions (require SEGGER_RTT_printf.c)
*
**********************************************************************
*/
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
#ifdef __cplusplus
}
#endif
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
//
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
//
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0U) // Skip. Do not block, output nothing. (Default)
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1U) // Trim: Do not block, output as much as fits.
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2U) // Block: Wait until there is space in the buffer.
#define SEGGER_RTT_MODE_MASK (3U)
//
// Control sequences, based on ANSI.
// Can be used to control color, and clear the screen
//
#define RTT_CTRL_RESET "" // Reset to default colors
#define RTT_CTRL_CLEAR "" // Clear screen, reposition cursor to top left
#define RTT_CTRL_TEXT_BLACK ""
#define RTT_CTRL_TEXT_RED ""
#define RTT_CTRL_TEXT_GREEN ""
#define RTT_CTRL_TEXT_YELLOW ""
#define RTT_CTRL_TEXT_BLUE ""
#define RTT_CTRL_TEXT_MAGENTA ""
#define RTT_CTRL_TEXT_CYAN ""
#define RTT_CTRL_TEXT_WHITE ""
#define RTT_CTRL_TEXT_BRIGHT_BLACK ""
#define RTT_CTRL_TEXT_BRIGHT_RED ""
#define RTT_CTRL_TEXT_BRIGHT_GREEN ""
#define RTT_CTRL_TEXT_BRIGHT_YELLOW ""
#define RTT_CTRL_TEXT_BRIGHT_BLUE ""
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA ""
#define RTT_CTRL_TEXT_BRIGHT_CYAN ""
#define RTT_CTRL_TEXT_BRIGHT_WHITE ""
#define RTT_CTRL_BG_BLACK ""
#define RTT_CTRL_BG_RED ""
#define RTT_CTRL_BG_GREEN ""
#define RTT_CTRL_BG_YELLOW ""
#define RTT_CTRL_BG_BLUE ""
#define RTT_CTRL_BG_MAGENTA ""
#define RTT_CTRL_BG_CYAN ""
#define RTT_CTRL_BG_WHITE ""
#define RTT_CTRL_BG_BRIGHT_BLACK ""
#define RTT_CTRL_BG_BRIGHT_RED ""
#define RTT_CTRL_BG_BRIGHT_GREEN ""
#define RTT_CTRL_BG_BRIGHT_YELLOW ""
#define RTT_CTRL_BG_BRIGHT_BLUE ""
#define RTT_CTRL_BG_BRIGHT_MAGENTA ""
#define RTT_CTRL_BG_BRIGHT_CYAN ""
#define RTT_CTRL_BG_BRIGHT_WHITE ""
#endif
/*************************** End of file ****************************/
-242
View File
@@ -1,242 +0,0 @@
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* 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. *
* *
* 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. *
* *
**********************************************************************
* *
* 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------------------------------
*/
#ifndef SEGGER_RTT_CONF_H
#define SEGGER_RTT_CONF_H
#ifdef __ICCARM__
#include <intrinsics.h>
#endif
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#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)
#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)
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
//
// 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)
/*********************************************************************
*
* RTT lock configuration for SEGGER Embedded Studio,
* Rowley CrossStudio and GCC
*/
#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)
#ifdef __ARM_ARCH_6M__
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, primask \n\t" \
"mov 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__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, basepri \n\t" \
"mov r1, %1 \n\t" \
"msr basepri, r1 \n\t" \
: "=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; \
__asm volatile ("mrs r1, CPSR \n\t" \
"mov %0, r1 \n\t" \
"orr r1, r1, #0xC0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
"mrs r1, CPSR \n\t" \
"bic r1, r1, #0xC0 \n\t" \
"and r0, r0, #0xC0 \n\t" \
"orr r1, r1, r0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: \
: "r" (LockState) \
: "r0", "r1" \
); \
}
#else
#define SEGGER_RTT_LOCK()
#define SEGGER_RTT_UNLOCK()
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for IAR EWARM
*/
#ifdef __ICCARM__
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__))
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
LockState = __get_PRIMASK(); \
__set_PRIMASK(1);
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
}
#elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)))
#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);
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for KEIL ARM
*/
#ifdef __CC_ARM
#if (defined __TARGET_ARCH_6S_M)
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
register unsigned char PRIMASK __asm( "primask"); \
LockState = PRIMASK; \
PRIMASK = 1u; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
__schedule_barrier(); \
}
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
register unsigned char BASEPRI __asm( "basepri"); \
LockState = BASEPRI; \
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
__schedule_barrier(); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration fallback
*/
#ifndef SEGGER_RTT_LOCK
#define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
#endif
#ifndef SEGGER_RTT_UNLOCK
#define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
#endif
#endif
/*************************** End of file ****************************/
-76
View File
@@ -1,76 +0,0 @@
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 - 2015 SEGGER Microcontroller GmbH & Co. KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* 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. *
* *
* 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
implementation of __putchar and __getchar using RTT in SES.
To use RTT for printf output, include this file in your
application.
----------------------------------------------------------------------
*/
#include "SEGGER_RTT.h"
#include "__libc.h"
#include <stdarg.h>
#include <stdio.h>
int printf(const char *fmt,...) {
char buffer[128];
va_list args;
va_start (args, fmt);
int n = vsnprintf(buffer, sizeof(buffer), fmt, args);
SEGGER_RTT_Write(0, buffer, n);
va_end(args);
return n;
}
int puts(const char *s) {
return SEGGER_RTT_WriteString(0, s);
}
int __putchar(int x, __printf_tag_ptr ctx) {
(void)ctx;
SEGGER_RTT_Write(0, (char *)&x, 1);
return x;
}
int __getchar() {
return SEGGER_RTT_WaitKey();
}
/****** End Of File *************************************************/
-43
View File
@@ -1,43 +0,0 @@
<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
<MemorySegment name="$(FLASH_NAME:FLASH)">
<ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
<ProgramSection alignment="4" load="Yes" name=".init" />
<ProgramSection alignment="4" load="Yes" name=".init_rodata" />
<ProgramSection alignment="4" load="Yes" name=".text" />
<ProgramSection alignment="4" load="Yes" name=".dtors" />
<ProgramSection alignment="4" load="Yes" name=".ctors" />
<ProgramSection alignment="4" load="Yes" name=".rodata" />
<ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
<ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
<ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
<ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
</MemorySegment>
<MemorySegment name="$(RAM_NAME:RAM);SRAM">
<ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
<ProgramSection alignment="4" load="No" name=".fast_run" />
<ProgramSection alignment="4" load="No" name=".data_run" />
<ProgramSection alignment="4" load="No" name=".tdata_run" />
<ProgramSection alignment="4" load="No" name=".bss" />
<ProgramSection alignment="4" load="No" name=".tbss" />
<ProgramSection alignment="4" load="No" name=".non_init" />
<ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
<ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" />
<ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
</MemorySegment>
<MemorySegment name="$(FLASH2_NAME:BOOTLOADER_SETTINGS)">
<ProgramSection alignment="4" load="No" name=".bootloaderSettings" />
</MemorySegment>
<MemorySegment name="$(FLASH3_NAME:MBR_PARAMS_PAGE)">
<ProgramSection alignment="4" load="No" name=".mbrParamsPage" keep="Yes" />
</MemorySegment>
<MemorySegment name="$(FLASH4_NAME:UICR_BOOTLOADER)">
<ProgramSection alignment="4" load="Yes" name=".uicrBootStartAddress" keep="Yes" />
</MemorySegment>
<MemorySegment name="$(FLASH5_NAME:UICR_MBR_PARAM_PAGE)">
<ProgramSection alignment="4" load="Yes" name=".uicrMbrParamsPageAddress" keep="Yes" />
</MemorySegment>
<MemorySegment name="$(RAM2_NAME:NOINIT)">
<ProgramSection alignment="4" load="No" name=".noinit" />
</MemorySegment>
</Root>
-10
View File
@@ -1,10 +0,0 @@
<!DOCTYPE Board_Memory_Definition_File>
<root name="nRF52832_xxAA">
<MemorySegment name="FLASH" start="0x74000" size="0xA000" access="ReadOnly" />
<MemorySegment name="BOOTLOADER_SETTINGS" start="0x0007F000" size="0x1000" access="ReadOnly" />
<MemorySegment name="MBR_PARAMS_PAGE" start="0x0007E000" size="0x1000" access="ReadOnly" />
<MemorySegment name="UICR_BOOTLOADER" start="0x10001014" size="0x04" access="ReadOnly" />
<MemorySegment name="UICR_MBR_PARAM_PAGE" start="0x10001018" size="0x04" access="ReadOnly" />
<MemorySegment name="RAM" start="0x20003000" size="0x4F7C" access="Read/Write" />
<MemorySegment name="NOINIT" start="0x20007F80" size="0x80" access="Read/Write" />
</root>
-10
View File
@@ -1,10 +0,0 @@
<!DOCTYPE Board_Memory_Definition_File>
<root name="nRF52840_xxAA">
<MemorySegment name="FLASH" start="0x000F4000" size="0xA000" access="ReadOnly" />
<MemorySegment name="BOOTLOADER_SETTINGS" start="0x000FF000" size="0x1000" access="ReadOnly" />
<MemorySegment name="MBR_PARAMS_PAGE" start="0x000FE000" size="0x1000" access="ReadOnly" />
<MemorySegment name="UICR_BOOTLOADER" start="0x10001014" size="0x04" access="ReadOnly" />
<MemorySegment name="UICR_MBR_PARAM_PAGE" start="0x10001018" size="0x04" access="ReadOnly" />
<MemorySegment name="RAM" start="0x20008000" size="0x38000" access="Read/Write" />
<MemorySegment name="NOINIT" start="0x20007F80" size="0x80" access="Read/Write" />
</root>
-19
View File
@@ -1,19 +0,0 @@
/*****************************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
*****************************************************************************
* *
* (c) 2017 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
*****************************************************************************/
function Reset() {
TargetInterface.resetAndStop();
}
function EnableTrace(traceInterfaceType) {
// TODO: Enable trace
}
File diff suppressed because it is too large. Load diff
-420
View File
@@ -1,420 +0,0 @@
// SEGGER Embedded Studio, runtime support.
//
// Copyright (c) 2014-2017 SEGGER Microcontroller GmbH & Co KG
// Copyright (c) 2001-2017 Rowley Associates Limited.
//
// This file may be distributed under the terms of the License Agreement
// provided with this software.
//
// THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
//
// Preprocessor Definitions
// ------------------------
// APP_ENTRY_POINT
//
// Defines the application entry point function, if undefined this setting
// defaults to "main".
//
// INITIALIZE_STACK
//
// If defined, the contents of the stack will be initialized to a the
// value 0xCC.
//
// INITIALIZE_SECONDARY_SECTIONS
//
// If defined, the .data2, .text2, .rodata2 and .bss2 sections will be initialized.
//
// INITIALIZE_TCM_SECTIONS
//
// If defined, the .data_tcm, .text_tcm, .rodata_tcm and .bss_tcm sections
// will be initialized.
//
// INITIALIZE_USER_SECTIONS
//
// If defined, the function InitializeUserMemorySections will be called prior
// to entering main in order to allow the user to initialize any user defined
// memory sections.
//
// FULL_LIBRARY
//
// If defined then
// - argc, argv are setup by the debug_getargs.
// - the exit symbol is defined and executes on return from main.
// - the exit symbol calls destructors, atexit functions and then debug_exit.
//
// If not defined then
// - argc and argv are zero.
// - the exit symbol is defined, executes on return from main and loops
//
#ifndef APP_ENTRY_POINT
#define APP_ENTRY_POINT main
#endif
#ifndef ARGSSPACE
#define ARGSSPACE 128
#endif
.syntax unified
.global _start
.extern APP_ENTRY_POINT
.global exit
.weak exit
#ifdef INITIALIZE_USER_SECTIONS
.extern InitializeUserMemorySections
#endif
.section .init, "ax"
.code 16
.align 2
.thumb_func
_start:
/* Set up main stack if size > 0 */
ldr r1, =__stack_end__
ldr r0, =__stack_start__
subs r2, r1, r0
beq 1f
#ifdef __ARM_EABI__
movs r2, #0x7
bics r1, r2
#endif
mov sp, r1
#ifdef INITIALIZE_STACK
movs r2, #0xCC
ldr r0, =__stack_start__
bl memory_set
#endif
1:
/* Set up process stack if size > 0 */
ldr r1, =__stack_process_end__
ldr r0, =__stack_process_start__
subs r2, r1, r0
beq 1f
#ifdef __ARM_EABI__
movs r2, #0x7
bics r1, r2
#endif
msr psp, r1
movs r2, #2
msr control, r2
#ifdef INITIALIZE_STACK
movs r2, #0xCC
bl memory_set
#endif
1:
/* Copy initialized memory sections into RAM (if necessary). */
ldr r0, =__data_load_start__
ldr r1, =__data_start__
ldr r2, =__data_end__
bl memory_copy
ldr r0, =__text_load_start__
ldr r1, =__text_start__
ldr r2, =__text_end__
bl memory_copy
ldr r0, =__fast_load_start__
ldr r1, =__fast_start__
ldr r2, =__fast_end__
bl memory_copy
ldr r0, =__ctors_load_start__
ldr r1, =__ctors_start__
ldr r2, =__ctors_end__
bl memory_copy
ldr r0, =__dtors_load_start__
ldr r1, =__dtors_start__
ldr r2, =__dtors_end__
bl memory_copy
ldr r0, =__rodata_load_start__
ldr r1, =__rodata_start__
ldr r2, =__rodata_end__
bl memory_copy
ldr r0, =__tdata_load_start__
ldr r1, =__tdata_start__
ldr r2, =__tdata_end__
bl memory_copy
#ifdef INITIALIZE_SECONDARY_SECTIONS
ldr r0, =__data2_load_start__
ldr r1, =__data2_start__
ldr r2, =__data2_end__
bl memory_copy
ldr r0, =__text2_load_start__
ldr r1, =__text2_start__
ldr r2, =__text2_end__
bl memory_copy
ldr r0, =__rodata2_load_start__
ldr r1, =__rodata2_start__
ldr r2, =__rodata2_end__
bl memory_copy
#endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
#ifdef INITIALIZE_TCM_SECTIONS
ldr r0, =__data_tcm_load_start__
ldr r1, =__data_tcm_start__
ldr r2, =__data_tcm_end__
bl memory_copy
ldr r0, =__text_tcm_load_start__
ldr r1, =__text_tcm_start__
ldr r2, =__text_tcm_end__
bl memory_copy
ldr r0, =__rodata_tcm_load_start__
ldr r1, =__rodata_tcm_start__
ldr r2, =__rodata_tcm_end__
bl memory_copy
#endif /* #ifdef INITIALIZE_TCM_SECTIONS */
/* Zero the bss. */
ldr r0, =__bss_start__
ldr r1, =__bss_end__
movs r2, #0
bl memory_set
ldr r0, =__tbss_start__
ldr r1, =__tbss_end__
movs r2, #0
bl memory_set
#ifdef INITIALIZE_SECONDARY_SECTIONS
ldr r0, =__bss2_start__
ldr r1, =__bss2_end__
mov r2, #0
bl memory_set
#endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
#ifdef INITIALIZE_TCM_SECTIONS
ldr r0, =__bss_tcm_start__
ldr r1, =__bss_tcm_end__
mov r2, #0
bl memory_set
#endif /* #ifdef INITIALIZE_TCM_SECTIONS */
/* Initialize the heap */
ldr r0, = __heap_start__
ldr r1, = __heap_end__
subs r1, r1, r0
cmp r1, #8
blt 1f
movs r2, #0
str r2, [r0]
adds r0, r0, #4
str r1, [r0]
1:
#ifdef INITIALIZE_USER_SECTIONS
ldr r2, =InitializeUserMemorySections
blx r2
#endif
/* Call constructors */
ldr r0, =__ctors_start__
ldr r1, =__ctors_end__
ctor_loop:
cmp r0, r1
beq ctor_end
ldr r2, [r0]
adds r0, #4
push {r0-r1}
blx r2
pop {r0-r1}
b ctor_loop
ctor_end:
/* Setup initial call frame */
movs r0, #0
mov lr, r0
mov r12, sp
.type start, function
start:
/* Jump to application entry point */
#ifdef FULL_LIBRARY
movs r0, #ARGSSPACE
ldr r1, =args
ldr r2, =debug_getargs
blx r2
ldr r1, =args
#else
movs r0, #0
movs r1, #0
#endif
ldr r2, =APP_ENTRY_POINT
blx r2
.thumb_func
exit:
#ifdef FULL_LIBRARY
mov r5, r0 // save the exit parameter/return result
/* Call destructors */
ldr r0, =__dtors_start__
ldr r1, =__dtors_end__
dtor_loop:
cmp r0, r1
beq dtor_end
ldr r2, [r0]
add r0, #4
push {r0-r1}
blx r2
pop {r0-r1}
b dtor_loop
dtor_end:
/* Call atexit functions */
ldr r2, =_execute_at_exit_fns
blx r2
/* Call debug_exit with return result/exit parameter */
mov r0, r5
ldr r2, =debug_exit
blx r2
#endif
/* Returned from application entry point, loop forever. */
exit_loop:
b exit_loop
.thumb_func
memory_copy:
cmp r0, r1
beq 2f
subs r2, r2, r1
beq 2f
1:
ldrb r3, [r0]
adds r0, r0, #1
strb r3, [r1]
adds r1, r1, #1
subs r2, r2, #1
bne 1b
2:
bx lr
.thumb_func
memory_set:
cmp r0, r1
beq 1f
strb r2, [r0]
adds r0, r0, #1
b memory_set
1:
bx lr
// default C/C++ library helpers
.macro HELPER helper_name
.section .text.\helper_name, "ax", %progbits
.global \helper_name
.weak \helper_name
\helper_name:
.thumb_func
.endm
.macro JUMPTO name
#if defined(__thumb__) && !defined(__thumb2__)
mov r12, r0
ldr r0, =\name
push {r0}
mov r0, r12
pop {pc}
#else
b \name
#endif
.endm
HELPER __aeabi_read_tp
ldr r0, =__tbss_start__-8
bx lr
HELPER __heap_lock
bx lr
HELPER __heap_unlock
bx lr
HELPER __printf_lock
bx lr
HELPER __printf_unlock
bx lr
HELPER __scanf_lock
bx lr
HELPER __scanf_unlock
bx lr
HELPER __debug_io_lock
bx lr
HELPER __debug_io_unlock
bx lr
HELPER abort
b .
HELPER __assert
b .
HELPER __aeabi_assert
b .
HELPER __cxa_pure_virtual
b .
HELPER __cxa_guard_acquire
ldr r3, [r0]
#if defined(__thumb__) && !defined(__thumb2__)
movs r0, #1
tst r3, r0
#else
tst r3, #1
#endif
beq 1f
movs r0, #0
bx lr
1:
movs r0, #1
bx lr
HELPER __cxa_guard_release
movs r3, #1
str r3, [r0]
bx lr
HELPER __cxa_guard_abort
bx lr
HELPER __sync_synchronize
bx lr
HELPER __getchar
JUMPTO debug_getchar
HELPER __putchar
JUMPTO debug_putchar
HELPER __open
JUMPTO debug_fopen
HELPER __close
JUMPTO debug_fclose
HELPER __write
mov r3, r0
mov r0, r1
movs r1, #1
JUMPTO debug_fwrite
HELPER __read
mov r3, r0
mov r0, r1
movs r1, #1
JUMPTO debug_fread
HELPER __seek
push {r4, lr}
mov r4, r0
bl debug_fseek
cmp r0, #0
bne 1f
mov r0, r4
bl debug_ftell
pop {r4, pc}
1:
ldr r0, =-1
pop {r4, pc}
// char __user_locale_name_buffer[];
.section .bss.__user_locale_name_buffer, "aw", %nobits
.global __user_locale_name_buffer
.weak __user_locale_name_buffer
__user_locale_name_buffer:
.word 0x0
#ifdef FULL_LIBRARY
.bss
args:
.space ARGSSPACE
#endif
/* Setup attibutes of stack and heap sections so they don't take up room in the elf file */
.section .stack, "wa", %nobits
.section .stack_process, "wa", %nobits
.section .heap, "wa", %nobits
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+15 -18
View File
@@ -25,43 +25,40 @@
#ifndef ADM_B_NRF52840_1_H
#define ADM_B_NRF52840_1_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 19) // Red
//#define LED_SECONDARY_PIN 12 // Blue
#define LED_STATE_ON 0
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(0, 19) // Red
// #define LED_SECONDARY_PIN 12 // Blue
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 11)
#define BUTTON_2 _PINNUM(0, 12)
#define BUTTON_DFU PINNUM(0, 11)
#define BUTTON_DFU_OTA PINNUM(0, 12)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Atelier-Du-Maker"
#define BLEDIS_MODEL "ADM_B_NRF52840_1"
#define BLEDIS_MANUFACTURER "Atelier-Du-Maker"
#define BLEDIS_MODEL "ADM_B_NRF52840_1"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x009F
#define USB_DESC_CDC_ONLY_PID 0x009F
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x009F
#define USB_DESC_CDC_ONLY_PID 0x009F
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "AtelierDuMaker NRF52840 Breakout"
#define UF2_VOLUME_LABEL "ADM840BOOT"
#define UF2_BOARD_ID "ADM_B_NRF52840_1"
#define UF2_INDEX_URL "https://github.com/Atelier-Du-Maker/HolyIoT_NRF52840"
#define UF2_PRODUCT_NAME "AtelierDuMaker NRF52840 Breakout"
#define UF2_VOLUME_LABEL "ADM840BOOT"
#define UF2_BOARD_ID "ADM_B_NRF52840_1"
#define UF2_INDEX_URL "https://github.com/Atelier-Du-Maker/HolyIoT_NRF52840"
#endif // ADM_B_NRF52840_1_H
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52)
+12 -13
View File
@@ -28,27 +28,26 @@
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // LED1
#define LED_SECONDARY_PIN 19 // LED2
#define LED_STATE_ON 1
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // LED1
#define LED_SECONDARY_PIN 19 // LED2
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 11 // BTN1
#define BUTTON_2 15 // BTN2
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU 11 // BTN1
#define BUTTON_DFU_OTA 15 // BTN2
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
//--------------------------------------------------------------------+
// BLE OTA
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+17 -20
View File
@@ -25,41 +25,38 @@
#ifndef _ARAMCON2_BADGE_H
#define _ARAMCON2_BADGE_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 11) // Red
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(1, 11) // Red
#define LED_NEOPIXEL _PINNUM(0, 8)
#define NEOPIXELS_NUMBER 2
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(0, 8)
#define NEOPIXELS_NUMBER 2
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 2) // left Button
#define BUTTON_2 _PINNUM(0, 29) // middle button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 2) // left Button
#define BUTTON_DFU_OTA PINNUM(0, 29) // middle button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
// Used as model string in OTA mode
#define BLEDIS_MANUFACTURER "ARAMCON Badge Team"
#define BLEDIS_MODEL "ARAMCON2 Badge"
#define BLEDIS_MANUFACTURER "ARAMCON Badge Team"
#define BLEDIS_MODEL "ARAMCON2 Badge"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x007B
#define USB_DESC_CDC_ONLY_PID 0x007B
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x007B
#define USB_DESC_CDC_ONLY_PID 0x007B
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "ARAMCON2 Badge"
#define UF2_VOLUME_LABEL "ARAMBOOT"
#define UF2_BOARD_ID "nrf52840-ARAMCON2-Badge"
#define UF2_INDEX_URL "https://github.com/aramcon-badge"
#define UF2_PRODUCT_NAME "ARAMCON2 Badge"
#define UF2_VOLUME_LABEL "ARAMBOOT"
#define UF2_BOARD_ID "nrf52840-ARAMCON2-Badge"
#define UF2_INDEX_URL "https://github.com/aramcon-badge"
#endif // _ARAMCON2_BADGE_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+17 -20
View File
@@ -26,43 +26,40 @@
#ifndef _ARAMCON_BADGE_2019_H
#define _ARAMCON_BADGE_2019_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 11) // Red
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(1, 11) // Red
#define LED_NEOPIXEL _PINNUM(0, 8)
#define NEOPIXELS_NUMBER 4
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(0, 8)
#define NEOPIXELS_NUMBER 4
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 2) // left Button
#define BUTTON_2 _PINNUM(0, 29) // middle button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 2) // left Button
#define BUTTON_DFU_OTA PINNUM(0, 29) // middle button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "ARAMCON Badge Team"
#define BLEDIS_MODEL "ARAMCON Badge 2019"
#define BLEDIS_MANUFACTURER "ARAMCON Badge Team"
#define BLEDIS_MODEL "ARAMCON Badge 2019"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0079
#define USB_DESC_CDC_ONLY_PID 0x0079
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0079
#define USB_DESC_CDC_ONLY_PID 0x0079
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "ARAMCON Badge 2019"
#define UF2_VOLUME_LABEL "ARAMBOOT"
#define UF2_BOARD_ID "nrf52840-ARAMCON-Badge-2019"
#define UF2_INDEX_URL "https://github.com/aramcon-badge"
#define UF2_PRODUCT_NAME "ARAMCON Badge 2019"
#define UF2_VOLUME_LABEL "ARAMBOOT"
#define UF2_BOARD_ID "nrf52840-ARAMCON-Badge-2019"
#define UF2_INDEX_URL "https://github.com/aramcon-badge"
#endif // _ARAMCON_BADGE_2019_H
@@ -1,62 +0,0 @@
#include "boards.h"
__attribute__((used, section(".bootloaderConfig")))
const uint32_t bootloaderConfig[] = {
/* CF2 START */
513675505, 539130489, // magic
49, 100, // used entries, total entries
4, 0x18, // PIN_BTN_A = PIN_RX
5, 0xa, // PIN_BTN_B = PIN_D2
13, 0x29, // PIN_LED = PIN_D13
18, 0xf, // PIN_MISO = PA15
19, 0xd, // PIN_MOSI = PA13
20, 0x23, // PIN_NEOPIXEL = PB03
21, 0x18, // PIN_RX = PA24
23, 0xe, // PIN_SCK = PA14
24, 0xb, // PIN_SCL = PA11
25, 0xc, // PIN_SDA = PA12
28, 0x19, // PIN_TX = PA25
32, 0xe, // PIN_DISPLAY_SCK = PIN_SCK
34, 0xd, // PIN_DISPLAY_MOSI = PIN_MOSI
35, 0x1e, // PIN_DISPLAY_CS = PIN_A2
36, 0x1c, // PIN_DISPLAY_DC = PIN_A3
37, 0xa0, // DISPLAY_WIDTH = 160
38, 0x80, // DISPLAY_HEIGHT = 128
39, 0x80, // DISPLAY_CFG0 = 0x80
40, 0x603, // DISPLAY_CFG1 = 0x603
41, 0x20, // DISPLAY_CFG2 = 0x20
43, 0x2, // PIN_DISPLAY_RST = PIN_A4
44, 0x3, // PIN_DISPLAY_BL = PIN_A5
47, 0x6, // PIN_BTN_LEFT = PIN_D11
48, 0x1a, // PIN_BTN_RIGHT = PIN_D9
49, 0x1b, // PIN_BTN_UP = PIN_D10
50, 0x7, // PIN_BTN_DOWN = PIN_D6
51, 0x8, // PIN_BTN_MENU = PIN_D12
56, 0x2a, // PIN_LED2 = PB10
60, 0x19, // PIN_JACK_TX = PIN_TX
100, 0x4, // PIN_A0 = PA04
101, 0x5, // PIN_A1 = PA05
102, 0x1e, // PIN_A2 = PA30
103, 0x1c, // PIN_A3 = PA28
104, 0x2, // PIN_A4 = PA02
105, 0x3, // PIN_A5 = PA03
152, 0xa, // PIN_D2 = PA10
155, 0x28, // PIN_D5 = PB08
156, 0x7, // PIN_D6 = PA07
159, 0x1a, // PIN_D9 = PA26
160, 0x1b, // PIN_D10 = PA27
161, 0x6, // PIN_D11 = PA06
162, 0x8, // PIN_D12 = PA08
163, 0x29, // PIN_D13 = PB09
200, 0x1, // NUM_NEOPIXELS = 1
204, 0x100000, // FLASH_BYTES = 0x100000
205, 0x40000, // RAM_BYTES = 0x40000
208, 0xd7688ea1, // BOOTLOADER_BOARD_ID = 0xd7688ea1
209, 0xada52840, // UF2_FAMILY = 0xada52840
210, 0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
/* CF2 END */
};
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+15 -18
View File
@@ -25,40 +25,37 @@
#ifndef _ARDUINOBLE33_NRF52840_H
#define _ARDUINOBLE33_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1 // red LED
#define LED_PRIMARY_PIN _PINNUM(0, 24)
#define LED_STATE_ON 0
#define LEDS_NUMBER 1 // red LED
#define LED_PRIMARY_PIN PINNUM(0, 24)
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 11) // D2 switch
#define BUTTON_2 _PINNUM(1, 12) // D3 switch
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(1, 11) // D2 switch
#define BUTTON_DFU_OTA PINNUM(1, 12) // D3 switch
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Arduino"
#define BLEDIS_MODEL "Nano 33 BLE"
#define BLEDIS_MANUFACTURER "Arduino"
#define BLEDIS_MODEL "Nano 33 BLE"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0063
#define USB_DESC_CDC_ONLY_PID 0x0064
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0063
#define USB_DESC_CDC_ONLY_PID 0x0064
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Arduino Nano 33 BLE"
#define UF2_VOLUME_LABEL "NANO33BOOT"
#define UF2_BOARD_ID "nRF52840-Nano-33"
#define UF2_INDEX_URL "https://www.arduino.cc/"
#define UF2_PRODUCT_NAME "Arduino Nano 33 BLE"
#define UF2_VOLUME_LABEL "NANO33BOOT"
#define UF2_BOARD_ID "nRF52840-Nano-33"
#define UF2_INDEX_URL "https://www.arduino.cc/"
#endif // _ITSY_NRF52840_H
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+15 -17
View File
@@ -25,40 +25,38 @@
#ifndef _BASTBLE_NRF52840_H
#define _BASTBLE_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1 // red LED
#define LED_PRIMARY_PIN _PINNUM(0, 24)
#define LED_STATE_ON 0
#define LEDS_NUMBER 1 // red LED
#define LED_PRIMARY_PIN PINNUM(0, 24)
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 05)
#define BUTTON_2 _PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 05)
#define BUTTON_DFU_OTA PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "ElectronicCats"
#define BLEDIS_MODEL "BastBLE"
#define BLEDIS_MANUFACTURER "ElectronicCats"
#define BLEDIS_MODEL "BastBLE"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
// Shared VID/PID with Feather nRF52840, will be disabled for building in the future
#define USB_DESC_VID 0x1209
#define USB_DESC_UF2_PID 0x805A
#define USB_DESC_CDC_ONLY_PID 0x805A
#define USB_DESC_VID 0x1209
#define USB_DESC_UF2_PID 0x805A
#define USB_DESC_CDC_ONLY_PID 0x805A
#define UF2_PRODUCT_NAME "Bast BLE"
#define UF2_VOLUME_LABEL "BASTBLE"
#define UF2_BOARD_ID "Bast-ble-v1"
#define UF2_INDEX_URL "https://www.electroniccats.com"
#define UF2_PRODUCT_NAME "Bast BLE"
#define UF2_VOLUME_LABEL "BASTBLE"
#define UF2_BOARD_ID "Bast-ble-v1"
#define UF2_INDEX_URL "https://www.electroniccats.com"
#endif // _BASTBLE_NRF52840_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52833)
+19 -22
View File
@@ -25,45 +25,42 @@
#ifndef _BLUEMICRO_NRF52833_H
#define _BLUEMICRO_NRF52833_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 4)
#define LED_SECONDARY_PIN _PINNUM(0, 25)
#define LED_STATE_ON 1
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN PINNUM(1, 4)
#define LED_SECONDARY_PIN PINNUM(0, 25)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 7)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(0, 7)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2 // none connected at all
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
#define BUTTON_2 _PINNUM(1, 1) // no connection on E73-2G4M08S1E Module
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 18) // unusable: RESET
#define BUTTON_DFU_OTA PINNUM(1, 1) // no connection on E73-2G4M08S1E Module
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "BlueMicro"
#define BLEDIS_MODEL "BlueMicro 833"
#define BLEDIS_MANUFACTURER "BlueMicro"
#define BLEDIS_MODEL "BlueMicro 833"
//--------------------------------------------------------------------+
// USB PID from openmoko:
// PR https://github.com/openmoko/openmoko-usb-oui/pull/34
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x1d50
#define USB_DESC_UF2_PID 0x616f
#define USB_DESC_CDC_ONLY_PID 0x616f
#define USB_DESC_VID 0x1d50
#define USB_DESC_UF2_PID 0x616f
#define USB_DESC_CDC_ONLY_PID 0x616f
#define UF2_PRODUCT_NAME "BlueMicro"
#define UF2_VOLUME_LABEL "BLUEMICRO"
#define UF2_BOARD_ID "nRF52833-BlueMicro-v1"
#define UF2_INDEX_URL "http://bluemicro.jpconstantineau.com/"
#define UF2_PRODUCT_NAME "BlueMicro"
#define UF2_VOLUME_LABEL "BLUEMICRO"
#define UF2_BOARD_ID "nRF52833-BlueMicro-v1"
#define UF2_INDEX_URL "http://bluemicro.jpconstantineau.com/"
#endif // _BLUEMICRO_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+16 -19
View File
@@ -25,41 +25,38 @@
#ifndef _BLUEMICRO_NRF52840_H
#define _BLUEMICRO_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 4)
#define LED_SECONDARY_PIN _PINNUM(1, 10)
#define LED_STATE_ON 1
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN PINNUM(1, 4)
#define LED_SECONDARY_PIN PINNUM(1, 10)
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2 // none connected at all
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
#define BUTTON_2 _PINNUM(1, 1) // no connection on E73-2G4M08S1C Module
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 18) // unusable: RESET
#define BUTTON_DFU_OTA PINNUM(1, 1) // no connection on E73-2G4M08S1C Module
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "BlueMicro"
#define BLEDIS_MODEL "BlueMicro 840"
#define BLEDIS_MANUFACTURER "BlueMicro"
#define BLEDIS_MODEL "BlueMicro 840"
//--------------------------------------------------------------------+
// USB PID from openmoko:
// Approved PR https://github.com/openmoko/openmoko-usb-oui/pull/20
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x1d50
#define USB_DESC_UF2_PID 0x6160
#define USB_DESC_CDC_ONLY_PID 0x6160
#define USB_DESC_VID 0x1d50
#define USB_DESC_UF2_PID 0x6160
#define USB_DESC_CDC_ONLY_PID 0x6160
#define UF2_PRODUCT_NAME "BlueMicro"
#define UF2_VOLUME_LABEL "BLUEMICRO"
#define UF2_BOARD_ID "nRF52840-BlueMicro-v1"
#define UF2_INDEX_URL "http://bluemicro.jpconstantineau.com/"
#define UF2_PRODUCT_NAME "BlueMicro"
#define UF2_VOLUME_LABEL "BLUEMICRO"
#define UF2_BOARD_ID "nRF52840-BlueMicro-v1"
#define UF2_INDEX_URL "http://bluemicro.jpconstantineau.com/"
#endif // _BLUEMICRO_H
+25 -11
View File
@@ -27,14 +27,14 @@
#include "app_scheduler.h"
#include "app_timer.h"
#ifdef LED_APA102
#ifdef LED_APA102_CLK
#include "nrf_spim.h"
#endif
#define SCHED_MAX_EVENT_DATA_SIZE sizeof(app_timer_event_t) /**< Maximum size of scheduler events. */
#define SCHED_QUEUE_SIZE 30 /**< Maximum number of events in the scheduler queue. */
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
void neopixel_init(void);
void neopixel_write(uint8_t* pixels);
void neopixel_teardown(void);
@@ -50,6 +50,7 @@ void SysTick_Handler(void) {
led_tick();
}
#if defined(BUTTON_DFU) || defined(BUTTON_DFU_OTA)
void button_init(uint32_t pin) {
if (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN) {
nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_HIGH);
@@ -62,6 +63,7 @@ bool button_pressed(uint32_t pin) {
uint32_t const active_state = (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ? 1 : 0);
return nrf_gpio_pin_read(pin) == active_state;
}
#endif
// This is declared so that a board specific init can be called from here.
void __attribute__((weak)) board_init2(void) {}
@@ -74,8 +76,12 @@ void board_init(void) {
NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC;
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
#ifdef BUTTON_DFU
button_init(BUTTON_DFU);
button_init(BUTTON_FRESET);
#endif
#ifdef BUTTON_DFU_OTA
button_init(BUTTON_DFU_OTA);
#endif
NRFX_DELAY_US(100); // wait for the pin state is stable
#if LEDS_NUMBER > 0
@@ -86,7 +92,7 @@ void board_init(void) {
#endif
#endif
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
// use neopixel for use enumeration
#ifdef NEOPIXEL_POWER_PIN
nrf_gpio_cfg_output(NEOPIXEL_POWER_PIN);
@@ -111,7 +117,13 @@ void board_init(void) {
// #define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
// in board.h when using that power configuration.
#ifdef UICR_REGOUT0_VALUE
if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) != (UICR_REGOUT0_VALUE << UICR_REGOUT0_VOUT_Pos)){
// for some reason bellow condition is true even though debugger show 3.0V
// pyocd> rw 0x10001304
// 10001304: fffffffc
// it leads to infinite boot loop. Let wait for NVM to be ready first.
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos)){
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) |
@@ -119,8 +131,10 @@ void board_init(void) {
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NVIC_SystemReset();
// to avoid infinity boot loop reset only if REGOUT0 was set correctly
if((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == (UICR_REGOUT0_VALUE << UICR_REGOUT0_VOUT_Pos)){
NVIC_SystemReset();
}
}
#endif
@@ -147,7 +161,7 @@ void board_teardown(void) {
led_pwm_teardown();
#endif
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
neopixel_teardown();
#endif
@@ -362,7 +376,7 @@ static uint32_t primary_cycle_length;
static uint32_t secondary_cycle_length;
#endif
void led_tick() {
void led_tick(void) {
uint32_t millis = _systick_count;
uint32_t cycle = millis % primary_cycle_length;
@@ -452,7 +466,7 @@ void led_state(uint32_t state) {
final_color = (uint8_t*) &rgb_color;
}
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
if (final_color != NULL) {
neopixel_write(final_color);
}
@@ -560,7 +574,7 @@ void neopixel_write(uint8_t* pixels) {
#endif
#ifdef LED_APA102
#ifdef LED_APA102_CLK
#define BYTE_PER_PIXEL 4
// 4 zero bytes are required to initiate update
+3 -13
View File
@@ -31,20 +31,13 @@
#include "nrf.h"
#include "nrf_gpio.h"
#define PINNUM(port, pin) ((port) * 32 + (pin))
#include "board.h"
#ifndef UF2_VOLUME_LABEL
#define UF2_VOLUME_LABEL "NRF52BOOT "
#endif
#ifndef BUTTON_DFU
#define BUTTON_DFU BUTTON_1
#endif
#ifndef BUTTON_FRESET
#define BUTTON_FRESET BUTTON_2
#endif
// The primary LED is usually Red but not in all cases.
#define LED_PRIMARY 0
// The secondary LED, when available, is usually blue.
@@ -104,13 +97,10 @@ void led_tick(void);
//--------------------------------------------------------------------+
// BUTTONS
//--------------------------------------------------------------------+
// Make sure we have at least two buttons (DFU + FRESET since DFU+FRST=OTA)
#if BUTTONS_NUMBER < 2
#error "At least two buttons required in the BSP (see 'BUTTONS_NUMBER')"
#endif
#if defined(BUTTON_DFU) || defined(BUTTON_DFU_OTA)
void button_init(uint32_t pin);
bool button_pressed(uint32_t pin);
#endif
bool is_ota(void);
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+70 -73
View File
@@ -1,73 +1,70 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries, 2022 Invector Labs
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _CHALLENGER_840_BLE_H
#define _CHALLENGER_840_BLE_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 12)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(1, 8)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 19)
#define BUTTON_2 _PINNUM(0, 8) // Pulls flash cs high
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* On board LDO control
*------------------------------------------------------------------*/
#define LDO_CONTROL_PIN _PINNUM(1, 9) // Enables external pwr
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Invector Labs"
#define BLEDIS_MODEL "Challenger 840 BLE"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x1209
#define USB_DESC_UF2_PID 0x7380
#define USB_DESC_CDC_ONLY_PID 0x7381
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "ILabs Challenger 840"
#define UF2_VOLUME_LABEL "CH840BOOT"
#define UF2_BOARD_ID "nRF52840-Challenger-840"
#define UF2_INDEX_URL "https://www.ilabs.se"
#endif // _CHALLENGER_840_BLE_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries, 2022 Invector Labs
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _CHALLENGER_840_BLE_H
#define _CHALLENGER_840_BLE_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(0, 12)
#define LED_STATE_ON 1
#define LED_NEOPIXEL PINNUM(1, 8)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTON_DFU PINNUM(0, 19)
#define BUTTON_DFU_OTA PINNUM(0, 8) // Pulls flash cs high
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* On board LDO control
*------------------------------------------------------------------*/
#define LDO_CONTROL_PIN PINNUM(1, 9) // Enables external pwr
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Invector Labs"
#define BLEDIS_MODEL "Challenger 840 BLE"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x1209
#define USB_DESC_UF2_PID 0x7380
#define USB_DESC_CDC_ONLY_PID 0x7381
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "ILabs Challenger 840"
#define UF2_VOLUME_LABEL "CH840BOOT"
#define UF2_BOARD_ID "nRF52840-Challenger-840"
#define UF2_INDEX_URL "https://www.ilabs.se"
#endif // _CHALLENGER_840_BLE_H
+18 -21
View File
@@ -25,44 +25,41 @@
#ifndef _CPLAY_NRF52840_H
#define _CPLAY_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 14)
#define LED_STATE_ON 1
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(1, 14)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 13)
#define NEOPIXELS_NUMBER 10
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(0, 13)
#define NEOPIXELS_NUMBER 10
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 02) // left button
#define BUTTON_2 _PINNUM(1, 15) // right button
#define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN
#define BUTTON_DFU PINNUM(1, 02) // left button
#define BUTTON_DFU_OTA PINNUM(1, 15) // right button
#define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Circuit Playground nRF52840"
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Circuit Playground nRF52840"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0045
#define USB_DESC_CDC_ONLY_PID 0x0045
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0045
#define USB_DESC_CDC_ONLY_PID 0x0045
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Circuit Playground nRF52840"
#define UF2_VOLUME_LABEL "CPLAYBTBOOT"
#define UF2_BOARD_ID "nRF52840-CircuitPlayground-revD"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4333"
#define UF2_PRODUCT_NAME "Adafruit Circuit Playground nRF52840"
#define UF2_VOLUME_LABEL "CPLAYBTBOOT"
#define UF2_BOARD_ID "nRF52840-CircuitPlayground-revD"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4333"
#endif // _CPLAY_NRF52840_H
+32 -35
View File
@@ -25,70 +25,67 @@
#ifndef _CLUE_NRF52840_H
#define _CLUE_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 01)
#define LED_STATE_ON 1
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(1, 01)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 16)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(0, 16)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 02) // left button
#define BUTTON_2 _PINNUM(1, 10) // right button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(1, 02) // left button
#define BUTTON_DFU_OTA PINNUM(1, 10) // right button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// Display
//--------------------------------------------------------------------+
#define DISPLAY_CONTROLLER_ST7789
#define DISPLAY_PIN_SCK _PINNUM(0, 14)
#define DISPLAY_PIN_MOSI _PINNUM(0, 15)
#define DISPLAY_PIN_SCK PINNUM(0, 14)
#define DISPLAY_PIN_MOSI PINNUM(0, 15)
#define DISPLAY_PIN_CS _PINNUM(0, 12)
#define DISPLAY_PIN_DC _PINNUM(0, 13)
#define DISPLAY_PIN_RST _PINNUM(1, 3)
#define DISPLAY_PIN_BL _PINNUM(1, 5)
#define DISPLAY_BL_ON 1 // GPIO state to enable back light
#define DISPLAY_PIN_CS PINNUM(0, 12)
#define DISPLAY_PIN_DC PINNUM(0, 13)
#define DISPLAY_PIN_RST PINNUM(1, 3)
#define DISPLAY_PIN_BL PINNUM(1, 5)
#define DISPLAY_BL_ON 1 // GPIO state to enable back light
#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 240
#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 240
#define DISPLAY_COL_OFFSET 0
#define DISPLAY_ROW_OFFSET 80
#define DISPLAY_COL_OFFSET 0
#define DISPLAY_ROW_OFFSET 80
// Memory Data Access Control & // Vertical Scroll Start Address
#define DISPLAY_MADCTL (TFT_MADCTL_MY)
#define DISPLAY_VSCSAD 0
#define DISPLAY_MADCTL (TFT_MADCTL_MY)
#define DISPLAY_VSCSAD 0
#define DISPLAY_TITLE "CLUE"
#define DISPLAY_TITLE "CLUE"
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "CLUE nRF52840"
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "CLUE nRF52840"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0071
#define USB_DESC_CDC_ONLY_PID 0x0071
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0071
#define USB_DESC_CDC_ONLY_PID 0x0071
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit CLUE nRF52840"
#define UF2_VOLUME_LABEL "CLUEBOOT"
#define UF2_BOARD_ID "nRF52840-CLUE-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4500"
#define UF2_PRODUCT_NAME "Adafruit CLUE nRF52840"
#define UF2_VOLUME_LABEL "CLUEBOOT"
#define UF2_BOARD_ID "nRF52840-CLUE-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4500"
#endif // _CLUE_NRF52840_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52)
+66 -66
View File
@@ -1,66 +1,66 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Pierre Constantineau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _EBYTE_E104_BT5032A_H
#define _EBYTE_E104_BT5032A_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 31 // Red - named "Data"
#define LED_SECONDARY_PIN 30 // Blue - named "Link" (also a red one on the Test Board)
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 29 // DISC Button on E104-BT5032A-TB Test Board
// BUTTON_1 is DFU. The module does not have reset circuitry.
// The Test Board from Ebyte (E104-BT5032A-TB) also does not have reset circuitry
// To be able to upload using the Arduino IDE, (To enter DFU mode)
// Press "DISC", press and release "RST", then release "DISC"
#define BUTTON_2 28 // No button - WKP pin
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 14
#define TX_PIN_NUMBER 18
#define CTS_PIN_NUMBER 20
#define RTS_PIN_NUMBER 19
#define HWFC false // leaving it false to make GPIO available
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "CDEBYTE"
#define BLEDIS_MODEL "E104-BT5032A"
#define UF2_PRODUCT_NAME "Ebyte E104-BT5032A nRF52832"
#define UF2_INDEX_URL "https://www.ebyte.com/en/product-view-news.html?id=756"
#endif // _EBYTE_E104_BT5032A_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Pierre Constantineau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _EBYTE_E104_BT5032A_H
#define _EBYTE_E104_BT5032A_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 31 // Red - named "Data"
#define LED_SECONDARY_PIN 30 // Blue - named "Link" (also a red one on the Test Board)
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTON_DFU \
29 // DISC Button on E104-BT5032A-TB Test Board
// BUTTON_DFU is DFU. The module does not have reset circuitry.
// The Test Board from Ebyte (E104-BT5032A-TB) also does not have reset circuitry
// To be able to upload using the Arduino IDE, (To enter DFU mode)
// Press "DISC", press and release "RST", then release "DISC"
#define BUTTON_DFU_OTA 28 // No button - WKP pin
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 14
#define TX_PIN_NUMBER 18
#define CTS_PIN_NUMBER 20
#define RTS_PIN_NUMBER 19
#define HWFC false // leaving it false to make GPIO available
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "CDEBYTE"
#define BLEDIS_MODEL "E104-BT5032A"
#define UF2_PRODUCT_NAME "Ebyte E104-BT5032A nRF52832"
#define UF2_INDEX_URL "https://www.ebyte.com/en/product-view-news.html?id=756"
#endif // _EBYTE_E104_BT5032A_H
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52)
+67 -67
View File
@@ -1,67 +1,67 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Pierre Constantineau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _EBYTE_E73_TBB_H
#define _EBYTE_E73_TBB_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // Red - named "LED1"
#define LED_SECONDARY_PIN 18 // Blue - named "LED2" (also a red one on the Test Board)
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 14 // BUTTON_1 is DFU. SW1 on E73-TBB Test Board.
// This Test board uses the E73-2G4M04S1B module which contains a nrf52832.
// The module does not have reset circuitry.
// The Test Board from Ebyte (E73-TBB) also does not have reset circuitry
// To be able to upload using the Arduino IDE, (To enter DFU mode)
// Press "SW1", momentarily ground "RST/P0.21", then release "SW1"
#define BUTTON_2 13 // SW2 on board
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 5
#define RTS_PIN_NUMBER 7
#define HWFC false // leaving it false to make GPIO available
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "CDEBYTE"
#define BLEDIS_MODEL "E73-TBB"
#define UF2_PRODUCT_NAME "Ebyte E73-TBB nRF52832"
#define UF2_INDEX_URL "https://www.ebyte.com/en/product-view-news.aspx?id=889"
#endif // _EBYTE_E73_TBB_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Pierre Constantineau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _EBYTE_E73_TBB_H
#define _EBYTE_E73_TBB_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // Red - named "LED1"
#define LED_SECONDARY_PIN 18 // Blue - named "LED2" (also a red one on the Test Board)
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTON_DFU \
14 // BUTTON_DFU is DFU. SW1 on E73-TBB Test Board.
// This Test board uses the E73-2G4M04S1B module which contains a nrf52832.
// The module does not have reset circuitry.
// The Test Board from Ebyte (E73-TBB) also does not have reset circuitry
// To be able to upload using the Arduino IDE, (To enter DFU mode)
// Press "SW1", momentarily ground "RST/P0.21", then release "SW1"
#define BUTTON_DFU_OTA 13 // SW2 on board
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 5
#define RTS_PIN_NUMBER 7
#define HWFC false // leaving it false to make GPIO available
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "CDEBYTE"
#define BLEDIS_MODEL "E73-TBB"
#define UF2_PRODUCT_NAME "Ebyte E73-TBB nRF52832"
#define UF2_INDEX_URL "https://www.ebyte.com/en/product-view-news.aspx?id=889"
#endif // _EBYTE_E73_TBB_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+15 -16
View File
@@ -30,10 +30,10 @@
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 13
#define LED_SECONDARY_PIN 14
#define LED_STATE_ON 0
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 13
#define LED_SECONDARY_PIN 14
#define LED_STATE_ON 0
/*------------------------------------------------------------------*/
/* BUTTON
@@ -42,26 +42,25 @@
// App can trigger OTA bootloader by writing DFU_MAGIC_OTA_APPJUM to
// GPREGRET register if softdevice is not initialized; or by
// writing DFU_MAGIC_OTA_RESET in case softdevice is initialized.
#define BUTTONS_NUMBER 2
#define BUTTON_1 18 // RESET also by default
#define BUTTON_2 1 // P0.1 not exposed anywhere, FRST n/a
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU 18 // RESET also by default
#define BUTTON_DFU_OTA 1 // P0.1 not exposed anywhere, FRST n/a
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Electronut Labs"
#define BLEDIS_MODEL "Papyr"
#define BLEDIS_MANUFACTURER "Electronut Labs"
#define BLEDIS_MODEL "Papyr"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define UF2_PRODUCT_NAME "Electronut Labs Papyr"
#define UF2_BOARD_ID "nRF52840-Papyr-v1"
#define UF2_INDEX_URL "https://docs.electronut.in/papyr"
#define UF2_PRODUCT_NAME "Electronut Labs Papyr"
#define UF2_BOARD_ID "nRF52840-Papyr-v1"
#define UF2_INDEX_URL "https://docs.electronut.in/papyr"
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x003B
#define USB_DESC_CDC_ONLY_PID 0x003B
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x003B
#define USB_DESC_CDC_ONLY_PID 0x003B
#endif // PPAPYR_H
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52)
+61 -62
View File
@@ -1,62 +1,61 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _FEATHER_NRF52832_H
#define _FEATHER_NRF52832_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // Red
#define LED_SECONDARY_PIN 19 // Blue
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 20
#define BUTTON_2 22
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52832"
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52832"
#define UF2_INDEX_URL "https://www.adafruit.com/product/3406"
#endif // _FEATHER_NRF52832_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _FEATHER_NRF52832_H
#define _FEATHER_NRF52832_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // Red
#define LED_SECONDARY_PIN 19 // Blue
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTON_DFU 20
#define BUTTON_DFU_OTA 22
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52832"
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52832"
#define UF2_INDEX_URL "https://www.adafruit.com/product/3406"
#endif // _FEATHER_NRF52832_H
@@ -1,2 +0,0 @@
MCU_SUB_VARIANT = nrf52833
SD_VERSION = 7.3.0
+68 -70
View File
@@ -1,70 +1,68 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _FEATHER_NRF52840_H
#define _FEATHER_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 15)
#define LED_SECONDARY_PIN _PINNUM(1, 10)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 16)
#define NEOPIXEL_POWER_PIN _PINNUM(1, 14)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 02)
#define BUTTON_2 _PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52840 Express"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0029
#define USB_DESC_CDC_ONLY_PID 0x002A
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express"
#define UF2_VOLUME_LABEL "FTHR840BOOT"
#define UF2_BOARD_ID "nRF52840-Feather-revE"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4062"
#endif // _FEATHER_NRF52840_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _FEATHER_NRF52840_H
#define _FEATHER_NRF52840_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN PINNUM(1, 15)
#define LED_SECONDARY_PIN PINNUM(1, 10)
#define LED_STATE_ON 1
#define LED_NEOPIXEL PINNUM(0, 16)
#define NEOPIXEL_POWER_PIN PINNUM(1, 14)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTON_DFU PINNUM(1, 02)
#define BUTTON_DFU_OTA PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52840 Express"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0029
#define USB_DESC_CDC_ONLY_PID 0x002A
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express"
#define UF2_VOLUME_LABEL "FTHR840BOOT"
#define UF2_BOARD_ID "nRF52840-Feather-revE"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4062"
#endif // _FEATHER_NRF52840_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+19 -22
View File
@@ -25,45 +25,42 @@
#ifndef _FEATHER_NRF52840_SENSE_H
#define _FEATHER_NRF52840_SENSE_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 9)
#define LED_SECONDARY_PIN _PINNUM(1, 10)
#define LED_STATE_ON 1
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN PINNUM(1, 9)
#define LED_SECONDARY_PIN PINNUM(1, 10)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 16)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(0, 16)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 02)
#define BUTTON_2 _PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(1, 02)
#define BUTTON_DFU_OTA PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52840 Sense"
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52840 Sense"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0087
#define USB_DESC_CDC_ONLY_PID 0x0088
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0087
#define USB_DESC_CDC_ONLY_PID 0x0088
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense"
#define UF2_VOLUME_LABEL "FTHRSNSBOOT"
#define UF2_BOARD_ID "nRF52840-Feather-Sense"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4516"
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense"
#define UF2_VOLUME_LABEL "FTHRSNSBOOT"
#define UF2_BOARD_ID "nRF52840-Feather-Sense"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4516"
#endif // _FEATHER_NRF52840_SENSE_H
+35 -38
View File
@@ -25,76 +25,73 @@
#ifndef _FEATHER_NRF52840_SENSE_TFT_H
#define _FEATHER_NRF52840_SENSE_TFT_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 11)
#define LED_STATE_ON 1
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(0, 11)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(1, 8)
#define NEOPIXEL_POWER_PIN _PINNUM(1, 2)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(1, 8)
#define NEOPIXEL_POWER_PIN PINNUM(1, 2)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 6)
#define BUTTON_2 _PINNUM(1, 10) // DFU pin
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(1, 6)
#define BUTTON_DFU_OTA PINNUM(1, 10) // DFU pin
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// Display
//--------------------------------------------------------------------+
// VSensor required to power the display
#define DISPLAY_VSENSOR_PIN _PINNUM(1, 7)
#define DISPLAY_VSENSOR_ON 1
#define DISPLAY_VSENSOR_PIN PINNUM(1, 7)
#define DISPLAY_VSENSOR_ON 1
#define DISPLAY_CONTROLLER_ST7789
#define DISPLAY_PIN_SCK _PINNUM(0, 26)
#define DISPLAY_PIN_MOSI _PINNUM(0, 5)
#define DISPLAY_PIN_SCK PINNUM(0, 26)
#define DISPLAY_PIN_MOSI PINNUM(0, 5)
#define DISPLAY_PIN_CS _PINNUM(1, 5)
#define DISPLAY_PIN_DC _PINNUM(1, 1)
#define DISPLAY_PIN_RST _PINNUM(1, 3)
#define DISPLAY_PIN_BL _PINNUM(0, 27)
#define DISPLAY_BL_ON 1 // GPIO state to enable back light
#define DISPLAY_PIN_CS PINNUM(1, 5)
#define DISPLAY_PIN_DC PINNUM(1, 1)
#define DISPLAY_PIN_RST PINNUM(1, 3)
#define DISPLAY_PIN_BL PINNUM(0, 27)
#define DISPLAY_BL_ON 1 // GPIO state to enable back light
#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 135
#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 135
#define DISPLAY_COL_OFFSET 53
#define DISPLAY_ROW_OFFSET 40
#define DISPLAY_COL_OFFSET 53
#define DISPLAY_ROW_OFFSET 40
// Memory Data Access Control & // Vertical Scroll Start Address
#define DISPLAY_MADCTL (TFT_MADCTL_MX)
#define DISPLAY_VSCSAD 0
#define DISPLAY_MADCTL (TFT_MADCTL_MX)
#define DISPLAY_VSCSAD 0
#define DISPLAY_TITLE "Sense TFT"
#define DISPLAY_TITLE "Sense TFT"
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52840 Sense TFT"
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Feather nRF52840 Sense TFT"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0087
#define USB_DESC_CDC_ONLY_PID 0x0088
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0087
#define USB_DESC_CDC_ONLY_PID 0x0088
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense TFT"
#define UF2_VOLUME_LABEL "SENSTFTBOOT"
#define UF2_BOARD_ID "nRF52840-FeatherSenseTFT-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/product/"
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense TFT"
#define UF2_VOLUME_LABEL "SENSTFTBOOT"
#define UF2_BOARD_ID "nRF52840-FeatherSenseTFT-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/product/"
#endif
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+66 -69
View File
@@ -1,69 +1,66 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _IKIGAISENSE_VITA_NRF52840_H
#define _IKIGAISENSE_VITA_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 15)
#define LED_SECONDARY_PIN _PINNUM(1, 10)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 16)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 02)
#define BUTTON_2 _PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "IkigaiSense Technologies"
#define BLEDIS_MODEL "Vita nRF52840"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0093
#define USB_DESC_CDC_ONLY_PID 0x0093
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "IkigaiSense Vita nRF52840"
#define UF2_VOLUME_LABEL "ISVITABoot"
#define UF2_BOARD_ID "nRF52840-isVITA-revA"
#define UF2_INDEX_URL "https://github.com/ikigaisense/vita"
#endif // _IKIGAISENSE_VITA_NRF52840_H
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _IKIGAISENSE_VITA_NRF52840_H
#define _IKIGAISENSE_VITA_NRF52840_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN PINNUM(1, 15)
#define LED_SECONDARY_PIN PINNUM(1, 10)
#define LED_STATE_ON 1
#define LED_NEOPIXEL PINNUM(0, 16)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTON_DFU PINNUM(1, 02)
#define BUTTON_DFU_OTA PINNUM(0, 10)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "IkigaiSense Technologies"
#define BLEDIS_MODEL "Vita nRF52840"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0093
#define USB_DESC_CDC_ONLY_PID 0x0093
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "IkigaiSense Vita nRF52840"
#define UF2_VOLUME_LABEL "ISVITABoot"
#define UF2_BOARD_ID "nRF52840-isVITA-revA"
#define UF2_INDEX_URL "https://github.com/ikigaisense/vita"
#endif // _IKIGAISENSE_VITA_NRF52840_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+12 -11
View File
@@ -25,25 +25,26 @@
#ifndef _ITSYBITSY_NRF52840_H
#define _ITSYBITSY_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 6)
#define LED_PRIMARY_PIN PINNUM(0, 6)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 8)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_APA102_CLK PINNUM(1, 9)
#define LED_APA102_DATA PINNUM(0, 8)
#define LED_APA102_BRIGHTNESS 0x1
#define APA102_NUMBER 1
// For dotstart set to max for colour information is not masked off
#define BOARD_RGB_BRIGHTNESS 0xffffffff
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 29) // user switch
#define BUTTON_2 _PINNUM(1, 02) // D2 breakout
#define BUTTON_DFU PINNUM(0, 29) // user switch
#define BUTTON_DFU_OTA PINNUM(1, 02) // D2 breakout
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
@@ -63,6 +64,6 @@
#define UF2_PRODUCT_NAME "Adafruit ItsyBitsy nRF52840 Express"
#define UF2_VOLUME_LABEL "ITSY840BOOT"
#define UF2_BOARD_ID "nRF52840-ItsyBitsy-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4481"
#endif // _ITSY_NRF52840_H
#endif
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+18 -21
View File
@@ -25,44 +25,41 @@
#ifndef _LEDGLASSES_NRF52840_H
#define _LEDGLASSES_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 31)
#define LED_STATE_ON 1
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(0, 31)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(1, 15)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(1, 15)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 30) // user switch
#define BUTTON_2 _PINNUM(0, 28) // NC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 30) // user switch
#define BUTTON_DFU_OTA PINNUM(0, 28) // NC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "LED Glasses Driver nRF52840"
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "LED Glasses Driver nRF52840"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x010D
#define USB_DESC_CDC_ONLY_PID 0x010E
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x010D
#define USB_DESC_CDC_ONLY_PID 0x010E
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit LED Glasses Driver nRF52840"
#define UF2_VOLUME_LABEL "GLASSESBOOT"
#define UF2_BOARD_ID "nRF52840-LedGlasses-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/product/5217"
#define UF2_PRODUCT_NAME "Adafruit LED Glasses Driver nRF52840"
#define UF2_VOLUME_LABEL "GLASSESBOOT"
#define UF2_BOARD_ID "nRF52840-LedGlasses-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/product/5217"
#endif // _LEDGLASSES_NRF52840_H
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+20 -23
View File
@@ -25,52 +25,49 @@
#ifndef _MAKERDIARY_M60_KEYBOARD_H_
#define _MAKERDIARY_M60_KEYBOARD_H_
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 30) // Red
#define LED_STATE_ON 0
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(0, 30) // Red
#define LED_STATE_ON 0
#define LED_RGB_RED_PIN _PINNUM(0, 30)
#define LED_RGB_GREEN_PIN _PINNUM(0, 29)
#define LED_RGB_BLUE_PIN _PINNUM(0, 31)
#define BOARD_RGB_BRIGHTNESS 0x404040
#define LED_RGB_RED_PIN PINNUM(0, 30)
#define LED_RGB_GREEN_PIN PINNUM(0, 29)
#define LED_RGB_BLUE_PIN PINNUM(0, 31)
#define BOARD_RGB_BRIGHTNESS 0x404040
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 27)
#define BUTTON_2 _PINNUM(0, 19) // ESC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 27)
#define BUTTON_DFU_OTA PINNUM(0, 19) // ESC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* On board regulator control
*------------------------------------------------------------------*/
#define LDO_CONTROL_PIN _PINNUM(0, 28) // Enables external pwr
#define LDO_CONTROL_PIN PINNUM(0, 28) // Enables external pwr
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Makerdiary"
#define BLEDIS_MODEL "M60 Mechanical Keyboard"
#define BLEDIS_MANUFACTURER "Makerdiary"
#define BLEDIS_MODEL "M60 Mechanical Keyboard"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x2886
#define USB_DESC_UF2_PID 0xF00F
#define USB_DESC_CDC_ONLY_PID 0xF00F
#define USB_DESC_VID 0x2886
#define USB_DESC_UF2_PID 0xF00F
#define USB_DESC_CDC_ONLY_PID 0xF00F
//--------------------------------------------------------------------+
// UF2
//--------------------------------------------------------------------+
#define UF2_PRODUCT_NAME "MakerDiary M60 Mechanical Keyboard"
#define UF2_VOLUME_LABEL "M60KEYBOARD"
#define UF2_BOARD_ID "M60KEYBOARD"
#define UF2_INDEX_URL "https://wiki.makerdiary.com/m60/"
#define UF2_PRODUCT_NAME "MakerDiary M60 Mechanical Keyboard"
#define UF2_VOLUME_LABEL "M60KEYBOARD"
#define UF2_BOARD_ID "M60KEYBOARD"
#define UF2_INDEX_URL "https://wiki.makerdiary.com/m60/"
#endif /* _MAKERDIARY_M60_KEYBOARD_H_ */
+33 -29
View File
@@ -2,56 +2,60 @@
#include "board.h"
#include "uf2/configkeys.h"
__attribute__((used, section(".bootloaderConfig")))
const uint32_t bootloaderConfig[] =
{
__attribute__((used, section(".bootloaderConfig"))) const uint32_t bootloaderConfig[] = {
/* CF2 START */
CFG_MAGIC0, CFG_MAGIC1, // magic
5, 100, // used entries, total entries
CFG_MAGIC0,
CFG_MAGIC1, // magic
5,
100, // used entries, total entries
204, 0x100000, // FLASH_BYTES = 0x100000
205, 0x40000, // RAM_BYTES = 0x40000
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
209, 0xada52840, // UF2_FAMILY = 0xada52840
210, 0x20, // PINS_PORT_SIZE = PA_32
204,
0x100000, // FLASH_BYTES = 0x100000
205,
0x40000, // RAM_BYTES = 0x40000
208,
(USB_DESC_VID << 16) |
USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
209,
0xada52840, // UF2_FAMILY = 0xada52840
210,
0x20, // PINS_PORT_SIZE = PA_32
0, 0, 0, 0, 0, 0, 0, 0
0,
0,
0,
0,
0,
0,
0,
0
/* CF2 END */
};
static void power_on(void)
{
static void power_on(void) {
// Turn on the regulator
nrf_gpio_cfg_output(LDO_CONTROL_PIN);
nrf_gpio_pin_write(LDO_CONTROL_PIN, 1);
}
void board_init2(void)
{
void board_init2(void) {
power_on();
// configure P0.05 for ESC/BUTTON_2
// configure P0.05 for ESC/BUTTON_DFU_OTA
// P0.05 --- |<- --- / --- P0.19
// diode sw(esc)
// mode: output, push-pull, low
nrf_gpio_cfg(
_PINNUM(0, 5),
NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_H0D1,
NRF_GPIO_PIN_NOSENSE
);
nrf_gpio_pin_write(_PINNUM(0, 5), 0);
nrf_gpio_cfg(PINNUM(0, 5), NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_H0D1, NRF_GPIO_PIN_NOSENSE);
nrf_gpio_pin_write(PINNUM(0, 5), 0);
// Wait the buttons stable.
// This is mandatory, or the keyboard will enter bootloader whenever
// booted by pressing the button at back (same with BUTTON_1)
// booted by pressing the button at back (same with BUTTON_DFU)
NRFX_DELAY_MS(300);
}
void board_teardown2(void)
{
void board_teardown2(void) {
// re-enable the battery
power_on();
}
}
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52)
+62
View File
@@ -0,0 +1,62 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _MBN52832DK_H
#define _MBN52832DK_H
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 17 // LED1
#define LED_SECONDARY_PIN 18 // LED2
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTON_DFU 13
#define BUTTON_DFU_OTA 14
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Murata"
#define BLEDIS_MODEL "MBN52832DK"
#define UF2_BOARD_ID "nRF52832-MBN52832DK-v1"
#define UF2_PRODUCT_NAME "Murata MBN52832DK"
#define UF2_INDEX_URL "https://www.murata.com/ja-jp/products/connectivitymodule/bluetooth/overview/lineup/mbn52832"
#endif // _MBN52832DK_H
+2
View File
@@ -0,0 +1,2 @@
# nrf52 is nrf52832
MCU_SUB_VARIANT = nrf52
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+20 -23
View File
@@ -25,48 +25,45 @@
#ifndef _MDK_NRF52840_DONGLE_H_
#define _MDK_NRF52840_DONGLE_H_
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2 // TODO(gpshead): support 0.
#define LED_PRIMARY_PIN _PINNUM(0, 23) // Red
#define LED_SECONDARY_PIN _PINNUM(0, 24) // Blue
#define LED_STATE_ON 0
#define LEDS_NUMBER 2 // TODO(gpshead): support 0.
#define LED_PRIMARY_PIN PINNUM(0, 23) // Red
#define LED_SECONDARY_PIN PINNUM(0, 24) // Blue
#define LED_STATE_ON 0
//#define LED_RGB_RED_PIN _PINNUM(0, 23)
//#define LED_RGB_GREEN_PIN _PINNUM(0, 22)
//#define LED_RGB_BLUE_PIN _PINNUM(0, 24)
#define BOARD_RGB_BRIGHTNESS 0x404040
// #define LED_RGB_RED_PIN PINNUM(0, 23)
// #define LED_RGB_GREEN_PIN PINNUM(0, 22)
// #define LED_RGB_BLUE_PIN PINNUM(0, 24)
#define BOARD_RGB_BRIGHTNESS 0x404040
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
// TODO(gpshead): simplify, have code support 0. double reset only.
#define BUTTONS_NUMBER 2 // none connected at all
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
#define BUTTON_2 _PINNUM(0, 19) // no connection
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 18) // unusable: RESET
#define BUTTON_DFU_OTA PINNUM(0, 19) // no connection
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "MakerDiary"
#define BLEDIS_MODEL "nRF52840 Micro Dev Kit USB Dongle"
#define BLEDIS_MANUFACTURER "MakerDiary"
#define BLEDIS_MODEL "nRF52840 Micro Dev Kit USB Dongle"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
// Shared VID/PID with Feather nRF52840, will be disabled for building in the future
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0029
#define USB_DESC_CDC_ONLY_PID 0x0029
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0029
#define USB_DESC_CDC_ONLY_PID 0x0029
#define UF2_PRODUCT_NAME "MDK nRF52840 USB Dongle"
#define UF2_VOLUME_LABEL "MDK840DONGL"
#define UF2_BOARD_ID "nRF52840-Dongle-v1"
#define UF2_INDEX_URL "https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/"
#define UF2_PRODUCT_NAME "MDK nRF52840 USB Dongle"
#define UF2_VOLUME_LABEL "MDK840DONGL"
#define UF2_BOARD_ID "nRF52840-Dongle-v1"
#define UF2_INDEX_URL "https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/"
#endif /* _MDK_NRF52840_DONGLE_H_ */
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+19 -22
View File
@@ -25,46 +25,43 @@
#ifndef _METRO_NRF52840_H_
#define _METRO_NRF52840_H_
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 13)
#define LED_SECONDARY_PIN _PINNUM(1, 15)
#define LED_STATE_ON 1
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN PINNUM(1, 13)
#define LED_SECONDARY_PIN PINNUM(1, 15)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 13)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_NEOPIXEL PINNUM(0, 13)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 0)
#define BUTTON_2 _PINNUM(2, 2)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(1, 0)
#define BUTTON_DFU_OTA PINNUM(2, 2)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Metro nRF52840 Express"
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "Metro nRF52840 Express"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x003F
#define USB_DESC_CDC_ONLY_PID 0x0040
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x003F
#define USB_DESC_CDC_ONLY_PID 0x0040
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Metro nRF52840 Express"
#define UF2_VOLUME_LABEL "METR840BOOT"
#define UF2_BOARD_ID "nRF52840-Metro-revA"
#define UF2_PRODUCT_NAME "Adafruit Metro nRF52840 Express"
#define UF2_VOLUME_LABEL "METR840BOOT"
#define UF2_BOARD_ID "nRF52840-Metro-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/"
#define UF2_INDEX_URL "https://www.adafruit.com/"
#endif /* _METRO_NRF52840_H_ */
+1
View File
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+15 -18
View File
@@ -25,41 +25,38 @@
#ifndef _MIKOTO_H
#define _MIKOTO_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
#define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 15) // Blue
#define LED_STATE_ON 1
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(0, 15) // Blue
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2 // none connected at all
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
#define BUTTON_2 _PINNUM(0, 19) // no connection
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(0, 18) // unusable: RESET
#define BUTTON_DFU_OTA PINNUM(0, 19) // no connection
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "zhiayang"
#define BLEDIS_MODEL "mikoto"
#define BLEDIS_MANUFACTURER "zhiayang"
#define BLEDIS_MODEL "mikoto"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x1209
#define USB_DESC_UF2_PID 0x7A01
#define USB_DESC_CDC_ONLY_PID 0x7A01
#define USB_DESC_VID 0x1209
#define USB_DESC_UF2_PID 0x7A01
#define USB_DESC_CDC_ONLY_PID 0x7A01
#define UF2_PRODUCT_NAME "Mikoto nRF52840"
#define UF2_VOLUME_LABEL "MIKOTO-BOOT"
#define UF2_BOARD_ID "nRF52840-mikoto-rev520"
#define UF2_INDEX_URL "https://github.com/zhiayang/mikoto"
#define UF2_PRODUCT_NAME "Mikoto nRF52840"
#define UF2_VOLUME_LABEL "MIKOTO-BOOT"
#define UF2_BOARD_ID "nRF52840-mikoto-rev520"
#define UF2_INDEX_URL "https://github.com/zhiayang/mikoto"
#endif // _MIKOTO_H
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
+19 -22
View File
@@ -25,47 +25,44 @@
#ifndef _MAKERDIARY_NRF82540_CONNECT_KIT_H_
#define _MAKERDIARY_NRF82540_CONNECT_KIT_H_
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 15) // Green
#define LED_STATE_ON 0
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN PINNUM(1, 15) // Green
#define LED_STATE_ON 0
#define LED_RGB_RED_PIN _PINNUM(1, 10)
#define LED_RGB_GREEN_PIN _PINNUM(1, 11)
#define LED_RGB_BLUE_PIN _PINNUM(1, 12)
#define BOARD_RGB_BRIGHTNESS 0x404040
#define LED_RGB_RED_PIN PINNUM(1, 10)
#define LED_RGB_GREEN_PIN PINNUM(1, 11)
#define LED_RGB_BLUE_PIN PINNUM(1, 12)
#define BOARD_RGB_BRIGHTNESS 0x404040
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 0) // P1.00: User Button
#define BUTTON_2 _PINNUM(1, 7) // P1.07: NC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_DFU PINNUM(1, 0) // P1.00: User Button
#define BUTTON_DFU_OTA PINNUM(1, 7) // P1.07: NC
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Makerdiary"
#define BLEDIS_MODEL "nRF52840 Connect Kit"
#define BLEDIS_MANUFACTURER "Makerdiary"
#define BLEDIS_MODEL "nRF52840 Connect Kit"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x2886
#define USB_DESC_UF2_PID 0xF00F
#define USB_DESC_CDC_ONLY_PID 0xF00F
#define USB_DESC_VID 0x2886
#define USB_DESC_UF2_PID 0xF00F
#define USB_DESC_CDC_ONLY_PID 0xF00F
//--------------------------------------------------------------------+
// UF2
//--------------------------------------------------------------------+
#define UF2_PRODUCT_NAME "nRF52840 Connect Kit"
#define UF2_VOLUME_LABEL "CONNECTKIT"
#define UF2_BOARD_ID "nRF52840-Connect-Kit"
#define UF2_INDEX_URL "https://wiki.makerdiary.com/nrf52840-connectkit/"
#define UF2_PRODUCT_NAME "nRF52840 Connect Kit"
#define UF2_VOLUME_LABEL "CONNECTKIT"
#define UF2_BOARD_ID "nRF52840-Connect-Kit"
#define UF2_INDEX_URL "https://wiki.makerdiary.com/nrf52840-connectkit/"
#endif /* _MAKERDIARY_NRF82540_CONNECT_KIT_H_ */
Loaded 100 of 169 files, more files were not shown because too many files have changed in this diff. Show more