RTEMS on Virtex 4
Joel Sherrill
joel.sherrill at OARcorp.com
Sat Jun 1 19:25:41 UTC 2013
Hi
Your results bothered me enough to investigate some this weekend.
This is with the git master and newly built tools. I am just referring
to hello and minimum found in testsuites/samples. minimum is
a simple application that does a system start up and shutdown. Its
size is usually more indicative of BSP complexity and unexpected
or unnecessary references in the core part of the BSP.
The size info I am showing is the output of the size command. The
numbers are text, data, bss, total in decimal and total in hex.
Configuring with networking and POSIX disabled, hello and minimum
have these sizes:
SIZE: 36759 1212 1653 39624 9ac8 minimum.exe
SIZE: 74831 1496 2057 78384 13230 hello.exe
Moving from -O2 to -Os resulted in:
SIZE: 32599 1336 1653 35588 8b04 minimum.exe
SIZE: 65467 1620 2057 69144 10e18 hello.exe
hello is 9364 bytes smaller which is over 10% reduction in size.
Getting a bit more aggressive and into something you would have
to confirm still works on target hardware... I turned on GCC function
and data sections. This lets GNU ld leave out unreferenced symbols.
Unfortunately, unless the linker script is 100% correct, it can accidentally
leave out things you need. We will likely be turning this on in the future
as it gets tested on a board per board basis. But on sparc/erc32, I
got this to work and every test ran. On larger RTEMS tests, this was
averaging around 50% reduction in .text size.
SIZE: 24081 476 1637 26194 6652 minimum.exe
SIZE: 60318 1472 2049 63839 f95f hello.exe
Overall, that's a sizeable drop in hello -- from 75K to 60K and all are
smaller than yours.
As one final example, I tinkered with
testsuites/samples/samples/hello/init.c
to use printk(), call rtems_shutdown_executive() not exit() and to turn off
the console device driver (thus avoiding termios). This dropped the
hello executable further to:
SIZE: 46009 1392 1809 49210 c03a hello.exe
That gets us from 75831 to 46009 which is approximately 40% smaller
and about 1/3 of your original size.
Each of the 5 tasks in your app will require a stack whose size you can
specify, I would guess about 3K for semaphores and task control structures
as a safe estimate. You should follow the minimum example and let the
init task become the idle task and only configure 16 priorities. If you
don't
need termios, disable the console and use printk() for debug.
I have attached a diff to the rtems master showing what I did along
with a text file with the sizes of all the samples. I do need to repeat
that the function sections change would need to be tested to ensure
the executables are still OK. But since they only have reasonable
reductions in size, they should work. I saw one BSP where my executables
when to 0x80 bytes in all cases. Obviously there were linker script
issues I had to fix. :)
--joel
On 05/31/2013 05:57 AM, Gempeler Stefan wrote:
>
> Hi,
>
> First I would like to introduce myself: the last couple of years I
> developed software for PCs and embedded systems (always worked on
> "bare metal" ARM etc. or on a runnung "big" OS). Therefore I never had
> to use and set up an OS on an embedded system. Now I have to evaluate
> one for a space project which should run on the following hardware:
>
> - Xilinx Virtex4, PowerPC405
>
> - Evaluationboard: ML410
>
> - final design: RAM: max. 192 kB for program and data
>
> Our system should support (estimation):
>
> - 5 threads
>
> - accurate system time
>
> - around 5 interrupts: peripheral (UARTs + IO)
>
> - around 5 mutex
>
> - around 5 semaphores
>
> - …
>
> I came across the RTEMS project which seems to be very interesting.
> Since I'm quite unexperienced in setting up such a system, I went
> through the documentation and some websites which made me build a
> "running" system:
>
> - built the rtems system with the system builder:
>
> >
> http://www.rtems.org/ftp/pub/rtems/people/chrisj/source-builder/source-builder.html
>
> - set up eclipse inspired by
>
> > http://www.rtems.org/pipermail/rtems-users/2012-February/009439.html
>
> - working on RTEMS commit e67025e3900f23e1b9a25b939d7bff37a9c5e9f0
>
> - made some changes on BSP "virtex"
>
> - took the init.c from examples-v2/hello (tested all 3: Classic,
> POSIX, Classic+POSIX)
>
> -> now I've got a "Hello World" application running on the evaluation
> board using an UART as stdio J
>
> So far so good, now my Questions:
>
> 1. When I try to add some code the system, it does not work anymore.
> Well, I'm not surprised when I consider my tinkering ;-)
>
> 2. The test program is only a simple "Hello World" and it already
> consumes 2/3 of our memory, which is a no-go:
>
> text data bss dec hex filename
>
> 126520 1724 4004 132248 20498 o-optimize/rtems-app.exe
>
> Ok, I'm sure that the system I put together is not optimized at
> all, but I'm still quite surprised...
>
> 3. I also got stuck (and confused) using interrupts:
> rtems_interrupt_catch() as mentioned in the RTEMS C User’s Guide seems
> to be deprecated. Tried the BSP_install_rtems_irq_handler(), but
> didn't succeed either...
>
> 4. Most important: To have a good feeling about the correct setup of
> the system, I would appreciate to get in touch with an expert who
> helps me to move on setting up for evaluating RTEMS. Where can I get
> such additional support for our system (http://support.rtems.com/ and
> http://www.rtems.com/support.html seems to be down)?
>
> Thank you very much!
>
> Kind regards
>
> Stefan Gempeler
>
--
Joel Sherrill, Ph.D. Director of Research& Development
joel.sherrill at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35806
Support Available (256) 722-9985
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20130601/2ea8bb8a/attachment.html>
-------------- next part --------------
diff --git a/c/src/lib/libbsp/bfin/acinclude.m4 b/c/src/lib/libbsp/bfin/acinclude.m4
index 828fd89..ab6082e 100644
--- a/c/src/lib/libbsp/bfin/acinclude.m4
+++ b/c/src/lib/libbsp/bfin/acinclude.m4
@@ -2,12 +2,12 @@
AC_DEFUN([RTEMS_CHECK_BSPDIR],
[
case "$1" in
+ TLL6527M )
+ AC_CONFIG_SUBDIRS([TLL6527M]);;
bf537Stamp )
AC_CONFIG_SUBDIRS([bf537Stamp]);;
eZKit533 )
AC_CONFIG_SUBDIRS([eZKit533]);;
- TLL6527M )
- AC_CONFIG_SUBDIRS([TLL6527M]);;
*)
AC_MSG_ERROR([Invalid BSP]);;
esac
diff --git a/c/src/lib/libbsp/powerpc/acinclude.m4 b/c/src/lib/libbsp/powerpc/acinclude.m4
index e46fa2b..6442399 100644
--- a/c/src/lib/libbsp/powerpc/acinclude.m4
+++ b/c/src/lib/libbsp/powerpc/acinclude.m4
@@ -38,12 +38,12 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
AC_CONFIG_SUBDIRS([t32mppc]);;
tqm8xx )
AC_CONFIG_SUBDIRS([tqm8xx]);;
+ virtex )
+ AC_CONFIG_SUBDIRS([virtex]);;
virtex4 )
AC_CONFIG_SUBDIRS([virtex4]);;
virtex5 )
AC_CONFIG_SUBDIRS([virtex5]);;
- virtex )
- AC_CONFIG_SUBDIRS([virtex]);;
*)
AC_MSG_ERROR([Invalid BSP]);;
esac
diff --git a/c/src/lib/libbsp/powerpc/virtex4/make/custom/virtex4.cfg b/c/src/lib/libbsp/powerpc/virtex4/make/custom/virtex4.cfg
index 333b144..a659f73 100644
--- a/c/src/lib/libbsp/powerpc/virtex4/make/custom/virtex4.cfg
+++ b/c/src/lib/libbsp/powerpc/virtex4/make/custom/virtex4.cfg
@@ -9,7 +9,10 @@ RTEMS_CPU_MODEL=ppc405
CPU_CFLAGS = -mcpu=405 -Dppc405
# optimize flag: typically -O2
-CFLAGS_OPTIMIZE_V = -O2 -g -fno-keep-inline-functions
+CFLAGS_OPTIMIZE_V = -Os -g -fno-keep-inline-functions
+CFLAGS_OPTIMIZE_V += -ffunction-sections -fdata-sections
+LDFLAGS += -Wl,--gc-sections
+
# Miscellaneous additions go here
define bsp-post-link
diff --git a/testsuites/samples/hello/init.c b/testsuites/samples/hello/init.c
index 8a44a88..7740306 100644
--- a/testsuites/samples/hello/init.c
+++ b/testsuites/samples/hello/init.c
@@ -23,16 +23,15 @@ rtems_task Init(
rtems_task_argument ignored
)
{
- printf( "\n\n*** HELLO WORLD TEST ***\n" );
- printf( "Hello World\n" );
- printf( "*** END OF HELLO WORLD TEST ***\n" );
- exit( 0 );
+ printk( "\n\n*** HELLO WORLD TEST ***\n" );
+ printk( "Hello World\n" );
+ printk( "*** END OF HELLO WORLD TEST ***\n" );
+ rtems_shutdown_executive( 0 );
}
/* NOTICE: the clock driver is explicitly disabled */
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
-#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
-------------- next part --------------
Baseline w/Networking and POSIX Disabled
========================================
SIZE: 218227 2376 4257 224860 36e5c capture.exe
SIZE: 103719 1844 5917 111480 1b378 unlimited.exe
SIZE: 36759 1212 1653 39624 9ac8 minimum.exe
SIZE: 74831 1496 2057 78384 13230 hello.exe
SIZE: 200023 2244 3065 205332 32214 paranoia.exe
SIZE: 139467 1988 2473 143928 23238 ticker.exe
SIZE: 145235 1988 2473 149696 248c0 nsecs.exe
SIZE: 134091 1908 2433 138432 21cc0 base_sp.exe
SIZE: 520239 5460 13981 539680 83c20 fileio.exe
Change to -Os
=============
SIZE: 187883 2500 4257 194640 2f850 capture.exe
SIZE: 91087 1968 5917 98972 1829c unlimited.exe
SIZE: 32599 1336 1653 35588 8b04 minimum.exe
SIZE: 65467 1620 2057 69144 10e18 hello.exe
SIZE: 181655 2368 3065 187088 2dad0 paranoia.exe
SIZE: 126587 2112 2473 131172 20064 ticker.exe
SIZE: 132355 2112 2473 136940 216ec nsecs.exe
SIZE: 121675 2032 2433 126140 1ecbc base_sp.exe
SIZE: 447599 5584 13981 467164 720dc fileio.exe
Change to use function sections
===============================
SIZE: 181409 2112 4205 187726 2dd4e capture.exe
SIZE: 86373 1604 5897 93874 16eb2 unlimited.exe
SIZE: 24081 476 1637 26194 6652 minimum.exe
SIZE: 60318 1472 2049 63839 f95f hello.exe
SIZE: 177101 2008 3041 182150 2c786 paranoia.exe
SIZE: 90781 1740 2449 94970 172fa ticker.exe
SIZE: 96573 1740 2449 100762 1899a nsecs.exe
SIZE: 85905 1668 2409 89982 15f7e base_sp.exe
SIZE: 432499 5216 13685 451400 6e348 fileio.exe
More information about the users
mailing list