embedding epics/rtems into altera nios2 fpga softcore
DESCRIPTION
Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore. Jeffrey O. Hill. Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore. Overview Requirements Proof of Principal Issues … First Step – Wrap Altera NIOS2 GNU Tools Next Step – Build RTEMS/NIOS GNU Tools Future Plans. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/1.jpg)
![Page 2: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/2.jpg)
Overview› Requirements› Proof of Principal› Issues …› First Step – Wrap Altera NIOS2 GNU Tools› Next Step – Build RTEMS/NIOS GNU Tools› Future Plans
![Page 3: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/3.jpg)
Requirements for EPICS IOCs, LANSCE RF system upgrade› Must be deterministically synchronized with
the timing system Binding of captured waveforms with beam flavor
attributes obtained from the timing system Modal behavior changes of low level RF controls
depending on the flavor of beam› Must move captured waveforms from FPGA,
into the IOC, and out to Ethernet
![Page 4: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/4.jpg)
Traditional VME/cPCI backplanes› Now they are becoming a bottleneck
There are Altera IP cores for› System processor› Ethernet interface
Can we distribute the solution?› One IOC on each cPCI RF board › Stream data directly, FPGA to Ethernet
A proof of principal is needed
![Page 5: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/5.jpg)
Third party FPGA intellectual property libraries for ARM, MIPS, etc › Are well supported by the GNU tools› However, use of these IP modules involves
licensing expense Which our RF group prefers to avoid
![Page 6: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/6.jpg)
Hardware› Altera NIOS Embedded Evaluation Kit
NIOS II Reference Platform on FPGA Software
› GNU Cross Development Tools› RTEMS OS› EPICS IOC
![Page 7: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/7.jpg)
Altera does› Provide source code for their nios2
enhancements to binutils/gcc/newlib› Modern version now available
FSF binutils 2.20 for nios2 FSF gcc 4.1 for nios2 FSF newlib 1.16 for nios2
Altera doesn't feed back their nios2 enhancements into the asynchronous FSF releases of binutils/gcc/newlib
![Page 8: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/8.jpg)
RTEMS does feed their enhancements back into the asynchronous FSF releases of binutils/gcc/newlib
RTEMS does depend on these enhancements› RTEMS 4.10 appears to require a recent
release of gnu gcc and newlib
![Page 9: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/9.jpg)
RTEMS doesn’t supply it’s nios2 support files in any production release, but › These files can be obtained by fetching the
main development trunk out of CVS
In summary, bringing all of the players together can be somewhat complicated …
![Page 10: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/10.jpg)
Various components independently maintained but working closely together› Binutils
Loader, assembler, and others …› Newlib
C runtime library for embedded systems› GCC
We use … C and C++ compilers
Proper runtime support for C++ is essential Various support libraries
![Page 11: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/11.jpg)
I tried the instructions available at http://www.nios2rtems.com/› Create wrapper script for altera-built gnu cross compiler
binaries› Build newlib, and then rtems
Very helpful tutorials at this site› See details about creating rtems bsp using output from
Altera’s nios2-bsp tool Unfortunately, some insurmountable issues with
this specific approach› The Altera built gnu cross compiler…
Configured with –disable-threads Compiler’s c++ runtime isn't using rtems primitives for
synchronization
![Page 12: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/12.jpg)
Altera enhanced sources for binutils/gcc/newlib are available
Perhaps we can configure and build them specifically for RTEMS› Configuring RTEMS thread model› Configuring RTEMS BSP startup libraries to
be implicitly linked in
![Page 13: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/13.jpg)
RTEMS main trunk is currently incompatible with newlib 1.16
Two options1. Back annotate rtems nios2 support files from
main trunk into earlier RTEMS release compatible with Altera’s newlib 1.16
2. Forward annotate newlib nios2 support files from Altera modified FSF newlib 1.16 to FSF newlib 1.18
Currently I am concentrating on 2, but expect to eventually use a combination of 1 and 2 in production systems
![Page 14: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/14.jpg)
Typical steps when installing a GNU package from source › Obtain source› Patch source› Run autoconf in the source› Configure the source› Build the package› Install the package
![Page 15: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/15.jpg)
“cat ../gcc-4.3.2-rtems4.10-20080917.diff | patch -p1”
“find . -name "*.rej" –print” Sometimes we have to fix by hand
what is found in *.rej
![Page 16: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/16.jpg)
Need autoconf and automake› Always run first autoreconf in source tree if
patches apply to *.am, *.ac, *.in, …› Maybe running autoconf isn't enough
› Different packages need different versions of these tools› Sometimes the exact same version is needed› Sometimes the same or newer version is needed?› Different components have different requirements
![Page 17: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/17.jpg)
Need gnu libgmp, libppl, libelf… http://gcc.gnu.org/install/prerequisites.html But in practice, the uninitiated may
iterate a few times as follows… Run gnu “configure” Look in config.log for “error” If there are errors install missing packages Run configure again …
![Page 18: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/18.jpg)
Altera Nios enhanced FSF source code› ftp://ftp.altera.com/outgoing/download/
support/ip/processors/nios2/gnu/› I used nios2_gnu_gcc4_11.0.tgz
Apply RTEMS patches› ftp://ftp.rtems.com/pub/rtems/SOURCES/4.10/› ftp://ftp.rtems.com/pub/rtems/SOURCES/4.7
![Page 19: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/19.jpg)
Added gcc/config/nios2/rtems.h Added gcc/config/nios2/t-rtems Added new case in gcc/config.gcc Added symbolic link to gcc/newlib
![Page 20: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/20.jpg)
http://sourceware.org/newlib/› Altera’s newlib 1.16
Incompatible with RTEMS 4.11- Transplanting NIOS2 specific code from
Altera’s Newlib 1.16 wasn't too daunting› Applied RTEMS 4.10 patches
Patch file “newlib-1.18.0-rtems4.10-20110518”
› Some RTEMS modifications for nios2
![Page 21: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/21.jpg)
Modified› newlib/include/machine/setjmp.h› newlib/libc/sys/rtems/machine/_types.h› newlib/libc/sys/rtems/crt0.c
![Page 22: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/22.jpg)
Run autoconf in gcc source tree “mkdir b-gcc” “cd b-gcc” Run configure
../gcc/altera-gcc-4.1-patched/configure--target=nios2-rtems --enable-threads --with-gnu-as --with-gnu-ld --with-newlib --verbose --disable-libstdcxx-pch--enable-multilib--enable-languages="c,c++" --prefix=$(INSTALL_RTEMS)
“make all” followed by “make install”
![Page 23: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/23.jpg)
I used RTEMS 4.11-› But, nios2 support isn't included in any
public rtems release› I obtained 4.11- from anonymous CVS
In the cvs trunk, nios2 support is bundled
![Page 24: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/24.jpg)
“mkdir b-rtems” “cd b-rtems” ../rtems-4.11-/rtems/configure
--target=nios2-rtems --enable-posix --enable-networking --enable-rtbg --enable-cxx --disable-tests --enable-rtemsbsp=neek--prefix=$(INSTALL_RTEMS)
![Page 25: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/25.jpg)
The g++ appears to expect c++ header are in a different location than where they are actually installed.
Still working in this issue Have booted RTEMS on NIOS, but not
with C++ code.
![Page 26: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/26.jpg)
Altera Triple-Speed-Ethernet driver› Port Linux Ethernet driver to RTEMS
Regression Tests Performance tests
![Page 27: Embedding EPICS/RTEMS into Altera NIOS2 FPGA Softcore](https://reader036.vdocument.in/reader036/viewer/2022062323/56816837550346895dddf87b/html5/thumbnails/27.jpg)
http://www.nios2rtems.com http://www.alterawiki.com/wiki/CrossGcc http://www.ifp.illinois.edu/~nakazato/
tips/xgcc.html