RTEMS Ada Questions

avy st astrominger at yahoo.com
Tue Feb 13 19:21:57 UTC 2007


Joel,

Thanks for the detailed answer.  Two short questions:
Where can I see the wrapper task and how it is initialized (i.e. is the elaboration code executed in the wrapper task after RTEMS was started)?
How do I build the posix tests on PSIM so that I can run them?
Thanks
Avy

----- Original Message ----
From: Joel Sherrill <joel.sherrill at oarcorp.com>
To: avy st <astrominger at yahoo.com>
Cc: RTEMS mailing list <rtems-users at rtems.org>
Sent: Tuesday, February 13, 2007 8:21:18 PM
Subject: Re: RTEMS Ada Questions


avy st wrote:
> Hello all,
>  
>   After successfully building powerpc-rtems-4.7 Ada capable toolset on 
> Cygwin host and rtems-4-7-branch itself (or at least so I hope, since 
> no Ada program was run yet), I've tried compiling and running the 
> following Ada 'hello' program,  appearing on the Ada and RTEMS wiki 
> page (http://www.rtems.com/wiki/index.php/RTEMSAda):
>
>     $ cat t.adb  with Ada.Text_IO;  procedure T is  begin     Ada.Text''IO.Put''Line ("Hello RTEMS Ada");  end T;  $ powerpc-rtems-gnatmake -f -g t -largs -BINSTALL -specs bsp_specs -qrtems  ...  $ INSTALL/powerpc-rtems/psim/tests/runtest ./t  
>
> Running it, on the PSIM BSP, resulted in internal error after program end.  Joel Sherrill looked at it, and suspected that 
> it was a stack overrun after program end.

psim has a pretty powerful (and underdocumented) debug trace facility.  
Modify whatever
script you are using to add the following line to what the RTEMS script 
psim/psim-gdb
calls TREE_FILE.

/openprom/trace/semantics 1

This will cause psim to print every instruction as it executes it and 
should tell you
precisely how far you are getting no matter how poor any other debug info
is.

Attached is my hacked script to call powerpc-rtems4.7-run with this 
option enabled.


> However, having a look at RTEMS Ada hello example and the elaboration code, I saw that, in my opinion, RTEMS was not even 
> started, and no task was created when building the program as described on the Wiki page.  All RTEMS Ada examples
> EXPLICITLY create the tasks and start RTEMS on their main, which is not the case in this examples.
> So, here are the
>  questions:
>
>    1. Is my observation correct?
>

The above trace option will show that.
>
>    1. If so, is there a way to create the environment task
>       'automatically' (from the Ada code point of view), and run the
>       Ada main
>       procedure in the context of the environment task automatically,
>       as is required and done bu all the Ada environments
>       that I've worked with?
>
Yes.  When things are all running, the RTEMS wrapper task for gnat_main 
will make this happen.
>
>    1. What about defining tasks in Ada - defining a task type and an
>       object of that type? Would this automatically create a task
>       as it should? Is Ada task=RTEMS task?
>
Each Ada task == an RTEMS POSIX thread created by pthread_create just 
like the GNU/Linux port.
>
>    1. Is all this behavior documented anywhere?
>
Only in the source.  Most of the assumptions are from GNAT's run-time.  
We just wrap their gnat_main
as needed and map their calls to POSIX thread calls.

Just to be sure, can you run the RTEMS posix tests on your psim build?

--joel
> Thanks
> Avy
>  
>  
>  
>  
>  
>  
>  
> ------------------------------------------------------------------------
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>
#! /bin/sh
#
#  Shell script to ease invocation of the powerpc simulator
#
#  COPYRIGHT (c) 1989-2006.
#  On-Line Applications Research Corporation (OAR).
#
#  The license and distribution terms for this file may be
#  found in found in the file LICENSE in this distribution or at
#  http://www.rtems.com/license/LICENSE.
#
#  $Id: psim,v 1.10 2006/01/20 17:30:39 joel Exp $
#

TREE_FILE=psim_tree.${LOGNAME}
RUN=powerpc-rtems4.7-run


progname=${0##*/}        # fast basename hack for ksh, bash

USAGE=\
"usage: $progname [ -opts ] test [ test ... ]
    -v       -- verbose
        -l limit   -- specify time limit (default is 'no limit')
"

#   log an error to stderr
prerr()
{
    echo "$*" >&2
}

fatal() {
    [ "$1" ] && prerr $*
    prerr "$USAGE"
    exit 1
}

warn() {
    [ "$1" ] && prerr $*
}

#
# process the options
#
# defaults for getopt vars
#

verbose=""
limit="0"

while getopts vl: OPT
do
    case "$OPT" in
    v)
        verbose="yes";;
        l)
            limit="$OPTARG";;
        *)
            fatal;;
    esac
done
shiftcount=`expr $OPTIND - 1`
shift $shiftcount

args=$*

# RUN_DEBUG="-t sem_device"

#  Build this user's device tree file
echo "/#address-cells 2"                              >  ${TREE_FILE}
echo "/openprom/init/register/pvr 0xfffe0000"         >> ${TREE_FILE}
echo "/openprom/options/oea-memory-size 8388608"      >> ${TREE_FILE}
echo "/openprom/trace/semantics 1"      >> ${TREE_FILE}

# These require the semaphore and shared memory device models.
# echo "/shm at 0xc0000000/reg 0xc0000000 0x10000"         >> ${TREE_FILE}
# echo "/shm at 0xc0000000/key ${RTEMS_SHM_KEY}"           >> ${TREE_FILE}
# echo "/sem at 0xc0010000/reg 0xc0010000 12"              >> ${TREE_FILE}
# echo "/sem at 0xc0010000/key ${RTEMS_SHM_SEMAPHORE_KEY}" >> ${TREE_FILE}
# echo "/sem at 0xc0010000/value -1"                       >> ${TREE_FILE}

runtest()
{
  testname=${1}
  max_run_time=${2}
  if [ ${max_run_time} -eq 0 ] ; then
    #echo run ${testname} forever
    ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname}
  else
    #echo run ${testname} for maximum ${max_run_time} seconds
    ${RUN} -f ${TREE_FILE} ${RUN_DEBUG} ${testname} &
    pid=$!

    # Make sure it won't run forever...
    time_run=0
    while [ $time_run -lt $max_run_time ]
    do
      # sleep 5s at a time waiting for job to finish or timer to expire
      # if job has exited, then we exit, too.
      sleep 1
      kill -0 $pid 2> /dev/null
      running=$?
      if [ $running -eq 0 ] ; then
        time_run=$((time_run + 5))
        if [ $time_run -ge $max_run_time ]; then
      kill -9 $pid 2> /dev/null
      ran_too_long="yes"
          echo "${testname} killed after running ${max_run_time} seconds"
        fi
      else
        ran_too_long="no"
        break
      fi
    done
  fi
}

if [ "X${1}" = "X" ] ; then
  echo no tests to run
  exit 1
fi
runtest ${1} ${limit}
rm -f ${TREE_FILE}
exit $?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20070213/70ed3aad/attachment-0001.html>


More information about the users mailing list