Fw: rtems_task_create segmentation fault unix bsp
Joel Sherrill <joel@OARcorp.com>
joel.sherrill at OARcorp.com
Mon Aug 2 14:35:31 UTC 2004
Pablo Casado wrote:
> Hi,
>
> Newbie question. This is a basic question but I could not find any help in
> the FAQ, archives or docs.
>
> I'm trying to create a task but getting a segmentation fault when calling
> rtems_task_create function using the unix(posix) bsp. I'm sure I'm missing
> the plot completely. Any hints to point me in the right direction would be
> appreciated. Here's my dev environment followed by the source.
>
> gcc 3.3.1
> rtems 4.6.1
> cygwin 1.5.9.1
When using the POSIX BSP, the C library is not the same as it is on
an embedded port of RTEMS. You are mostly using the Cygwin system
calls, printf, etc. THus the RTEMS filesystem code is not going to work
at all.
In this case, I would also think you don't need your own main().
Since the environment of the POSIX BSP has to start executing
at main(), that is ownedby the BSP.
If just experimenting, you would be better off playing with
one of the simulator BSPs which use a simulator in gdb.
The sparc/erc32, powerpc/psim, and mips/jmr3904 are all
nice BSPs with nice simulators. You will get a simple
and complete RTEMS "board" that way which can run the
RTEMS POSIX API, filesystems, etc. They are much
better for learning the APIs.
--joel
> Thanks
> Pablo.
>
> /*
> * Simple test program -- simplified version of sample test hello.
> */
>
> #include <bsp.h>
> #include <stdio.h>
>
> rtems_task Init( rtems_task_argument ignored)
> {
> rtems_name task_name;
> rtems_id tid;
> rtems_status_code status;
>
> /* this function works fine */
> task_name = rtems_build_name( 'T', 'A', '1', ' ' );
> /* this one seg faults */
> status = rtems_task_create(
> task_name,
> 1,
> RTEMS_MINIMUM_STACK_SIZE,
> RTEMS_INTERRUPT_LEVEL(0),
> RTEMS_DEFAULT_ATTRIBUTES,
> &tid );
> if (status != RTEMS_SUCCESSFUL)
> {
> printf("\nFailed to create task 1, error code: %d",status);
> }
> else
> {
> printf("\nSuccessfully created task 1, task id is: %d",tid);
> }
> }
>
> int main( int argc, char** argv )
> {
> /* I have absolutely no idea if I should be calling the Init function here
> * or configuring it somewhere
> */
> Init(0);
> return 0;
> }
>
> /* configuration information */
>
> //#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
> #define CONFIGURE_TERMIOS_DISABLED
> #define CONFIGURE_HAS_OWN_MOUNT_TABLE
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>
> #define CONFIGURE_MAXIMUM_TASKS 2
>
> //#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
>
> #define CONFIGURE_INIT
>
> #include <confdefs.h>
>
> rtems_filesystem_mount_table_t configuration_mount_table = {
> NULL,
> RTEMS_FILESYSTEM_BAD_OPTIONS,
> NULL,
> NULL
> };
>
> rtems_filesystem_mount_table_t *rtems_filesystem_mount_table =
> &configuration_mount_table;
> int rtems_filesystem_mount_table_size = 1;
>
> /* end of file */
>
>
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list