-
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
atmega based boards freeze when main thread is over #6526
Comments
@kYc0o I doubt this is a bug. I mean the
So I'd say this is not a problem in general, I understand (and checked) that other platforms do not stop answering pings after main thread completes. But then, whats the use of that? If main (and any other thread) are done, the node wouldn't do anything anymore. |
Not sure I understand your point, but in GNRC the main thread is not responsible for responding to ICMP echo requests. Hence, it should reply with pongs whether the main thread terminates or not. P.S. remember the main thread has no particular role or function in RIOT, except that it serves as an entry point. |
I don't have an xbee shield available. However, I ran Maybe if every thread is done it finally freezes, but then: whats the problem with that --other than its different to other platforms? However again: if the app (and all it threads) terminates, what use does it have to answer pings? Typically an IoT app will have some infinite loop driving the system, hence the problem should not arise? |
I also added a |
so basically that agrees with @OlegHahm, stating:
So either there is no interrupt from the network device/driver or something blocks the system from handling such interrupt and switch to the network threads responsible to answer pings. |
However it doesn't explain why adding an infinite loop at the end keeps the board alive... |
what do you do in your infinite loop? What happens if you add (if not already done that way) something like |
and can you share your application code? |
Well the application is basically the gnrc_minimal example: int main(void)
{
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
puts("RIOT network stack example application");
/* get the first IPv6 interface and prints its address */
size_t numof = gnrc_netif_get(ifs);
if (numof > 0) {
gnrc_ipv6_netif_t *entry = gnrc_ipv6_netif_get(ifs[0]);
for (int i = 0; i < GNRC_IPV6_NETIF_ADDR_NUMOF; i++) {
if ((ipv6_addr_is_link_local(&entry->addrs[i].addr)) && !(entry->addrs[i].flags & GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST)) {
char ipv6_addr[IPV6_ADDR_MAX_STR_LEN];
ipv6_addr_to_str(ipv6_addr, &entry->addrs[i].addr, IPV6_ADDR_MAX_STR_LEN);
printf("My address is %s\n", ipv6_addr);
}
}
}
while(1);
/* main thread exits */
return 0;
} |
ah okay, simple |
without your infinite loop, that is!a |
@kYc0o Please check if main uses too much stack. |
The idle thread's stack is defined right after the main thread's stack, in core/kernel_init.h. So if the main thread overuses it's stack, it overwrites the idle thread's stack space. That will most probably lead to immediate mess-up when jumping to the idle thread. |
default stack size is 256B for atmegas, so @kaspar030 could be right, that main stack is smallish. The mega2560 has 8K,
|
Well I tested with different stack sizes and the problem persists. I'll take a look to the scheduler to see if something gets wrong there. |
Which ones did you test? |
512 and 1024 for now. You think I should increase more? |
@ZetaR60 your PRs solved this part of the problem, closing. |
While testing gnrc_minimal with arduino-mega2560 + XBee, the board seems to freeze when the main thread is over, as the examples behaves. However, if an infinite loop is used to avoid the thread to finish, the board doesn't freeze and it answers to pings.
I think it's related to the way threading works on this platform, maybe only task switching, but I didn't investigate further.
The text was updated successfully, but these errors were encountered: