-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
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
Use createChar_P to save SRAM in bootscreen #6965
Use createChar_P to save SRAM in bootscreen #6965
Conversation
Oh! I even knew those existed! I must have had a brain fart to not include those too. |
1d26a7f
to
cf02b4a
Compare
I'm currently investigating a 1k hacky bootloader for the AT90USB to replace the Atmel 4k DFU bootloader (which apparently reserves 5.2k - wtf ???) just because Marlin has gotten so feature-rich, I want them all, so everylittle bit [sic] helps. 😉 Thanks ! |
Excellent. Our main emphasis is definitely on recovering SRAM, as we have lots of PROGMEM to spare. Good luck! |
610818d
to
cdb8c2a
Compare
I bet there is a bunch of RAM to be saved when we crawl through the Graphics LCD Panel code. If that is true, would we be willing to have a Marlin version of it? |
2badb29
to
961449e
Compare
961449e
to
ede3ba7
Compare
...by moving `homing_feedrate_mm_s` to PROGMEM.
ede3ba7
to
707707d
Compare
@@ -782,7 +782,7 @@ extern "C" { | |||
#endif // !SDSUPPORT | |||
|
|||
#if ENABLED(DIGIPOT_I2C) | |||
extern void digipot_i2c_set_current(int channel, float current); | |||
extern void digipot_i2c_set_current(uint8_t channel, float current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thinkyhead speaking of optimizing, couldn't DAC_STEPPER_CURRENT be changed from uint16_t to uint8_t since drive percent is always 0-100 ?
Also, do we really need to see motor current percent as float ? I would think closest integer value is sufficient (seeing it reported as float while configuring my printer is what got me digging into it, which led me here).
I know you can take this too far, but same thing with PID Kp and Kd values, but everyone loves to believe that those 2 extra decimal digits that M303 spits out are significant ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a free byte.... Take it! And any conversion from float to int is 2 free bytes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked and with this change: fiveangle@3261024
I get:
Sketch uses 84748 bytes (65%) of program storage space. Maximum is 130048 bytes.
Global variables use 3263 bytes (39%) of dynamic memory, leaving 4929 bytes for local variables. Maximum is 8192 bytes.
Compared to:
Sketch uses 84742 bytes (65%) of program storage space. Maximum is 130048 bytes.
Global variables use 3259 bytes (39%) of dynamic memory, leaving 4933 bytes for local variables. Maximum is 8192 bytes.
Is Global variables the SRAM ? If not, how do you guys check that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Global variables the SRAM ? If not, how do you guys check that ?
Yes. The AVR parts we are using have 8KB of Static RAM inside them. The Global variables are always present. The space for them is 'hard allocated'. They can be accessed from any code that knows how to reach out and touch them.
The local variable space is what is left over out of the 8KB or RAM. The stack lives in that space. And any local variables defined at the start of a function live on the stack. They go away when the function exits. (Any static variable is an exception because it ends up in the global space even though it was declared at the start of a function.)
The boot screen uses custom characters too, so using
createChar_P
allows it to give back 32 bytes of SRAM.I'll continue to add to this PR as I look for other variables (instances of
const static
throughout the code) which can be moved to PROGMEM. We may be able to recover as much as 1K of SRAM with typical configurations.pin_is_protected
by puttingsensitive_pins
in PROGMEM.homing_feedrate_mm_s
to PROGMEM.(Costs 32 extra bytes of PROGMEM to access.)
pin_is_protected
get_homing_bump_feedrate
MarlinSettings::reset
DIGIPOTS_I2C
. Also much PROGMEM.smart_fill_mesh
Total recovery so far: 364 bytes SRAM. Several K of PROGMEM, possibly.