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