MCUdude / MicroCore

A light-weight Arduino hardware package for ATtiny13
551 stars 88 forks source link

-ffixed is no longer needed? #160

Open WestfW opened 1 month ago

WestfW commented 1 month ago

platform.txt contains:

# fixed registers: r4 = isr_tmp, r3:r2 = WDT counter for millis
#compiler.optimize_flags=-Os -flto -fno-move-loop-invariants -fno-reorder-blocks -ffixed-r2 -ffixed-r3 -ffixed-r4
compiler.optimize_flags=-Os -flto -fno-reorder-blocks -ffixed-r2 -ffixed-r3 -ffixed-r4

However, it looks like the nerdRalph millis code no longer keeps stuff in registers; I can't find any actual used of r2-r4 anywhere in the current source code.

(it is unlikely that this will change anything in any program small enough to fit in a tiny13, but...)

MCUdude commented 1 month ago

To be honest, I don't know for sure. I was struggling to get the size of a compiled, blank sketch down to the same size as @nerdralph's picoCore would achieve. I asked him what the secret sauce was, and I was allowed to borrow code (and platform.txt data) to achieve similar results.

Can you try to remove the -ffixed flags and see how/if it makes a difference?

WestfW commented 1 month ago

It looks like picoCore uses an entirely register-based WDT/millis implementation: https://github.com/nerdralph/picoCore/blob/master/avr/cores/picocore/millis.S#L23 While microCore has the somewhat bigger NerdRalph Memory-based millis() (when it's turned on.) ( https://github.com/MCUdude/MicroCore/blob/master/avr/cores/microcore/millis.S#L46 )

MCUdude commented 1 month ago

Not sure why I haven't caught the change. Would you like to submit a PR for it? I'm all for saving every bit of memory on these tiny AVRs!

nerdralph commented 1 month ago

The discussion was years ago, but my recollection is that you opted for the larger code size for better accuracy. Your sample of t13s had an average WDT frequency around 110 kHz, and chose a 19/16 correction factor. PicoCore supports the t13 and t85, and my sampling of chips had a somewhat higher average WDT frequency, and minimum size took priority over accuracy.

On Wed, Sep 25, 2024 at 6:18 AM Hans @.***> wrote:

Not sure why I haven't caught the change. Would you like to submit a PR for it? I'm all for saving every bit of memory on these tiny AVRs!

— Reply to this email directly, view it on GitHub https://github.com/MCUdude/MicroCore/issues/160#issuecomment-2373527715, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKNZ6X5O7YG3RCOGNRTX7TZYJ5XFAVCNFSM6AAAAABOZZE22OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZTGUZDONZRGU . You are receiving this because you were mentioned.Message ID: @.***>