Skip to content
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

sdp: cmake: soc-specific files #19095

Merged
merged 9 commits into from
Feb 4, 2025

Conversation

masz-nordic
Copy link
Contributor

Add soc-specific asm files.
Add common wrapper for all SDP asm related cmake functions.

@masz-nordic masz-nordic requested review from a team as code owners November 27, 2024 12:46
@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Nov 27, 2024
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Nov 27, 2024

CI Information

To view the history of this post, clich the 'edited' button above
Build number: 13

Inputs:

Sources:

sdk-nrf: PR head: d2fa56cf5bb08c22bcac8548859cedab2d314039

more details

sdk-nrf:

PR head: d2fa56cf5bb08c22bcac8548859cedab2d314039
merge base: 571676740aacb35db0cc99ee67a5598820ed1c59
target head (main): c82b2b0a53f78238913390d5a49ef4bd29905c76
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (12)
applications
│  ├── sdp
│  │  ├── gpio
│  │  │  ├── CMakeLists.txt
│  │  │  ├── src
│  │  │  │  ├── hrt
│  │  │  │  │  │ hrt-nrf54l15.s
│  │  ├── mspi
│  │  │  ├── CMakeLists.txt
│  │  │  ├── src
│  │  │  │  ├── hrt
│  │  │  │  │  │ hrt-nrf54l15.s
cmake
│  ├── sdp.cmake
│  ├── sdp_asm_check.cmake
│  │ sdp_asm_install.cmake
tests
│  ├── drivers
│  │  ├── sdp_asm
│  │  │  ├── CMakeLists.txt
│  │  │  ├── pytest
│  │  │  │  │ test_sdp_asm.py
│  │  │  ├── src
│  │  │  │  ├── add_1-nrf54l15.s
│  │  │  │  ├── add_10-nrf54l15.s
│  │  │  │  │ add_100-nrf54l15.s

Outputs:

Toolchain

Version: 342151af73
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:342151af73_912848a074

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister - Skipped: Skipping Build & Test as it succeeded in a previous run: 12
  • ✅ Integration tests
    • ✅ test-sdk-audio - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ desktop52_verification - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-boot - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-apps - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test_ble_nrf_config
    • ✅ test-fw-nrfconnect-ble_mesh - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-ble_samples - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-chip - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nfc - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf-iot_serial_lte_modem - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf-iot_zephyr_lwm2m - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf-iot_samples - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf-iot_lwm2m
    • ✅ doc-internal - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf-iot_thingy91 - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf_crypto - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-rpc - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-rs - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-fem - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-tfm
    • ✅ test-fw-nrfconnect-thread - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-zigbee - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-sdk-find-my - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf-iot_mosh - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-nrf-iot_positioning - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-sdk-sidewalk - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-sdk-wifi - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-low-level - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-sdk-pmic-samples - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-sdk-mcuboot - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-sdk-dfu - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-fw-nrfconnect-ps - Skipped: Job was skipped as it succeeded in a previous run
    • ✅ test-secdom-samples-public - Skipped: Job was skipped as it succeeded in a previous run

Note: This message is automatically posted and updated by the CI

@NordicBuilder
Copy link
Contributor

You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds.

Note: This comment is automatically posted by the Documentation Publish GitHub Action.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 13, 2024

Memory footprint analysis revealed the following potential issues

sample.matter.template.debug[nrf7002dk/nrf5340/cpuapp]: High ROM usage: 912074[B] - link (cc: @kkasperczyk-no @ArekBalysNordic @markaj-nordic)
sample.matter.template.release[nrf7002dk/nrf5340/cpuapp]: High ROM usage: 821050[B] - link (cc: @kkasperczyk-no @ArekBalysNordic @markaj-nordic)

Note: This message is automatically posted and updated by the CI (latest/sdk-nrf/PR-19095/12)

@masz-nordic masz-nordic added this to the 3.0.0 milestone Jan 14, 2025
cmake/sdp.cmake Outdated
@@ -4,6 +4,24 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

function(sdp_assembly hrt_srcs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please describe the function and its arguments.

And would be nice if you could also followup on the same for other functions, as that seems to have been overlooked in #17638

cmake/sdp.cmake Outdated
@@ -4,6 +4,24 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

function(sdp_assembly hrt_srcs)
sdp_assembly_generate("${CMAKE_SOURCE_DIR}/${hrt_srcs}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please allow for hrt_srcs to have absolute path.

Do not assume that that path is always relative.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems my comment was misread.

I asked for the possibility for hrt_srcs to have absolute path, not require it to have absolute path.
CMake has the test: if(IS_ABSOLUTE <path>) https://cmake.org/cmake/help/latest/command/if.html#is-absolute which can be used to test if path should be converted when it's relative.

Note, requiring an absolute path always is also acceptable, so this comment in non-blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep only absolute path for now, if necessary I will make a followup PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully acceptable, only reason for my followup comment was to clarify the intent of my original comment.

cmake/sdp.cmake Outdated
sdp_assembly_prepare_install("${CMAKE_SOURCE_DIR}/${hrt_srcs}")
sdp_assembly_target_sources("${CMAKE_SOURCE_DIR}/${hrt_srcs}")

add_dependencies(app asm_check)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions should not be hardcoded to a given target / library but take this as a function argument.

cmake/sdp.cmake Outdated
get_filename_component(hrt_dir ${hrt_src} DIRECTORY) # directory
get_filename_component(hrt_src_file ${hrt_src} NAME_WE) # filename without extension
set(hrt_s_file "${hrt_dir}/${hrt_src_file}.s")
target_sources(app PRIVATE ${hrt_s_file})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions should not be hardcoded to a given target / library but take this as a function argument.

sdp_assembly_generate("${CMAKE_SOURCE_DIR}/src/hrt/hrt.c")
sdp_assembly_check("${CMAKE_SOURCE_DIR}/src/hrt/hrt.c")
sdp_assembly_prepare_install("${CMAKE_SOURCE_DIR}/src/hrt/hrt.c")
sdp_assembly("src/hrt/hrt.c")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shows that this function name is for from ideal as assembly has no indication that this file will actually be:

  • be stop after compilation proper, to form an assembly file
  • an install target will be created
  • sources will be added to the app library.

This should be improved by a better function name, as well as provided the app target as argument will indicate a relation between the call and the app target.

cmake/sdp.cmake Outdated
BYPRODUCTS ${src_filename}-temp.s
COMMAND ${CMAKE_C_COMPILER} ${compiler_options} ${hrt_opts} -S ${hrt_src} -o ${src_filename}-temp.s
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_NRF_MODULE_DIR}/scripts/sdp/remove_comments.py ${src_filename}-temp.s
BYPRODUCTS ${src_filename}-${target_soc}-temp.s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_soc is undefined if this function is called directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added as a parameter, is that okay or further validation is necessary?

cmake/sdp.cmake Outdated
@@ -80,7 +84,7 @@ function(sdp_assembly_check hrt_srcs)
string(REPLACE ";" "$<SEMICOLON>" hrt_srcs_semi "${hrt_srcs}")

add_custom_target(asm_check
COMMAND ${CMAKE_COMMAND} -D hrt_srcs="${hrt_srcs_semi}" -P ${ZEPHYR_NRF_MODULE_DIR}/cmake/sdp_asm_check.cmake
COMMAND ${CMAKE_COMMAND} -D hrt_srcs="${hrt_srcs_semi}" -D target_soc="${target_soc}" -P ${ZEPHYR_NRF_MODULE_DIR}/cmake/sdp_asm_check.cmake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_soc is undefined if this function is called directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added as a parameter, is that okay or further validation is necessary?

cmake/sdp.cmake Outdated
@@ -100,7 +104,7 @@ function(sdp_assembly_prepare_install hrt_srcs)
string(REPLACE ";" "$<SEMICOLON>" hrt_srcs_semi "${hrt_srcs}")

add_custom_target(asm_install
COMMAND ${CMAKE_COMMAND} -D hrt_srcs="${hrt_srcs_semi}" -P ${ZEPHYR_NRF_MODULE_DIR}/cmake/sdp_asm_install.cmake
COMMAND ${CMAKE_COMMAND} -D hrt_srcs="${hrt_srcs_semi}" -D target_soc="${target_soc}" -P ${ZEPHYR_NRF_MODULE_DIR}/cmake/sdp_asm_install.cmake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_soc is undefined if this function is called directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added as a parameter, is that okay or further validation is necessary?

@@ -11,17 +11,17 @@ function(asm_check)
get_filename_component(src_dir ${hrt_src} DIRECTORY)

execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol
${src_dir}/${asm_filename}.s ${asm_filename}-temp.s
${src_dir}/${asm_filename}-${target_soc}.s ${asm_filename}-${target_soc}-temp.s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_soc is a required argument to the CMake script, please ensure proper validation.

@@ -10,12 +10,12 @@ function(asm_install)
get_filename_component(asm_filename ${hrt_src} NAME_WE) # filename without extension
get_filename_component(src_dir ${hrt_src} DIRECTORY)

file(RENAME ${asm_filename}-temp.s ${src_dir}/${asm_filename}.s RESULT rename_result)
file(RENAME ${asm_filename}-${target_soc}-temp.s ${src_dir}/${asm_filename}-${target_soc}.s RESULT rename_result)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_soc is a required argument to the CMake script, please ensure proper validation.

@masz-nordic masz-nordic requested a review from a team as a code owner January 29, 2025 14:59
@masz-nordic masz-nordic requested a review from tejlmand January 29, 2025 15:00
@nordic-segl
Copy link
Contributor

I sow Piotr Kosycarz added sdp_asm test to the integration CI scope.
Nevertheless, here is manual run confirming that it passes on this PR:
https://jenkins-ncs.nordicsemi.no/job/latest/job/test-fw-twister-ncs-zephyr/job/customizable/job/main/543/testReport/

Copy link
Contributor

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better.

Some small adjustments required, and then some general observation for future PRs but not required to change in this PR (marked non-blocking).

cmake/sdp.cmake Outdated
Comment on lines 19 to 21
# Get SoC name
string(REPLACE "/" ";" target_quals ${BOARD_QUALIFIERS})
list(GET target_quals 1 target_soc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use CONFIG_SOC instead to get the SoC name.

This code will break when Zephyr introduces proper SiP support.

cmake/sdp.cmake Outdated
string(REPLACE "/" ";" target_quals ${BOARD_QUALIFIERS})
list(GET target_quals 1 target_soc)

sdp_assembly_generate(${hrt_srcs} ${target_soc})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sdp_assembly_generate(${hrt_srcs} ${target_soc})
sdp_assembly_generate(${hrt_srcs} ${CONFIG_SOC})

and similar on lines below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When addressing review comments, then please squash the changes into the commit which originally introduced the code that was commented.

For example, the commit:
0d52442 still has: function(sdp_assembly_install hrt_srcs)
but later commit: 05afd9a changes this to: function(sdp_assembly_install target hrt_srcs)

This makes reviewing PRs commit-by-commit harder because I don't know if the code in commit A which i'm currently reviewing and commenting will be modified later at commit Z.

Not mentioning that making two commits in a PR (introduce function + changes the same function) instead of a single commit makes reviewing slower. (Multiple commit are good when they have different kind of changes, that is not touching the same codelines).

Note: Non blocking comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my intention was to make separate commits for each functional change. Will squash them.

# Arguments:
# target - target to which the dependencies are to be applied
# hrt_srcs - path to the .c source file(s) to verify

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the empty line here, and before other functions ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my formatting preference, removed.

sdp_assembly_check("${CMAKE_CURRENT_SOURCE_DIR}/src/add_1.c;${CMAKE_CURRENT_SOURCE_DIR}/src/add_10.c;${CMAKE_CURRENT_SOURCE_DIR}/src/add_100.c")
sdp_assembly_prepare_install("${CMAKE_CURRENT_SOURCE_DIR}/src/add_1.c;${CMAKE_CURRENT_SOURCE_DIR}/src/add_10.c;${CMAKE_CURRENT_SOURCE_DIR}/src/add_100.c")
sdp_assembly_install(app
"${CMAKE_CURRENT_SOURCE_DIR}/src/add_1.c;${CMAKE_CURRENT_SOURCE_DIR}/src/add_10.c;${CMAKE_CURRENT_SOURCE_DIR}/src/add_100.c")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please line wrap, or perhaps create a list of files which are passed as argument, like this:

set(sdp_files
    ${CMAKE_CURRENT_SOURCE_DIR}/src/add_1.c
    ${CMAKE_CURRENT_SOURCE_DIR}/src/add_10.c
    ${CMAKE_CURRENT_SOURCE_DIR}/src/add_100.c
)
sdp_assembly_install(app "${sdp_files}")

cmake/sdp.cmake Outdated
@@ -4,6 +4,24 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

function(sdp_assembly hrt_srcs)
sdp_assembly_generate("${CMAKE_SOURCE_DIR}/${hrt_srcs}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems my comment was misread.

I asked for the possibility for hrt_srcs to have absolute path, not require it to have absolute path.
CMake has the test: if(IS_ABSOLUTE <path>) https://cmake.org/cmake/help/latest/command/if.html#is-absolute which can be used to test if path should be converted when it's relative.

Note, requiring an absolute path always is also acceptable, so this comment in non-blocking.

CMakeLists can now simply call `sdp_assembly_install`
to add a C file for assembly generation and tracking.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Each SoC should have own unique assembly file, since their
configuration may differ.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Add documentation for CMake functions used in SDP.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Use `sdp_assembly_install()`.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Use `sdp_assembly_install()`.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Use `sdp_assembly_install()`.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Currently only nRF54L15 has one.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Currently only nRF54L15 has one.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
Currently only nRF54L15 has one.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
@masz-nordic masz-nordic merged commit fe193fc into nrfconnect:main Feb 4, 2025
13 checks passed
@masz-nordic masz-nordic deleted the sdp_extend_cmake branch February 4, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants