Skip to content

cpu/nrf5x: Pull Vendor Header Files from External Repository#21800

Merged
maribu merged 2 commits intoRIOT-OS:masterfrom
crasbe:pr/nrf52_vendor
Oct 18, 2025
Merged

cpu/nrf5x: Pull Vendor Header Files from External Repository#21800
maribu merged 2 commits intoRIOT-OS:masterfrom
crasbe:pr/nrf52_vendor

Conversation

@crasbe
Copy link
Copy Markdown
Contributor

@crasbe crasbe commented Oct 16, 2025

Contribution description

As discussed in #21739, it would be nice to exclude the Nordic nRF5x vendor header files from RIOT, as these are big and updating them means multi-thousand line commits and pull requests.

Current issues:

  • When not using git-cache-rs, the build system will not perform a sparse checkout and will download the full 230-ish MB of nrfx, this is not ideal.
  • The package is currently named anrfx_mdk because it has to be built before mpaland-printf, and inconveniently N comes after M in the alphabet... This has never been a problem before because cmsis starts with C and esp32-sdk with E, which are both waaaay before M. Fixed: now using the same mechanism that stm32 uses.
  • Ideally I would like to avoid having nrfx and nrfx_mdk as essentially the same packages, however I'm not sure how to handle the case when the full nrfx is used.

Status:

  • Only nRF52832 and nRF52840 work, but migrating everything else is trivial (I just have to add the PKG_SPARSE_PATHs).
  • Everything should work.

Testing procedure

Make sure all your applications still work.

Issues/PRs references

Came up in #21739.

@crasbe crasbe requested a review from aabadie as a code owner October 16, 2025 13:59
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: help wanted The contributors require help from other members of the community CI: no fast fail don't abort PR build after first error labels Oct 16, 2025
@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: pkg Area: External package ports Area: cpu Area: CPU/MCU ports labels Oct 16, 2025
@riot-ci
Copy link
Copy Markdown

riot-ci commented Oct 16, 2025

Murdock results

✔️ PASSED

4752d2e cpu/nrf5x_common: remove local vendor header files from sourcetree

Success Failures Total Runtime
10549 0 10551 08m:27s

Artifacts

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Oct 16, 2025

image

Nice :)

@github-actions github-actions bot removed the Area: pkg Area: External package ports label Oct 16, 2025
@crasbe crasbe requested a review from kaspar030 as a code owner October 16, 2025 15:20
@github-actions github-actions bot added the Area: CI Area: Continuous Integration of RIOT components label Oct 16, 2025
@crasbe crasbe removed the Community: help wanted The contributors require help from other members of the community label Oct 16, 2025
@github-actions github-actions bot removed the Area: CI Area: Continuous Integration of RIOT components label Oct 17, 2025
@crasbe crasbe enabled auto-merge October 17, 2025 17:47
@crasbe crasbe added this pull request to the merge queue Oct 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 17, 2025
@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Oct 17, 2025

So I had to change basically two things: the patching of the vendor files worked only once, so switching from nRF52 to nRF53 caused an error related to the unpatched header. This did not occur in CI because CI always starts with a clean slate.

