<html dir="ltr"><head><title>Re: RTEMS4.11 / newlib / gcc issue on Sparc / LEON3</title><meta content="text/html; charset=unicode" http-equiv="Content-Type" /><meta name="GENERATOR" content="MSHTML 9.00.8112.16575" /></head><body>Anyone have thoughts on a more generous minimum attach size for the shell? 4k is one of the larger minimums across the architectures.<br>
<br>
FWIW on the arm or m68k, stack usage is lower. The SPARC has large stack frames thanks to the register windows <br>
<br>
--joel<br><br><div class="gmail_quote">On October 15, 2014 2:11:41 AM CDT, Hoefle Marco <Marco.Hoefle@nanotronic.ch> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr" id="idOWAReplyText51263">
<div dir="ltr"><font color="#000000" size="2" face="Arial">Hello Joel,</font></div>
<div dir="ltr"><font size="2" face="Arial">this did the trick. The default stack size was 4kBytes. 8kBytes seem to work fine.</font></div>
<div dir="ltr"><font size="2" face="Arial">Maybe the default stack size of the rtems shell can be increased as a simple command like "ls" will exceed the 4kBytes.</font></div>
<div dir="ltr"><font size="2" face="Arial">Thank you for the hint.</font></div>
<div dir="ltr"><font size="2" face="Arial"></font> </div></div>
<div dir="ltr"><br />
<hr tabindex="-1" />
<font size="2" face="Tahoma"><b>Von:</b> Joel Sherrill [mailto:joel.sherrill@oarcorp.com]<br /><b>Gesendet:</b> Di 14.10.2014 18:12<br /><b>An:</b> Hoefle Marco; Chris Johns; Jiri Gaisler; Sebastian Huber; users@rtems.org<br /><b>Betreff:</b> Re: RTEMS4.11 / newlib / gcc issue on Sparc / LEON3<br /></font><br /></div>
<div>
<p><font size="2">Can you turn on stack checking?<br /><br />it is either a stray write, a stack overflow, or something<br />writing past the end of a buffer. Given that is appears<br />to be a local variable which should be a register in<br />a SPARC register window, I lean to stack overflow.<br /><br />Especially since you passed 0 to rtems_shell_init for<br />task_stacksize. That gives it a minimum stack size.<br />Try a large number like 256 * 1024 and see if the<br />problem goes away.<br /><br />Stack checking also allows you to use the stackuse command<br />which will help you trim it back down.<br />On 10/14/2014 10:07 AM, Hoefle Marco wrote:<br />> Hello again,<br />> I had this memory aligned failure and I thought it is fixed with the new<br />> newlib version.<br />> We have now a new strange phenomena: A local variable is overwritten in<br />> a thread when the command "ls" is executed in the rtems shell:<br />><br />><br />> Starting 1
threads...<br />> started thread 0: id: 0x0b010002, prio: 10<br />> =========================<br />> starting shell<br />> =========================<br />><br />> RTEMS SHELL (Ver.1.0-FRC):/dev/console. Oct 14 2014. 'help' to list<br />> commands.<br />> [/] # hello dude, this is tick nr: 1<br />> hello dude, this is tick nr: 2<br />> hello dude, this is tick nr: 3<br />> hello dude, this is tick nr: 4<br />> hello dude, this is tick nr: 5<br />> hello dude, this is tick nr: 6<br />><br />> [/] #<br />> [/] #<br />> [/] # ls<br />> dev<br />> hello dude, this is tick nr: 0<br />> hello dude, this is tick nr: 1<br />> hello dude, this is tick nr: 2<br />> hello dude, this is tick nr: 3<br />><br />> [/] # ls<br />> dev<br />> hello dude, this is tick nr: 0<br />><br />> [/] #<br />> hello dude, this is tick nr: 1<br />> hello dude, this is tick nr: 2<br />> hello dude
, this
is tick nr: 3<br />> hello dude, this is tick nr: 4<br />> hello dude, this is tick nr: 5<br />> hello dude, this is tick nr: 6<br />> hello dude, this is tick nr: 7<br />><br />><br />> This will be the simple rtems4.11 test app:<br />><br />><br />> #include <bsp.h><br />> #include <errno.h><br />> #include <fcntl.h><br />> #include <stdlib.h><br />> #include <stdio.h><br />> #include <unistd.h><br />> #include <pthread.h><br />> #include <sched.h><br />> #include <rtems/shell.h><br />> #include <errno.h><br />><br />> #include "rtems_config.h"<br />><br />><br />> void *tsk_core(void *unused);<br />> void *tsk_dummy(void *unused);<br />><br />><br />> struct {<br />> int prio;<br />> void *(*func)(void *arg);<br />> pthread_t id;<b
r
/>> }static threads[] = {<br />> { .prio = 10, .func = tsk_core },<br />> // { .prio = 3, .func = tsk_shell }, /* minimum prio */<br />> // { .prio = 10, .func =tsk_spw0 },<br />> // { .prio = 10, .func = tsk_spw1 },<br />> // { .prio = 2, .func = tsk_script },<br />> // { .prio = 3, .func = tsk_shell }, /* minimum prio */<br />> // { .prio = 3, .func = tsk_dummy }, /* minimum prio */<br />> };<br />><br />> static uint8_t nr_threads = sizeof(threads) / sizeof(threads[0]);<br />><br />><br />> void
start_shell(void)<br />> {<br />> rtems_status_code sc = RTEMS_SUCCESSFUL;<br />> printf(" =========================\n\r");<br />> printf(" starting shell\n\r");<br />> printf(" =========================\n\r");<br />><br />><br />> sc = rtems_shell_init(<br />> "SHLL", /* task name */<br />> 0, /* task stack size */<br />> 100, /* task priority */<br />> "/dev/console", /* device name */<br />> true, /* run forever */<br /
>>
true, /* wait for shell to terminate */<br />> NULL /* login check function,<br />> use NULL to disable a login check */<br />> );<br />><br />> printf("sc: %d, errno: %s\n\r", sc, strerror(errno));<br />> }<br />><br />><br />> void hello_dude(int ticks)<br />> {<br />> printf("hello dude, this is tick nr: %d\n\r", ticks);<br />> }<br />><br />><br />> void *tsk_core(void *unsued)<br />> {<br />> int ticks = 1;<br />> while (1) {<br />> sleep(10);<br />>
hello_dude(ticks++);<br />> }<br />><br />> return NULL;<br />> }<br />><br />> static int initUart( const char *devname)<br />> {<br />> int fd = open( devname, O_RDWR);<br />> if (fd < 0) {<br />> return -errno;<br />> }<br />><br />> struct termios settings;<br />> tcgetattr( fd, &settings);<br />> settings.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP<br />> | INLCR | IGNCR | ICRNL | IXON);<br />> settings.c_oflag &= ~OPOST;<br
/>> settings.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);<br />> settings.c_cflag &= ~(CSIZE | PARENB);<br />> settings.c_cflag |= CS8;<br />> settings.c_cc[VMIN] = 1;<br />> settings.c_cc[VTIME] = 0;<br />><br />> if(cfsetispeed(&settings, B115200) < 0 || cfsetospeed(&settings,<br />> B115200) < 0) {<br />> return -1;<br />> }<br />><br />> int err = tcsetattr( fd, TCSADRAIN, &settings);<br />> if (err) return -err;<br />><br />> return fd;<br />> }<br />><br />> void *POSIX_Init(void *argument)<br />> {<br />> pthread_attr_t attr;<br />>
struct sched_param schedparam;<br />> int retVal;<br />><br />><br />> initUart("/dev/console");<br />><br />> retVal = pthread_attr_init(&attr);<br />> retVal |= pthread_attr_getschedparam(&attr, &schedparam);<br />> retVal |= pthread_attr_setinheritsched(&attr,<br />> PTHREAD_EXPLICIT_SCHED);<br />> retVal |= pthread_attr_setschedpolicy(&attr, SCHED_RR);<br />> if (retVal) {<br />> printf("thread setup failed!\n\r");<br />> }<br />><br />> if(retVal == 0) {<br />>
/* starting threads */<br />> printf( "Starting %d threads...\n\r", nr_threads);<br />><br />> for (uint8_t i = 0; i < nr_threads; i++) {<br />> schedparam.sched_priority = threads[i].prio;<br />> retVal |= pthread_attr_setschedparam(&attr,<br />> &schedparam);<br />> retVal |= pthread_create(&threads[i].id, &attr,<br />> threads[i].func, NULL);<br />><br />>
if (retVal)<br />> {<br />> printf("thread creation failed!\n\r");<br />><br />> // cancel loop<br />> i = nr_threads;<br />> }<br />>
printf( "started thread %d: id: 0x%08x, prio:<br />> %d\n\r", i, threads[i].id, threads[i].prio);<br />> }<br />> }<br />><br />> start_shell();<br />><br />> return NULL;<br />> }<br />><br />> I'll be happy to provide the c files, retms config and Makefile as an<br />> email attachment if somebody is interested.<br />><br />> Marco<br />><br />><br />><br />><br /><br />--<br />Joel Sherrill, Ph.D. Director of Research & Development<br />joel.sherrill@OARcorp.com On-Line Applications Research<br />Ask me about RTEMS: a free RTOS Huntsville AL 35805<br />Support
Available (256) 722-9985<br /><br /><br /><br /><br /></font></p></div></blockquote></div></body></html>