Skip to content

Fix: log string deduplication #2097

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
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ALTracer
Copy link
Contributor

Detailed description

  • No significant new features.
  • The existing problem is suboptimal/repeating message strings for DEBUG_ERROR/WARN/TARGET().
  • This PR solves it by factoring out unique substrings and enabling linker relaxation across newly-identical strings.

Discovered by staring at strings -n16 build-f411ce/blackmagic_blackpill_f411ce_firmware.bin | less output.

  1. First commit saves up to 256 bytes when all targets are enabled and DEBUG_TARGET() is enabled.
  2. In stm32h7.c, I drop the logline I added previously for H7B3 compat FLASH_CR patcher helper, because the driver is tested to work and that logline spams output during flashing. -116 bytes.
  3. Renesas RA driver has three really long warnings with identical prefix/suffix and missing comma. -136 bytes.
  4. LPC17xx & LPC40xx have similar mass-erase functions in which strings differ and hence don't get merged. -104 bytes.
  5. LPC55xx reports IAP errors for five unique commands, and I decided to extract these instead. -52 bytes.

I would need some autobuilder script to measure size savings from each commit, but they're on the order of 50-100 bytes, for a total of about -292 bytes up to DEBUG_WARN, and -372 bytes more up to DEBUG_TARGET (-664).
Can't test on most of targets modified in PR scope. Idea similar to #1527 and #1863. Should have no effect on release firmware with disabled logging. When -Ddebug_output=true, default native and swlink/stlink/bluepill and f072 builds still overflow by 17-23 KiB. The other probe platforms are not 128 KiB but 256 KiB or even larger.

Your checklist for this pull request

Closing issues

@dragonmux dragonmux added the Enhancement General project improvement label Mar 21, 2025
Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

LGTM, we'll get this merged when the v2.1 merge window opens. Thank you for the contribution!

@dragonmux dragonmux added this to the v2.1 release milestone Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement General project improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants