This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: how to build an eCos library for ARM7tdmi simulator
- From: "Robert Cragie" <rcc at jennic dot com>
- To: <ecos-discuss at sources dot redhat dot com>
- Date: Tue, 3 Sep 2002 09:09:10 +0100
- Subject: RE: [ECOS] how to build an eCos library for ARM7tdmi simulator
Seeing as there is some interest in this, I am attaching the draft of my
'mini-HOWTO' on how I got it going. Note this is in draft state, and I have
not followed it all step-by-step; the SID bits are from memory. I will have
a go following step-by-step when I get a spare few minutes. I would also be
interested to know how Cygwin users get on.
Note I have provided a patch to support the missing ldmia instruction (and
others) that Nick refers to; see
http://sources.redhat.com/ml/sid/2002-q3/msg00033.html. You also don't
necessarily need to build a PID ROM version as you can override the mapper
settings in SID; I used the standard build (RAM) with only two changes to
the config for the UART and debugging.
Robert Cragie, Design Engineer
_______________________________________________________________
Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
http://www.jennic.com Tel: +44 (0) 114 281 2655
Note the Redhat mailer daemon kicked out the original text/html attachment.
Here it is in source:
<HTML>
<HEAD>
<TITLE>eCos and SID on ARM PID target HOWTO</TITLE>
</HEAD>
<BODY>
<H1>eCos and SID on ARM PID target HOWTO</H1>
<P>This document describes howto set up the environments for getting
eCos
and a target application to work with SID. By the end of this
tutorial,
you should be able to:</P>
<OL>
<LI>Build a simple, multi-threaded application linked with eCos.</LI>
<LI>Build the SID simulator infrastucture to support a simulated ARM
PID
target.</LI>
<LI>Debug and run the application using GDB (Insight) connected to a
simulated ARM PID target.</LI>
</OL>
<H2>What is eCos?</H2>
<P>eCos is an embedded, configurable multi-threaded operating system
which
can target many systems and CPUs.</P>
<P>For more details see <A
HREF="http://sources.redhat.com/ecos">Redhat's
eCos page</A>.</P>
<H2>What is SID?</H2>
<P>SID is a simulation environment which allows a number of
software-defined components to be built together to provide a target
which
simulates a real hardware target.</P>
<P>For more details see <A HREF="http://sources.redhat.com/sid">Redhat's
SID page</A>.</P>
<H2>Assumptions</H2>
<P>I am assuming use of the following environment:</P>
<UL>
<LI>Linux.</LI>
<LI><TT>bash</TT> is used as the command shell.</LI>
<LI>The user's user ID is '<EM>user</EM>'.</LI>
<LI>All created directories are based on the user's root directory
(reached using '<TT>cd ~</TT>', or '<TT>cd /home/user</TT>').</LI>
<LI>Superuser access is possible.</LI>
<LI>Tcl/Tk is installed (8.0 or later)</LI>
</UL>
<P>It is undoubtedly possible to get it all working using
<A HREF="http://sources.redhat.com/cygwin">cygwin</A> on Windows(tm),
but
I have not done this.</P>
<P>The following syntax indicates a command run as <EM>user</EM>:</P>
<P><TT>$ <command></TT></P>
<P>The following syntax indicates a command run as a superuser:</P>
<P><TT># <command></TT></P>
<H1>Installing eCos</H1>
<H2>Getting eCos source</H2>
<P>I would strongly recommend getting the latest CVS version of eCos,
and
not attempt to use version 1.3.1, which still seems to be being used
even
though it is very old. The following contains extracts from Redhat's
<A HREF="http://sources.redhat.com/ecos/anoncvs.html">eCos anonymous
CVS
page</A>.</P>
<P>Type the following command to login to the CVS server:</P>
<P><TT>$ cvs -d :pserver:anoncvs@sources.redhat.com:/cvs/ecos
login</TT></P>
<P>You will be prompted for a password which is <EM>anoncvs</EM>. You
only
need to perform this login the first time you access the eCos CVS
repository. The password is saved in the file <TT>.cvspass</TT> in
your
home directory for use in subsequent sessions.</P>
<P>It is recommended that you use different directory trees for the
anonymous CVS sources and for full releases of eCos. Create a new
directory for the check out and change to that directory:</P>
<P><TT>$ mkdir ~/ecos-cvs</TT></P>
<P><TT>$ cd ~/ecos-cvs</TT></P>
<P>Now type:</P>
<P><TT>$ cvs -d :pserver:anoncvs@sources.redhat.com:/cvs/ecos co -P
ecos</TT>
</P>
<P>This command should initiate a connection to the CVS server and check
out the latest version of eCos, including TCP/IP networking stack and
SNMP. It may take quite a while.</P>
<P>If you are unable to use CVS, David Airlie of Parthus Technologies
plc.
<A HREF="ftp://ftp.skynet.ie/cvs">places complete CVS snapshots
here</A>;
obtain the latest one of these and unzip it into the <TT>ecos-cvs</TT>
directory.</P>
<H2>Getting eCos Configuration Tool Version 2</H2>
<P>I would recommend using the graphical Configuration Tool as it is
generally easier to use than trying to decipher the relatively terse
configuration files to change options. The following contains extracts
from Redhat's <A HREF="http://sources.redhat.com/ecos/ct2.html">eCos
Configuration Tool Version 2 page</A>:</P>
<P>Download
<A
HREF="ftp://sources.redhat.com/pub/ecos/ct2/configtool-2.11-i386.tar.gz">con
figtool-2.11-i386.tar.gz
(3.1Mb)</A> or
<A
HREF="ftp://sources.redhat.com/pub/ecos/ct2/configtool-2.11-i386.tar.bz2">co
nfigtool-2.11-i386.tar.bz2
(2.8Mb)</A></P>
<P>Login as superuser and unarchive the tar file into a suitable
directory.
I am assuming here that <TT>/usr/local/ecos/configtool</TT> is the
required destination directory for all files (note:
<TT>configtool</TT>
does not have to be installed by superuser, but it is preferable):</P>
<P><TT>$ su</TT></P>
<P><TT># mkdir -p /usr/local/ecos/configtool/bin</TT></P>
<P><TT># cd /usr/local/ecos/configtool/bin</TT></P>
<P><TT># tar xvfz /home/user/configtool-2.11-i386.tar.gz</TT> </P>
<P>(or, if you dowloaded the bz2 version)</P>
<P><TT># bunzip2 -c /home/user/configtool-2.11-i386.tar.bz2 |
tar -xf -</TT></P>
<P>You will probably need to add the executable directory to the
path:</P>
<P><TT># export PATH=/usr/local/ecos/configtool/bin:$PATH</TT></P>
<P>It is also wise to add this line to your shell initialisation script
(<TT>.bashrc</TT>,
or <TT>.bash_profile</TT>)</P>
<P>The following files will be extracted to the installation
directory:</P>
<P><TT>configtool, ecoslogo.png, rhlogo.png, about.htm, README.txt,
license.txt, ecosplatforms.tar.gz, manual/</TT></P>
<P>Optionally, untar the contents of ecosplatforms.tar.gz into your home
directory, where it will create a directory called .eCosPlatforms. The
information in these files isn't yet used by the Configuration Tool,
but
will keep the tool from generating some warnings.</P>
<P>The executable is statically linked to the wxWindows library, but
does
require the GTK+ 1.2, GDK 1.2 and TCL 8.x libraries to be installed.
</P>
<H2>Getting <TT>arm-elf</TT> tools</H2>
<P>As this is a complex procedure, you need to follow the directions
<A
HREF="http://sources.redhat.com/ecos/tools/linux-arm-elf.html">here</A>
exactly. Once you have done this, you will have all the required tools
needed to build for an <TT>arm-elf</TT> target (note this does not
include the thumb target).</P>
<H2>Building eCos environment for PID target</H2>
<H3>Set the repository</H3>
<P>Assuming you have checked out the latest version to a directory
called
<TT>ecos-cvs</TT>, you need to set the following environment variable
for
the Configuration Tool to pick up where all the source is (known as
the
<EM>repository</EM>, not to be confused with the CVS repository):</P>
<P><TT>$ ECOS_REPOSITORY=ecos-cvs/ecos/packages; export
ECOS_REPOSITORY</TT></P>
<H3>Create the <TT>ecos.ecc</TT> file</H3>
<P>Create a new directory in your home directory and change to it:</P>
<P><TT>$ mkdir -p ~/ecos-targets/pid-current</TT></P>
<P><TT>$ cd ~/ecos-targets/pid-current</TT></P>
<H3>Run the configtool</H3>
<P>Enter the following</P>
<P><TT>$ configtool</TT></P>
<P>You should see the Configuration Tool start.</P>
<H3>Create default settings for the PID target</H3>
<P>To create the default settings needed for the PID development board
target, select the <EM>Build->Templates...</EM> menu item. In the
'Hardware' combo box, select 'ARM development board (PID)', and press
'OK'.</P>
<P>Change the following options:</P>
<P><EM>eCos HAL->ROM Monitor support->Work with a ROM Monitor</EM>
to Disabled (unchecked)</P>
<P><EM>eCos HAL->Platform-independent HAL options->Route
diagnostic
output to debug channel</EM> to Disabled (unchecked)</P>
<P>Now save the file as ecos.ecc using the <EM>File->Save as...</EM>
menu item</P>
<H3>Build the tree</H3>
<P>To build the tree for the PID development board, select the
<EM>Build->Generate
Build Tree</EM> menu item. You will see three directories:
<TT>ecos_build</TT>,
<TT>ecos_install</TT> and <TT>ecos_mlt</TT></P>
<H3>Make the libraries</H3>
<P><TT>$ cd ecos_build</TT></P>
<P><TT>$ make</TT></P>
<P>This will place all the required files for an application in
<TT>ecos_install</TT>.
</P>
<H3>Create the 'two threads' example</H3>
<P><TT>$ cd ../ecos_install</TT></P>
<P><TT>$ mkdir examples</TT></P>
<P><TT>$ cd examples</TT></P>
<P><A
HREF="http://sources.redhat.com/ecos/docs-latest/tutorials/arm/ecos-tutorial
.13.html#pgfId=1982019">Get
the two threads source code from here</A>. Copy it into a file
called
<TT>twothreads.c</TT>.</P>
<P>Build this as follows</P>
<P><TT>$ arm-elf-gcc -g -I../include twothreads.c -L../lib -o
twothreads.x
-Ttarget.ld -nostdlib</TT></P>
<P>There should be no errors. You now have the executable
(<TT>twothreads.x</TT>)
which you can download, debug and run on the SID target using Insight,
or
gdb.</P>
<H1>Installing SID</H1>
<H2>Getting SID source</H2>
<P><STRONG>Note: The SID CGEN source must contain the
<A HREF="http://sources.redhat.com/ml/sid/2002-q3/msg00033.html">patch
submitted by Robert Cragie on 29-Aug-02</A> to work with the eCos
PID
target.</STRONG></P>
<P>The following contains extracts from Redhat's
<A HREF="http://sources.redhat.com/sid">SID page</A>.</P>
<P>Type the following command to login to the CVS server:</P>
<P><TT>$ cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src
login</TT></P>
<P>You will be prompted for a password which is <EM>anoncvs</EM>. You
only
need to perform this login the first time you access the SID CVS
repository. The password is saved in the file <TT>.cvspass</TT> in
your
home directory for use in subsequent sessions.</P>
<P>It is recommended that you use different directory trees for the
anonymous CVS sources and for full releases of SID. Create a new
directory
for the check out and change to that directory:</P>
<P><TT>$ mkdir ~/sid-cvs</TT></P>
<P><TT>$ cd ~/sid-cvs</TT></P>
<P>Now type:</P>
<P><TT>$ cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co
sid</TT>
</P>
<P>This command should initiate a connection to the CVS server and check
out the latest version of SID. It may take quite a while.</P>
<P>If you are unable to use CVS, automated CVS snapshots are available
<A HREF="ftp://sources.redhat.com/pub/sid/snapshots">here</A>; obtain
the
latest one of these and unzip it into the <TT>sid-cvs</TT>
directory.</P>
<H2>Building SID</H2>
<P>Having checked out the source, you should see a single <TT>src</TT>
subdirectory in the <TT>sid-cvs</TT> directory. Create a
<TT>build</TT>
directory alongside this:</P>
<P><TT>$ mkdir build</TT></P>
<P><TT>$ cd build</TT></P>
<P>Login as superuser and run <TT>configure</TT> to produce the build
tree. I am assuming here that <TT>/usr/local/sid</TT> is the required
destination directory for all files:</P>
<P><TT>$ su</TT></P>
<P><TT># ../src/configure --prefix=/usr/local/sid
--exec-prefix=/usr/local/sid 2>&1 | tee configure.out</TT></P>
<P>Now make all the files and install them:</P>
<P><TT># make all install</TT></P>
<P>You will probably need to add the executable directory to the
path:</P>
<P><TT>$ export PATH=/usr/local/sid/bin:$PATH</TT></P>
<P>It is also wise to add this line to your shell initialisation script
(<TT>.bashrc</TT>,
or <TT>.bash_profile</TT>)</P>
<H1>Running a sample session </H1>
<P>Change back to where the twothreads executable is:</P>
<P><TT>$ cd ~/ecos-targets/pid-current/ecos_install/examples</TT></P>
<P>Run SID with the following options:</P>
<P><TT>$ arm-elf-sid --board=arm7t-normalmap --gdb=2000 -EL --tksm
&</TT></P>
<P>What this actually does is run a script file called
<TT>arm-elf-sid</TT>.
This in turn runs a more complex Perl script called
<TT>configrun-sid</TT>,
which builds the complex configuration file needed for SID on the fly,
and
then runs it.</P>
<UL>
<LI>The <TT>--board=arm7t</TT> option is a <TT>configrun-sid</TT>
option which specifies that the configuration file for the PID7T
target
should be constructed. The additional <TT>-normalmap</TT> option
ensures that the remapping operations done at startup by eCos do not
affect the board.</LI>
<LI>The <TT>--gdb=2000</TT> option is also a <TT>configrun-sid</TT>
option which specifies that the configuration file should also
include a
stub to allow GDB connection to the PID7T target via TCP/IP using
port
2000.</LI>
<LI>The -EL option specifies little-endian mode</LI>
<LI>The <TT>--tksm</TT> option is also a <TT>configrun-sid</TT> option
which specifies that the configuration file should also include an
experimental GUI interface which can show the 'innards' of the
target.
This is needed to see the output from the UART.</LI>
<LI><TT>&</TT> simply runs it as a background task.</LI>
</UL>
<P>Select the experimental GUI window titled 'System Monitor' and
left-click and hold on 'uart1' in the left hand column. Select 'GUIs'
and
then 'tk tty'. You should see an empty window called 'hw-uart-ns16550
uart1' come up.</P>
<P>Run GDB (I am assuming you are using Insight):</P>
<P><TT>$ arm-elf-gdb twothreads.x</TT></P>
<P>Connect to the target by selecting the <EM>Run->Connect to
target</EM>
menu item. In the resulting dialog box, select the following options
in
the combo boxes on the left hand side:</P>
<TABLE WIDTH="50%" BORDER="1">
<TR>
<TD WIDTH="80"><EM>Target</EM></TD>
<TD WIDTH="129">Remote/TCP</TD>
</TR>
<TR>
<TD WIDTH="80"><EM>Hostname</EM></TD>
<TD WIDTH="129">localhost</TD>
</TR>
<TR>
<TD WIDTH="80"><EM>Port</EM></TD>
<TD WIDTH="129">2000</TD>
</TR>
</TABLE>
<P>Enable (check) the <EM>Set breakpoint at</EM> checkbox, and enter
'cyg_user_start' in the edit box to the right.</P>
<P>Enable (check) the <EM>Display download Dialog</EM> checkbox.</P>
<P>Click on OK. You should see a dialog saying 'Successfully connected';
press OK on this dialog to dismiss it.</P>
<P>Download the code to the target by selecting the
<EM>Run->Download</EM>
menu item.You should see a dialog showing the download progress; when
it
has finished downloading, press OK on this dialog to dismiss it.</P>
<P>Run the code by selecting the <EM>Run->Run</EM> menu item. You
should see the code run up to the breakpoint specified at
'cyg_user_start'.</P>
<P>Continue the execution by selecting the <EM>Control->Continue</EM>
menu item. You will see it hit another breakpoint at the end of
'main';
ignore this and continue the execution further by selecting the
<EM>Control->Continue</EM>
menu item.</P>
<P>Select the 'hw-uart-ns16550 uart1' window. You should already see the
following text:</P>
<P><TT>Entering twothreads' cyg_user_start() function<BR>
Beginning execution, thread data is 0<BR>
Beginning execution, thread data is 1</TT></P>
<P>Wait patiently. After a while, you should see something like the
following:</P>
<P><TT>Thread 0: and now a delay of 239 clock ticks<BR>
Thread 1: and now a delay of 230 clock ticks</TT></P>
<P>You are now running a fully multi-thread application using eCos
running
on a simulated real target board (i.e. one which actually exists in
real
life).</P>
<H1>Finishing the sample session </H1>
<P>To finish, simply exit GDB as usual, and kill SID by typing:</P>
<P><TT>$ killall -9 sid</TT></P>
<H1>Further issues</H1>
<P>The main problem with the simulation is that the timer tick seems to
be
running much slower than it would do in real life. This needs to be
looked
at. If the delays are reduced in <TT>twothreads.c</TT> then the above
will run quicker.</P>
<P>SID is a complex package, and modifying it for other targets will
require a very good understanding of how it all works and fits
together.
It may also require additional components to be written. This is not a
trivial task.</P>
</BODY>
</HTML>
> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Nick Garnett
> Sent: 02 September 2002 18:51
> To: Tim Drury
> Cc: eCos Discussion
> Subject: Re: [ECOS] how to build an eCos library for ARM7tdmi simulator
>
>
> Tim Drury <tdrury@siliconmotorsports.com> writes:
>
> > Gary Thomas wrote:
> > > Did you follow the instructions? Try looking at the FAQ:
> > > http://sources.redhat.com/fom-serv/sid/cache/6.html
> > > This should work (it does for me).
> >
> > Yes, I tried this. I invoke sid using:
> >
> > /usr/local/sid/bin/arm-elf-sid --gdb=2000 -EL
> >
> > then in another window I run my hello world app:
> >
> > arm-elf-gdb a.out
> >
> > which brings up insight. I connect to remote/tcp (localhost:2000)
> > and hit run. I get:
> >
> > Loading section .rom_vectors, size 0x40 lma 0x2020000
> >
> > in the gdb console, but no source appears in the main window and
> > no "hello world" appears anywhere.
> >
>
> You need to build a PID ROM startup configuration.
>
> However, my experience of trying SID a few months ago is that it no
> longer works for eCos. The ARM HAL in version 2.0 of eCos uses
> instructions that the ARM emulator in SID does not support
> (specifically, the load-multiple-and-restore-PSR instructions). Any
> pre-2.0 HAL will still work since it does not use those instructions.
>
> My investigations into trying to update SID to emulate these
> instructions foundered on the mysteries of cgen and how to convert
> its output files to be useful to SID.
>
> Maybe I'll take another look at it.
>
> --
> Nick Garnett - eCos Kernel Architect
> http://www.eCosCentric.com/
>
>
> --
> Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
> and search the list archive: http://sources.redhat.com/ml/ecos-discuss
>
>
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss