RTEMS+Cexp+GeSys

Anton Derbenev aaderbenev at gmail.com
Thu Dec 14 02:13:18 UTC 2017


Hello all,

at NSLS-II, we have several dozen MVME3100 VME crates running RTEMS with
EPICS driver for various diagnostics and MRF timing hardware. The entire
setup was handily created quite some time ago by combining RTEMS 4.9 with
Cexp and GeSys to provide convenient booting and debugging capabilities. As
an effort to make the setup more up-to-date, I made an attempt to compose a
how-to which would describe how to successfully compile a bootable
RTEMS+Cexp+GeSys image. A nice "bonus" would be if that image also worked
when being run on a crate.

It is not my first attempt as I already tried to do a similar thing for
RTEMS 4.10. While in both cases I found lots of work being put by the
community in helpful toolsets and documentation, the building process was
not as straightforward as one would imagine by reading the QuickStart
guide. There are many stumbles which, while probably being primitive in
most cases, could be annoying to a user who lacks core developer knowledge
and perspective. Some things can be mentioned _somewhere_ and can only be
found quickly by google-fu and/or luck.

This time I reached for RTEMS 5 right away. Results which I achieved are
very similar to those which I had for RTEMS 4.10 - I can create a bootable
image which appears to have working GeSys and Cexp shell, but access to
"st.sys" fails along with other suspicious symptoms.

Below is my "how-to" process which yields a bootable "rtems.ralf" file, and
results for our test MVME3100 system boot procedure. Some points
highlighted will probably be useful for further users' reference, and some
of them come from earlier conversations on the mailing list. My hope is
that someone knowledgeable will kindly review my steps and give some hint
why the image fails to work as expected. Perhaps it would be great to have
a step-by-step how-to as a part of documentation somewhere.

====================
RTEMS 5 + Cexp + GeSys How-To

1. Get RTEMS source builder (rsb). As a part of its configuration, rsb will
try to fetch various sources from multiple locations. If rsb is being
configured in a protected environment (e.g. http proxy, firewalls, etc.),
source locations can be unavailable. Get rsb sources on a machine which can
freely download from git.rtems.org, github.com etc. with both http(s) and
git protocol:

$ mkdir --parents ~/src/RTEMS
$ cd ~/src/RTEMS
$ git clone http://github.com/RTEMS/rtems-source-builder.git rsb
$ cd rsb/rtems

Perform dry configuration and only download sources, as suggested here:

https://lists.rtems.org/pipermail/users/2017-September/031647.html

Choose profile as appropriate (rtems-powerpc for MVME3100):

$ ../source-builder/sb-set-builder --dry-run --with-download
--without-error-report --without-release-url 5/rtems-powerpc

2. If firewalls and proxies are not a problem for you, skip this step. Even
though sources were pre-downloaded, rsb will try to fetch the rtems-tools
repository during the build process (even if --no-download is specified).
We need to make sure the repository is accessible or the lengthy build
process (~ hour on two cores) will fail. In our environment, git protocol
didn't work through http(s) proxy, so git config was modified:

$ cd ~/src/RTEMS/rsb/rtems
$ nano sources/git/rtems-tools.git/.git/config

Replace:
url = git://git.rtems.org/rtems-tools.git
with:
url = https://github.com/RTEMS/rtems-tools.git

3. rsb now has sources and patches downloaded. If you will build RTEMS on a
different host, move the entire folder to the build machine.

My build setup:

$ uname -a
Linux sandbox8 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26)
x86_64 GNU/Linux
$ cat /etc/debian_version
8.9

All further steps are performed on the build machine.

4. Run sb-check and install necessary packages if the check tool complains:

$ cd ~/src/RTEMS/rsb
$ ./source-builder/sb-check

Alas, sb-check doesn't check for everything. For example, the build process
can fail with something like:

checking for python... /usr/bin/python
checking for python2.7... no

