├── .gitmodules ├── FIDO2-Conformance-Tools-Passed.png ├── LICENSE ├── README.md ├── U2F-Conformance-Tools-Passed.png ├── bootloader ├── .github │ ├── ISSUE_TEMPLATE │ │ ├── bug_report.md │ │ └── feature_request.md │ └── workflows │ │ └── githubci.yml ├── .gitignore ├── .gitmodules ├── .travis.yml.bck ├── CODE_OF_CONDUCT.md ├── LICENSE ├── Makefile ├── README.md ├── changelog.md ├── lib │ ├── sdk │ │ ├── components │ │ │ ├── drivers_nrf │ │ │ │ ├── common │ │ │ │ │ ├── nrf_drv_common.c │ │ │ │ │ └── nrf_drv_common.h │ │ │ │ ├── delay │ │ │ │ │ └── nrf_delay.h │ │ │ │ └── uart │ │ │ │ │ ├── nrf_drv_uart.c │ │ │ │ │ └── nrf_drv_uart.h │ │ │ └── libraries │ │ │ │ ├── crc16 │ │ │ │ ├── crc16.c │ │ │ │ └── crc16.h │ │ │ │ ├── hci │ │ │ │ ├── hci_mem_pool.c │ │ │ │ ├── hci_mem_pool.h │ │ │ │ ├── hci_slip.c │ │ │ │ ├── hci_slip.h │ │ │ │ ├── hci_transport.c │ │ │ │ └── hci_transport.h │ │ │ │ ├── scheduler │ │ │ │ ├── app_scheduler.c │ │ │ │ └── app_scheduler.h │ │ │ │ ├── timer │ │ │ │ ├── app_timer.c │ │ │ │ └── app_timer.h │ │ │ │ ├── uart │ │ │ │ ├── app_uart.c │ │ │ │ └── app_uart.h │ │ │ │ └── util │ │ │ │ ├── app_error.c │ │ │ │ ├── app_error.h │ │ │ │ ├── app_error_weak.h │ │ │ │ ├── app_util.h │ │ │ │ ├── app_util_bds.h │ │ │ │ ├── app_util_platform.c │ │ │ │ ├── app_util_platform.h │ │ │ │ ├── nordic_common.h │ │ │ │ ├── nrf_assert.c │ │ │ │ ├── nrf_assert.h │ │ │ │ ├── nrf_bitmask.h │ │ │ │ ├── sdk_common.h │ │ │ │ ├── sdk_errors.h │ │ │ │ ├── sdk_macros.h │ │ │ │ ├── sdk_mapped_flags.c │ │ │ │ ├── sdk_mapped_flags.h │ │ │ │ ├── sdk_os.h │ │ │ │ └── sdk_resources.h │ │ └── readme.md │ ├── sdk11 │ │ ├── components │ │ │ ├── ble │ │ │ │ ├── ble_services │ │ │ │ │ ├── ble_dfu │ │ │ │ │ │ ├── ble_dfu.c │ │ │ │ │ │ └── ble_dfu.h │ │ │ │ │ └── ble_dis │ │ │ │ │ │ ├── ble_dis.c │ │ │ │ │ │ └── ble_dis.h │ │ │ │ └── common │ │ │ │ │ └── ble_srv_common.h │ │ │ ├── drivers_nrf │ │ │ │ └── pstorage │ │ │ │ │ ├── pstorage.h │ │ │ │ │ └── pstorage_raw.c │ │ │ └── libraries │ │ │ │ ├── bootloader_dfu │ │ │ │ ├── ble_transport │ │ │ │ │ └── hci_mem_pool_internal.h │ │ │ │ ├── bootloader.c │ │ │ │ ├── bootloader.h │ │ │ │ ├── bootloader_settings.c │ │ │ │ ├── bootloader_settings.h │ │ │ │ ├── bootloader_types.h │ │ │ │ ├── bootloader_util.c │ │ │ │ ├── bootloader_util.h │ │ │ │ ├── dfu.h │ │ │ │ ├── dfu_bank_internal.h │ │ │ │ ├── dfu_ble_svc.h │ │ │ │ ├── dfu_ble_svc_internal.h │ │ │ │ ├── dfu_dual_bank.c │ │ │ │ ├── dfu_init.h │ │ │ │ ├── dfu_single_bank.c │ │ │ │ ├── dfu_transport.h │ │ │ │ ├── dfu_transport_ble.c │ │ │ │ ├── dfu_transport_serial.c │ │ │ │ ├── dfu_types.h │ │ │ │ └── hci_transport │ │ │ │ │ ├── hci_mem_pool_internal.h │ │ │ │ │ └── hci_transport_config.h │ │ │ │ └── util │ │ │ │ └── nrf_log.h │ │ └── readme.md │ └── softdevice │ │ ├── s132_nrf52_6.1.1 │ │ ├── s132_nrf52_6.1.1_API │ │ │ └── include │ │ │ │ ├── ble.h │ │ │ │ ├── ble_err.h │ │ │ │ ├── ble_gap.h │ │ │ │ ├── ble_gatt.h │ │ │ │ ├── ble_gattc.h │ │ │ │ ├── ble_gatts.h │ │ │ │ ├── ble_hci.h │ │ │ │ ├── ble_l2cap.h │ │ │ │ ├── ble_ranges.h │ │ │ │ ├── ble_types.h │ │ │ │ ├── nrf52 │ │ │ │ └── nrf_mbr.h │ │ │ │ ├── nrf_error.h │ │ │ │ ├── nrf_error_sdm.h │ │ │ │ ├── nrf_error_soc.h │ │ │ │ ├── nrf_nvic.h │ │ │ │ ├── nrf_sdm.h │ │ │ │ ├── nrf_soc.h │ │ │ │ └── nrf_svc.h │ │ ├── s132_nrf52_6.1.1_license-agreement.txt │ │ └── s132_nrf52_6.1.1_softdevice.hex │ │ └── s140_nrf52_6.1.1 │ │ ├── s140_nrf52_6.1.1_API │ │ └── include │ │ │ ├── ble.h │ │ │ ├── ble_err.h │ │ │ ├── ble_gap.h │ │ │ ├── ble_gatt.h │ │ │ ├── ble_gattc.h │ │ │ ├── ble_gatts.h │ │ │ ├── ble_hci.h │ │ │ ├── ble_l2cap.h │ │ │ ├── ble_ranges.h │ │ │ ├── ble_types.h │ │ │ ├── nrf52 │ │ │ └── nrf_mbr.h │ │ │ ├── nrf_error.h │ │ │ ├── nrf_error_sdm.h │ │ │ ├── nrf_error_soc.h │ │ │ ├── nrf_nvic.h │ │ │ ├── nrf_sdm.h │ │ │ ├── nrf_soc.h │ │ │ └── nrf_svc.h │ │ ├── s140_nrf52_6.1.1_license-agreement.txt │ │ └── s140_nrf52_6.1.1_softdevice.hex ├── src │ ├── boards.c │ ├── boards.h │ ├── boards │ │ ├── aramcon_badge_2019 │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── arcade_feather_nrf52840_express │ │ │ ├── board.h │ │ │ ├── board.mk │ │ │ └── pinconfig.c │ │ ├── arduino_nano_33_ble │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── circuitplayground_nrf52840 │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── clue_nrf52840 │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── electronut_labs_papyr │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── feather_nrf52832 │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── feather_nrf52840_express │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── feather_nrf52840_sense │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── itsybitsy_nrf52840_express │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── mdk_nrf52840_dongle │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── metro_nrf52840_express │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── ohs2020_badge │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── particle_argon │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── particle_boron │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── particle_xenon │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── pca10056 │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── pca10059 │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── pca10100 │ │ │ ├── board.h │ │ │ └── board.mk │ │ ├── raytac_mdbt50q_rx │ │ │ ├── board.h │ │ │ └── board.mk │ │ └── waveshare_nrf52840_eval │ │ │ ├── board.h │ │ │ └── board.mk │ ├── cmsis │ │ └── include │ │ │ ├── arm_common_tables.h │ │ │ ├── arm_const_structs.h │ │ │ ├── arm_math.h │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armcc_V6.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_cmFunc.h │ │ │ ├── core_cmInstr.h │ │ │ ├── core_cmSimd.h │ │ │ ├── core_sc000.h │ │ │ └── core_sc300.h │ ├── dfu_ble_svc.c │ ├── dfu_init.c │ ├── flash_nrf5x.c │ ├── flash_nrf5x.h │ ├── linker │ │ ├── nrf52833_s140_v6.ld │ │ ├── nrf52840_s140_v6.ld │ │ ├── nrf52840_s140_v6.ld.orig │ │ ├── nrf52_s132_v6.ld │ │ └── nrf_common.ld │ ├── main.c │ ├── nrfx_config.h │ ├── nrfx_glue.h │ ├── pstorage_platform.h │ ├── sdk_config.h │ ├── secec.c │ ├── segger │ │ ├── Adafruit_nRF52_Bootloader.emProject │ │ ├── SEGGER_RTT.c │ │ ├── SEGGER_RTT.h │ │ ├── SEGGER_RTT_Conf.h │ │ ├── SEGGER_RTT_SES.c │ │ ├── flash_placement.xml │ │ ├── nRF52832_xxAA_MemoryMap.xml │ │ ├── nRF52840_xxAA_MemoryMap.xml │ │ ├── nRF_Target.js │ │ ├── nrf52840_Registers.xml │ │ └── thumb_crt0.s │ └── usb │ │ ├── bn.c │ │ ├── bn.h │ │ ├── main │ │ ├── main.c │ │ ├── msc_uf2.c │ │ ├── rsa_verify.c │ │ ├── rsa_verify.h │ │ ├── tusb_config.h │ │ ├── uf2 │ │ ├── LICENSE │ │ ├── compile_date.h │ │ ├── ghostfat.c │ │ ├── nrf_cc310 │ │ │ ├── crys_error.h │ │ │ ├── crys_hash.h │ │ │ ├── crys_hash_defs.h │ │ │ ├── crys_pka_defs_hw.h │ │ │ ├── crys_rnd.h │ │ │ ├── crys_rsa_build.h │ │ │ ├── crys_rsa_prim.h │ │ │ ├── crys_rsa_schemes.h │ │ │ ├── crys_rsa_types.h │ │ │ ├── sns_silib.h │ │ │ ├── ssi_aes.h │ │ │ ├── ssi_aes_defs.h │ │ │ ├── ssi_aes_error.h │ │ │ ├── ssi_pal_compiler.h │ │ │ ├── ssi_pal_types.h │ │ │ ├── ssi_pal_types_plat.h │ │ │ └── ssi_pka_hw_plat_defs.h │ │ ├── sha256.c │ │ ├── sha256.h │ │ ├── uf2.h │ │ └── uf2cfg.h │ │ ├── usb.c │ │ ├── usb_desc.c │ │ ├── usb_desc.c.orig │ │ └── usb_desc.h └── tools │ ├── build_all.py │ ├── github_requests.py │ └── upload_release_files.py ├── fido2_u2f ├── boot.py ├── build.sh ├── cbor_ctap_parameters.py ├── cbor_io.py ├── cert.der ├── ctap2.py ├── ctap_errors.py ├── fido-drive.h ├── hid.py ├── keystore.py ├── main.py ├── u2f.py ├── up_check.py ├── util.py ├── utils │ └── make_cheader.py └── wink.py └── modules └── cc310 ├── aes.c ├── aes.h ├── cc310.c ├── libnrf_cc310_0.9.12.a └── micropython.mk /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "bootloader/lib/nrfx"] 2 | path = bootloader/lib/nrfx 3 | url = https://github.com/NordicSemiconductor/nrfx 4 | [submodule "bootloader/lib/tinyusb"] 5 | path = bootloader/lib/tinyusb 6 | url = https://github.com/hathach/tinyusb/ 7 | [submodule "adapted-circuitpython"] 8 | path = adapted-circuitpython 9 | url = git@github.com:pmvr/adapted-circuitpython.git 10 | -------------------------------------------------------------------------------- /FIDO2-Conformance-Tools-Passed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmvr/pykey/96503b4889d31cd6dc1cd649c5f7ffcfa6a225ed/FIDO2-Conformance-Tools-Passed.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Matthias Vögeler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /U2F-Conformance-Tools-Passed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmvr/pykey/96503b4889d31cd6dc1cd649c5f7ffcfa6a225ed/U2F-Conformance-Tools-Passed.png -------------------------------------------------------------------------------- /bootloader/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[Bug]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Set up (please complete the following information)** 14 | - Your Board and BSP version 15 | - Your OS (mac/windows/linux) and its version 16 | - Serial debug log (enable IDE's Debug Mode Level to 1 or 2) 17 | 18 | **To Reproduce** 19 | Steps to reproduce the behavior: 20 | 1. Go to '...' 21 | 2. Click on '....' 22 | 3. Scroll down to '....' 23 | 4. See error 24 | 25 | **Expected behavior** 26 | A clear and concise description of what you expected to happen. 27 | 28 | **Screenshots** 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /bootloader/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /bootloader/.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | pull_request: 6 | release: 7 | types: [published] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Setup Python 14 | uses: actions/setup-python@v1 15 | 16 | - name: Setup Node.js 17 | uses: actions/setup-node@v1.1.0 18 | 19 | - name: Checkout Code 20 | uses: actions/checkout@v1 21 | with: 22 | submodules: true 23 | 24 | - name: Install Toolchains 25 | run: | 26 | pip3 install adafruit-nrfutil uritemplate requests 27 | wget https://www.nordicsemi.com/api/sitecore/Products/DownloadPlatform --post-data=fileid=8F19D314130548209E75EFFADD9348DB -O cli-tools.tar 28 | tar -xv -f cli-tools.tar 29 | echo "::add-path::$GITHUB_WORKSPACE/mergehex" 30 | npm install --global xpm 31 | xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest 32 | echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin`" 33 | 34 | - name: Build 35 | run: python3 tools/build_all.py 36 | 37 | - name: Upload Release Asset 38 | if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested') 39 | working-directory: tools 40 | env: 41 | UPLOAD_URL: ${{ github.event.release.upload_url }} 42 | ADABOT_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} 43 | run: "[ -z \"$ADABOT_GITHUB_ACCESS_TOKEN\" ] || python3 -u upload_release_files.py" 44 | 45 | -------------------------------------------------------------------------------- /bootloader/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | #*.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | src/segger/Output 55 | _build-*/ 56 | bin/ 57 | *.emSession 58 | *.jlink 59 | 60 | TAGS 61 | -------------------------------------------------------------------------------- /bootloader/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tinyusb"] 2 | path = lib/tinyusb 3 | url = https://github.com/hathach/tinyusb.git 4 | [submodule "lib/nrfx"] 5 | path = lib/nrfx 6 | url = https://github.com/NordicSemiconductor/nrfx.git 7 | -------------------------------------------------------------------------------- /bootloader/.travis.yml.bck: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: xenial 3 | language: c 4 | compiler: 5 | - gcc 6 | 7 | deploy: 8 | provider: releases 9 | api_key: "$GITHUB_TOKEN" 10 | file_glob: true 11 | file: "$TRAVIS_BUILD_DIR/bin/*/*" 12 | skip_cleanup: true 13 | on: 14 | tags: true 15 | 16 | before_script: 17 | - (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb) 18 | - (wget https://www.nordicsemi.com/api/sitecore/Products/DownloadPlatform --post-data=fileid=8F19D314130548209E75EFFADD9348DB -O cli-tools.tar && tar -xv -f cli-tools.tar && mv mergehex mergehex_all && mv mergehex_all/mergehex .) 19 | - export PATH=.:$PATH 20 | - mergehex --version 21 | 22 | # report some good version numbers to the build 23 | - gcc --version 24 | - arm-none-eabi-gcc --version 25 | - python3 --version 26 | - python --version 27 | - sudo apt-get install -y python3-pip python3-setuptools 28 | - pip3 install --user adafruit-nrfutil 29 | 30 | script: 31 | - python3 tools/build_all.py 32 | -------------------------------------------------------------------------------- /bootloader/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at . All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /bootloader/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Adafruit Industries 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bootloader/changelog.md: -------------------------------------------------------------------------------- 1 | # Adafruit nRF52 Bootloader Changelog 2 | 3 | ## 0.3.2 - 2020.03.12 4 | 5 | - Make sure all pins are in reset state when jumping to app mode. 6 | 7 | ## 0.3.1 - 2020.03.05 8 | - Correct LED1 for Feather Sense and change volume name to FTHRSNSBOOT. 9 | 10 | ## 0.3.0 - 2020.01.13 11 | 12 | - Upgrade nrfx to v2 for supporting future nrf mcu such as nrf52833, nrf5340 13 | - Upgrade TinyUSB 14 | - New boards support 15 | - Arduino ble nano 33 16 | - Adafruit CLUE 17 | - Raytac MDBT50Q-RX dongle 18 | - Migrate CI to github Action 19 | 20 | ## 0.2.13 - 2019.09.25 21 | 22 | - Fixed button pulldown with Adafruit Circuit Playground Bluefruit, PR #77 thanks to @khanning 23 | 24 | ## 0.2.12 - 2019.08.22 25 | 26 | - Fixed block alignment bug also in dfu_sd_image_validate (single & dual banks), PR #71 thanks to @fanoush 27 | - Added new board: Adafruit Circuit Playground Bluefruit 28 | - Added new board: Adafruit ItsyBitsy nRF52840 Express (WIP) 29 | - Fixed bug in __DOSTIME__ macro, PR #75 thanks to @henrygab 30 | 31 | ## 0.2.11 32 | 33 | - Fixed various FAT issues, thanks to @henrygab 34 | - Added MakerDiary MDK nrf52840 USB dongle support, thanks to @gpshead 35 | - Fixed incorrect button mapping for Feather nRF52840 36 | - NFC pins are forced to GPIO mode by bootloader 37 | - Added Metro nRF52840 Express VID/PID 38 | - Enhance board management 39 | - Added electronut/papyr_support 40 | 41 | ## 0.2.9 42 | 43 | - Fixed incomplete writes on Windows. Upated tinyusb to handle write10 completion, and use it for finalizing dfu process. Will prevent windows error message pop up. This will also give an extra time for flash writing to complete. 44 | 45 | ## 0.2.8 46 | 47 | - Fixed OTA issue with nrfConnect on iOS 48 | - Increased LED conn cycle when ble connected for easier recognition 49 | 50 | ## 0.2.7 51 | 52 | - Fixed PWM psel[1] is not reset 53 | - Fixed #41 move RXD, TXD into board header 54 | - Added Metro nRF52840 Rev A 55 | - Fixed #40 OTA issue with BLE_GAP_EVT_PHY_UPDATE_REQUEST e.g connecting with iPhone X 56 | 57 | ## 0.2.6 58 | 59 | - Fixed copy/restore current.uf2 issue 60 | - Fixed neopixel won't turn off after dfu cdc 61 | 62 | ## 0.2.5 63 | 64 | - Make led pattern more consistent 65 | - Fixed issue nrf52840 not reset properly when upgrading bootloader+sd combo 66 | - Make led pattern more consistent 67 | 68 | ## 0.2.3 69 | 70 | - Fully support Feather nRF52840 71 | - Update bootloader with new led pattern 72 | - Fix #203: return software timer handle 73 | -------------------------------------------------------------------------------- /bootloader/lib/sdk/components/libraries/crc16/crc16.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | #include "sdk_common.h" 41 | #if NRF_MODULE_ENABLED(CRC16) 42 | #include "crc16.h" 43 | 44 | #include 45 | 46 | uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc) 47 | { 48 | uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc; 49 | 50 | for (uint32_t i = 0; i < size; i++) 51 | { 52 | crc = (uint8_t)(crc >> 8) | (crc << 8); 53 | crc ^= p_data[i]; 54 | crc ^= (uint8_t)(crc & 0xFF) >> 4; 55 | crc ^= (crc << 8) << 4; 56 | crc ^= ((crc & 0xFF) << 4) << 1; 57 | } 58 | 59 | return crc; 60 | } 61 | #endif //NRF_MODULE_ENABLED(CRC16) 62 | -------------------------------------------------------------------------------- /bootloader/lib/sdk/components/libraries/crc16/crc16.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | /** @file 41 | * 42 | * @defgroup crc16 CRC16 compute 43 | * @{ 44 | * @ingroup hci_transport 45 | * 46 | * @brief This module implements CRC-16-CCITT (polynomial 0x1021) with 0xFFFF initial value. 47 | * The data can be passed in multiple blocks. 48 | */ 49 | 50 | #ifndef CRC16_H__ 51 | #define CRC16_H__ 52 | 53 | #include 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /**@brief Function for calculating CRC-16 in blocks. 60 | * 61 | * Feed each consecutive data block into this function, along with the current value of p_crc as 62 | * returned by the previous call of this function. The first call of this function should pass NULL 63 | * as the initial value of the crc in p_crc. 64 | * 65 | * @param[in] p_data The input data block for computation. 66 | * @param[in] size The size of the input data block in bytes. 67 | * @param[in] p_crc The previous calculated CRC-16 value or NULL if first call. 68 | * 69 | * @return The updated CRC-16 value, based on the input supplied. 70 | */ 71 | uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc); 72 | 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif // CRC16_H__ 79 | 80 | /** @} */ 81 | -------------------------------------------------------------------------------- /bootloader/lib/sdk/components/libraries/util/app_error_weak.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | #ifndef APP_ERROR_WEAK_H__ 41 | #define APP_ERROR_WEAK_H__ 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** @file 48 | * 49 | * @defgroup app_error Common application error handler 50 | * @{ 51 | * @ingroup app_common 52 | * 53 | * @brief Common application error handler. 54 | */ 55 | 56 | /**@brief Callback function for errors, asserts, and faults. 57 | * 58 | * @details This function is called every time an error is raised in app_error, nrf_assert, or 59 | * in the SoftDevice. Information about the error can be found in the @p info 60 | * parameter. 61 | * 62 | * See also @ref nrf_fault_handler_t for more details. 63 | * 64 | * @note The function is implemented as weak so that it can be redefined by a custom error 65 | * handler when needed. 66 | * 67 | * @param[in] id Fault identifier. See @ref NRF_FAULT_IDS. 68 | * @param[in] pc The program counter of the instruction that triggered the fault, or 0 if 69 | * unavailable. 70 | * @param[in] info Optional additional information regarding the fault. The value of the @p id 71 | * parameter dictates how to interpret this parameter. Refer to the documentation 72 | * for each fault identifier (@ref NRF_FAULT_IDS and @ref APP_ERROR_FAULT_IDS) for 73 | * details about interpreting @p info. 74 | */ 75 | void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info); 76 | 77 | 78 | /** @} */ 79 | 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif // APP_ERROR_WEAK_H__ 86 | -------------------------------------------------------------------------------- /bootloader/lib/sdk/components/libraries/util/nrf_assert.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2006 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | #include "nrf_assert.h" 41 | #include "app_error.h" 42 | #include "nordic_common.h" 43 | 44 | __WEAK void assert_nrf_callback(uint16_t line_num, const uint8_t * file_name) 45 | { 46 | assert_info_t assert_info = 47 | { 48 | .line_num = line_num, 49 | .p_file_name = file_name, 50 | }; 51 | app_error_fault_handler(NRF_FAULT_ID_SDK_ASSERT, 0, (uint32_t)(&assert_info)); 52 | 53 | UNUSED_VARIABLE(assert_info); 54 | } 55 | -------------------------------------------------------------------------------- /bootloader/lib/sdk/components/libraries/util/sdk_common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | /** @cond */ 41 | /**@file 42 | * 43 | * @ingroup experimental_api 44 | * @defgroup sdk_common SDK Common Header 45 | * @brief All common headers needed for SDK examples will be included here so that application 46 | * developer does not have to include headers on him/herself. 47 | * @{ 48 | */ 49 | 50 | #ifndef SDK_COMMON_H__ 51 | #define SDK_COMMON_H__ 52 | 53 | #include 54 | #include 55 | #include 56 | #include "sdk_config.h" 57 | #include "nordic_common.h" 58 | #include "compiler_abstraction.h" 59 | #include "sdk_os.h" 60 | #include "sdk_errors.h" 61 | #include "app_util.h" 62 | #include "sdk_macros.h" 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | 69 | /** @} */ 70 | /** @endcond */ 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif // SDK_COMMON_H__ 77 | 78 | -------------------------------------------------------------------------------- /bootloader/lib/sdk/components/libraries/util/sdk_os.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 - 2017, Nordic Semiconductor ASA 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this 10 | * list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form, except as embedded into a Nordic 13 | * Semiconductor ASA integrated circuit in a product or a software update for 14 | * such product, must reproduce the above copyright notice, this list of 15 | * conditions and the following disclaimer in the documentation and/or other 16 | * materials provided with the distribution. 17 | * 18 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 19 | * contributors may be used to endorse or promote products derived from this 20 | * software without specific prior written permission. 21 | * 22 | * 4. This software, with or without modification, must only be used with a 23 | * Nordic Semiconductor ASA integrated circuit. 24 | * 25 | * 5. Any software provided in binary form under this license must not be reverse 26 | * engineered, decompiled, modified and/or disassembled. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 29 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 34 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 37 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | */ 40 | /** @cond */ 41 | /**@file 42 | * 43 | * @defgroup sdk_os SDK OS Abstraction 44 | * @ingroup experimental_api 45 | * @details In order to made SDK modules independent of use of an embedded OS, and permit 46 | * application with varied task architecture, SDK abstracts the OS specific 47 | * elements here in order to make all other modules agnostic to the OS or task 48 | * architecture. 49 | * @{ 50 | */ 51 | 52 | #ifndef SDK_OS_H__ 53 | #define SDK_OS_H__ 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | #define SDK_MUTEX_DEFINE(X) 60 | #define SDK_MUTEX_INIT(X) 61 | #define SDK_MUTEX_LOCK(X) 62 | #define SDK_MUTEX_UNLOCK(X) 63 | 64 | /** 65 | * @defgroup os_data_type Data types. 66 | */ 67 | 68 | /** @} */ 69 | /** @endcond */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif // SDK_OS_H__ 76 | 77 | -------------------------------------------------------------------------------- /bootloader/lib/sdk/readme.md: -------------------------------------------------------------------------------- 1 | SDK version is 14.2.0_17b948a 2 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup memory_pool_internal Memory Pool Internal 16 | * @{ 17 | * @ingroup memory_pool 18 | * 19 | * @brief Memory pool internal definitions 20 | */ 21 | 22 | #ifndef MEM_POOL_INTERNAL_H__ 23 | #define MEM_POOL_INTERNAL_H__ 24 | 25 | #define TX_BUF_SIZE 4u /**< TX buffer size in bytes. */ 26 | #define RX_BUF_SIZE 32u /**< RX buffer size in bytes. */ 27 | 28 | #define RX_BUF_QUEUE_SIZE 8u /**< RX buffer element size. */ 29 | 30 | #endif // MEM_POOL_INTERNAL_H__ 31 | 32 | /** @} */ 33 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/bootloader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader Bootloader API. 16 | * @{ 17 | * 18 | * @brief Bootloader module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_H__ 22 | #define BOOTLOADER_H__ 23 | 24 | #include 25 | #include 26 | #include "bootloader_types.h" 27 | #include 28 | 29 | /**@brief Function for initializing the Bootloader. 30 | * 31 | * @retval NRF_SUCCESS If bootloader was succesfully initialized. 32 | */ 33 | uint32_t bootloader_init(void); 34 | 35 | /**@brief Function for validating application region in flash. 36 | * 37 | * @param[in] app_addr Address to the region in flash where the application is stored. 38 | * 39 | * @retval true If Application region is valid. 40 | * @retval false If Application region is not valid. 41 | */ 42 | bool bootloader_app_is_valid(uint32_t app_addr); 43 | 44 | /**@brief Function for starting the Device Firmware Update. 45 | * 46 | * @retval NRF_SUCCESS If new application image was successfully transferred. 47 | */ 48 | uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms); 49 | 50 | /**@brief Function for exiting bootloader and booting into application. 51 | * 52 | * @details This function will disable SoftDevice and all interrupts before jumping to application. 53 | * The SoftDevice vector table base for interrupt forwarding will be set the application 54 | * address. 55 | * 56 | * @param[in] app_addr Address to the region where the application is stored. 57 | */ 58 | void bootloader_app_start(uint32_t app_addr); 59 | 60 | /**@brief Function for retrieving the bootloader settings. 61 | * 62 | * @param[out] p_settings A copy of the current bootloader settings is returned in the structure 63 | * provided. 64 | */ 65 | void bootloader_settings_get(bootloader_settings_t * const p_settings); 66 | 67 | /**@brief Function for processing DFU status update. 68 | * 69 | * @param[in] update_status DFU update status. 70 | */ 71 | void bootloader_dfu_update_process(dfu_update_status_t update_status); 72 | 73 | /**@brief Function getting state of SoftDevice update in progress. 74 | * After a successfull SoftDevice transfer the system restarts in orderto disable SoftDevice 75 | * and complete the update. 76 | * 77 | * @retval true A SoftDevice update is in progress. This indicates that second stage 78 | * of a SoftDevice update procedure can be initiated. 79 | * @retval false No SoftDevice update is in progress. 80 | */ 81 | bool bootloader_dfu_sd_in_progress(void); 82 | 83 | /**@brief Function for continuing the Device Firmware Update of a SoftDevice. 84 | * 85 | * @retval NRF_SUCCESS If the final stage of SoftDevice update was successful. 86 | */ 87 | uint32_t bootloader_dfu_sd_update_continue(void); 88 | 89 | /**@brief Function for finalizing the Device Firmware Update of a SoftDevice. 90 | * 91 | * @retval NRF_SUCCESS If the final stage of SoftDevice update was successful. 92 | */ 93 | uint32_t bootloader_dfu_sd_update_finalize(void); 94 | 95 | #endif // BOOTLOADER_H__ 96 | 97 | /**@} */ 98 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_settings Bootloader settings API. 16 | * @{ 17 | * 18 | * @brief Bootloader settings module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_SETTINGS_H__ 22 | #define BOOTLOADER_SETTINGS_H__ 23 | 24 | #include 25 | #include "bootloader_types.h" 26 | 27 | /**@brief Function for getting the bootloader settings. 28 | * 29 | * @param[out] pp_bootloader_settings Bootloader settings. 30 | */ 31 | void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings); 32 | 33 | #endif // BOOTLOADER_SETTINGS_H__ 34 | 35 | /**@} */ 36 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/bootloader_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_types Types and definitions. 16 | * @{ 17 | * 18 | * @ingroup nrf_bootloader 19 | * 20 | * @brief Bootloader module type and definitions. 21 | */ 22 | 23 | #ifndef BOOTLOADER_TYPES_H__ 24 | #define BOOTLOADER_TYPES_H__ 25 | 26 | #include 27 | 28 | #define BOOTLOADER_DFU_START 0xB1 29 | 30 | #define BOOTLOADER_SVC_APP_DATA_PTR_GET 0x02 31 | 32 | /**@brief DFU Bank state code, which indicates wether the bank contains: A valid image, invalid image, or an erased flash. 33 | */ 34 | typedef enum 35 | { 36 | BANK_VALID_APP = 0x01, 37 | BANK_VALID_SD = 0xA5, 38 | BANK_VALID_BOOT = 0xAA, 39 | BANK_ERASED = 0xFE, 40 | BANK_INVALID_APP = 0xFF, 41 | } bootloader_bank_code_t; 42 | 43 | /**@brief Structure holding bootloader settings for application and bank data. 44 | */ 45 | typedef struct 46 | { 47 | uint16_t bank_0; /**< Variable to store if bank 0 contains a valid application. */ 48 | uint16_t bank_0_crc; /**< If bank is valid, this field will contain a valid CRC of the total image. */ 49 | uint16_t bank_1; /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */ 50 | uint32_t bank_0_size; /**< Size of active image in bank0 if present, otherwise 0. */ 51 | uint32_t sd_image_size; /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */ 52 | uint32_t bl_image_size; /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */ 53 | uint32_t app_image_size; /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */ 54 | uint32_t sd_image_start; /**< Location in flash where SoftDevice image is stored for SoftDevice update. */ 55 | } bootloader_settings_t; 56 | 57 | #endif // BOOTLOADER_TYPES_H__ 58 | 59 | /**@} */ 60 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/bootloader_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_util Bootloader util API. 16 | * @{ 17 | * 18 | * @brief Bootloader util module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_UTIL_H__ 22 | #define BOOTLOADER_UTIL_H__ 23 | 24 | #include 25 | #include "bootloader_types.h" 26 | 27 | /**@brief Function for starting the application (or bootloader) at the provided address. 28 | * 29 | * @param[in] start_addr Start address. 30 | * 31 | * @note This function will never retrun. Instead it will reset into the application of the 32 | * provided address. 33 | */ 34 | void bootloader_util_app_start(uint32_t start_addr); 35 | 36 | #endif // BOOTLOADER_UTIL_H__ 37 | 38 | /**@} */ 39 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/dfu_ble_svc_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup nrf_dfu_ble_svc_internal DFU BLE SVC internal 16 | * @{ 17 | * 18 | * @brief DFU BLE SVC internal functions in bootloader. The DFU BLE SuperVisor Calls allow an 19 | * application to execute functions in the installed bootloader. This interface provides 20 | * internal Bootloader DFU functions for retrieving data exchanged through SuperVisor Calls. 21 | * 22 | */ 23 | 24 | #ifndef DFU_BLE_SVC_INTERNAL_H__ 25 | #define DFU_BLE_SVC_INTERNAL_H__ 26 | 27 | #include 28 | #include "dfu_ble_svc.h" 29 | #include "ble_gap.h" 30 | 31 | /**@brief Internal bootloader/DFU function for retrieving peer data provided from application. 32 | * 33 | * @param[out] p_peer_data Peer data set by application to be used for DFU connection. 34 | * 35 | * @retval NRF_SUCCESS If peer data is valid and can be used for connection. 36 | * @retval NRF_ERROR_NULL If p_peer_data is a NULL pointer. 37 | * @retval NRF_ERROR_INVALID_DATA If peer data is not available or invalid. 38 | */ 39 | uint32_t dfu_ble_peer_data_get(dfu_ble_peer_data_t * p_peer_data); 40 | 41 | #endif // DFU_BLE_SVC_INTERNAL_H__ 42 | 43 | /** @} */ 44 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_dfu_transport DFU transport API. 16 | * @{ 17 | * 18 | * @brief DFU transport module interface. 19 | */ 20 | 21 | #ifndef DFU_TRANSPORT_H__ 22 | #define DFU_TRANSPORT_H__ 23 | 24 | #include 25 | 26 | /**@brief Function for starting the update of Device Firmware. 27 | * 28 | * @retval NRF_SUCCESS Operation success. 29 | */ 30 | uint32_t dfu_transport_serial_update_start(void); 31 | 32 | /**@brief Function for closing the transport layer. 33 | * 34 | * @retval NRF_SUCCESS Operation success. 35 | */ 36 | uint32_t dfu_transport_serial_close(void); 37 | 38 | 39 | uint32_t dfu_transport_ble_update_start(void); 40 | uint32_t dfu_transport_ble_close(); 41 | 42 | #endif // DFU_TRANSPORT_H__ 43 | 44 | /**@} */ 45 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_mem_pool_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup memory_pool_internal Memory Pool Internal 16 | * @{ 17 | * @ingroup memory_pool 18 | * 19 | * @brief Memory pool internal definitions 20 | */ 21 | 22 | #ifndef MEM_POOL_INTERNAL_H__ 23 | #define MEM_POOL_INTERNAL_H__ 24 | 25 | #define TX_BUF_SIZE 32u /**< TX buffer size in bytes. */ 26 | #define RX_BUF_SIZE 600u /**< RX buffer size in bytes. */ 27 | 28 | #define RX_BUF_QUEUE_SIZE 2u /**< RX buffer element size. */ 29 | 30 | #endif // MEM_POOL_INTERNAL_H__ 31 | 32 | /** @} */ 33 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/components/libraries/bootloader_dfu/hci_transport/hci_transport_config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup ble_sdk_bootloader_hci_congfig HCI Transport Layer Configuration 16 | * @{ 17 | * @ingroup dfu_bootloader_api 18 | * @brief Definition of HCI Transport Layer configurable parameters 19 | */ 20 | 21 | #ifndef HCI_TRANSPORT_CONFIG_H__ 22 | #define HCI_TRANSPORT_CONFIG_H__ 23 | 24 | #include "boards.h" /**< Default include for boards.h which means that default pin numbers will be used for RX, TX, CTS, and RTS on the UART. Other pin number can be used if desired. */ 25 | 26 | /** This section covers configurable parameters for the HCI Transport SLIP layer. */ 27 | #define HCI_SLIP_UART_RX_PIN_NUMBER RX_PIN_NUMBER /**< Defines the UART RX pin number. The default pin for the board is chosen, but can be overwritten. */ 28 | 29 | #define HCI_SLIP_UART_TX_PIN_NUMBER TX_PIN_NUMBER /**< Defines the UART TX pin number. The default pin for the board is chosen, but can be overwritten. */ 30 | 31 | #define HCI_SLIP_UART_RTS_PIN_NUMBER RTS_PIN_NUMBER /**< Defines the UART RTS pin number. The default pin for the board is chosen, but can be overwritten. */ 32 | 33 | #define HCI_SLIP_UART_CTS_PIN_NUMBER CTS_PIN_NUMBER /**< Defines the UART CTS pin number. The default pin for the board is chosen, but can be overwritten. */ 34 | 35 | #define HCI_SLIP_UART_MODE HWFC /**< Defines the UART mode to be used. Use UART Low Power with Flow Control - Valid values are defined in \ref app_uart_flow_control_t. For further information on the UART Low Power mode, please refer to: \ref app_uart . */ 36 | 37 | #define HCI_SLIP_UART_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 // UART_BAUDRATE_BAUDRATE_Baud38400 /**< Defines the UART Baud rate. Default is 38400 baud. */ 38 | 39 | /** This section covers configurable parameters for the HCI Transport layer that are used for calculating correct value for the retransmission timer timeout. */ 40 | #define MAX_PACKET_SIZE_IN_BITS 8000u /**< Maximum size of a single application packet in bits. */ 41 | #define USED_BAUD_RATE 115200u /**< The used uart baudrate. */ 42 | 43 | #endif // HCI_TRANSPORT_CONFIG_H__ 44 | 45 | /** @} */ 46 | -------------------------------------------------------------------------------- /bootloader/lib/sdk11/readme.md: -------------------------------------------------------------------------------- 1 | This bootloader is based on the non-secure one in the SDK version 11.0.0_89a8197. It still has some dependency/code that is dropped in the later sdk 2 | -------------------------------------------------------------------------------- /bootloader/lib/softdevice/s132_nrf52_6.1.1/s132_nrf52_6.1.1_API/include/nrf_error_sdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup nrf_sdm_api 41 | @{ 42 | @defgroup nrf_sdm_error SoftDevice Manager Error Codes 43 | @{ 44 | 45 | @brief Error definitions for the SDM API 46 | */ 47 | 48 | /* Header guard */ 49 | #ifndef NRF_ERROR_SDM_H__ 50 | #define NRF_ERROR_SDM_H__ 51 | 52 | #include "nrf_error.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | #define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown LFCLK source. 59 | #define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts). 60 | #define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erroneous SoftDevice flashing). 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif // NRF_ERROR_SDM_H__ 66 | 67 | /** 68 | @} 69 | @} 70 | */ 71 | -------------------------------------------------------------------------------- /bootloader/lib/softdevice/s132_nrf52_6.1.1/s132_nrf52_6.1.1_API/include/nrf_svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #ifndef NRF_SVC__ 40 | #define NRF_SVC__ 41 | 42 | #include "stdint.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | #ifdef SVCALL_AS_NORMAL_FUNCTION 49 | #define SVCALL(number, return_type, signature) return_type signature 50 | #else 51 | 52 | #ifndef SVCALL 53 | #if defined (__CC_ARM) 54 | #define SVCALL(number, return_type, signature) return_type __svc(number) signature 55 | #elif defined (__GNUC__) 56 | #ifdef __cplusplus 57 | #define GCC_CAST_CPP (uint16_t) 58 | #else 59 | #define GCC_CAST_CPP 60 | #endif 61 | #define SVCALL(number, return_type, signature) \ 62 | _Pragma("GCC diagnostic push") \ 63 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ 64 | __attribute__((naked)) \ 65 | __attribute__((unused)) \ 66 | static return_type signature \ 67 | { \ 68 | __asm( \ 69 | "svc %0\n" \ 70 | "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ 71 | ); \ 72 | } \ 73 | _Pragma("GCC diagnostic pop") 74 | 75 | #elif defined (__ICCARM__) 76 | #define PRAGMA(x) _Pragma(#x) 77 | #define SVCALL(number, return_type, signature) \ 78 | PRAGMA(swi_number = (number)) \ 79 | __swi return_type signature; 80 | #else 81 | #define SVCALL(number, return_type, signature) return_type signature 82 | #endif 83 | #endif // SVCALL 84 | 85 | #endif // SVCALL_AS_NORMAL_FUNCTION 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | #endif // NRF_SVC__ 91 | -------------------------------------------------------------------------------- /bootloader/lib/softdevice/s132_nrf52_6.1.1/s132_nrf52_6.1.1_license-agreement.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2018, Nordic Semiconductor ASA 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form, except as embedded into a Nordic 11 | Semiconductor ASA integrated circuit in a product or a software update for 12 | such product, must reproduce the above copyright notice, this list of 13 | conditions and the following disclaimer in the documentation and/or other 14 | materials provided with the distribution. 15 | 16 | 3. Neither the name of Nordic Semiconductor ASA nor the names of its 17 | contributors may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | 4. This software, with or without modification, must only be used with a 21 | Nordic Semiconductor ASA integrated circuit. 22 | 23 | 5. Any software provided in binary form under this license must not be reverse 24 | engineered, decompiled, modified and/or disassembled. 25 | 26 | THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 27 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 | OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 30 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 35 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /bootloader/lib/softdevice/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include/nrf_error_sdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | /** 40 | @addtogroup nrf_sdm_api 41 | @{ 42 | @defgroup nrf_sdm_error SoftDevice Manager Error Codes 43 | @{ 44 | 45 | @brief Error definitions for the SDM API 46 | */ 47 | 48 | /* Header guard */ 49 | #ifndef NRF_ERROR_SDM_H__ 50 | #define NRF_ERROR_SDM_H__ 51 | 52 | #include "nrf_error.h" 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | #define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown LFCLK source. 59 | #define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts). 60 | #define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erroneous SoftDevice flashing). 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif // NRF_ERROR_SDM_H__ 66 | 67 | /** 68 | @} 69 | @} 70 | */ 71 | -------------------------------------------------------------------------------- /bootloader/lib/softdevice/s140_nrf52_6.1.1/s140_nrf52_6.1.1_API/include/nrf_svc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 - 2017, Nordic Semiconductor ASA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, this 9 | * list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form, except as embedded into a Nordic 12 | * Semiconductor ASA integrated circuit in a product or a software update for 13 | * such product, must reproduce the above copyright notice, this list of 14 | * conditions and the following disclaimer in the documentation and/or other 15 | * materials provided with the distribution. 16 | * 17 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * 4. This software, with or without modification, must only be used with a 22 | * Nordic Semiconductor ASA integrated circuit. 23 | * 24 | * 5. Any software provided in binary form under this license must not be reverse 25 | * engineered, decompiled, modified and/or disassembled. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 28 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 36 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #ifndef NRF_SVC__ 40 | #define NRF_SVC__ 41 | 42 | #include "stdint.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | #ifdef SVCALL_AS_NORMAL_FUNCTION 49 | #define SVCALL(number, return_type, signature) return_type signature 50 | #else 51 | 52 | #ifndef SVCALL 53 | #if defined (__CC_ARM) 54 | #define SVCALL(number, return_type, signature) return_type __svc(number) signature 55 | #elif defined (__GNUC__) 56 | #ifdef __cplusplus 57 | #define GCC_CAST_CPP (uint16_t) 58 | #else 59 | #define GCC_CAST_CPP 60 | #endif 61 | #define SVCALL(number, return_type, signature) \ 62 | _Pragma("GCC diagnostic push") \ 63 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ 64 | __attribute__((naked)) \ 65 | __attribute__((unused)) \ 66 | static return_type signature \ 67 | { \ 68 | __asm( \ 69 | "svc %0\n" \ 70 | "bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \ 71 | ); \ 72 | } \ 73 | _Pragma("GCC diagnostic pop") 74 | 75 | #elif defined (__ICCARM__) 76 | #define PRAGMA(x) _Pragma(#x) 77 | #define SVCALL(number, return_type, signature) \ 78 | PRAGMA(swi_number = (number)) \ 79 | __swi return_type signature; 80 | #else 81 | #define SVCALL(number, return_type, signature) return_type signature 82 | #endif 83 | #endif // SVCALL 84 | 85 | #endif // SVCALL_AS_NORMAL_FUNCTION 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | #endif // NRF_SVC__ 91 | -------------------------------------------------------------------------------- /bootloader/lib/softdevice/s140_nrf52_6.1.1/s140_nrf52_6.1.1_license-agreement.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 - 2018, Nordic Semiconductor ASA 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form, except as embedded into a Nordic 11 | Semiconductor ASA integrated circuit in a product or a software update for 12 | such product, must reproduce the above copyright notice, this list of 13 | conditions and the following disclaimer in the documentation and/or other 14 | materials provided with the distribution. 15 | 16 | 3. Neither the name of Nordic Semiconductor ASA nor the names of its 17 | contributors may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | 4. This software, with or without modification, must only be used with a 21 | Nordic Semiconductor ASA integrated circuit. 22 | 23 | 5. Any software provided in binary form under this license must not be reverse 24 | engineered, decompiled, modified and/or disassembled. 25 | 26 | THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 27 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 | OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 30 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 35 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /bootloader/src/boards/aramcon_badge_2019/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2019 Uri Shaked 5 | * Copyright (c) 2019 Benjamin Meisels 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | #ifndef _ARAMCON_BADGE_2019_H 27 | #define _ARAMCON_BADGE_2019_H 28 | 29 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 30 | 31 | /*------------------------------------------------------------------*/ 32 | /* LED 33 | *------------------------------------------------------------------*/ 34 | #define LEDS_NUMBER 1 35 | #define LED_PRIMARY_PIN _PINNUM(1, 11) // Red 36 | 37 | #define LED_NEOPIXEL _PINNUM(0, 8) 38 | #define NEOPIXELS_NUMBER 4 39 | #define BOARD_RGB_BRIGHTNESS 0x040404 40 | 41 | /*------------------------------------------------------------------*/ 42 | /* BUTTON 43 | *------------------------------------------------------------------*/ 44 | #define BUTTONS_NUMBER 2 45 | #define BUTTON_1 _PINNUM(0, 2) // left Button 46 | #define BUTTON_2 _PINNUM(0, 29) // middle button 47 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 48 | 49 | /*------------------------------------------------------------------*/ 50 | /* UART (only used by nRF52832) 51 | *------------------------------------------------------------------*/ 52 | #define RX_PIN_NUMBER _PINNUM(0, 28) // SDA 53 | #define TX_PIN_NUMBER _PINNUM(0, 3) // SCL 54 | #define CTS_PIN_NUMBER 0 55 | #define RTS_PIN_NUMBER 0 56 | #define HWFC false 57 | 58 | // Used as model string in OTA mode 59 | #define BLEDIS_MANUFACTURER "ARAMCON Badge Team" 60 | #define BLEDIS_MODEL "ARAMCON Badge 2019" 61 | 62 | //--------------------------------------------------------------------+ 63 | // USB 64 | //--------------------------------------------------------------------+ 65 | #define USB_DESC_VID 0x239A 66 | #define USB_DESC_UF2_PID 0x0079 67 | #define USB_DESC_CDC_ONLY_PID 0x0079 68 | 69 | //------------- UF2 -------------// 70 | #define UF2_PRODUCT_NAME "ARAMCON Badge 2019" 71 | #define UF2_VOLUME_LABEL "ARAMBOOT" 72 | #define UF2_BOARD_ID "nrf52840-ARAMCON-Badge-2019" 73 | #define UF2_INDEX_URL "https://github.com/aramcon-badge" 74 | 75 | #endif // _ARAMCON_BADGE_2019_H 76 | -------------------------------------------------------------------------------- /bootloader/src/boards/aramcon_badge_2019/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/arcade_feather_nrf52840_express/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _ARCARDE_FEATHER_NRF52840_H 26 | #define _ARCARDE_FEATHER_NRF52840_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 2 34 | #define LED_PRIMARY_PIN _PINNUM(1, 15) 35 | #define LED_SECONDARY_PIN _PINNUM(1, 10) 36 | #define LED_STATE_ON 1 37 | 38 | #define LED_NEOPIXEL _PINNUM(0, 16) 39 | #define NEOPIXELS_NUMBER 1 40 | #define BOARD_RGB_BRIGHTNESS 0x040404 41 | 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_1 _PINNUM(1, 02) 47 | #define BUTTON_2 _PINNUM(0, 10) 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 8 54 | #define TX_PIN_NUMBER 6 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | //--------------------------------------------------------------------+ 60 | // BLE OTA 61 | //--------------------------------------------------------------------+ 62 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 63 | #define BLEDIS_MODEL "Feather nRF52840 Express" 64 | 65 | //--------------------------------------------------------------------+ 66 | // USB 67 | //--------------------------------------------------------------------+ 68 | #define USB_DESC_VID 0x239A 69 | #define USB_DESC_UF2_PID 0x0029 70 | #define USB_DESC_CDC_ONLY_PID 0x002A 71 | 72 | //------------- UF2 -------------// 73 | #define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express" 74 | #define UF2_VOLUME_LABEL "ARCADE-N4" 75 | #define UF2_BOARD_ID "nRF52840-Feather-revD" 76 | #define UF2_INDEX_URL "https://www.adafruit.com/product/4062" 77 | 78 | #endif // _ARCARDE_FEATHER_NRF52840_H 79 | 80 | -------------------------------------------------------------------------------- /bootloader/src/boards/arcade_feather_nrf52840_express/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/arcade_feather_nrf52840_express/pinconfig.c: -------------------------------------------------------------------------------- 1 | #include "boards.h" 2 | 3 | __attribute__((used, section(".bootloaderConfig"))) 4 | const uint32_t bootloaderConfig[] = { 5 | /* CF2 START */ 6 | 513675505, 539130489, // magic 7 | 49, 100, // used entries, total entries 8 | 4, 0x18, // PIN_BTN_A = PIN_RX 9 | 5, 0xa, // PIN_BTN_B = PIN_D2 10 | 13, 0x29, // PIN_LED = PIN_D13 11 | 18, 0xf, // PIN_MISO = PA15 12 | 19, 0xd, // PIN_MOSI = PA13 13 | 20, 0x23, // PIN_NEOPIXEL = PB03 14 | 21, 0x18, // PIN_RX = PA24 15 | 23, 0xe, // PIN_SCK = PA14 16 | 24, 0xb, // PIN_SCL = PA11 17 | 25, 0xc, // PIN_SDA = PA12 18 | 28, 0x19, // PIN_TX = PA25 19 | 32, 0xe, // PIN_DISPLAY_SCK = PIN_SCK 20 | 34, 0xd, // PIN_DISPLAY_MOSI = PIN_MOSI 21 | 35, 0x1e, // PIN_DISPLAY_CS = PIN_A2 22 | 36, 0x1c, // PIN_DISPLAY_DC = PIN_A3 23 | 37, 0xa0, // DISPLAY_WIDTH = 160 24 | 38, 0x80, // DISPLAY_HEIGHT = 128 25 | 39, 0x80, // DISPLAY_CFG0 = 0x80 26 | 40, 0x603, // DISPLAY_CFG1 = 0x603 27 | 41, 0x20, // DISPLAY_CFG2 = 0x20 28 | 43, 0x2, // PIN_DISPLAY_RST = PIN_A4 29 | 44, 0x3, // PIN_DISPLAY_BL = PIN_A5 30 | 47, 0x6, // PIN_BTN_LEFT = PIN_D11 31 | 48, 0x1a, // PIN_BTN_RIGHT = PIN_D9 32 | 49, 0x1b, // PIN_BTN_UP = PIN_D10 33 | 50, 0x7, // PIN_BTN_DOWN = PIN_D6 34 | 51, 0x8, // PIN_BTN_MENU = PIN_D12 35 | 56, 0x2a, // PIN_LED2 = PB10 36 | 60, 0x19, // PIN_JACK_TX = PIN_TX 37 | 100, 0x4, // PIN_A0 = PA04 38 | 101, 0x5, // PIN_A1 = PA05 39 | 102, 0x1e, // PIN_A2 = PA30 40 | 103, 0x1c, // PIN_A3 = PA28 41 | 104, 0x2, // PIN_A4 = PA02 42 | 105, 0x3, // PIN_A5 = PA03 43 | 152, 0xa, // PIN_D2 = PA10 44 | 155, 0x28, // PIN_D5 = PB08 45 | 156, 0x7, // PIN_D6 = PA07 46 | 159, 0x1a, // PIN_D9 = PA26 47 | 160, 0x1b, // PIN_D10 = PA27 48 | 161, 0x6, // PIN_D11 = PA06 49 | 162, 0x8, // PIN_D12 = PA08 50 | 163, 0x29, // PIN_D13 = PB09 51 | 200, 0x1, // NUM_NEOPIXELS = 1 52 | 204, 0x100000, // FLASH_BYTES = 0x100000 53 | 205, 0x40000, // RAM_BYTES = 0x40000 54 | 208, 0xd7688ea1, // BOOTLOADER_BOARD_ID = 0xd7688ea1 55 | 209, 0xada52840, // UF2_FAMILY = 0xada52840 56 | 210, 0x20, // PINS_PORT_SIZE = PA_32 57 | 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, 58 | 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, 59 | 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, 60 | 0, 0, 0, 0, 0, 0, 61 | /* CF2 END */ 62 | }; 63 | -------------------------------------------------------------------------------- /bootloader/src/boards/arduino_nano_33_ble/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _ARDUINOBLE33_NRF52840_H 26 | #define _ARDUINOBLE33_NRF52840_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 // red LED 34 | #define LED_PRIMARY_PIN _PINNUM(0, 24) 35 | #define LED_STATE_ON 0 36 | 37 | /*------------------------------------------------------------------*/ 38 | /* BUTTON 39 | *------------------------------------------------------------------*/ 40 | #define BUTTONS_NUMBER 2 41 | #define BUTTON_1 _PINNUM(1, 11) // D2 switch 42 | #define BUTTON_2 _PINNUM(1, 12) // D3 switch 43 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 44 | 45 | /*------------------------------------------------------------------*/ 46 | /* UART (only used by nRF52832) 47 | *------------------------------------------------------------------*/ 48 | #define RX_PIN_NUMBER _PINNUM(1, 10) 49 | #define TX_PIN_NUMBER _PINNUM(1, 3) 50 | #define CTS_PIN_NUMBER 0 51 | #define RTS_PIN_NUMBER 0 52 | #define HWFC false 53 | 54 | // Used as model string in OTA mode 55 | #define BLEDIS_MANUFACTURER "Arduino" 56 | #define BLEDIS_MODEL "Nano 33 BLE" 57 | 58 | //--------------------------------------------------------------------+ 59 | // USB 60 | //--------------------------------------------------------------------+ 61 | #define USB_DESC_VID 0x239A 62 | #define USB_DESC_UF2_PID 0x0063 63 | #define USB_DESC_CDC_ONLY_PID 0x0064 64 | 65 | //------------- UF2 -------------// 66 | #define UF2_PRODUCT_NAME "Arduino Nano 33 BLE" 67 | #define UF2_VOLUME_LABEL "NANO33BOOT" 68 | #define UF2_BOARD_ID "nRF52840-Nano-33" 69 | #define UF2_INDEX_URL "https://www.arduino.cc/" 70 | 71 | #endif // _ITSY_NRF52840_H 72 | -------------------------------------------------------------------------------- /bootloader/src/boards/arduino_nano_33_ble/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/circuitplayground_nrf52840/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _CPLAY_NRF52840_H 26 | #define _CPLAY_NRF52840_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 34 | #define LED_PRIMARY_PIN _PINNUM(1, 14) 35 | #define LED_STATE_ON 1 36 | 37 | #define LED_NEOPIXEL _PINNUM(0, 13) 38 | #define NEOPIXELS_NUMBER 10 39 | #define BOARD_RGB_BRIGHTNESS 0x040404 40 | 41 | /*------------------------------------------------------------------*/ 42 | /* BUTTON 43 | *------------------------------------------------------------------*/ 44 | #define BUTTONS_NUMBER 2 45 | #define BUTTON_1 _PINNUM(1, 02) // left button 46 | #define BUTTON_2 _PINNUM(1, 15) // right button 47 | #define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN 48 | 49 | /*------------------------------------------------------------------*/ 50 | /* UART (only used by nRF52832) 51 | *------------------------------------------------------------------*/ 52 | #define RX_PIN_NUMBER _PINNUM(0, 30) 53 | #define TX_PIN_NUMBER _PINNUM(0, 14) 54 | #define CTS_PIN_NUMBER 0 55 | #define RTS_PIN_NUMBER 0 56 | #define HWFC false 57 | 58 | // Used as model string in OTA mode 59 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 60 | #define BLEDIS_MODEL "Circuit Playground nRF52840" 61 | 62 | //--------------------------------------------------------------------+ 63 | // USB 64 | //--------------------------------------------------------------------+ 65 | #define USB_DESC_VID 0x239A 66 | #define USB_DESC_UF2_PID 0x0045 67 | #define USB_DESC_CDC_ONLY_PID 0x0045 68 | 69 | //------------- UF2 -------------// 70 | #define UF2_PRODUCT_NAME "Adafruit Circuit Playground nRF52840" 71 | #define UF2_VOLUME_LABEL "CPLAYBTBOOT" 72 | #define UF2_BOARD_ID "nRF52840-CircuitPlayground-revD" 73 | #define UF2_INDEX_URL "https://www.adafruit.com/product/4333" 74 | 75 | #endif // _CPLAY_NRF52840_H 76 | -------------------------------------------------------------------------------- /bootloader/src/boards/circuitplayground_nrf52840/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/clue_nrf52840/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _CLUE_NRF52840_H 26 | #define _CLUE_NRF52840_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 34 | #define LED_PRIMARY_PIN _PINNUM(1, 01) 35 | #define LED_STATE_ON 1 36 | 37 | #define LED_NEOPIXEL _PINNUM(0, 16) 38 | #define NEOPIXELS_NUMBER 1 39 | #define BOARD_RGB_BRIGHTNESS 0x040404 40 | 41 | /*------------------------------------------------------------------*/ 42 | /* BUTTON 43 | *------------------------------------------------------------------*/ 44 | #define BUTTONS_NUMBER 2 45 | #define BUTTON_1 _PINNUM(1, 02) // left button 46 | #define BUTTON_2 _PINNUM(1, 10) // right button 47 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 48 | 49 | /*------------------------------------------------------------------*/ 50 | /* UART (only used by nRF52832) 51 | *------------------------------------------------------------------*/ 52 | #define RX_PIN_NUMBER _PINNUM(0, 09) 53 | #define TX_PIN_NUMBER _PINNUM(0, 10) 54 | #define CTS_PIN_NUMBER 0 55 | #define RTS_PIN_NUMBER 0 56 | #define HWFC false 57 | 58 | // Used as model string in OTA mode 59 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 60 | #define BLEDIS_MODEL "CLUE nRF52840" 61 | 62 | //--------------------------------------------------------------------+ 63 | // USB 64 | //--------------------------------------------------------------------+ 65 | #define USB_DESC_VID 0x239A 66 | #define USB_DESC_UF2_PID 0x0071 67 | #define USB_DESC_CDC_ONLY_PID 0x0071 68 | 69 | //------------- UF2 -------------// 70 | #define UF2_PRODUCT_NAME "Adafruit CLUE nRF52840" 71 | #define UF2_VOLUME_LABEL "CLUEBOOT" 72 | #define UF2_BOARD_ID "nRF52840-CLUE-revA" 73 | #define UF2_INDEX_URL "https://www.adafruit.com/product/4500" 74 | 75 | #endif // _CLUE_NRF52840_H 76 | -------------------------------------------------------------------------------- /bootloader/src/boards/clue_nrf52840/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/electronut_labs_papyr/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * @author Tavish Naruka 5 | * 6 | * Copyright (c) 2018 Adafruit Industries 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #ifndef PAPYR_H 28 | #define PAPYR_H 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 2 34 | #define LED_PRIMARY_PIN 13 35 | #define LED_SECONDARY_PIN 14 36 | #define LED_STATE_ON 0 37 | 38 | /*------------------------------------------------------------------*/ 39 | /* BUTTON 40 | *------------------------------------------------------------------*/ 41 | // NOTE: USB UF2 bootloader can be triggered by double pressing RESET 42 | // App can trigger OTA bootloader by writing DFU_MAGIC_OTA_APPJUM to 43 | // GPREGRET register if softdevice is not initialized; or by 44 | // writing DFU_MAGIC_OTA_RESET in case softdevice is initialized. 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_1 18 // RESET also by default 47 | #define BUTTON_2 1 // P0.1 not exposed anywhere, FRST n/a 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 7 54 | #define TX_PIN_NUMBER 8 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | // Used as model string in OTA mode 60 | #define BLEDIS_MANUFACTURER "Electronut Labs" 61 | #define BLEDIS_MODEL "Papyr" 62 | 63 | #define UF2_PRODUCT_NAME "Electronut Labs Papyr" 64 | #define UF2_BOARD_ID "nRF52840-Papyr-v1" 65 | #define UF2_INDEX_URL "https://docs.electronut.in/papyr" 66 | 67 | #define USB_DESC_VID 0x239A 68 | #define USB_DESC_UF2_PID 0x003B 69 | 70 | #endif // PPAPYR_H 71 | -------------------------------------------------------------------------------- /bootloader/src/boards/electronut_labs_papyr/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/feather_nrf52832/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _FEATHER_NRF52832_H 26 | #define _FEATHER_NRF52832_H 27 | 28 | /*------------------------------------------------------------------*/ 29 | /* LED 30 | *------------------------------------------------------------------*/ 31 | #define LEDS_NUMBER 2 32 | #define LED_PRIMARY_PIN 17 // Red 33 | #define LED_SECONDARY_PIN 19 // Blue 34 | #define LED_STATE_ON 1 35 | 36 | /*------------------------------------------------------------------*/ 37 | /* BUTTON 38 | *------------------------------------------------------------------*/ 39 | #define BUTTONS_NUMBER 2 40 | #define BUTTON_1 20 41 | #define BUTTON_2 22 42 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 43 | 44 | /*------------------------------------------------------------------*/ 45 | /* UART (only used by nRF52832) 46 | *------------------------------------------------------------------*/ 47 | #define RX_PIN_NUMBER 8 48 | #define TX_PIN_NUMBER 6 49 | #define CTS_PIN_NUMBER 0 50 | #define RTS_PIN_NUMBER 0 51 | #define HWFC false 52 | 53 | // Used as model string in OTA mode 54 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 55 | #define BLEDIS_MODEL "Feather nRF52832" 56 | 57 | #define UF2_PRODUCT_NAME "Adafruit Feather nRF52832" 58 | #define UF2_INDEX_URL "https://www.adafruit.com/product/3406" 59 | 60 | #endif // _FEATHER_NRF52832_H 61 | -------------------------------------------------------------------------------- /bootloader/src/boards/feather_nrf52832/board.mk: -------------------------------------------------------------------------------- 1 | # nrf52 is nrf52832 2 | MCU_SUB_VARIANT = nrf52 3 | -------------------------------------------------------------------------------- /bootloader/src/boards/feather_nrf52840_express/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _FEATHER_NRF52840_H 26 | #define _FEATHER_NRF52840_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 2 34 | #define LED_PRIMARY_PIN _PINNUM(1, 15) 35 | #define LED_SECONDARY_PIN _PINNUM(1, 10) 36 | #define LED_STATE_ON 1 37 | 38 | #define LED_NEOPIXEL _PINNUM(0, 16) 39 | #define NEOPIXELS_NUMBER 1 40 | #define BOARD_RGB_BRIGHTNESS 0x040404 41 | 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_1 _PINNUM(1, 02) 47 | #define BUTTON_2 _PINNUM(0, 10) 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 8 54 | #define TX_PIN_NUMBER 6 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | //--------------------------------------------------------------------+ 60 | // BLE OTA 61 | //--------------------------------------------------------------------+ 62 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 63 | #define BLEDIS_MODEL "Feather nRF52840 Express" 64 | 65 | //--------------------------------------------------------------------+ 66 | // USB 67 | //--------------------------------------------------------------------+ 68 | #define USB_DESC_VID 0x239A 69 | #define USB_DESC_UF2_PID 0x0029 70 | #define USB_DESC_CDC_ONLY_PID 0x002A 71 | 72 | //------------- UF2 -------------// 73 | #define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express" 74 | #define UF2_VOLUME_LABEL "FTHR840BOOT" 75 | #define UF2_BOARD_ID "nRF52840-Feather-revD" 76 | #define UF2_INDEX_URL "https://www.adafruit.com/product/4062" 77 | 78 | #endif // _FEATHER_NRF52840_H 79 | -------------------------------------------------------------------------------- /bootloader/src/boards/feather_nrf52840_express/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/feather_nrf52840_sense/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _FEATHER_NRF52840_SENSE_H 26 | #define _FEATHER_NRF52840_SENSE_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 2 34 | #define LED_PRIMARY_PIN _PINNUM(1, 9) 35 | #define LED_SECONDARY_PIN _PINNUM(1, 10) 36 | #define LED_STATE_ON 1 37 | 38 | #define LED_NEOPIXEL _PINNUM(0, 16) 39 | #define NEOPIXELS_NUMBER 1 40 | #define BOARD_RGB_BRIGHTNESS 0x040404 41 | 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_1 _PINNUM(1, 02) 47 | #define BUTTON_2 _PINNUM(0, 10) 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 8 54 | #define TX_PIN_NUMBER 6 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | //--------------------------------------------------------------------+ 60 | // BLE OTA 61 | //--------------------------------------------------------------------+ 62 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 63 | #define BLEDIS_MODEL "Feather nRF52840 Sense" 64 | 65 | //--------------------------------------------------------------------+ 66 | // USB 67 | //--------------------------------------------------------------------+ 68 | #define USB_DESC_VID 0x239A 69 | #define USB_DESC_UF2_PID 0x0087 70 | #define USB_DESC_CDC_ONLY_PID 0x0088 71 | 72 | //------------- UF2 -------------// 73 | #define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense" 74 | #define UF2_VOLUME_LABEL "FTHRSNSBOOT" 75 | #define UF2_BOARD_ID "nRF52840-Feather-Sense" 76 | #define UF2_INDEX_URL "https://www.adafruit.com/product/4516" 77 | 78 | #endif // _FEATHER_NRF52840_SENSE_H 79 | -------------------------------------------------------------------------------- /bootloader/src/boards/feather_nrf52840_sense/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/itsybitsy_nrf52840_express/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _ITSYBITSY_NRF52840_H 26 | #define _ITSYBITSY_NRF52840_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 34 | #define LED_PRIMARY_PIN _PINNUM(0, 6) 35 | #define LED_STATE_ON 1 36 | 37 | #define LED_NEOPIXEL _PINNUM(0, 8) 38 | #define NEOPIXELS_NUMBER 1 39 | #define BOARD_RGB_BRIGHTNESS 0x040404 40 | 41 | /*------------------------------------------------------------------*/ 42 | /* BUTTON 43 | *------------------------------------------------------------------*/ 44 | #define BUTTONS_NUMBER 2 45 | #define BUTTON_1 _PINNUM(0, 29) // user switch 46 | #define BUTTON_2 _PINNUM(1, 02) // D2 breakout 47 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 48 | 49 | /*------------------------------------------------------------------*/ 50 | /* UART (only used by nRF52832) 51 | *------------------------------------------------------------------*/ 52 | #define RX_PIN_NUMBER _PINNUM(0, 25) 53 | #define TX_PIN_NUMBER _PINNUM(0, 24) 54 | #define CTS_PIN_NUMBER 0 55 | #define RTS_PIN_NUMBER 0 56 | #define HWFC false 57 | 58 | // Used as model string in OTA mode 59 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 60 | #define BLEDIS_MODEL "ItsyBitsy nRF52840 Express" 61 | 62 | //--------------------------------------------------------------------+ 63 | // USB 64 | //--------------------------------------------------------------------+ 65 | #define USB_DESC_VID 0x239A 66 | #define USB_DESC_UF2_PID 0x0051 67 | #define USB_DESC_CDC_ONLY_PID 0x0052 68 | 69 | //------------- UF2 -------------// 70 | #define UF2_PRODUCT_NAME "Adafruit ItsyBitsy nRF52840 Express" 71 | #define UF2_VOLUME_LABEL "ITSY840BOOT" 72 | #define UF2_BOARD_ID "nRF52840-ItsyBitsy-revA" 73 | #define UF2_INDEX_URL "https://www.adafruit.com/" 74 | 75 | #endif // _ITSY_NRF52840_H 76 | -------------------------------------------------------------------------------- /bootloader/src/boards/itsybitsy_nrf52840_express/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/mdk_nrf52840_dongle/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 gpshead (krypto.org) for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _MDK_NRF52840_DONGLE_H_ 26 | #define _MDK_NRF52840_DONGLE_H_ 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 2 // TODO(gpshead): support 0. 34 | #define LED_PRIMARY_PIN _PINNUM(0, 23) // Red 35 | #define LED_SECONDARY_PIN _PINNUM(0, 24) // Blue 36 | #define LED_STATE_ON 0 37 | 38 | //#define LED_RGB_RED_PIN _PINNUM(0, 23) 39 | //#define LED_RGB_GREEN_PIN _PINNUM(0, 22) 40 | //#define LED_RGB_BLUE_PIN _PINNUM(0, 24) 41 | #define BOARD_RGB_BRIGHTNESS 0x404040 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | // TODO(gpshead): simplify, have code support 0. double reset only. 46 | #define BUTTONS_NUMBER 2 // none connected at all 47 | #define BUTTON_1 _PINNUM(0, 18) // unusable: RESET 48 | #define BUTTON_2 _PINNUM(0, 19) // no connection 49 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 50 | 51 | // Used as model string in OTA mode 52 | #define BLEDIS_MANUFACTURER "MakerDiary" 53 | #define BLEDIS_MODEL "nRF52840 Micro Dev Kit USB Dongle" 54 | 55 | #define UF2_PRODUCT_NAME "MDK nRF52840 USB Dongle" 56 | #define UF2_VOLUME_LABEL "MDK840DONGL" 57 | #define UF2_BOARD_ID "nRF52840-Dongle-v1" 58 | #define UF2_INDEX_URL "https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/" 59 | 60 | #endif /* _MDK_NRF52840_DONGLE_H_ */ 61 | -------------------------------------------------------------------------------- /bootloader/src/boards/mdk_nrf52840_dongle/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/metro_nrf52840_express/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _METRO_NRF52840_H_ 26 | #define _METRO_NRF52840_H_ 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 2 34 | #define LED_PRIMARY_PIN _PINNUM(1, 13) 35 | #define LED_SECONDARY_PIN _PINNUM(1, 15) 36 | #define LED_STATE_ON 1 37 | 38 | #define LED_NEOPIXEL _PINNUM(0, 13) 39 | #define NEOPIXELS_NUMBER 1 40 | #define BOARD_RGB_BRIGHTNESS 0x040404 41 | 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_1 _PINNUM(1, 0) 47 | #define BUTTON_2 _PINNUM(2, 2) 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 8 54 | #define TX_PIN_NUMBER 6 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | // Used as model string in OTA mode 60 | #define BLEDIS_MANUFACTURER "Adafruit Industries" 61 | #define BLEDIS_MODEL "Metro nRF52840 Express" 62 | 63 | //--------------------------------------------------------------------+ 64 | // USB 65 | //--------------------------------------------------------------------+ 66 | #define USB_DESC_VID 0x239A 67 | #define USB_DESC_UF2_PID 0x003F 68 | #define USB_DESC_CDC_ONLY_PID 0x0040 69 | 70 | //------------- UF2 -------------// 71 | #define UF2_PRODUCT_NAME "Adafruit Metro nRF52840 Express" 72 | #define UF2_VOLUME_LABEL "METR840BOOT" 73 | #define UF2_BOARD_ID "nRF52840-Metro-revA" 74 | 75 | #define UF2_INDEX_URL "https://www.adafruit.com/" 76 | 77 | #endif /* _METRO_NRF52840_H_ */ 78 | -------------------------------------------------------------------------------- /bootloader/src/boards/metro_nrf52840_express/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/ohs2020_badge/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * Copyright (c) 2020 Michael Welling 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | #ifndef _OHS2020_BADGE_H 27 | #define _OHS2020_BADGE_H 28 | 29 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 30 | 31 | /*------------------------------------------------------------------*/ 32 | /* LED 33 | *------------------------------------------------------------------*/ 34 | #define LEDS_NUMBER 1 35 | #define LED_PRIMARY_PIN _PINNUM(0, 04) // fake LED since we have none 36 | #define LED_STATE_ON 1 37 | 38 | /*------------------------------------------------------------------*/ 39 | /* BUTTON 40 | *------------------------------------------------------------------*/ 41 | #define BUTTONS_NUMBER 2 42 | #define BUTTON_1 _PINNUM(0, 29) // SW2 43 | #define BUTTON_2 _PINNUM(0, 03) // SW1 44 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 45 | 46 | /*------------------------------------------------------------------*/ 47 | /* UART (only used by nRF52832) 48 | *------------------------------------------------------------------*/ 49 | #define RX_PIN_NUMBER _PINNUM(0, 09) 50 | #define TX_PIN_NUMBER _PINNUM(0, 10) 51 | #define CTS_PIN_NUMBER 0 52 | #define RTS_PIN_NUMBER 0 53 | #define HWFC false 54 | 55 | // Used as model string in OTA mode 56 | #define BLEDIS_MANUFACTURER "OSHWA" 57 | #define BLEDIS_MODEL "OHS2020 Badge" 58 | 59 | //--------------------------------------------------------------------+ 60 | // USB 61 | //--------------------------------------------------------------------+ 62 | #define USB_DESC_VID 0x239A 63 | #define USB_DESC_UF2_PID 0x007F 64 | #define USB_DESC_CDC_ONLY_PID 0x007F 65 | 66 | //------------- UF2 -------------// 67 | #define UF2_PRODUCT_NAME "OHS2020 Badge" 68 | #define UF2_VOLUME_LABEL "BADGEBOOT" 69 | #define UF2_BOARD_ID "OHS2020-Badge-revA" 70 | #define UF2_INDEX_URL "https://2020.oshwa.org/" 71 | 72 | #endif // _OHS2020_BADGE_H 73 | -------------------------------------------------------------------------------- /bootloader/src/boards/ohs2020_badge/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/particle_argon/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _PARTICLE_ARGON_H 26 | #define _PARTICLE_ARGON_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 34 | #define LED_PRIMARY_PIN _PINNUM(1, 12) 35 | #define LED_STATE_ON 1 36 | 37 | #define LED_RGB_RED_PIN _PINNUM(0, 13) 38 | #define LED_RGB_GREEN_PIN _PINNUM(0, 14) 39 | #define LED_RGB_BLUE_PIN _PINNUM(0, 15) 40 | #define BOARD_RGB_BRIGHTNESS 0x202020 41 | 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_DFU _PINNUM(0, 11) 47 | #define BUTTON_FRESET _PINNUM(0, 03) // A0 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 8 54 | #define TX_PIN_NUMBER 6 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | // Used as model string in OTA mode 60 | #define BLEDIS_MANUFACTURER "Particle Industries" 61 | #define BLEDIS_MODEL "Argon" 62 | 63 | #define UF2_PRODUCT_NAME "Particle Argon" 64 | #define UF2_VOLUME_LABEL "ARGONBOOT " 65 | #define UF2_BOARD_ID "nRF52840-Argon-v1" 66 | #define UF2_INDEX_URL "https://www.particle.io/mesh/" 67 | 68 | #endif // _PARTICLE_ARGON_H 69 | -------------------------------------------------------------------------------- /bootloader/src/boards/particle_argon/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/particle_boron/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _PARTICLE_BORON_H 26 | #define _PARTICLE_BORON_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 34 | #define LED_PRIMARY_PIN _PINNUM(1, 12) 35 | #define LED_STATE_ON 1 36 | 37 | #define LED_RGB_RED_PIN _PINNUM(0, 13) 38 | #define LED_RGB_GREEN_PIN _PINNUM(0, 14) 39 | #define LED_RGB_BLUE_PIN _PINNUM(0, 15) 40 | #define BOARD_RGB_BRIGHTNESS 0x202020 41 | 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_DFU _PINNUM(0, 11) 47 | #define BUTTON_FRESET _PINNUM(0, 03) // A0 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 8 54 | #define TX_PIN_NUMBER 6 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | // Used as model string in OTA mode 60 | #define BLEDIS_MANUFACTURER "Particle Industries" 61 | #define BLEDIS_MODEL "Boron" 62 | 63 | #define UF2_PRODUCT_NAME "Particle Boron" 64 | #define UF2_VOLUME_LABEL "BORONBOOT " 65 | #define UF2_BOARD_ID "nRF52840-Boron-v1" 66 | #define UF2_INDEX_URL "https://www.particle.io/mesh/" 67 | 68 | #endif // _PARTICLE_BORON_H 69 | -------------------------------------------------------------------------------- /bootloader/src/boards/particle_boron/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/particle_xenon/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _PARTICLE_XENON_H 26 | #define _PARTICLE_XENON_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 34 | #define LED_PRIMARY_PIN _PINNUM(1, 12) 35 | #define LED_STATE_ON 1 36 | 37 | #define LED_RGB_RED_PIN _PINNUM(0, 13) 38 | #define LED_RGB_GREEN_PIN _PINNUM(0, 14) 39 | #define LED_RGB_BLUE_PIN _PINNUM(0, 15) 40 | #define BOARD_RGB_BRIGHTNESS 0x202020 41 | 42 | /*------------------------------------------------------------------*/ 43 | /* BUTTON 44 | *------------------------------------------------------------------*/ 45 | #define BUTTONS_NUMBER 2 46 | #define BUTTON_DFU _PINNUM(0, 11) 47 | #define BUTTON_FRESET _PINNUM(0, 03) // A0 48 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 49 | 50 | /*------------------------------------------------------------------*/ 51 | /* UART (only used by nRF52832) 52 | *------------------------------------------------------------------*/ 53 | #define RX_PIN_NUMBER 8 54 | #define TX_PIN_NUMBER 6 55 | #define CTS_PIN_NUMBER 0 56 | #define RTS_PIN_NUMBER 0 57 | #define HWFC false 58 | 59 | // Used as model string in OTA mode 60 | #define BLEDIS_MANUFACTURER "Particle Industries" 61 | #define BLEDIS_MODEL "Xenon" 62 | 63 | #define UF2_PRODUCT_NAME "Particle Xenon" 64 | #define UF2_VOLUME_LABEL "XENONBOOT " 65 | #define UF2_BOARD_ID "nRF52840-Xenon-v1" 66 | #define UF2_INDEX_URL "https://www.particle.io/mesh/" 67 | 68 | #endif // _PARTICLE_XENON_H 69 | -------------------------------------------------------------------------------- /bootloader/src/boards/particle_xenon/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/pca10056/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef PCA10056_H 26 | #define PCA10056_H 27 | 28 | /*------------------------------------------------------------------*/ 29 | /* LED 30 | *------------------------------------------------------------------*/ 31 | #define LEDS_NUMBER 2 32 | #define LED_PRIMARY_PIN 13 33 | #define LED_SECONDARY_PIN 14 34 | #define LED_STATE_ON 0 35 | 36 | /*------------------------------------------------------------------*/ 37 | /* BUTTON 38 | *------------------------------------------------------------------*/ 39 | #define BUTTONS_NUMBER 2 40 | #define BUTTON_1 11 41 | #define BUTTON_2 12 42 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 43 | 44 | /*------------------------------------------------------------------*/ 45 | /* UART (only used by nRF52832) 46 | *------------------------------------------------------------------*/ 47 | #define RX_PIN_NUMBER 8 48 | #define TX_PIN_NUMBER 6 49 | #define CTS_PIN_NUMBER 0 50 | #define RTS_PIN_NUMBER 0 51 | #define HWFC false 52 | 53 | // Used as model string in OTA mode 54 | #define BLEDIS_MANUFACTURER "Nordic" 55 | #define BLEDIS_MODEL "PCA10056" 56 | 57 | #define UF2_PRODUCT_NAME "Nordic nRF52840 DK" 58 | #define UF2_BOARD_ID "nRF52840-pca10056-v1" 59 | #define UF2_INDEX_URL "https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK" 60 | 61 | #endif // PCA10056_H 62 | -------------------------------------------------------------------------------- /bootloader/src/boards/pca10056/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/pca10059/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef PCA10059_H 26 | #define PCA10059_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 2 34 | #define LED_PRIMARY_PIN 6 // Red 35 | #define LED_SECONDARY_PIN 12 // Blue 36 | #define LED_STATE_ON 0 37 | 38 | /*------------------------------------------------------------------*/ 39 | /* BUTTON 40 | *------------------------------------------------------------------*/ 41 | #define BUTTONS_NUMBER 2 42 | 43 | #define BUTTON_1 _PINNUM(1, 6) 44 | #define BUTTON_2 _PINNUM(1, 10) 45 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 46 | 47 | /*------------------------------------------------------------------*/ 48 | /* UART (only used by nRF52832) 49 | *------------------------------------------------------------------*/ 50 | #define RX_PIN_NUMBER 20 51 | #define TX_PIN_NUMBER 17 52 | #define CTS_PIN_NUMBER 15 53 | #define RTS_PIN_NUMBER 13 54 | #define HWFC false 55 | 56 | // Used as model string in OTA mode 57 | #define BLEDIS_MANUFACTURER "Nordic" 58 | #define BLEDIS_MODEL "PCA10059" 59 | 60 | #define UF2_PRODUCT_NAME "Nordic nRF52840 Dongle" 61 | #define UF2_BOARD_ID "nRF52840-pca10059-v1" 62 | #define UF2_INDEX_URL "https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-Dongle" 63 | 64 | #endif // PCA10059_H 65 | -------------------------------------------------------------------------------- /bootloader/src/boards/pca10059/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/pca10100/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef PCA10100_H 26 | #define PCA10100_H 27 | 28 | /*------------------------------------------------------------------*/ 29 | /* LED 30 | *------------------------------------------------------------------*/ 31 | #define LEDS_NUMBER 2 32 | #define LED_PRIMARY_PIN 13 33 | #define LED_SECONDARY_PIN 14 34 | #define LED_STATE_ON 0 35 | 36 | /*------------------------------------------------------------------*/ 37 | /* BUTTON 38 | *------------------------------------------------------------------*/ 39 | #define BUTTONS_NUMBER 2 40 | #define BUTTON_1 11 41 | #define BUTTON_2 12 42 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 43 | 44 | /*------------------------------------------------------------------*/ 45 | /* UART (only used by nRF52832) 46 | *------------------------------------------------------------------*/ 47 | #define RX_PIN_NUMBER 8 48 | #define TX_PIN_NUMBER 6 49 | #define CTS_PIN_NUMBER 0 50 | #define RTS_PIN_NUMBER 0 51 | #define HWFC false 52 | 53 | // Used as model string in OTA mode 54 | #define BLEDIS_MANUFACTURER "Nordic" 55 | #define BLEDIS_MODEL "PCA10100" 56 | 57 | #define UF2_PRODUCT_NAME "Nordic nRF52833 DK" 58 | #define UF2_BOARD_ID "nRF52833-pca10100-v1" 59 | #define UF2_INDEX_URL "https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52833-DK" 60 | 61 | #endif // PCA10100_H 62 | -------------------------------------------------------------------------------- /bootloader/src/boards/pca10100/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52833 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/raytac_mdbt50q_rx/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef RAYTAC_MDBT50Q_RX_H 26 | #define RAYTAC_MDBT50Q_RX_H 27 | 28 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 29 | 30 | /*------------------------------------------------------------------*/ 31 | /* LED 32 | *------------------------------------------------------------------*/ 33 | #define LEDS_NUMBER 1 34 | #define LED_PRIMARY_PIN _PINNUM(1, 13) 35 | #define LED_STATE_ON 0 36 | 37 | /*------------------------------------------------------------------*/ 38 | /* BUTTON 39 | *------------------------------------------------------------------*/ 40 | #define BUTTONS_NUMBER 2 41 | 42 | #define BUTTON_1 _PINNUM(0, 15) 43 | #define BUTTON_2 _PINNUM(0, 10) 44 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 45 | 46 | /*------------------------------------------------------------------*/ 47 | /* UART (only used by nRF52832) (only used by nRF52832) 48 | *------------------------------------------------------------------*/ 49 | #define RX_PIN_NUMBER 8 50 | #define TX_PIN_NUMBER 6 51 | #define CTS_PIN_NUMBER 0 52 | #define RTS_PIN_NUMBER 0 53 | #define HWFC false 54 | 55 | //--------------------------------------------------------------------+ 56 | // BLE OTA 57 | //--------------------------------------------------------------------+ 58 | #define BLEDIS_MANUFACTURER "Raytac" 59 | #define BLEDIS_MODEL "MDBT50Q-RX" 60 | 61 | //--------------------------------------------------------------------+ 62 | // USB 63 | //--------------------------------------------------------------------+ 64 | #define USB_DESC_VID 0x239A 65 | #define USB_DESC_UF2_PID 0x0029 66 | #define USB_DESC_CDC_ONLY_PID 0x002A 67 | 68 | //------------- UF2 -------------// 69 | #define UF2_PRODUCT_NAME "Raytac MDBT50Q-RX" 70 | #define UF2_VOLUME_LABEL "MDBT50QBOOT" 71 | #define UF2_BOARD_ID "nRF52840-MDBT50Q_RX-verD" 72 | #define UF2_INDEX_URL "https://www.raytac.com/product/ins.php?index_id=89" 73 | 74 | #endif // RAYTAC_MDBT50Q_RX_H 75 | -------------------------------------------------------------------------------- /bootloader/src/boards/raytac_mdbt50q_rx/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/boards/waveshare_nrf52840_eval/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | #ifndef _WAVESHARE_NRF52840_H 24 | #define _WAVESHARE_NRF52840_H 25 | 26 | #define _PINNUM(port, pin) ((port)*32 + (pin)) 27 | 28 | /*------------------------------------------------------------------*/ 29 | /* LED 30 | *------------------------------------------------------------------*/ 31 | #define LEDS_NUMBER 2 32 | /* This is led marked LED1 on the board */ 33 | #define LED_PRIMARY_PIN _PINNUM(0, 13) 34 | /* This is led marked LED2 on the board */ 35 | #define LED_SECONDARY_PIN _PINNUM(0, 14) 36 | /* There are two more LEDs, but for the purposes of bootloader that 37 | * doesn't matter. */ 38 | #define LED_STATE_ON 0 39 | 40 | /*------------------------------------------------------------------*/ 41 | /* BUTTON 42 | *------------------------------------------------------------------*/ 43 | #define BUTTONS_NUMBER 2 44 | /* This is the 'KEY1' in top left of the board under RESET key. 45 | * It is used to remain in bootloader mode after reset. */ 46 | #define BUTTON_1 _PINNUM(0, 11) 47 | /* Pin below is in the bottom left of PCB, and can be shorted to GND 48 | * with a regular 2.54mm jumper or tweezers. This pin is used to 49 | * clear user firmware and remain in bootloader mode. */ 50 | #define BUTTON_2 _PINNUM(0, 29) 51 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 52 | 53 | /*------------------------------------------------------------------*/ 54 | /* UART (only used by nRF52832) 55 | *------------------------------------------------------------------*/ 56 | #define RX_PIN_NUMBER 8 57 | #define TX_PIN_NUMBER 6 58 | #define CTS_PIN_NUMBER 0 59 | #define RTS_PIN_NUMBER 0 60 | #define HWFC false 61 | 62 | //--------------------------------------------------------------------+ 63 | // BLE OTA 64 | //--------------------------------------------------------------------+ 65 | #define BLEDIS_MANUFACTURER "Waveshare" 66 | #define BLEDIS_MODEL "nRF52840 Eval" 67 | 68 | //--------------------------------------------------------------------+ 69 | // USB 70 | //--------------------------------------------------------------------+ 71 | #define USB_DESC_VID 0x239A 72 | #define USB_DESC_UF2_PID 0x0029 73 | #define USB_DESC_CDC_ONLY_PID 0x002A 74 | 75 | //------------- UF2 -------------// 76 | #define UF2_PRODUCT_NAME "Waveshare nRF52840 Eval" 77 | #define UF2_VOLUME_LABEL "WS52840EVK" 78 | #define UF2_BOARD_ID "WS-nRF52840-EVK" 79 | #define UF2_INDEX_URL "https://www.waveshare.com/wiki/NRF52840_Eval_Kit" 80 | 81 | #endif // _WAVESHARE_NRF52840_H 82 | -------------------------------------------------------------------------------- /bootloader/src/boards/waveshare_nrf52840_eval/board.mk: -------------------------------------------------------------------------------- 1 | MCU_SUB_VARIANT = nrf52840 2 | -------------------------------------------------------------------------------- /bootloader/src/cmsis/include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | #if defined ( __ICCARM__ ) 35 | #pragma system_include /* treat file as system include file for MISRA check */ 36 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 37 | #pragma clang system_header /* treat file as system include file */ 38 | #endif 39 | 40 | #ifndef __CORE_CMFUNC_H 41 | #define __CORE_CMFUNC_H 42 | 43 | 44 | /* ########################### Core Function Access ########################### */ 45 | /** \ingroup CMSIS_Core_FunctionInterface 46 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 47 | @{ 48 | */ 49 | 50 | /*------------------ RealView Compiler -----------------*/ 51 | #if defined ( __CC_ARM ) 52 | #include "cmsis_armcc.h" 53 | 54 | /*------------------ ARM Compiler V6 -------------------*/ 55 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 56 | #include "cmsis_armcc_V6.h" 57 | 58 | /*------------------ GNU Compiler ----------------------*/ 59 | #elif defined ( __GNUC__ ) 60 | #include "cmsis_gcc.h" 61 | 62 | /*------------------ ICC Compiler ----------------------*/ 63 | #elif defined ( __ICCARM__ ) 64 | #include 65 | 66 | /*------------------ TI CCS Compiler -------------------*/ 67 | #elif defined ( __TMS470__ ) 68 | #include 69 | 70 | /*------------------ TASKING Compiler ------------------*/ 71 | #elif defined ( __TASKING__ ) 72 | /* 73 | * The CMSIS functions have been implemented as intrinsics in the compiler. 74 | * Please use "carm -?i" to get an up to date list of all intrinsics, 75 | * Including the CMSIS ones. 76 | */ 77 | 78 | /*------------------ COSMIC Compiler -------------------*/ 79 | #elif defined ( __CSMC__ ) 80 | #include 81 | 82 | #endif 83 | 84 | /*@} end of CMSIS_Core_RegAccFunctions */ 85 | 86 | #endif /* __CORE_CMFUNC_H */ 87 | -------------------------------------------------------------------------------- /bootloader/src/cmsis/include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /bootloader/src/flash_nrf5x.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include "nrf_sdm.h" 27 | #include "flash_nrf5x.h" 28 | #include "boards.h" 29 | 30 | #define FLASH_PAGE_SIZE 4096 31 | #define FLASH_CACHE_INVALID_ADDR 0xffffffff 32 | 33 | static uint32_t _fl_addr = FLASH_CACHE_INVALID_ADDR; 34 | static uint8_t _fl_buf[FLASH_PAGE_SIZE] __attribute__((aligned(4))); 35 | 36 | void flash_nrf5x_flush (bool need_erase) 37 | { 38 | if ( _fl_addr == FLASH_CACHE_INVALID_ADDR ) return; 39 | 40 | if ( memcmp(_fl_buf, (void *) _fl_addr, FLASH_PAGE_SIZE) != 0 ) 41 | { 42 | // - nRF52832 dfu via uart can miss incoming byte when erasing because cpu is blocked for > 2ms. 43 | // Since dfu_prepare_func_app_erase() already erase the page for us, we can skip it here. 44 | // - nRF52840 dfu serial/uf2 are USB-based which are DMA and should have no problems. 45 | // 46 | // Note: MSC uf2 does not erase page in advance like dfu serial 47 | if ( need_erase ) nrfx_nvmc_page_erase(_fl_addr); 48 | 49 | nrfx_nvmc_words_write(_fl_addr, (uint32_t *) _fl_buf, FLASH_PAGE_SIZE / 4); 50 | } 51 | 52 | _fl_addr = FLASH_CACHE_INVALID_ADDR; 53 | } 54 | 55 | void flash_nrf5x_write (uint32_t dst, void const *src, int len, bool need_erase) 56 | { 57 | uint32_t newAddr = dst & ~(FLASH_PAGE_SIZE - 1); 58 | 59 | if ( newAddr != _fl_addr ) 60 | { 61 | flash_nrf5x_flush(need_erase); 62 | _fl_addr = newAddr; 63 | memcpy(_fl_buf, (void *) newAddr, FLASH_PAGE_SIZE); 64 | } 65 | memcpy(_fl_buf + (dst & (FLASH_PAGE_SIZE - 1)), src, len); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /bootloader/src/flash_nrf5x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef FLASH_NRF5X_H_ 26 | #define FLASH_NRF5X_H_ 27 | 28 | #include 29 | #include 30 | 31 | #include "nrfx_nvmc.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | void flash_nrf5x_write (uint32_t dst, void const *src, int len, bool need_erase); 38 | void flash_nrf5x_flush (bool need_erase); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* FLASH_NRF5X_H_ */ 45 | -------------------------------------------------------------------------------- /bootloader/src/linker/nrf52833_s140_v6.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the 9 | * MBR to init the bootloader when starting the system. This value must correspond to 10 | * BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if 11 | * those values do not match. The check is performed in main.c, see 12 | * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); 13 | */ 14 | FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */ 15 | 16 | /** Location of mbr params page in flash. */ 17 | MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000 18 | 19 | /** Location of bootloader setting in flash. */ 20 | BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000 21 | 22 | 23 | 24 | /** RAM Region for bootloader. */ 25 | /* Avoid conflict with NOINIT for OTA bond sharing */ 26 | RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20020000-0x20008000 27 | 28 | /* Location for double reset detection, no init */ 29 | DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04 30 | 31 | /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information 32 | * from application to bootloader when using buttonluss DFU OTA. */ 33 | NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 34 | 35 | 36 | 37 | /** Location in UICR where bootloader start address is stored. */ 38 | UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 39 | 40 | /** Location in UICR where mbr params page address is stored. */ 41 | UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 42 | } 43 | 44 | SECTIONS 45 | { 46 | .fs_data_out ALIGN(4): 47 | { 48 | PROVIDE( __start_fs_data = .); 49 | KEEP(*(fs_data)) 50 | PROVIDE( __stop_fs_data = .); 51 | } = 0 52 | 53 | /* Place the bootloader settings page in flash. */ 54 | .bootloaderSettings(NOLOAD) : 55 | { 56 | 57 | } > BOOTLOADER_SETTINGS 58 | 59 | /* Write the bootloader address in UICR. */ 60 | .uicrBootStartAddress : 61 | { 62 | KEEP(*(.uicrBootStartAddress)) 63 | } > UICR_BOOTLOADER 64 | 65 | /* Place the mbr params page in flash. */ 66 | .mbrParamsPage(NOLOAD) : 67 | { 68 | 69 | } > MBR_PARAMS_PAGE 70 | 71 | /* Write the bootloader address in UICR. */ 72 | .uicrMbrParamsPageAddress : 73 | { 74 | KEEP(*(.uicrMbrParamsPageAddress)) 75 | } > UICR_MBR_PARAM_PAGE 76 | 77 | .dbl_reset(NOLOAD) : 78 | { 79 | 80 | } > DBL_RESET 81 | 82 | /* No init RAM section in bootloader. Used for bond information exchange. */ 83 | .noinit(NOLOAD) : 84 | { 85 | 86 | } > NOINIT 87 | 88 | /* other placements follow here... */ 89 | } 90 | 91 | INCLUDE "nrf_common.ld" 92 | -------------------------------------------------------------------------------- /bootloader/src/linker/nrf52840_s140_v6.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the 9 | * MBR to init the bootloader when starting the system. This value must correspond to 10 | * BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if 11 | * those values do not match. The check is performed in main.c, see 12 | * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); 13 | */ 14 | FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xFE000-0xF4000-2048-32 /* 38 KB */ 15 | SECEC (rx) : ORIGIN = 0xfd7e0, LENGTH = 0x20 16 | 17 | BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 2048, LENGTH = 2048 18 | 19 | /** Location of mbr params page in flash. */ 20 | MBR_PARAMS_PAGE (rw) : ORIGIN = 0xFE000, LENGTH = 0x1000 21 | 22 | /** Location of bootloader setting in flash. */ 23 | BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000 24 | 25 | 26 | 27 | /** RAM Region for bootloader. */ 28 | /* Avoid conflict with NOINIT for OTA bond sharing */ 29 | RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20040000-0x20008000 30 | 31 | /* Location for double reset detection, no init */ 32 | DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04 33 | 34 | /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information 35 | * from application to bootloader when using buttonluss DFU OTA. */ 36 | NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 37 | 38 | 39 | 40 | /** Location in UICR where bootloader start address is stored. */ 41 | UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 42 | 43 | /** Location in UICR where mbr params page address is stored. */ 44 | UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 45 | } 46 | 47 | SECTIONS 48 | { 49 | .secec : 50 | { 51 | *(.secec); 52 | } > SECEC 53 | 54 | .fs_data_out ALIGN(4): 55 | { 56 | PROVIDE( __start_fs_data = .); 57 | KEEP(*(fs_data)) 58 | PROVIDE( __stop_fs_data = .); 59 | } = 0 60 | 61 | .bootloaderConfig : 62 | { 63 | KEEP(*(.bootloaderConfig)) 64 | } > BOOTLOADER_CONFIG 65 | 66 | /* Place the bootloader settings page in flash. */ 67 | .bootloaderSettings(NOLOAD) : 68 | { 69 | 70 | } > BOOTLOADER_SETTINGS 71 | 72 | /* Write the bootloader address in UICR. */ 73 | .uicrBootStartAddress : 74 | { 75 | KEEP(*(.uicrBootStartAddress)) 76 | } > UICR_BOOTLOADER 77 | 78 | /* Place the mbr params page in flash. */ 79 | .mbrParamsPage(NOLOAD) : 80 | { 81 | 82 | } > MBR_PARAMS_PAGE 83 | 84 | /* Write the bootloader address in UICR. */ 85 | .uicrMbrParamsPageAddress : 86 | { 87 | KEEP(*(.uicrMbrParamsPageAddress)) 88 | } > UICR_MBR_PARAM_PAGE 89 | 90 | .dbl_reset(NOLOAD) : 91 | { 92 | 93 | } > DBL_RESET 94 | 95 | /* No init RAM section in bootloader. Used for bond information exchange. */ 96 | .noinit(NOLOAD) : 97 | { 98 | 99 | } > NOINIT 100 | 101 | /* other placements follow here... */ 102 | } 103 | 104 | INCLUDE "nrf_common.ld" 105 | -------------------------------------------------------------------------------- /bootloader/src/linker/nrf52840_s140_v6.ld.orig: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the 9 | * MBR to init the bootloader when starting the system. This value must correspond to 10 | * BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if 11 | * those values do not match. The check is performed in main.c, see 12 | * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); 13 | */ 14 | FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xFE000-0xF4000-2048 /* 38 KB */ 15 | 16 | BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 2048, LENGTH = 2048 17 | 18 | /** Location of mbr params page in flash. */ 19 | MBR_PARAMS_PAGE (rw) : ORIGIN = 0xFE000, LENGTH = 0x1000 20 | 21 | /** Location of bootloader setting in flash. */ 22 | BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000 23 | 24 | 25 | 26 | /** RAM Region for bootloader. */ 27 | /* Avoid conflict with NOINIT for OTA bond sharing */ 28 | RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20040000-0x20008000 29 | 30 | /* Location for double reset detection, no init */ 31 | DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04 32 | 33 | /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information 34 | * from application to bootloader when using buttonluss DFU OTA. */ 35 | NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 36 | 37 | 38 | 39 | /** Location in UICR where bootloader start address is stored. */ 40 | UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 41 | 42 | /** Location in UICR where mbr params page address is stored. */ 43 | UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 44 | } 45 | 46 | SECTIONS 47 | { 48 | .fs_data_out ALIGN(4): 49 | { 50 | PROVIDE( __start_fs_data = .); 51 | KEEP(*(fs_data)) 52 | PROVIDE( __stop_fs_data = .); 53 | } = 0 54 | 55 | .bootloaderConfig : 56 | { 57 | KEEP(*(.bootloaderConfig)) 58 | } > BOOTLOADER_CONFIG 59 | 60 | /* Place the bootloader settings page in flash. */ 61 | .bootloaderSettings(NOLOAD) : 62 | { 63 | 64 | } > BOOTLOADER_SETTINGS 65 | 66 | /* Write the bootloader address in UICR. */ 67 | .uicrBootStartAddress : 68 | { 69 | KEEP(*(.uicrBootStartAddress)) 70 | } > UICR_BOOTLOADER 71 | 72 | /* Place the mbr params page in flash. */ 73 | .mbrParamsPage(NOLOAD) : 74 | { 75 | 76 | } > MBR_PARAMS_PAGE 77 | 78 | /* Write the bootloader address in UICR. */ 79 | .uicrMbrParamsPageAddress : 80 | { 81 | KEEP(*(.uicrMbrParamsPageAddress)) 82 | } > UICR_MBR_PARAM_PAGE 83 | 84 | .dbl_reset(NOLOAD) : 85 | { 86 | 87 | } > DBL_RESET 88 | 89 | /* No init RAM section in bootloader. Used for bond information exchange. */ 90 | .noinit(NOLOAD) : 91 | { 92 | 93 | } > NOINIT 94 | 95 | /* other placements follow here... */ 96 | } 97 | 98 | INCLUDE "nrf_common.ld" 99 | -------------------------------------------------------------------------------- /bootloader/src/linker/nrf52_s132_v6.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the 9 | * MBR to init the bootloader when starting the system. This value must correspond to 10 | * BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if 11 | * those values do not match. The check is performed in main.c, see 12 | * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); 13 | */ 14 | FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */ 15 | 16 | /** Location of mbr params page in flash. */ 17 | MBR_PARAMS_PAGE (rw) : ORIGIN = 0x7E000, LENGTH = 0x1000 18 | 19 | /** Location of bootloader setting in flash. */ 20 | BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x7F000, LENGTH = 0x1000 21 | 22 | 23 | 24 | /** RAM Region for bootloader. */ 25 | RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20010000-0x20008000 26 | 27 | /* Location for double reset detection, no init */ 28 | DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04 29 | 30 | /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information 31 | * from application to bootloader when using buttonluss DFU OTA. */ 32 | NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 33 | 34 | 35 | 36 | /** Location in UICR where bootloader start address is stored. */ 37 | UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 38 | 39 | /** Location in UICR where mbr params page address is stored. */ 40 | UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 41 | } 42 | 43 | SECTIONS 44 | { 45 | .fs_data_out ALIGN(4): 46 | { 47 | PROVIDE( __start_fs_data = .); 48 | KEEP(*(fs_data)) 49 | PROVIDE( __stop_fs_data = .); 50 | } = 0 51 | 52 | /* Place the bootloader settings page in flash. */ 53 | .bootloaderSettings(NOLOAD) : 54 | { 55 | 56 | } > BOOTLOADER_SETTINGS 57 | 58 | /* Write the bootloader address in UICR. */ 59 | .uicrBootStartAddress : 60 | { 61 | KEEP(*(.uicrBootStartAddress)) 62 | } > UICR_BOOTLOADER 63 | 64 | /* Place the mbr params page in flash. */ 65 | .mbrParamsPage(NOLOAD) : 66 | { 67 | 68 | } > MBR_PARAMS_PAGE 69 | 70 | /* Write the bootloader address in UICR. */ 71 | .uicrMbrParamsPageAddress : 72 | { 73 | KEEP(*(.uicrMbrParamsPageAddress)) 74 | } > UICR_MBR_PARAM_PAGE 75 | 76 | .dbl_reset(NOLOAD) : 77 | { 78 | 79 | } > DBL_RESET 80 | 81 | /* No init RAM section in bootloader. Used for bond information exchange. */ 82 | .noinit(NOLOAD) : 83 | { 84 | 85 | } > NOINIT 86 | /* other placements follow here... */ 87 | } 88 | 89 | INCLUDE "nrf_common.ld" 90 | -------------------------------------------------------------------------------- /bootloader/src/nrfx_config.h: -------------------------------------------------------------------------------- 1 | #ifndef NRFX_CONFIG_H__ 2 | #define NRFX_CONFIG_H__ 3 | 4 | // Power 5 | #define NRFX_POWER_ENABLED 1 6 | #define NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY 7 7 | 8 | #define NRFX_CLOCK_ENABLED 0 9 | 10 | #define NRFX_NVMC_ENABLED 1 11 | 12 | // UART 13 | #ifdef NRF52832_XXAA 14 | #define NRFX_UART_ENABLED 1 15 | #define NRFX_UART0_ENABLED 1 16 | 17 | #define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 7 18 | #define NRFX_UART_DEFAULT_CONFIG_HWFC NRF_UART_HWFC_DISABLED 19 | #define NRFX_UART_DEFAULT_CONFIG_PARITY NRF_UART_PARITY_EXCLUDED 20 | #define NRFX_UART_DEFAULT_CONFIG_BAUDRATE NRF_UART_BAUDRATE_115200 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /bootloader/src/secec.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | __attribute__((section(".secec"))) uint8_t eckey[] = {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77}; 4 | -------------------------------------------------------------------------------- /bootloader/src/segger/SEGGER_RTT_SES.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * SEGGER MICROCONTROLLER GmbH & Co. KG * 3 | * Solutions for real time microcontroller applications * 4 | ********************************************************************** 5 | * * 6 | * (c) 2014 - 2015 SEGGER Microcontroller GmbH & Co. KG * 7 | * * 8 | * www.segger.com Support: support@segger.com * 9 | * * 10 | ********************************************************************** 11 | * * 12 | * All rights reserved. * 13 | * * 14 | * * This software may in its unmodified form be freely redistributed * 15 | * in source form. * 16 | * * The source code may be modified, provided the source code * 17 | * retains the above copyright notice, this list of conditions and * 18 | * the following disclaimer. * 19 | * * Modified versions of this software in source or linkable form * 20 | * may not be distributed without prior consent of SEGGER. * 21 | * * This software may only be used for communication with SEGGER * 22 | * J-Link debug probes. * 23 | * * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 25 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 26 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * 27 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 28 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * 29 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * 31 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * 32 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 35 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 36 | * DAMAGE. * 37 | * * 38 | ********************************************************************** 39 | -------- END-OF-HEADER --------------------------------------------- 40 | File : SEGGER_RTT_Syscalls_SES.c 41 | Purpose : Reimplementation of printf, puts and 42 | implementation of __putchar and __getchar using RTT in SES. 43 | To use RTT for printf output, include this file in your 44 | application. 45 | ---------------------------------------------------------------------- 46 | */ 47 | #include "SEGGER_RTT.h" 48 | #include "__libc.h" 49 | #include 50 | #include 51 | 52 | int printf(const char *fmt,...) { 53 | char buffer[128]; 54 | va_list args; 55 | va_start (args, fmt); 56 | int n = vsnprintf(buffer, sizeof(buffer), fmt, args); 57 | SEGGER_RTT_Write(0, buffer, n); 58 | va_end(args); 59 | return n; 60 | } 61 | 62 | int puts(const char *s) { 63 | return SEGGER_RTT_WriteString(0, s); 64 | } 65 | 66 | int __putchar(int x, __printf_tag_ptr ctx) { 67 | (void)ctx; 68 | SEGGER_RTT_Write(0, (char *)&x, 1); 69 | return x; 70 | } 71 | 72 | int __getchar() { 73 | return SEGGER_RTT_WaitKey(); 74 | } 75 | 76 | /****** End Of File *************************************************/ 77 | -------------------------------------------------------------------------------- /bootloader/src/segger/flash_placement.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /bootloader/src/segger/nRF52832_xxAA_MemoryMap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /bootloader/src/segger/nRF52840_xxAA_MemoryMap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /bootloader/src/segger/nRF_Target.js: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * SEGGER Microcontroller GmbH & Co. KG * 3 | * Solutions for real time microcontroller applications * 4 | ***************************************************************************** 5 | * * 6 | * (c) 2017 SEGGER Microcontroller GmbH & Co. KG * 7 | * * 8 | * Internet: www.segger.com Support: support@segger.com * 9 | * * 10 | *****************************************************************************/ 11 | 12 | function Reset() { 13 | TargetInterface.resetAndStop(); 14 | } 15 | 16 | function EnableTrace(traceInterfaceType) { 17 | // TODO: Enable trace 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bootloader/src/usb/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmvr/pykey/96503b4889d31cd6dc1cd649c5f7ffcfa6a225ed/bootloader/src/usb/main -------------------------------------------------------------------------------- /bootloader/src/usb/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "rsa_verify.h" 5 | 6 | 7 | uint8_t char2byte(char input) 8 | { 9 | if(input >= '0' && input <= '9') 10 | return input - '0'; 11 | if(input >= 'A' && input <= 'F') 12 | return input - 'A' + 10; 13 | if(input >= 'a' && input <= 'f') 14 | return input - 'a' + 10; 15 | } 16 | 17 | void hex2bin(char *hex, uint8_t *bin) { 18 | while (*hex) { 19 | *bin = (char2byte(hex[0]) << 4) + char2byte(hex[1]); 20 | bin += 1; 21 | hex += 2; 22 | } 23 | } 24 | 25 | int main(int argc, char **argv) { 26 | uint8_t hash[32]; 27 | uint8_t signature[256]; 28 | 29 | hex2bin(argv[1], hash); 30 | hex2bin(argv[2], signature); 31 | 32 | return rsa_verify(hash, signature); 33 | } 34 | -------------------------------------------------------------------------------- /bootloader/src/usb/rsa_verify.c: -------------------------------------------------------------------------------- 1 | #include "bn.h" 2 | 3 | // modulus in big endian 4 | const uint8_t modulus[] = {0xd3, 0x58, 0x2e, 0x0e, 0x6e, 0xf0, 0xc6, 0x0f, 0x5f, 0x4d, 0x82, 0x85, 0x0b, 0xc0, 0xdf, 0xbe, 0x86, 0x70, 0x43, 0xbc, 0xb2, 0x76, 0xdc, 0x95, 0xbe, 0x17, 0x5c, 0xa8, 0x90, 0xc4, 0x86, 0x5c, 0x16, 0xd9, 0x28, 0x79, 0x5c, 0x5d, 0xef, 0x67, 0x3a, 0x63, 0x01, 0xcb, 0x7c, 0xbd, 0xef, 0xc6, 0xa9, 0x70, 0x13, 0x58, 0x22, 0x64, 0xad, 0xb0, 0xa9, 0x88, 0xdc, 0xa6, 0x3f, 0x91, 0x4f, 0x93, 0xfc, 0x68, 0x5c, 0xc7, 0xa3, 0x9d, 0x2e, 0x41, 0x80, 0x66, 0xae, 0x7b, 0x05, 0x40, 0xae, 0x2f, 0x0c, 0x8e, 0x5e, 0x83, 0x39, 0x53, 0x67, 0x60, 0xc9, 0xca, 0xfe, 0x86, 0x4f, 0x26, 0x18, 0x94, 0xda, 0x8a, 0x33, 0x62, 0xc4, 0xfe, 0xb2, 0x26, 0x5d, 0x17, 0x7e, 0x56, 0xdd, 0xbd, 0x90, 0x1d, 0xd3, 0x57, 0x47, 0x22, 0x98, 0x6d, 0xd4, 0xba, 0xca, 0x35, 0x09, 0xed, 0xcc, 0x3b, 0x9d, 0x88, 0x03, 0x21, 0xd4, 0xbf, 0x00, 0x84, 0x49, 0x84, 0x70, 0x6a, 0x7a, 0x71, 0x68, 0xb9, 0x7d, 0x07, 0xe3, 0xe0, 0x8e, 0x48, 0xa6, 0x4e, 0x90, 0x06, 0x3f, 0x14, 0xc4, 0x60, 0x5c, 0x78, 0xae, 0x28, 0xe5, 0x0f, 0x3f, 0x61, 0x00, 0xd9, 0xb3, 0x74, 0x47, 0x3e, 0x01, 0x91, 0x7d, 0xaa, 0x18, 0xcb, 0x8a, 0xf8, 0x7a, 0x22, 0x4b, 0x14, 0xeb, 0x80, 0xc3, 0xfe, 0x16, 0x80, 0x19, 0x25, 0x35, 0x62, 0xbf, 0x21, 0xc7, 0xf4, 0xea, 0x60, 0xde, 0x28, 0xbc, 0x1e, 0xe1, 0x7d, 0x3a, 0x3c, 0xc9, 0x9c, 0x00, 0x86, 0x00, 0xfb, 0xd6, 0x20, 0x2b, 0xae, 0xa0, 0xaf, 0x82, 0xf3, 0x81, 0x1d, 0xf9, 0xab, 0x0f, 0x84, 0x3f, 0xf7, 0x3c, 0xec, 0x48, 0xf6, 0x1d, 0x5c, 0xe1, 0xe4, 0x45, 0x06, 0x40, 0x06, 0x15, 0xf6, 0x7b, 0xcb, 0xba, 0xaa, 0xdb, 0x0c, 0x68, 0x9e, 0x6c, 0x06, 0x5e, 0x46, 0x2a, 0x05}; 5 | 6 | uint8_t rsa_verify(uint8_t *hash, uint8_t *signature) { 7 | struct bn m, s, t1, t2; 8 | 9 | bignum_init(&m); 10 | bignum_from_bytes(&m, modulus, sizeof(modulus)); 11 | bignum_init(&s); 12 | bignum_from_bytes(&s, signature, sizeof(modulus)); 13 | bignum_init(&t1); 14 | bignum_init(&t2); 15 | // s^3 % m 16 | bignum_mul(&s, &s, &t1); 17 | bignum_mod(&t1, &m, &t2); 18 | bignum_mul(&t2, &s, &t1); 19 | bignum_mod(&t1, &m, &t2); 20 | 21 | uint8_t hash_cmp[32]; 22 | bignum_to_bytes(&t2, hash_cmp, sizeof(hash_cmp)); 23 | 24 | // compare with signature SHA-256 25 | uint8_t i, cmp=0; 26 | for (i=0; i n ) verify_breakpoint();\ 86 | }while(0) 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* _TUSB_CONFIG_H_ */ 93 | -------------------------------------------------------------------------------- /bootloader/src/usb/uf2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /bootloader/src/usb/uf2/compile_date.h: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 6 | 7 | All rights reserved. 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | 27 | */ 28 | 29 | #ifndef COMPILE_DATE_H 30 | #define COMPILE_DATE_H 31 | 32 | #define __YEAR_INT__ ((( \ 33 | (__DATE__ [ 7u] - '0') * 10u + \ 34 | (__DATE__ [ 8u] - '0')) * 10u + \ 35 | (__DATE__ [ 9u] - '0')) * 10u + \ 36 | (__DATE__ [10u] - '0')) 37 | 38 | #define __MONTH_INT__ ( \ 39 | (__DATE__ [2u] == 'n' && __DATE__ [1u] == 'a') ? 1u /*Jan*/ \ 40 | : (__DATE__ [2u] == 'b' ) ? 2u /*Feb*/ \ 41 | : (__DATE__ [2u] == 'r' && __DATE__ [1u] == 'a') ? 3u /*Mar*/ \ 42 | : (__DATE__ [2u] == 'r' ) ? 4u /*Apr*/ \ 43 | : (__DATE__ [2u] == 'y' ) ? 5u /*May*/ \ 44 | : (__DATE__ [2u] == 'n' ) ? 6u /*Jun*/ \ 45 | : (__DATE__ [2u] == 'l' ) ? 7u /*Jul*/ \ 46 | : (__DATE__ [2u] == 'g' ) ? 8u /*Aug*/ \ 47 | : (__DATE__ [2u] == 'p' ) ? 9u /*Sep*/ \ 48 | : (__DATE__ [2u] == 't' ) ? 10u /*Oct*/ \ 49 | : (__DATE__ [2u] == 'v' ) ? 11u /*Nov*/ \ 50 | : 12u /*Dec*/ ) 51 | 52 | #define __DAY_INT__ ( \ 53 | (__DATE__ [4u] == ' ' ? 0u : __DATE__ [4u] - '0') * 10u \ 54 | + (__DATE__ [5u] - '0') ) 55 | 56 | // __TIME__ expands to an eight-character string constant 57 | // "23:59:01", or (if cannot determine time) "??:??:??" 58 | #define __HOUR_INT__ ( \ 59 | (__TIME__ [0u] == '?' ? 0u : __TIME__ [0u] - '0') * 10u \ 60 | + (__TIME__ [1u] == '?' ? 0u : __TIME__ [1u] - '0') ) 61 | 62 | #define __MINUTE_INT__ ( \ 63 | (__TIME__ [3u] == '?' ? 0u : __TIME__ [3u] - '0') * 10u \ 64 | + (__TIME__ [4u] == '?' ? 0u : __TIME__ [4u] - '0') ) 65 | 66 | #define __SECONDS_INT__ ( \ 67 | (__TIME__ [6u] == '?' ? 0u : __TIME__ [6u] - '0') * 10u \ 68 | + (__TIME__ [7u] == '?' ? 0u : __TIME__ [7u] - '0') ) 69 | 70 | 71 | #define __DOSDATE__ ( \ 72 | ((__YEAR_INT__ - 1980u) << 9u) | \ 73 | ( __MONTH_INT__ << 5u) | \ 74 | ( __DAY_INT__ << 0u) ) 75 | 76 | #define __DOSTIME__ ( \ 77 | ( __HOUR_INT__ << 11u) | \ 78 | ( __MINUTE_INT__ << 5u) | \ 79 | ( __SECONDS_INT__ << 0u) ) 80 | 81 | #endif // COMPILE_DATE_H 82 | 83 | -------------------------------------------------------------------------------- /bootloader/src/usb/uf2/nrf_cc310/crys_hash_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | #ifndef CRYS_HASH_DEFS_H 37 | #define CRYS_HASH_DEFS_H 38 | 39 | /*! 40 | @file 41 | @brief This file contains HASH definitions. 42 | @defgroup crys_hash_defs CryptoCell Hash definitions 43 | @{ 44 | @ingroup crys_hash 45 | */ 46 | 47 | #ifdef __cplusplus 48 | extern "C" 49 | { 50 | #endif 51 | 52 | 53 | /************************ Defines ******************************/ 54 | 55 | /*! The size of user's context prototype (see ::CRYS_HASHUserContext_t) in words. */ 56 | #define CRYS_HASH_USER_CTX_SIZE_IN_WORDS 60 57 | 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | /** 64 | @} 65 | */ 66 | #endif 67 | -------------------------------------------------------------------------------- /bootloader/src/usb/uf2/nrf_cc310/ssi_pal_types_plat.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 3 | * * 4 | * This file and the related binary are licensed under the following license: * 5 | * * 6 | * ARM Object Code and Header Files License, v1.0 Redistribution. * 7 | * * 8 | * Redistribution and use of object code, header files, and documentation, without * 9 | * modification, are permitted provided that the following conditions are met: * 10 | * * 11 | * 1) Redistributions must reproduce the above copyright notice and the * 12 | * following disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * 15 | * 2) Unless to the extent explicitly permitted by law, no reverse * 16 | * engineering, decompilation, or disassembly of is permitted. * 17 | * * 18 | * 3) Redistribution and use is permitted solely for the purpose of * 19 | * developing or executing applications that are targeted for use * 20 | * on an ARM-based product. * 21 | * * 22 | * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 23 | * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 24 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 25 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 28 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 29 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 33 | **************************************************************************************/ 34 | 35 | 36 | /*! @file 37 | @brief This file contains basic type definitions that are platform dependent. 38 | */ 39 | #ifndef SSI_PAL_TYPES_PLAT_H 40 | #define SSI_PAL_TYPES_PLAT_H 41 | /* Host specific types for standard (ISO-C99) compilant platforms */ 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | typedef uintptr_t SaSiVirtAddr_t; 48 | typedef uint32_t SaSiBool_t; 49 | typedef uint32_t SaSiStatus; 50 | 51 | #define SaSiError_t SaSiStatus 52 | #define SASI_INFINITE 0xFFFFFFFF 53 | 54 | #define CEXPORT_C 55 | #define CIMPORT_C 56 | 57 | #endif /*SSI_PAL_TYPES_PLAT_H*/ 58 | -------------------------------------------------------------------------------- /bootloader/src/usb/uf2/sha256.c: -------------------------------------------------------------------------------- 1 | #include "nrf_cc310/crys_hash.h" 2 | #include "boards.h" 3 | 4 | #include 5 | 6 | 7 | #define NRF_CRYPTOCELL_BASE 0x5002A000UL 8 | #define NRF_CRYPTOCELL ((NRF_CRYPTOCELL_Type*) NRF_CRYPTOCELL_BASE) 9 | 10 | typedef enum { 11 | SA_SILIB_RET_OK = 0, /*!< Success defintion.*/ 12 | SA_SILIB_RET_EINVAL_CTX_PTR, /*!< Illegal context pointer.*/ 13 | SA_SILIB_RET_EINVAL_WORK_BUF_PTR, /*!< Illegal work buffer pointer.*/ 14 | SA_SILIB_RET_HAL, /*!< Error returned from HAL layer.*/ 15 | SA_SILIB_RET_PAL, /*!< Error returned from PAL layer.*/ 16 | SA_SILIB_RET_EINVAL_HW_VERSION, /*!< Invalid HW version. */ 17 | SA_SILIB_RET_EINVAL_HW_SIGNATURE, /*!< Invalid HW signature. */ 18 | SA_SILIB_RESERVE32B = 0x7FFFFFFFL /*!< Reserved.*/ 19 | } SA_SilibRetCode_t; 20 | SA_SilibRetCode_t SaSi_LibInit(void); 21 | void SaSi_LibFini(void); 22 | 23 | 24 | void cc310_sha256(uint8_t *buffer, size_t len, uint8_t *hash) { 25 | CRYS_HASH_Result_t hashOutBuff; 26 | 27 | NVIC_EnableIRQ(CRYPTOCELL_IRQn); 28 | // enable CryptoCell hardware 29 | NRF_CRYPTOCELL->ENABLE = 1; 30 | SaSi_LibInit(); 31 | CRYS_HASH(CRYS_HASH_SHA256_mode, buffer, len, hashOutBuff); 32 | // disable CryptoCell hardware 33 | NVIC_DisableIRQ(CRYPTOCELL_IRQn); 34 | NRF_CRYPTOCELL->ENABLE = 0; 35 | SaSi_LibFini(); 36 | // return 32-Byte hash value 37 | memcpy(hash, (uint8_t*)hashOutBuff, 32); 38 | } 39 | -------------------------------------------------------------------------------- /bootloader/src/usb/uf2/sha256.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHA256_ 2 | #define _SHA256_ 3 | 4 | void cc310_sha256(uint8_t *buffer, size_t len, uint8_t *hash); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /bootloader/src/usb/uf2/uf2cfg.h: -------------------------------------------------------------------------------- 1 | #include "boards.h" 2 | 3 | #define UF2_NUM_BLOCKS 8000 // at least 4,1 MB for FAT16 4 | 5 | #ifndef UF2_VOLUME_LABEL 6 | #define UF2_VOLUME_LABEL "NRF52BOOT " 7 | #endif 8 | 9 | #define FLASH_SIZE (USER_FLASH_END-USER_FLASH_START) // Max flash size 10 | 11 | // Only allow to write application TODO dynamic depending on SD size 12 | #define USER_FLASH_START 0x26000 13 | #define USER_FLASH_END 0xAD000 // Fat Fs start here 14 | 15 | #define FLASH_PAGE_SIZE 4096 16 | 17 | #define UF2_FAMILY_ID 0xADA52840 18 | -------------------------------------------------------------------------------- /bootloader/src/usb/usb_desc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2018 Ha Thach for Adafruit Industries 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef USB_DESC_H_ 26 | #define USB_DESC_H_ 27 | 28 | #include "tusb.h" 29 | #include "boards.h" 30 | 31 | void usb_desc_init(); 32 | 33 | #ifndef USB_DESC_VID 34 | #define USB_DESC_VID 0x239A 35 | #endif 36 | 37 | #ifndef USB_DESC_UF2_PID 38 | #define USB_DESC_UF2_PID 0x0029 39 | #endif 40 | 41 | #ifndef USB_DESC_CDC_ONLY_PID 42 | #define USB_DESC_CDC_ONLY_PID 0x002A 43 | #endif 44 | 45 | #endif /* USB_DESC_H_ */ 46 | -------------------------------------------------------------------------------- /bootloader/tools/build_all.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import sys 4 | import subprocess 5 | import time 6 | 7 | subprocess.run("rm -rf _build*", shell=True) 8 | subprocess.run("rm -rf bin/*", shell=True) 9 | 10 | travis = False 11 | if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true": 12 | travis = True 13 | 14 | success_count = 0 15 | fail_count = 0 16 | exit_status = 0 17 | 18 | build_format = '| {:30} | {:9} ' 19 | build_separator = '-' * 54 20 | 21 | all_boards = [] 22 | for entry in os.scandir("src/boards"): 23 | all_boards.append(entry.name) 24 | 25 | #sha, version = build_info.get_version_info() 26 | 27 | total_time = time.monotonic() 28 | 29 | print(build_separator) 30 | print((build_format + '| {:5} |').format('Board', 'Result', 'Time')) 31 | print(build_separator) 32 | 33 | for board in all_boards: 34 | bin_directory = "bin/{}/".format(board) 35 | os.makedirs(bin_directory, exist_ok=True) 36 | 37 | start_time = time.monotonic() 38 | make_result = subprocess.run("make -j 4 BOARD={} combinehex genpkg".format(board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 39 | build_duration = time.monotonic() - start_time 40 | 41 | if make_result.returncode == 0: 42 | success = "\033[32msucceeded\033[0m" 43 | success_count += 1 44 | else: 45 | exit_status = make_result.returncode 46 | success = "\033[31mfailed\033[0m " 47 | fail_count += 1 48 | 49 | for entry in os.scandir("_build-{}".format(board)): 50 | for extension in ["zip", "hex"]: 51 | if entry.name.endswith(extension) and "nosd" not in entry.name: 52 | shutil.copy(entry.path, bin_directory) 53 | 54 | if travis: 55 | print('travis_fold:start:build-{}\\r'.format(board)) 56 | 57 | print((build_format + '| {:.2f}s |').format(board, success, build_duration)) 58 | 59 | if make_result.returncode != 0: 60 | print(make_result.stdout.decode("utf-8")) 61 | if travis: 62 | print('travis_fold:end:build-{}\\r'.format(board)) 63 | 64 | # Build Summary 65 | total_time = time.monotonic() - total_time 66 | print(build_separator) 67 | print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m and took {:.2f}s".format(success_count, fail_count, total_time)) 68 | print(build_separator) 69 | 70 | sys.exit(exit_status) 71 | -------------------------------------------------------------------------------- /bootloader/tools/github_requests.py: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 2017 Scott Shawcroft for Adafruit Industries 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | """ 23 | `adafruit_adabot` 24 | ==================================================== 25 | 26 | TODO(description) 27 | 28 | * Author(s): Scott Shawcroft 29 | """ 30 | import os 31 | 32 | import requests 33 | 34 | 35 | def _fix_url(url): 36 | if url.startswith("/"): 37 | url = "https://api.github.com" + url 38 | return url 39 | 40 | def _fix_kwargs(kwargs): 41 | api_version = "application/vnd.github.scarlet-witch-preview+json;application/vnd.github.hellcat-preview+json" 42 | if "headers" in kwargs: 43 | if "Accept" in kwargs["headers"]: 44 | kwargs["headers"]["Accept"] += ";" + api_version 45 | else: 46 | kwargs["headers"]["Accept"] = api_version 47 | else: 48 | kwargs["headers"] = {"Accept": "application/vnd.github.hellcat-preview+json"} 49 | if "ADABOT_GITHUB_ACCESS_TOKEN" in os.environ and "auth" not in kwargs: 50 | access_token = os.environ["ADABOT_GITHUB_ACCESS_TOKEN"] 51 | if "params" in kwargs: 52 | kwargs["params"]["access_token"] = access_token 53 | else: 54 | kwargs["params"] = {"access_token": access_token} 55 | if "timeout" not in kwargs: 56 | kwargs["timeout"] = 30 57 | return kwargs 58 | 59 | def get(url, **kwargs): 60 | response = requests.get(_fix_url(url), **_fix_kwargs(kwargs)) 61 | remaining = int(response.headers["X-RateLimit-Remaining"]) 62 | if remaining % 100 == 0: 63 | print(remaining, "requests remaining this hour") 64 | return response 65 | 66 | def post(url, **kwargs): 67 | return requests.post(_fix_url(url), **_fix_kwargs(kwargs)) 68 | 69 | def put(url, **kwargs): 70 | return requests.put(_fix_url(url), **_fix_kwargs(kwargs)) 71 | 72 | def patch(url, **kwargs): 73 | return requests.patch(_fix_url(url), **_fix_kwargs(kwargs)) 74 | 75 | def delete(url, **kwargs): 76 | return requests.delete(_fix_url(url), **_fix_kwargs(kwargs)) 77 | -------------------------------------------------------------------------------- /bootloader/tools/upload_release_files.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | import os 4 | import os.path 5 | import sys 6 | import uritemplate 7 | 8 | sys.path.append("adabot") 9 | import github_requests as github 10 | 11 | exit_status = 0 12 | 13 | for dirpath, dirnames, filenames in os.walk("../bin"): 14 | if not filenames: 15 | continue 16 | for filename in filenames: 17 | full_filename = os.path.join(dirpath, filename) 18 | label = filename.replace("adafruit-circuitpython-", "") 19 | url_vars = {} 20 | url_vars["name"] = filename 21 | url_vars["label"] = label 22 | url = uritemplate.expand(os.environ["UPLOAD_URL"], url_vars) 23 | headers = {"content-type": "application/octet-stream"} 24 | print(url) 25 | with open(full_filename, "rb") as f: 26 | response = github.post(url, data=f, headers=headers) 27 | if not response.ok: 28 | if response.status_code == 422 and response.json().get("errors", [{"code":""}])[0]["code"] == "already_exists": 29 | print("File already uploaded. Skipping.") 30 | continue 31 | print("Upload of {} failed with {}.".format(filename, response.status_code)) 32 | print(response.text) 33 | sys.exit(response.status_code) 34 | 35 | sys.exit(exit_status) 36 | -------------------------------------------------------------------------------- /fido2_u2f/boot.py: -------------------------------------------------------------------------------- 1 | import storage 2 | storage.remount("/") 3 | -------------------------------------------------------------------------------- /fido2_u2f/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p build/ 4 | for py in *.py; do 5 | if [ $py == "main.py" ] || [ $py == "boot.py" ]; then 6 | continue 7 | fi 8 | ../adapted-circuitpython/mpy-cross/mpy-cross $py 9 | done 10 | -------------------------------------------------------------------------------- /fido2_u2f/cert.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmvr/pykey/96503b4889d31cd6dc1cd649c5f7ffcfa6a225ed/fido2_u2f/cert.der -------------------------------------------------------------------------------- /fido2_u2f/ctap_errors.py: -------------------------------------------------------------------------------- 1 | CTAP2_OK = b'\x00' # Indicates successful response. 2 | CTAP1_ERR_INVALID_LENGTH = b'\x03' # Invalid message or item length. 3 | CTAP2_ERR_CBOR_UNEXPECTED_TYPE = b'\x11' # Invalid/unexpected CBOR error. 4 | CTAP2_ERR_INVALID_CBOR = b'\x12' # Error when parsing CBOR. 5 | CTAP2_ERR_MISSING_PARAMETER = b'\x14' # Missing non-optional parameter. 6 | CTAP2_ERR_LIMIT_EXCEEDED = b'\x15' # Limit for number of items exceeded. 7 | CTAP2_ERR_UNSUPPORTED_EXTENSION = b'\x16' # Unsupported extension. 8 | CTAP2_ERR_CREDENTIAL_EXCLUDED = b'\x19' # Valid credential found in the exclude list. 9 | CTAP2_ERR_PROCESSING = b'\x21' # Processing (Lengthy operation is in progress'. 10 | CTAP2_ERR_INVALID_CREDENTIAL = b'\x22' # Credential not valid for the authenticator. 11 | CTAP2_ERR_USER_ACTION_PENDING = b'\x23' # Authentication is waiting for user interaction. 12 | CTAP2_ERR_OPERATION_PENDING = b'\x24' # Processing, lengthy operation is in progress. 13 | CTAP2_ERR_NO_OPERATIONS = b'\x25' # No request is pending. 14 | CTAP2_ERR_UNSUPPORTED_ALGORITHM = b'\x26' # Authenticator does not support requested algorithm. 15 | CTAP2_ERR_OPERATION_DENIED = b'\x27' # Not authorized for requested operation. 16 | CTAP2_ERR_KEY_STORE_FULL = b'\x28' # Internal key storage is full. 17 | CTAP2_ERR_NO_OPERATION_PENDING = b'\x2A' # No outstanding operations. 18 | CTAP2_ERR_UNSUPPORTED_OPTION = b'\x2B' # Unsupported option. 19 | CTAP2_ERR_INVALID_OPTION = b'\x2C' # Not a valid option for current operation. 20 | CTAP2_ERR_KEEPALIVE_CANCEL = b'\x2D' # Pending keep alive was cancelled. 21 | CTAP2_ERR_NO_CREDENTIALS = b'\x2E' # No valid credentials provided. 22 | CTAP2_ERR_USER_ACTION_TIMEOUT = b'\x2F' # Timeout waiting for user interaction. 23 | CTAP2_ERR_NOT_ALLOWED = b'\x30' # Continuation command, such as, authenticatorGetNextAssertion not allowed. 24 | CTAP2_ERR_PIN_INVALID = b'\x31' # PIN Invalid. 25 | CTAP2_ERR_PIN_BLOCKED = b'\x32' # PIN Blocked. 26 | CTAP2_ERR_PIN_AUTH_INVALID = b'\x33' # PIN authentication,pinAuth, verification failed. 27 | CTAP2_ERR_PIN_AUTH_BLOCKED = b'\x34' # PIN authentication,pinAuth, blocked. Requires power recycle to reset. 28 | CTAP2_ERR_PIN_NOT_SET = b'\x35' # No PIN has been set. 29 | CTAP2_ERR_PIN_REQUIRED = b'\x36' # PIN is required for the selected operation. 30 | CTAP2_ERR_PIN_POLICY_VIOLATION = b'\x37' # PIN policy violation. Currently only enforces minimum length. 31 | CTAP2_ERR_PIN_TOKEN_EXPIRED = b'\x38' # pinToken expired on authenticator. 32 | CTAP2_ERR_REQUEST_TOO_LARGE = b'\x39' # Authenticator cannot handle this request due to memory constraints. 33 | CTAP2_ERR_ACTION_TIMEOUT = b'\x3A' # The current operation has timed out. 34 | CTAP2_ERR_UP_REQUIRED = b'\x3B' # User presence is required for the requested operation. 35 | CTAP1_ERR_OTHER = b'\x7f' # Other unspecified error. 36 | CTAP2_ERR_SPEC_LAST = b'\xDF' # CTAP 2 spec last error. 37 | CTAP2_ERR_EXTENSION_FIRST = b'\xE0' # Extension specific error. 38 | CTAP2_ERR_EXTENSION_LAST = b'\xEF' # Extension specific error. 39 | CTAP2_ERR_VENDOR_FIRST = b'\xF0' # Vendor specific error. 40 | CTAP2_ERR_VENDOR_LAST = b'\xFF' # Vendor specific error. 41 | -------------------------------------------------------------------------------- /fido2_u2f/main.py: -------------------------------------------------------------------------------- 1 | def initialize(): 2 | from microcontroller import nvm 3 | if nvm[:5] == bytes(5): 4 | from keystore import KS_CTAP2, KS_PIN, KS_U2F, Counter 5 | for k in [KS_CTAP2(), KS_PIN(), KS_U2F()]: 6 | k.gen_new_keys() 7 | k.save_keystore() 8 | Counter(0).reset() 9 | Counter(4).reset() 10 | 11 | 12 | def loop(): 13 | import hid 14 | from u2f import u2f 15 | from ctap2 import ctap2 16 | from ctap_errors import CTAP2_ERR_KEEPALIVE_CANCEL 17 | from up_check import ButtonLongPressed 18 | from util import reboot_to_bootloader 19 | 20 | h = hid.hid() 21 | blp = ButtonLongPressed(4) 22 | 23 | ret = None 24 | while True: 25 | if blp.check() is True: 26 | reboot_to_bootloader() 27 | ret = h.receive() 28 | if ret is not None: 29 | cmd, data = ret 30 | if cmd in (hid.CTAPHID_MSG, hid.CTAPHID_CBOR): 31 | if cmd == hid.CTAPHID_MSG: 32 | h.send(cmd, u2f(data)) 33 | else: 34 | resp = ctap2(data, h) 35 | if h.is_cancelled(): 36 | h.send(cmd, CTAP2_ERR_KEEPALIVE_CANCEL) 37 | else: 38 | h.send(cmd, resp) 39 | 40 | 41 | initialize() 42 | try: 43 | loop() 44 | except: 45 | while True: 46 | pass # needs a power recycle 47 | -------------------------------------------------------------------------------- /fido2_u2f/up_check.py: -------------------------------------------------------------------------------- 1 | from micropython import const 2 | from time import sleep, monotonic 3 | from board import LED1, SW1 4 | from digitalio import DigitalInOut, Direction 5 | from ctap_errors import CTAP2_OK, CTAP2_ERR_ACTION_TIMEOUT, CTAP2_ERR_KEEPALIVE_CANCEL 6 | 7 | DELAY_TIME = const(10) # 10 ms 8 | WINK_FREQ = const(10) # Hz 9 | 10 | 11 | def up_check(channel, led_type=LED1): 12 | led = DigitalInOut(led_type) 13 | led.direction = Direction.OUTPUT 14 | button = DigitalInOut(SW1) 15 | button.direction = Direction.INPUT 16 | MAX_TIME = const(10000) # 10 seconds 17 | counter = 0 18 | ka_counter = 0 19 | while True: 20 | if button.value is False: 21 | led.deinit() 22 | button.deinit() 23 | return CTAP2_OK 24 | if counter >= MAX_TIME: 25 | led.deinit() 26 | button.deinit() 27 | return CTAP2_ERR_ACTION_TIMEOUT 28 | if ((counter * WINK_FREQ) // 2000) % 2 == 0: 29 | led.value = False 30 | else: 31 | led.value = True 32 | sleep(DELAY_TIME / 1000) 33 | counter += DELAY_TIME 34 | ka_counter += DELAY_TIME 35 | if ka_counter > 70: 36 | if channel is not None: 37 | if channel.is_cancelled(): 38 | led.deinit() 39 | button.deinit() 40 | return CTAP2_ERR_KEEPALIVE_CANCEL 41 | channel.keepalive(channel.STATUS_UPNEEDED) 42 | ka_counter = 0 43 | 44 | 45 | def u2f_up_check(led_type=LED1): 46 | led = DigitalInOut(led_type) 47 | led.direction = Direction.OUTPUT 48 | button = DigitalInOut(SW1) 49 | button.direction = Direction.INPUT 50 | MAX_U2F_TIME = const(50) # 50 ms 51 | counter = 0 52 | led.value = False 53 | while True: 54 | if button.value is False: 55 | led.value = True 56 | led.deinit() 57 | button.deinit() 58 | return CTAP2_OK 59 | if counter >= MAX_U2F_TIME: 60 | led.value = True 61 | led.deinit() 62 | button.deinit() 63 | return CTAP2_ERR_ACTION_TIMEOUT 64 | sleep(DELAY_TIME / 1000) 65 | counter += DELAY_TIME 66 | 67 | 68 | class ButtonLongPressed: 69 | def __init__(self, period): 70 | self.period = period 71 | self.last_button_pressed = monotonic() - 10.0 72 | self.button_pressed_duration = 0.0 73 | 74 | def check(self): 75 | button = DigitalInOut(SW1) 76 | button.direction = Direction.INPUT 77 | if button.value is True: 78 | # no button button pressed 79 | button.deinit() 80 | return False 81 | else: 82 | button.deinit() 83 | t = monotonic() 84 | if t - self.last_button_pressed < 0.05: 85 | self.button_pressed_duration += t - self.last_button_pressed 86 | self.last_button_pressed = t 87 | if self.button_pressed_duration > self.period: 88 | self.button_pressed_duration = 0.0 89 | return True 90 | -------------------------------------------------------------------------------- /fido2_u2f/util.py: -------------------------------------------------------------------------------- 1 | def der_encode_signature(r, s): 2 | # sig = 30 len(r)+len(s)+4 02 len(r) r 02 len(s) s 3 | while r[0] == 0: 4 | r = r[1:] 5 | if r[0] & 0x80 != 0: 6 | r = b'\x00' + r 7 | while s[0] == 0: 8 | s = s[1:] 9 | if s[0] & 0x80 != 0: 10 | s = b'\x00' + s 11 | return bytes((0x30, 12 | len(r) + len(s) + 4, 0x02, 13 | len(r))) + r + bytes((0x02, len(s))) + s 14 | 15 | 16 | def reboot_to_bootloader(): 17 | import microcontroller 18 | microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER) 19 | microcontroller.reset() 20 | -------------------------------------------------------------------------------- /fido2_u2f/utils/make_cheader.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from os.path import basename 3 | import re 4 | 5 | defs = """#include 6 | 7 | struct file { 8 | char filename[30]; 9 | int len; 10 | const uint8_t *data; 11 | }; 12 | 13 | """ 14 | VERSION = 3 15 | 16 | with open("fido-drive.h", "r") as fin: 17 | s = re.search('^const uint32_t version = (\d+)', fin.read(), re.MULTILINE) 18 | VERSION = int(s.group(1)) + 1 19 | 20 | with open("fido-drive.h", "w") as fout: 21 | fout.write(defs); 22 | for fn in sys.argv[1:]: 23 | bn = basename(fn) 24 | fp = bn.split('.')[0] 25 | data = open(fn, 'rb').read() 26 | fout.write('const uint8_t %s_data[] = {' % fp); 27 | fout.write(', '.join(['0x%02x' % x for x in data])) 28 | fout.write('};\n') 29 | fout.write('const struct file file_%s = {"%s", %d, %s};\n\n' % (fp, bn, len(data), fp+'_data')) 30 | fout.write('const struct file *filesystem[] = {') 31 | fout.write(', '.join(['&file_%s' % basename(x).split('.')[0] for x in sys.argv[1:]])) 32 | fout.write('};\n\n') 33 | fout.write('const uint32_t version = %d;\n' % VERSION) 34 | fout.write('const struct file file_version = {"version.bin", 4, (uint8_t*)(&version)};\n') 35 | 36 | -------------------------------------------------------------------------------- /fido2_u2f/wink.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | import board 3 | from digitalio import DigitalInOut, Direction 4 | 5 | 6 | def flash_led(): 7 | led = DigitalInOut(board.LED1) 8 | led.direction = Direction.OUTPUT 9 | for i in range(10): 10 | if i % 2 == 0: 11 | led.value = True 12 | else: 13 | led.value = False 14 | sleep(0.08) 15 | -------------------------------------------------------------------------------- /modules/cc310/aes.h: -------------------------------------------------------------------------------- 1 | #ifndef _AES_H_ 2 | #define _AES_H_ 3 | 4 | #include 5 | 6 | // #define the macros below to 1/0 to enable/disable the mode of operation. 7 | // 8 | // CBC enables AES encryption in CBC-mode of operation. 9 | // CTR enables encryption in counter-mode. 10 | // ECB enables the basic ECB 16-byte block algorithm. All can be enabled simultaneously. 11 | 12 | // The #ifndef-guard allows it to be configured before #include'ing or at compile time. 13 | #ifndef CBC 14 | #define CBC 1 15 | #endif 16 | 17 | //#ifndef ECB 18 | // #define ECB 1 19 | //#endif 20 | 21 | //#ifndef CTR 22 | // #define CTR 1 23 | //#endif 24 | 25 | 26 | //#define AES128 1 27 | //#define AES192 1 28 | #define AES256 1 29 | 30 | #define AES_BLOCKLEN 16 //Block length in bytes AES is 128b block only 31 | 32 | #if defined(AES256) && (AES256 == 1) 33 | #define AES_KEYLEN 32 34 | #define AES_keyExpSize 240 35 | #elif defined(AES192) && (AES192 == 1) 36 | #define AES_KEYLEN 24 37 | #define AES_keyExpSize 208 38 | #else 39 | #define AES_KEYLEN 16 // Key length in bytes 40 | #define AES_keyExpSize 176 41 | #endif 42 | 43 | struct AES_ctx 44 | { 45 | uint8_t RoundKey[AES_keyExpSize]; 46 | #if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1)) 47 | uint8_t Iv[AES_BLOCKLEN]; 48 | #endif 49 | }; 50 | 51 | void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key); 52 | #if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1)) 53 | void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv); 54 | void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv); 55 | #endif 56 | 57 | #if defined(ECB) && (ECB == 1) 58 | // buffer size is exactly AES_BLOCKLEN bytes; 59 | // you need only AES_init_ctx as IV is not used in ECB 60 | // NB: ECB is considered insecure for most uses 61 | void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf); 62 | void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf); 63 | 64 | #endif // #if defined(ECB) && (ECB == !) 65 | 66 | 67 | #if defined(CBC) && (CBC == 1) 68 | // buffer size MUST be mutile of AES_BLOCKLEN; 69 | // Suggest https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme 70 | // NOTES: you need to set IV in ctx via AES_init_ctx_iv() or AES_ctx_set_iv() 71 | // no IV should ever be reused with the same key 72 | void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length); 73 | void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length); 74 | 75 | #endif // #if defined(CBC) && (CBC == 1) 76 | 77 | 78 | #if defined(CTR) && (CTR == 1) 79 | 80 | // Same function for encrypting as for decrypting. 81 | // IV is incremented for every block, and used after encryption as XOR-compliment for output 82 | // Suggesting https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme 83 | // NOTES: you need to set IV in ctx with AES_init_ctx_iv() or AES_ctx_set_iv() 84 | // no IV should ever be reused with the same key 85 | void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length); 86 | 87 | #endif // #if defined(CTR) && (CTR == 1) 88 | 89 | 90 | #endif //_AES_H_ 91 | -------------------------------------------------------------------------------- /modules/cc310/libnrf_cc310_0.9.12.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmvr/pykey/96503b4889d31cd6dc1cd649c5f7ffcfa6a225ed/modules/cc310/libnrf_cc310_0.9.12.a -------------------------------------------------------------------------------- /modules/cc310/micropython.mk: -------------------------------------------------------------------------------- 1 | EXAMPLE_MOD_DIR := $(USERMOD_DIR) 2 | 3 | # Add all C files to SRC_USERMOD. 4 | SRC_USERMOD += $(EXAMPLE_MOD_DIR)/cc310.c $(EXAMPLE_MOD_DIR)/aes.c 5 | 6 | # We can add our module folder to include paths if needed 7 | # This is not actually needed in this example. 8 | CFLAGS_USERMOD += -I$(EXAMPLE_MOD_DIR) 9 | --------------------------------------------------------------------------------