-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix iram/irom section contents #1566
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
Conversation
I also experienced that running hw_timer on NMI can yield unstable results, thus I'd confirm to change it to FRC1 for The linker magic is beyond my capabilities, though. Anybody feels like having a look? |
I'm not really back on board yet, but... can this PR be summarised thusly?
|
|
Ah, I was thinking that the SPIFFS part might overflow the meg boundary, but even if it does that would of course not be an issue. Riiight, I'd missed that the .irom0.text was now hoovering up more of the SDK's .text symbols. I'm not near a build system, how much of the SDK have you managed to move into ROM, roughly? Do you have before/after figures? You should be able to leave all the SDK's .rodata in ROM however, no need to hoist that back into RAM unless something has changed since ~1.4 when I did my analysis of that. And if there is something that needs to be in ROM, just move that, not all/most the SDKs rodata please. |
As I see, SPIFFS location is calculating from top of irom (with align), so they're should never overlap. Correct me if I wrong. So, there are no numbers, but before RAM-text was contain as much code as possible, so... there was problems. Now there are only And about rodata... I was verified that libs (listed above) using their rodata, and do not really know how and when them can access it. So, for upgrade safety, I prefer to leave them in RAM. Moving all of them into ROM may cause unstable crashes and more difficult issues. |
Alright, I'm back at my workstation now and have run through this stuff. Apologies for the delay. As-is, this PR costs us 112 bytes of RAM due to SDK constants being moved back into DRAM. They're currently sitting in ROM just fine; no rodata is being used by IRAM'd code (any constants used by such code are in .literal). You are correct that it would be safer/future-proof to have them DRAM in case the SDK changes behaviour, but since we're so tight on RAM I'd rather deal with it if it becomes a problem. There is also no need to spell out which SDK libs to pull .text sections from. The SDK libs all differentiate between IRAM and IROM sections. NodeMCU builds with -ffunction-sections and doesn't put anything into .text unless explicitly requested. The only library we use which isn't "ROM-clean" is libc, which is already explicitly loaded into IROM. I'm happy to switch that logic around to what you have, but I'd much prefer to see TL;DR: The below diff is all it takes to go from 43016 bytes of heap back to 43128 bytes:
And to be technically correct: the flash cache gets disabled and enabled a lot during run-time, it's not just the window at start-up when the cache is off. Whenever flash is written or erased the cache gets turned off, and there may be other circumstances too. It's largely academic though - ensuring IRAM'd code doesn't have ROM dependency is key regardless. |
Agree for |
That's what I'm trying to say - the SDK libraries already largely do load into IROM. If you If you want to see which libraries actually have functions which go (and need to go) into IRAM, you can use e.g.
(That also shows that The key point is that the SDK libs already do differentiate between IROM and IRAM code, and not honouring that is a quicker recipe for weirdness and crashes than the having the .rodata in ROM :) Placing SDK lib .text and .literal into IRAM is both needed and safe in the sense that it won't bloat the IRAM. |
OK, back to work. There is some numbers (for "all modules" build):
112 bytes moved from
Anyway I agree for |
Pushed back the changed. Also tested that it works on sdk200 branch. Yay! |
👍 @marcelstoer I see you removed the milestone, so I'll leave you to merge when you think it's suitable. |
Fixes #1562
Also fixes HW timer mode from NMI to FRC1 because NMI causes reboot
Verified that node and PWM module works properly, not checked another parts. Tests needed.