This is resolved by being lucky in finding a similar issue discussed on the
mailing list. Additional packages may be needed, in the mentioned case it
was:

$ sudo apt-get install python2.7-dev

5. Build rsb (takes a while, was an hour on my dual-core VM). Since sources
were pre-downloaded, specify "--no-download" (however rtems-tools will
still be fetched!):

$ ../source-builder/sb-set-builder --no-download --prefix=$HOME/src/RTEMS/5
5/rtems-powerpc

6. Build rtems. First make sure rsb tools are in path:

$ export PATH=$HOME/src/RTEMS/5/bin:$PATH

Get RTEMS source:

$ cd ~/src/RTEMS
$ mkdir kernel
$ cd kernel
$ git clone https://github.com/RTEMS/rtems.git

Run bootstrap scripts to generate files which are missing in cloned
repository:

$ cd rtems
$ ./bootstrap -c
$ ./bootstrap -p
$ ../../rsb/source-builder/sb-bootstrap
$ cd ..

Configure and build RTEMS for the target:

$ mkdir build-mvme3100
$ cd build-mvme3100
$ ../rtems/configure --enable-networking --enable-cxx --enable-rdbg
--enable-posix --prefix=$HOME/src/RTEMS/5 --target=powerpc-rtems5
--enable-rtemsbsp=mvme3100
$ make -j 8
$ make install

7. Build Cexp. Two things which are not straightforward is getting all
submodules and running "make prep".

$ cd ~/src/RTEMS
$ mkdir cexp
$ cd cexp
$ git clone https://github.com/till-s/cexpsh.git
$ cd cexpsh
$ git submodule update --init --recursive

As with RTEMS bootstrap, we need to generate some missing files.
Stunningly, I didn't find it mentioned in cexpsh/INSTALL:

$ make prep

Now the code is ready to be configured and built. Use
"--enable-std-rtems-installdirs"
to perform installation on top of the previously built RTEMS tree:

$ cd ..
$ mkdir build-mvme3100
$ cd build-mvme3100
$ ../cexpsh/configure --enable-std-rtems-installdirs
--with-rtems-top=$HOME/src/RTEMS/5 --host=powerpc-rtems5
--enable-rtemsbsp=mvme3100
$ make -j 8
$ make install

8. Build GeSys. Another trickery here - before configuring, it is necessary
to build the ldep tool as mentioned in documentation.

Get all GeSys sources and submodules:

$ cd ~/src/RTEMS
$ mkdir gesys
$ cd gesys
$ git clone https://github.com/till-s/rtems-gesys.git
$ cd rtems-gesys
$ git submodule update --init --recursive

As for other parts, generate missing files by running the bootstrap tool:

$ ./bootstrap

Another bootstrap is necessary for ldep:

$ cd ldep
$ ./bootstrap
$ mkdir build
$ cd build

Configure and install ldep to where all rsb stuff is:

$ ../configure --prefix=$HOME/src/RTEMS/5
$ make
$ make install

Configure and install GeSys in the same tree where RTEMS and Cexp are by
using "--enable-std-rtems-installdirs". Note that $HOME/src/RTEMS/5/bin
must be in PATH:

$ cd ~/src/RTEMS/gesys
$ mkdir build-mvme3100
$ cd build-mvme3100
$ ../rtems-gesys/configure --enable-std-rtems-installdirs
--with-rtems-top=$HOME/src/RTEMS/5 --host=powerpc-rtems5
--enable-rtemsbsp=mvme3100
$ make -j 8
$ make install

9. Behold the build binaries:

$ cd ~/src/RTEMS/5/powerpc-rtems5/bin
$ ls
ar  ld      nm       objdump  readelf    rtems.ralf  st.sys
as  ld.bfd  objcopy  ranlib   rtems.exe  strip

rtems.ralf is the thing. It worth mentioning that none of .obj files loaded
in the "st.sys" are present (telnetd.obj, monitor.obj etc.)

