-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/avr8_common: Add support to threadless idle #19741
Conversation
With this proposal, it fits in the 1KB SRAM of the atmega8 |
Nice! Thank you for feedback. |
6c6063e
to
c30abf1
Compare
AVR platform has few memory in general and each byte saved is precious. This add support to drop necessity of idle thread which saves hundreds of SRAM bytes. After this patch is possible to run RIOT-OS on AVR with 1k SRAM. Signed-off-by: Gerson Fernando Budke <[email protected]>
c30abf1
to
3e207a4
Compare
Sadly, this causes a number of regressions. See https://github.com/maribu/riot-test-results/blob/main/pr-19741/arduino-mega2560/failuresummary.md Note: Some of the test failures are also present in Guessing from the shell output I think it might roughly be three causes of issues:
The stack overflow is quite plausible: The call to The issue with AVR not having a dedicated IRQ stack and IRQs victimizing the stack of whatever thread is running when the IRQ is triggered is quite a pain in the ass. |
I realize that is not possible merge this at current state of cpu context switch. I think it will be necessary implement the stack for ISR and maybe more. In this proposal it was necessary re-enable the global interrupt inside context switch because of wake from sleep. However. I believe this could create serious issues because there is no valid context. For reference: This is one point that cpu call sched_run(): RIOT/cpu/avr8_common/thread_arch.c Lines 264 to 266 in 561e193
This is the place that sched_arch_idle() is called: Lines 158 to 160 in 561e193
This proposal introduces: void sched_arch_idle(void)
{
...
+ sei();
...} In the case above assumption is correct I'll keep this PR on hold for the moment. |
I think this won't be necessary after new IRQ handling. The PM from XMega can be moved to avr_common and shared between all SoC variants, initially. Maybe a mechanism will be necessary for Mega to define what Sleep Modes will be available by SoC. |
Contribution description
This attempts to introduces threadless idle support for AVR-8 platform.
Testing procedure
Local tests was conduct using
timer_periodic_wakeup
example on aatmega328p-xplained-mini
board (m328p).Triggered by #19740