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

Fix FW_COMMIT_HASH compiler warning #4432

Merged
merged 4 commits into from
Oct 11, 2023

Conversation

gudnimg
Copy link
Collaborator

@gudnimg gudnimg commented Oct 7, 2023

On my end, the default length for the abbreviated commit hash is 9 characters and won't fit into uint32_t.

To fix this I propose to change FW_COMMIT_HASH into a string and create preprocessor symbol for the string length so that it's known at compile time.

If the string should be longer or shorter then only FW_COMMIT_HASH_LENGTH needs to be configured on the CMake side

  • Cherry-pick PR to MK3_3.13.2

On my end, the default length for the abbreviated commit hash is 9 characters.
This won't fit into uint32_t (4 bytes).

Instead change FW_COMMIT_HASH into a string
and create preprocessor symbol for the string length
such that it's known at compile time.

If the string should be longer or shorter
then only FW_COMMIT_HASH_LENGTH needs to be configured on the CMake side
@gudnimg
Copy link
Collaborator Author

gudnimg commented Oct 7, 2023

The function FW_VERSION_HASH_P() isn't called anywhere yet. Is it supposed to be in M115?

@github-actions
Copy link

github-actions bot commented Oct 8, 2023

All values in bytes. Δ Delta to base

Target ΔFlash ΔSRAM Used Flash Used SRAM Free Flash Free SRAM
MK3S_MULTILANG 0 0 245982 5633 7970 2559
MK3_MULTILANG 0 0 245278 5642 8674 2550

@gudnimg
Copy link
Collaborator Author

gudnimg commented Oct 8, 2023

@vintagepc the last commit seems to have resolved the static assert :)

There is still an issue with the Github Action. The runner doesn't detect git. It's unrelated to this PR but I don't see why this is happening. The Ubuntu version we're using should have Git included according to Github.

I've tried to run the Workflow via Docker on Windows using https://github.com/nektos/act but no luck so far.

image

The command
/usr/bin/git describe --abbrev=0 --dirty=-D --broken=-B

Was returning error code 128 and no output.

In the workflow file, specifying fetch-depth = 0, will make sure
to fetch all branches and tags. This seems to fix the issue.
@gudnimg
Copy link
Collaborator Author

gudnimg commented Oct 8, 2023

Fixed the issue with the git description command. The problem was not that git command wasn't found, our script is just interpreting the error that way :)
image

@3d-gussner 3d-gussner added this to the FW 3.13.2 milestone Oct 10, 2023
@3d-gussner
Copy link
Collaborator

@gudnimg
Copy link
Collaborator Author

gudnimg commented Oct 10, 2023

We can shorten the hash to 8 chars with --abbrev=8 in https://github.com/gudnimg/Prusa-Firmware/blob/fix-compiler-warning-sha/cmake/GetGitRevisionDescription.cmake#L353.

Note that git_head_commit_data(FW_COMMIT_DATE "%ct") is using the same function. We would need to create a new function.

I think having the data as a string (char *) in the firmware is better than uint32_t, because then we don't need to convert the uint32_t to hexidecimal at runtime.

@3d-gussner
Copy link
Collaborator

Okay. Is the other comment resolved?

@gudnimg
Copy link
Collaborator Author

gudnimg commented Oct 10, 2023

Okay. Is the other comment resolved?

Yeah 69e06ba resolved it. Github always failed to build before that fix because I added a new static_assert which checks the string length is correct.

Copy link
Collaborator

@3d-gussner 3d-gussner left a comment

Choose a reason for hiding this comment

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

Tested and works well. No warnings.

@3d-gussner
Copy link
Collaborator

@vintagepc Can we merge it?

@3d-gussner 3d-gussner merged commit 0b5cf40 into prusa3d:MK3 Oct 11, 2023
5 checks passed
@gudnimg gudnimg deleted the fix-compiler-warning-sha branch September 1, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants