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

memory and flash optimizations for 3.12 PR3 #3432

Merged
merged 9 commits into from
Feb 28, 2022

Conversation

leptun
Copy link
Collaborator

@leptun leptun commented Feb 26, 2022

Cherrypicked changes from #3378
More commits to come.

Saved 1588B of flash, 130B of ram

@leptun leptun added this to the FW 3.12.0 milestone Feb 26, 2022
@leptun
Copy link
Collaborator Author

leptun commented Feb 27, 2022

@gudnimg I think we can easily switch to printf and not use ftostr3 anymore.

gudnimg and others added 8 commits February 27, 2022 20:57
I could not see any difference in the functionality when testing this locally

Changes save 818 bytes of flash memory
(I suspect this is due to dtostrf no longer being called in the firmware for MK3S?)
Also fixed indentation of if statement

Saves 248 bytes of flash
Saves 54 bytes of Flash and 2 bytes of SRAM
"PINDA cal status:" is always printed no matter what cal_status is so we can pull that out of the conditional statment.

cal_status is also a boolean, lets just print it directly. Its a simpler code.

Saves 32 bytes of flash and 22 bytes of SRAM

Change serial messages to PGM
Saves 34 bytes of flash memory and reduces code by 8 lines.
@leptun leptun force-pushed the MK3_3.12_Optimizations_PR3 branch from 7251e16 to 97c371e Compare February 27, 2022 20:02
Saves 12 bytes of SRAM but increases flash use by 12 bytes.
@leptun
Copy link
Collaborator Author

leptun commented Feb 28, 2022

@gudnimg Unless you have some other RAM->PGM improvements, this PR is final. Please let me know if you have any other plans, becase if you don't I'll ask for a review from a second reviewer.
For the future, it would be better if you made the PRs because this way I can approve and merge them. Can't really approve my own PRs :)

@gudnimg
Copy link
Collaborator

gudnimg commented Feb 28, 2022

@leptun I understand, I got no more changes for the time being :D

@@ -7786,14 +7786,14 @@ SERIAL_PROTOCOLPGM("\n\n");

updatePID();
SERIAL_PROTOCOLRPGM(MSG_OK);
SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOLPGM(" p:");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think flash usage increases because strings in ram are optimized much more than strings in progmem. So there will be duplicates in progmem, while in ram these are deduplicated. Sadly, I couldn't find a fix for this besides using PSTR only once and using the pointer on multiple PROTOCOLRPGM functions

@leptun leptun merged commit 56cb8cb into prusa3d:MK3 Feb 28, 2022
@leptun leptun deleted the MK3_3.12_Optimizations_PR3 branch February 28, 2022 11:16
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