====================
Boot the image

I put the resulting image in our VME timing test setup which successfully
boots and runs RTEMS 4.9. Boot procedure is DHCP with MOTLoad netBoot.
"rtems.ralf" was renamed to "rtems.boot" for booting purposes. Boot
sequence:

********************
Copyright(C)2008-2013,Emerson Network Power-Embedded Computing,Inc.
All Rights Reserved
Copyright Motorola Inc. 1999-2007, All Rights Reserved
MOTLoad RTOS Version 2.0,  PAL Version 1.2 RM04
Wed Nov  6 17:17:43 MST 2013

MPU-Type             =MPC8540
MPU-Int Clock Speed  =666MHz
MPU-CCB Clock Speed  =333MHz
MPU-DDR Clock Speed  =166MHz
MPU-PCI Clock Speed  =66MHz, PCI, 64-bit
MPU-Int Cache(L2) Enabled, 256KB, L2CTL =A8000300

Reset/Boot Vector    =Flash0

Local Memory Found   =10000000 (&268435456)
User Download Buffer =0159D000:0179CFFF

MVME3100> bootmem=malloc 0x500000

return = 0193D000 (&26464256)
errno  = 00000000
MVME3100> netBoot -d/dev/enet0 -v -abootmem -p -h -u
Network Loading from: /dev/enet0

Locating BOOTP Server... Found It!

Client IP Address      = 10.0.1.104
Server IP Address      = 10.0.1.1
Gateway IP Address     = 0.0.0.0
Subnet IP Address Mask = 255.255.255.0
Boot File Name         = rtems-5/rtems.boot
Load Address           = 0193D000
Buffer Size = ffffffff

Network Boot File Load Start - Press <ESC> to Bypass, <SPC> to Continue

Network Boot File Load in Progress - Press <CTRL-C> to Abort[]>>>>
...
Bytes Received =&4886264, Bytes Loaded =&4886264
Bytes/Second   =&488626, Elapsed Time =10 Second(s)

Execution Halted on Request
MV-----------------------------------------
Welcome to rtems-5.0.0 (PowerPC/Generic (no FPU)/mvme3100)
BSP: mvme3100, CVS Release ($Name$)
CPU 0x8020 - rev 0x20
Additionnal boot options are H
Initial system stack at 14c9980
Software IRQ stack starts at 14c9a90 with size 16384
Going to start PCI buses scanning and initialization
Board Type: MVME3100-1152 (S/N E10EA0D)
External (=PCI Bus) Clock Freq   :   66666666 Hz
Core Complex Bus (CCB) Clock Freq:  333333330 Hz
CPU Clock Freq:                     133333332 Hz
Ethernet 0                  EC:9E:CD:0E:16:5B
Ethernet 1                  EC:9E:CD:0E:16:5C
Ethernet 2                  EC:9E:CD:0E:16:5D
Number of PCI buses found is : 2
BUS:SLOT:FUN  VENDOR-DEV_ID: COMMAND STATUS BASE_ADDR0 BASE_ADDR1 IRQ_PIN
-> IRQ_LINE
  0:0x00:0    0x1057-0x0008:  0x0006 0x20b0 0x80000000 0x00000000       0
->   0 (=0x00)
  0:0x11:0    0x10e3-0x0148:  0x0146 0x02b0 0x80100004 0x00000000       1
->   0 (=0x00)
  0:0x12:0    0x10b5-0x6520:  0x0147 0x02b0 0x00000000 0x00000000       0
->   0 (=0x00)
  0:0x14:0    0x1095-0x3124:  0x01c7 0x02b0 0x80300004 0x00000000       1
->   2 (=0x02)
  1:0x00:0    0x10b5-0x9030:  0x0142 0x0290 0x80200000 0x00000000       1
->   4 (=0x04)
Memory:                             268435456 bytes
Cleared PCI errors: pci_stat was 0x20b0
OpenPIC Version 1.2 (1 CPUs and 56 IRQ sources) at 0x3775135744
OpenPIC Vendor 0 (Unknown), Device 0 (Unknown), Stepping 0
OpenPIC timer frequency is 41666666 Hz
MSR is 0x00001000, TCR 0x04000000
-----------------------------------------
Exit from bspstart
libi2c: Library not initialized
Registering mpc8540 i2c bus driver :No such file or directory
Tundra Tsi148 PCI-VME bridge detected at 0x80100000, IRQ 0
Tsi148 Outbound Ports:
Port  VME-Addr   Size       PCI-Adrs   Mode:
0:    0x20000000 0x0e000000 0xc0000000 A32, SUP, D32, SCT
1:    0x00000000 0x00ff0000 0xcf000000 A24, SUP, D32, SCT
2:    0x00000000 0x00010000 0xcfff0000 A16, SUP, D32, SCT
7:    0x00000000 0x01000000 0xce000000 CSR, SUP, D32, SCT
Tsi148 Inbound Ports:
Port  VME-Addr   Size       PCI-Adrs   Mode:
0:    0xc0000000 0x10000000 0x00000000 A32, PGM, DAT, SUP, USR, MBLT, BLT
vmeTsi148 IRQ manager: looking for registers on VME...
Trying to find CSR on VME...
vmeTsi148 - IRQ manager using VME CSR to flush FIFO
Registering /dev/console as minor 0 (==/dev/ttyS0)
Welcome to RTEMS 5.0.0 GeSys
This system  was built on 20171213EST19:00:39
Installing TIOCGWINSZ line discipline: ok.
To skip initialization, press a key now...
bootpc_init: using network interface 'tse1'
bootpc hw address is ec:9e:cd:e:16:5b
My ip address is 10 .0 .1 .104
Time Server is 10 .0 .1 .1
Domain name is cs.nsls2.local
Boot file is rtems-5/rtems.boot
Command line is IOCNAME=timing
Subnet mask is 255 .255 .255 .0
Server ip address is 10 .0 .1 .1
Gateway ip address is 0 .0 .0 .0
Log server ip address is 10 .0 .1 .1
bootpc_adjust_interface: add net route, error=114
Trying to synchronize NTP...OK
Trying symfile 'BUILTIN', system script 'st.sys'
'st.sys':
opening script file: No such file or directory
Type 'cexpsh.help()' for help (no quotes)
********************

There are several suspicious points: PCI buses scanning not reporting
anything, i2c library/driver errors, bootpc_adjust_interface error, and of
course "st.sys" script not being found. Peculiar enough, I can perform NFS
mount and run a script from there. It doesn't work smoothly however and
nfsMountsShow output is odd:

Cexp>nfsInit(0,0)
RTEMS-NFS, Till Straumann, Stanford/SLAC/SSRL 2002, See LICENSE file for
licensing info.
0x00000000 (0)
Cexp>nfsMount("10.0.1.1","/srv/tftp/rtems-5","/common")
Trying to mount 10.0.1.1:/srv/tftp/rtems-5 on /common
RTEMS-RPCIOD, Till Straumann, Stanford/SLAC/SSRL 2002, See LICENSE file for
licensing info.
0x00000000 (0)
Cexp>nfsMountsShow(0)
Currently Mounted NFS:
10.0.1.1:/srv/tftp/rtems-5 on /
0x00000000 (0)

====================
Conclusion

To conclude that, I'd be happy to hear any suggestions and insights to the
procedure described. It might be something as obvious as missing an option
somewhere. It would be also great if anyone who has a working
RTEMS+Cexp+GeSys setup would share instructions on how to make it work
properly.

Best regards,
Anton A. Derbenev
NSLS-II
Brookhaven National Laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20171213/d3858adf/attachment-0001.html>


More information about the users mailing list