This is the mail archive of the
sid@sources.redhat.com
mailing list for the SID project.
RE: [ECOS] how to build an eCos library for ARM7tdmi simulator
- From: Satish Kumar <satishkumar at sanyo dot co dot in>
- To: 'Robert Cragie ' <rcc at jennic dot com>, Satish Kumar <satishkumar at sanyo dot co dot in>, "'ijsung at csie dot nctu dot edu dot tw '" <ijsung at csie dot nctu dot edu dot tw>
- Cc: "'ecos-discuss at sources dot redhat dot com'" <ecos-discuss at sources dot redhat dot com>, "'sid at sources dot redhat dot com'" <sid at sources dot redhat dot com>
- Date: Fri, 13 Sep 2002 11:46:37 +0530
- Subject: RE: [ECOS] how to build an eCos library for ARM7tdmi simulator
Hi,
i followed the build procedure of sid, as stated in ur mails
was able to finish it sucessfully. but i m not able to connect to the
target board. i.e initially i tried this command:
arm-elf-sid --board=arm7t-normalmap -gdb=2000 -EL --tksm &
i got a message stating 'Unknown board arm7t-normalmap'
later i tried a different command:
arm-elf-sid --board=pid7t-normalmap -gdb=2000 -EL --tksm &
this time,i got a message stating : [1] 816
well next when i run the command
arm-elf-gdb twothread.x
the debugger window opened with the source file displyed in the source
window, now i clicked on Run->Connect to target. and i used the same
settings as stated:
Target: Remote/TCP.
Host:localHost.
port:2000
set breakpoint at 'cyg_user_start'
and other breakpoint at the exit.
on pressing ok, i get an Error message stating:
Error:bad option "-modal" : must be -default,-icon,-message,-parent,-title,
or -type..
and i m not able to run the program..plz kindly tell me how to run the
sid simulator for arm7tdmi and how to run my application programs once
they are compiled using the ecos library built for pid.
satish
-----Original Message-----
From: Robert Cragie
To: satishkumar@sanyo.co.in; ijsung@csie.nctu.edu.tw
Sent: 9/4/02 2:14 PM
Subject: FW: [ECOS] how to build an eCos library for ARM7tdmi simulator
Just in case you didn't get it from the mailing list...
-----Original Message-----
From: Robert Cragie [mailto:rcc@jennic.com]
Sent: 03 September 2002 16:07
To: ecos-discuss@sources.redhat.com
Subject: FW: [ECOS] how to build an eCos library for ARM7tdmi simulator
Further to my original message, I have now run through it step-by-step
doing
a clean install. There were some issues with the original text, so I
have
updated it. I am in the process of doing an SGML version.
Robert Cragie, Design Engineer
_______________________________________________________________
Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
http://www.jennic.com Tel: +44 (0) 114 281 2655
-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Robert Cragie
Sent: 03 September 2002 09:09
To: ecos-discuss@sources.redhat.com
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.
[snip]
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<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 'user'.</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 to 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>/opt/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 /opt/ecos/configtool/bin</TT></P>
<P><TT># cd /opt/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
xvf -</TT></P>
<P>As there is only one executable, it is probably easiest to create
a
symbolic link to it:</P>
<P><TT># ln -s /opt/ecos/configtool/configtool-2.11/bin/configtool
/usr/bin/configtool</TT></P>
<P>Alternatively, make sure that
<TT>/opt/ecos/configtool/configtool-2.11/bin</TT>
is added to your PATH environment variable.</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>
<P><STRONG>Note: On SuSE Linux, there needs to be an additional
symbolic
link to the Tcl library. Do the following:</STRONG></P>
<P><TT># cd /usr/lib</TT></P>
<P><TT># ln -s libtcl8.3.so libtcl.so</TT></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>
<P><STRONG>Note that the link to Insight 5.0 is broken. However, I
have
downloaded and installed
<A
HREF="ftp://sources.redhat.com/pub/gdb/releases/insight-5.2.1.tar.bz2">I
nsig
ht
5.2.1 (insight-5.2.1.tar.bz2)</A> instead and see that it has
some
worthwhile bugfixes from 5.0.</STRONG></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=/home/user/ecos-cvs/ecos/packages; export
ECOS_REPOSITORY</TT></P>
<P>This line should also be added to your shell initialisation
script
(<TT>.bashrc</TT>,
or <TT>.bash_profile</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>Select the <EM>Build->Templates...</EM> menu item. In the
<EM>Hardware</EM>
combo box, select <EM>ARM development board (PID)</EM>, 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 <TT>ecos.ecc</TT> 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-tuto
rial
.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></STRONG>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>/opt/sid</TT> is the required
destination directory for all files:</P>
<P><TT>$ su</TT></P>
<P><TT># ../src/configure --prefix=/opt/sid --exec-prefix=/opt/sid
2>&1
| tee configure.out</TT></P>
<P>You will need the additional
<A
HREF="http://sources.redhat.com/ml/sid/2002-q3/msg00036.html">patch
submitted by Robert Cragie on 03-Sep-02</A>:</P>
<P><TT># cd ~/sid-cvs/src/cgen/cpu</TT></P>
<P><TT># patch -p0 < arm7.cpu.patch</TT></P>
<P><TT># cd ~/sid-cvs/build/sid/component/cgen-cpu/arm7t</TT></P>
<P><TT># make cgen-all</TT></P>
<P>Now make all the files and install them:</P>
<P><TT># cd ~/sid-cvs/build</TT></P>
<P><TT># make all install</TT></P>
<P>Note that this may take a <EM>very</EM> long time (hours).</P>
<P>Add the executable directory to the path:</P>
<P><TT>$ export PATH=/opt/sid/bin:$PATH</TT></P>
<P>This line should also be added 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=pid7t-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=pid7t</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. Initially, you will get a 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>Disable (uncheck) 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. Note that on Insight 5.2.1
these
settings are remembered on further connections to the target.</P>
<P>Download the code to the target by selecting the
<EM>Run->Download</EM>
menu item.You should see a blue bar in the status bar showing the
download
progress.</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',
and another at 'exit'; ignore these and continue the execution
further
by
selecting the <EM>Control->Continue</EM> menu item in each
case.</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>