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

cmake: Show executable for memory report #66217

Conversation

hellesvik-nordic
Copy link
Contributor

With the addition of sysbuild, several memory reports can be printed for one build.
Because of this, it is useful to know which executable each memory report is printed for.

Copy link

github-actions bot commented Dec 6, 2023

Hello @hellesvik-nordic, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

CMakeLists.txt Outdated Show resolved Hide resolved
@hellesvik-nordic hellesvik-nordic force-pushed the pr/memory_report_print_executable_path branch from 17d67cc to 55ac863 Compare December 6, 2023 11:21
nordicjm
nordicjm previously approved these changes Dec 6, 2023
CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Collaborator

@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.

instead of yet another way of doing what is already done, then please update this line instead to provide full path:

COMMENT "Generating files from ${KERNEL_ELF_NAME} for board: ${BOARD}"

Note, a small detail regarding COMMENT, make will always print all comments, but ninja will not due to the way the ninja generator works on post build commands.

So the COMMENT should be changed into an echo COMMAND to give desired behavior on using both make and ninja.

@hellesvik-nordic
Copy link
Contributor Author

Good point, as you say it should already be printed, I just did not see it as I just west(and therefore ninja) to build.
Changed to echo, and also added full path to elf file, so we can differentiate images.
Here is how sysbuild hello world with mcuboot logs it:

[133/134] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       25184 B       472 KB      5.21%
             RAM:        5568 B       256 KB      2.12%
        IDT_LIST:          0 GB         2 KB      0.00%
image.py: sign the payload
image.py: sign the payload
Generating files from /home/sihe/git/sigurd/tmp/zephyr/samples/hello_world/build/hello_world/zephyr/zephyr.elf for board: nrf52840dk_nrf52840
[134/134] cd /home/sihe/git/sigurd/tmp/zephyr/samples/hello_world/build/hello_world/z...me/sihe/git/sigurd/tmp/zephyr/samples/hello_world/build/hello_world/zephyr/zephyr.elf
[11/16] Performing build step for 'mcuboot'
[1/269] Preparing syscall dependency handling

[10/269] Generating include/generated/version.h
-- Zephyr version: 3.5.99 (/home/sihe/git/sigurd/tmp/zephyr), build: d2c096c4d1b8
[268/269] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       32418 B        48 KB     65.95%
             RAM:       23808 B       256 KB      9.08%
        IDT_LIST:          0 GB         2 KB      0.00%
Generating files from /home/sihe/git/sigurd/tmp/zephyr/samples/hello_world/build/mcuboot/zephyr/zephyr.elf for board: nrf52840dk_nrf52840
[269/269] cd /home/sihe/git/sigurd/tmp/zephyr/samples/hello_world/build/mcuboot/zephy...=/home/sihe/git/sigurd/tmp/zephyr/samples/hello_world/build/mcuboot/zephyr/zephyr.elf
[16/16] Completed 'mcuboot'

@tejlmand
Copy link
Collaborator

tejlmand commented Dec 7, 2023

I just west(and therefore ninja) to build.

you can actually use make with west also, like this: west build ... -- -G'Unix Makefiles', then project will use make for building instead 😉

Copy link
Collaborator

@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.

Thanks for this nice improvement.

But let's move the echo command up.

CMakeLists.txt Outdated
Comment on lines 1888 to 1891
${post_build_commands}
BYPRODUCTS
${post_build_byproducts}
COMMENT "Generating files from ${KERNEL_ELF_NAME} for board: ${BOARD}"
COMMAND ${CMAKE_COMMAND} -E echo "Generating files from ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME} for board: ${BOARD}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor nit, if you move the COMMAND up so it's the first echo command, then it's printed first before other post build commands.

 POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E echo "Generating files from ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME} for board: ${BOARD}"
 ${post_build_commands}
 BYPRODUCTS
 ${post_build_byproducts}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow the memory report is still printed first:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Somehow the memory report is still printed first:

Because the memory report is printed by the linker when using gcc, and is not a postbuild command.
It will only help in relation to other postbuild commands, such as image.py 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see
Moved it up now

@hellesvik-nordic hellesvik-nordic force-pushed the pr/memory_report_print_executable_path branch from d2c096c to 9ba3613 Compare December 7, 2023 13:30
Firstly, COMMENT does not work for ninja.
Therefore, change COMMENT to echo.

With the addition of sysbuild, several memory reports can be printed
for one build.
Because of this, it is useful to know which executable each memory
report is printed for, so adding full path to elf file.

Signed-off-by: Sigurd Hellesvik <sigurd.hellesvik@nordicsemi.no>
@hellesvik-nordic hellesvik-nordic force-pushed the pr/memory_report_print_executable_path branch from 9ba3613 to 0fbd456 Compare December 7, 2023 13:31
Copy link
Collaborator

@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.

Thanks a lot for the effort 👍

@joerchan joerchan self-requested a review December 9, 2023 20:35
@hellesvik-nordic
Copy link
Contributor Author

This PR needs at least one more approval.
Tagging those who have commented so far to see if they want to help with this
@joerchan @nordicjm or @57300

@carlescufi carlescufi merged commit ed040f1 into zephyrproject-rtos:main Dec 15, 2023
16 checks passed
Copy link

Hi @hellesvik-nordic!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

@hellesvik-nordic hellesvik-nordic deleted the pr/memory_report_print_executable_path branch December 15, 2023 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants