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: enable -mcall-prologues #325

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

Conversation

gudnimg
Copy link
Collaborator

@gudnimg gudnimg commented Jul 27, 2024

An idea to save some flash memory.

Reduces flash memory usage by ~300B

The CMake build outputs an ASM file for the firmware image and is human readable.
To see the impacted functions, look for these routines:

__prologue_saves__
__epilogue_restores__

They should come in pairs.

For more info about this option, see:
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/AVR-Options.html#AVR-Options
Copy link

All values in bytes. Δ Delta to base

ΔFlash ΔSRAM Used Flash Used SRAM Free Flash Free SRAM
-306 0 28064 1669 608 891

@gudnimg
Copy link
Collaborator Author

gudnimg commented Jul 29, 2024

For reference, here is a copy of the ASM file at HEAD 49a82cd

firmware_asm_file.zip

@gudnimg
Copy link
Collaborator Author

gudnimg commented Jul 29, 2024

Affected functions:

  • void Motion::AbortPlannedMoves(Axis axis, bool halt)
  • void TMC2130::WriteRegister(const MotorParams &params, Registers reg, uint32_t data)
  • uint32_t TMC2130::ReadRegister(const MotorParams &params, Registers reg)
  • void __attribute__((noinline)) MovableBase::SetCurrents(uint8_t iRun, uint8_t iHold)
  • bool __attribute__((noinline)) TMC2130::Init(const MotorParams &params, const MotorCurrents &currents, MotorMode mode)
  • uint8_t Protocol::EncodeResponseRead(const RequestMsg &msg, bool accepted, uint16_t value2, uint8_t *txbuff)
  • void Application::ReportCommandAccepted(const mp::RequestMsg &rq, mp::ResponseMsgParamCodes status)
  • bool Motion::InitAxis(config::Axis axis, MotorCurrents mc)
  • void Motion::PlanMoveTo(Axis axis, pos_t pos, steps_t feed_rate, steps_t end_rate)
  • void Idler::PlanHomingMoveBack()
  • void Selector::PlanHomingMoveBack()
  • void Selector::PrepareMoveToPlannedSlot()
  • void Idler::PlanHomingMoveForward()
  • void Idler::PrepareMoveToPlannedSlot()
  • bool FilamentLoaded::set(uint8_t filament)
  • bool FeedToFinda::Step()
  • bool UnloadFilament::StepInner()
  • bool ToolChange::StepInner()
  • 0000470e <global constructors keyed to 65535_0_application.cpp.obj.10452>: (Some constructor?)
  • int main()
  • 0000622e <USB_Device_ProcessControlRequest>: (I guess this is the constructor of the class?)

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.

1 participant