The second thing is that apparently there are different nRF51 variants, nRF51x22xxaa and nRF51x22xxab. Therefore I just added a wildcard to after the nrf51x22% to cover both cases.
Same with the nRF5304, that can have an _app or _net (we don't have the latter yet) appendix. For some reason it didn't trigger in the CI (yet), even with the nRF5340DK-app board that I selected because the selection of tests did not need the header I guess? Who knows...

@crasbe crasbe enabled auto-merge October 17, 2025 20:17
@crasbe crasbe added this pull request to the merge queue Oct 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 17, 2025
@crasbe crasbe added the CI: full build disable CI build filter label Oct 17, 2025
@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Oct 17, 2025

the patching of the vendor files worked only once, so switching from nRF52 to nRF53 caused an error related to the unpatched header. This did not occur in CI because CI always starts with a clean slate.

That wasn't enough because we're not pulling all the nRF52xxx files at once but only the required ones. Changing the subdirectories to $(CPU_MODEL) would cause unnecessary duplication, so I just decided to pull all family headers at the same time.

@crasbe crasbe removed the CI: full build disable CI build filter label Oct 17, 2025
@crasbe crasbe enabled auto-merge October 17, 2025 21:21
@crasbe crasbe disabled auto-merge October 17, 2025 21:21
@crasbe crasbe requested a review from maribu October 17, 2025 21:21
@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Oct 17, 2025

Perhaps I shouldn't have squashed it already... sorry :/

@crasbe crasbe added this to the Release 2025.10 milestone Oct 17, 2025
@maribu maribu added this pull request to the merge queue Oct 18, 2025
@maribu
Copy link
Copy Markdown
Member

maribu commented Oct 18, 2025

No, please squash right away after the ACK, unless the change is significant

Merged via the queue into RIOT-OS:master with commit d51045b Oct 18, 2025
25 checks passed
@maribu
Copy link
Copy Markdown
Member

maribu commented Oct 18, 2025

Hooray! 🎉

@elenaf9
Copy link
Copy Markdown
Contributor

elenaf9 commented Oct 22, 2025

I just tried building the gnrc_networking example for the nrf52dk board and it doesn't compile anymore:

RIOT/build/nrf5x_nrfx_mdk/nrf52/drivers/nrfx_common.h:46:10: fatal error: nrf_mem.h: No such file or directory
   46 | #include <nrf_mem.h>
      |          ^~~~~~~~~~~
compilation terminated.

I guess it's somehow related to this PR?

@maribu
Copy link
Copy Markdown
Member

maribu commented Oct 22, 2025

@maribu
Copy link
Copy Markdown
Member

maribu commented Oct 22, 2025

diff --git a/cpu/nrf5x_common/Makefile.include b/cpu/nrf5x_common/Makefile.include
index cef6356d92..038c7701c3 100644
--- a/cpu/nrf5x_common/Makefile.include
+++ b/cpu/nrf5x_common/Makefile.include
@@ -19,7 +19,7 @@ ifneq (,$(filter nrf53%,$(CPU_MODEL)))
 else
   NRF5XFAM_INCLUDE_FILE = $(NRF5XFAM_INCLUDE_DIR)/vendor/$(CPU_FAM).h
 endif
-INCLUDES += -I$(NRF5XFAM_INCLUDE_DIR)
+INCLUDES += -I$(NRF5XFAM_INCLUDE_DIR) -I$(NRF5XFAM_INCLUDE_DIR)/vendor
 
 # Fetch all nRF52 vendor headers using the package mechanism. This rule is called all
 # the time to ensure it's correctly updated when versions in the packages are

fixes the issue for me. But I think we probably should first look into reproducing the issue in the CI to prevent this from popping up again before fixing the issue.

@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Oct 22, 2025

I know why that happens locally and not with the CI... The CI uses the Rust Git-Cache while you probably don't use it locally. The "old" version of the git cache as well as the non-cached versions don't do sparse checkouts. Therefore it clones the full nrfx and for some reason it seems to prefer the should-be-sparse folder over the actual nrfx folder.

cbuec@W11nMate:~/RIOTstuff/riot-guides/RIOT$ GIT_CACHE_RS=~/.cargo/bin/git-cache BOARD=nrf52dk make -C examp
les/networking/gnrc/gnrc_networking -j
make: Entering directory '/home/cbuec/RIOTstuff/riot-guides/RIOT/examples/networking/gnrc/gnrc_networking'
Building application "gnrc_networking" for "nrf52dk" with CPU "nrf52".

Cloning into '/home/cbuec/RIOTstuff/riot-guides/RIOT/build/nrf5x_nrfx_mdk/nrf52'...
done.
HEAD is now at 11f57e5 nrfx 3.14.0 release
Cloning into '/home/cbuec/RIOTstuff/riot-guides/RIOT/build/pkg/cmsis'...
done.
HEAD is now at 2b7495b85 Merge branch 'develop'
Cloning into '/home/cbuec/RIOTstuff/riot-guides/RIOT/build/pkg/mpaland-printf'...
done.
HEAD is now at 0dd4b64 test(test_suite): added support for PRINTF_DISABLE_SUPPORT_EXPONENTIAL
git-cache: cloning https://github.com/apache/mynewt-nimble.git into cache...
Cloning into bare repository '/home/cbuec/.gitcache/15402765282127293223.git'...
remote: Enumerating objects: 68261, done.
remote: Counting objects: 100% (2185/2185), done.
remote: Compressing objects: 100% (986/986), done.
remote: Total 68261 (delta 1737), reused 1203 (delta 1199), pack-reused 66076 (from 4)
Receiving objects: 100% (68261/68261), 20.97 MiB | 11.74 MiB/s, done.
Resolving deltas: 100% (44302/44302), done.
Cloning into '/home/cbuec/RIOTstuff/riot-guides/RIOT/build/pkg/nimble'...
done.
HEAD is now at 719bd3c43 drivers/nrf51: add missing include of os_cputime.h
Cloning into '/home/cbuec/RIOTstuff/riot-guides/RIOT/build/pkg/nrfx'...
done.
HEAD is now at 3521c97 nrfx 2.7.0 release
git-cache: cloning https://github.com/01org/tinycrypt into cache...
Cloning into bare repository '/home/cbuec/.gitcache/10412693831896225484.git'...
remote: Enumerating objects: 1100, done.
remote: Counting objects: 100% (431/431), done.
remote: Compressing objects: 100% (149/149), done.
remote: Total 1100 (delta 318), reused 282 (delta 282), pack-reused 669 (from 1)
Receiving objects: 100% (1100/1100), 1.13 MiB | 7.58 MiB/s, done.
Resolving deltas: 100% (727/727), done.
Cloning into '/home/cbuec/RIOTstuff/riot-guides/RIOT/build/pkg/tinycrypt'...
done.
HEAD is now at 5969b0e Merge pull request #40 from winnietwo/side_channel_patch
"make" -C /home/cbuec/RIOTstuff/riot-guides/RIOT/pkg/cmsis/
...
"make" -C /home/cbuec/RIOTstuff/riot-guides/RIOT/sys/net/gnrc/transport_layer/udp
   text    data     bss     dec     hex filename
 159788     352   38828  198968   30938 /home/cbuec/RIOTstuff/riot-guides/RIOT/examples/networking/gnrc/gnrc_networking/bin/nrf52dk/gnrc_networking.elf
make: Leaving directory '/home/cbuec/RIOTstuff/riot-guides/RIOT/examples/networking/gnrc/gnrc_networking'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: cpu Area: CPU/MCU ports CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants