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

common: remove rdimon when debug is enabled #1741

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tlyu
Copy link
Contributor

@tlyu tlyu commented Jan 19, 2024

Save about 1.2KiB (depending on GCC version) by redirecting _write directly in libnosys, instead of pulling in librdimon.

Detailed description

  • Improves firmware footprint on native BMP when debug output is enabled
  • There doesn't appear to be a current need to use librdimon semihosting capabilities
  • libnosys I/O functions such as _write can be retargeted directly without using semihosting
  • Initializing librdimon semihosting brings in a lot of unused code

I haven't tested on other probe platforms, so I might have unintentionally broken something.

Your checklist for this pull request

Closing issues

N/A

Save about 1.2KiB (depending on GCC version) by redirecting `_write`
directly in `libnosys`, instead of pulling in `librdimon`.
@tlyu tlyu changed the title common: remove rdimon common: remove rdimon when debug is enabled Jan 19, 2024
@ALTracer
Copy link
Contributor

Please rebase on main -- half of usb_serial.c moved to syscalls.c. I just tried rebasing your commit on main and got a -1344 byte size-diff for meson setup build-stlink --cross-file=cross-file/stlink.ini -Ddebug_output=true -Dbmd_bootloader=false -Dtargets="cortexm,at32f4,rp,stm", which is very nice. While writes definitely don't have to go through DebugMon handler, I expect another bonus: RDP1-locked stlinkv2 (and RDP2-locked stlinkv3) may stop hanging on their first DEBUG_INFO() call, because it no longer uses breakpoints or any (disabled) debug facilities. I can't confirm whether ST disables DebugMon, but it might be the case. Needs testing on ST_BOOTLOADER=1 stlinkv2 and stlinkv3 to confirm the benefit (of allowing users to do all the DEBUG_INFO prints on-probe without BMDA). Or any stm32f103 with normal BMD bootloader but read protection activated after confirming DEBUG_INFO works, to observe that it starts crashing.
If you don't want to handle all the Makefile.inc per-platform, I might handle it myself, checking the result on a few bluepills. f072 can't use debugmon anyways (goes into hardfault), so it's a win-win for it.

 src/platforms/common/stm32/meson.build |  2 +-
 src/platforms/common/syscalls.c        | 65 -----------------------------------------------------------------
 src/platforms/common/usb_serial.c      | 12 ------------
 3 files changed, 1 insertion(+), 78 deletions(-)

@tlyu
Copy link
Contributor Author

tlyu commented Oct 16, 2024

Thanks for taking a look! I will try to make time to work on this a bit next week.

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.

2 participants