-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add Nordic nRF54L15-DK variant (Zephyr + BLE + LoRa) #10193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cvaldess
wants to merge
9
commits into
meshtastic:develop
Choose a base branch
from
cvaldess:feature/nrf54l15-port
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
094346c
feat: add Nordic nRF54L15-DK variant (Zephyr + BLE + LoRa)
cvaldess 2bf7c69
fix(nrf54l15): use atomic fs_rename instead of copy fallback
cvaldess c69cabe
fix(nrf54l15): expand storage_partition from 36KB to 700KB
cvaldess f5210fa
fix(nrf54l15): drop USERPREFS_LORACONFIG_* so LoRa config stays mutable
cvaldess 34e62e5
fix(nrf54l15): enforce MITM passkey pairing on GATT service
cvaldess 99c6819
Merge remote-tracking branch 'upstream/develop' into feature/nrf54l15…
cvaldess e45b673
Merge branch 'develop' into feature/nrf54l15-port
thebentern f16ed41
fix(nrf54l15): resolve develop-merge conflict + cppcheck warnings
cvaldess f02a5e3
Merge remote-tracking branch 'upstream/develop' into feature/nrf54l15…
cvaldess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "build": { | ||
| "cpu": "cortex-m33", | ||
| "f_cpu": "128000000L", | ||
| "mcu": "nrf54l15", | ||
| "zephyr": { | ||
| "variant": "nrf54l15dk/nrf54l15/cpuapp" | ||
| } | ||
| }, | ||
| "connectivity": [ | ||
| "bluetooth" | ||
| ], | ||
| "debug": { | ||
| "default_tools": [ | ||
| "jlink" | ||
| ], | ||
| "jlink_device": "nRF54L15_M33", | ||
| "svd_path": "nrf54l15.svd" | ||
| }, | ||
| "frameworks": [ | ||
| "zephyr" | ||
| ], | ||
| "name": "Nordic nRF54L15-DK (PCA10156)", | ||
| "upload": { | ||
| "maximum_ram_size": 262144, | ||
| "maximum_size": 1572864, | ||
| "protocol": "jlink", | ||
| "protocols": [ | ||
| "jlink" | ||
| ] | ||
| }, | ||
| "url": "https://www.nordicsemi.com/Products/nRF54L15", | ||
| "vendor": "Nordic Semiconductor" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # post:extra_scripts/nrf54l15_linker.py | ||
| # | ||
| # Fix for Zephyr two-pass link on nRF54L15: | ||
| # platformio-build.py registers env.Depends("$PROG_PATH", final_ld_script) but | ||
| # the SCons dependency chain is broken (final_ld_script Command never runs). | ||
| # This script adds a PreAction on the final firmware binary that runs the gcc | ||
| # preprocessing command directly (extracted from build.ninja) to generate | ||
| # zephyr/linker.cmd before the link step. | ||
| # | ||
| # PlatformIO bundles an old Ninja that can't handle multi-output depslog rules, | ||
| # so we parse the COMMAND line from build.ninja and run just the gcc -E part, | ||
| # skipping the cmake_transform_depfile step (only needed for Ninja deps tracking). | ||
|
|
||
| Import("env") | ||
| import os | ||
| import re | ||
| import subprocess | ||
|
|
||
| if env.get("PIOENV") != "nrf54l15dk": | ||
| pass # Only for the nrf54l15dk environment | ||
| else: | ||
|
|
||
| def _extract_gcc_command(ninja_build): | ||
| """Parse build.ninja to find the gcc -E command that generates linker.cmd. | ||
|
|
||
| The rule looks like: | ||
| build zephyr/linker.cmd | ...: CUSTOM_COMMAND ... | ||
| COMMAND = cmd.exe /C "cd /D ZEPHYR_DIR && arm-none-eabi-gcc.exe ... -o linker.cmd && cmake.exe -E cmake_transform_depfile ..." | ||
| DESC = Generating linker.cmd | ||
|
|
||
| Returns (gcc_cmd_string, cwd_path) or raises RuntimeError. | ||
| """ | ||
| in_rule = False | ||
| with open(ninja_build, "r", encoding="utf-8", errors="replace") as f: | ||
| for line in f: | ||
| # Detect start of the linker.cmd custom command rule | ||
| if not in_rule: | ||
| if "build zephyr/linker.cmd" in line and "CUSTOM_COMMAND" in line: | ||
| in_rule = True | ||
| continue | ||
|
|
||
| stripped = line.strip() | ||
| if not stripped.startswith("COMMAND = "): | ||
| continue | ||
|
|
||
| command_val = stripped[len("COMMAND = ") :] | ||
|
|
||
| # The value is: C:\Windows\system32\cmd.exe /C "cd /D DIR && GCC_CMD && cmake ..." | ||
| # Extract the content between the outermost double-quotes. | ||
| m = re.search(r'/C\s+"(.*)"', command_val) | ||
| if not m: | ||
| raise RuntimeError( | ||
| "nRF54L15 linker fix: unexpected COMMAND format in build.ninja:\n%s" | ||
| % command_val[:200] | ||
| ) | ||
|
|
||
| inner = m.group(1) # "cd /D DIR && GCC_CMD && cmake ..." | ||
| parts = inner.split(" && ") | ||
|
|
||
| cwd = None | ||
| gcc_cmd = None | ||
| for part in parts: | ||
| part = part.strip() | ||
| if part.startswith("cd /D "): | ||
| cwd = part[len("cd /D ") :] | ||
| elif "arm-none-eabi-gcc" in part: | ||
| gcc_cmd = part | ||
|
|
||
| if not gcc_cmd: | ||
| raise RuntimeError( | ||
| "nRF54L15 linker fix: arm-none-eabi-gcc command not found in:\n%s" | ||
| % inner[:400] | ||
| ) | ||
|
|
||
| return gcc_cmd, cwd | ||
|
|
||
| raise RuntimeError( | ||
| "nRF54L15 linker fix: 'build zephyr/linker.cmd' rule not found in build.ninja" | ||
| ) | ||
|
|
||
| def _generate_linker_cmd(target, source, env): | ||
| """Generate zephyr/linker.cmd via direct gcc invocation before the final link.""" | ||
| build_dir = env.subst("$BUILD_DIR") | ||
| zephyr_dir = os.path.join(build_dir, "zephyr") | ||
| linker_cmd = os.path.join(zephyr_dir, "linker.cmd") | ||
|
|
||
| if os.path.exists(linker_cmd): | ||
| return # Already present — nothing to do | ||
|
|
||
| ninja_build = os.path.join(build_dir, "build.ninja") | ||
| if not os.path.exists(ninja_build): | ||
| raise RuntimeError( | ||
| "nRF54L15 linker fix: build.ninja not found at %s\n" | ||
| "Run a full build first so CMake generates the Ninja files." | ||
| % ninja_build | ||
| ) | ||
|
|
||
| gcc_cmd, cwd = _extract_gcc_command(ninja_build) | ||
| run_cwd = cwd if cwd else zephyr_dir | ||
|
|
||
| print( | ||
| "==> nRF54L15: Generating zephyr/linker.cmd (LINKER_ZEPHYR_FINAL) via GCC" | ||
| ) | ||
| # gcc_cmd comes verbatim from our own build.ninja (never user input) and | ||
| # contains Windows-style paths with spaces that cannot be safely argv-split | ||
| # with shlex, so we run it via the platform shell. nosec/nosemgrep below | ||
| # acknowledge this deliberate, scoped use of shell=True. | ||
| result = subprocess.run( # nosec B602 | ||
| gcc_cmd, | ||
| shell=True, # nosemgrep: python.lang.security.audit.subprocess-shell-true.subprocess-shell-true | ||
| cwd=run_cwd, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| if result.returncode != 0: | ||
| print("GCC stdout:", result.stdout[:2000]) | ||
| print("GCC stderr:", result.stderr[:2000]) | ||
| raise RuntimeError( | ||
| "nRF54L15 linker fix: GCC failed to generate linker.cmd (rc=%d)" | ||
| % result.returncode | ||
| ) | ||
| if not os.path.exists(linker_cmd): | ||
| raise RuntimeError( | ||
| "nRF54L15 linker fix: GCC returned 0 but linker.cmd was not created at %s" | ||
| % linker_cmd | ||
| ) | ||
| print("==> linker.cmd generated successfully") | ||
|
|
||
| # Use PIOMAINPROG (set by ZephyrBuildProgram) to get the exact SCons node | ||
| prog = env.get("PIOMAINPROG") | ||
| if prog: | ||
| env.AddPreAction(prog, _generate_linker_cmd) | ||
| else: | ||
| print( | ||
| "[nrf54l15_linker] WARNING: PIOMAINPROG not set, falling back to $PROG_PATH" | ||
| ) | ||
| env.AddPreAction(env.subst("$PROG_PATH"), _generate_linker_cmd) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_extract_gcc_command()assumes the NinjaCOMMAND =line is wrapped ascmd.exe /C "..."and hard-fails if that regex doesn't match. On non-Windows hosts (Linux/macOS CI/users) Zephyr's Ninja command format typically won’t usecmd.exe, so this script is likely to break the nrf54l15dk build. Consider making the parser cross-platform (handle non-cmd.exe formats) or gating this workaround to Windows only and falling back gracefully when the expected pattern isn’t found.