Custom RTEMS port

Joel Sherrill joel.sherrill at OARcorp.com
Mon Aug 6 12:49:59 UTC 2001


This is a quick answer but it should help out some.

Chris Ziomkowski wrote:
> 
> I am attempting to port RTEMS to the opencores openrisc Or1k
> architecture, and am running into some difficulties, which I'm hoping
> someone can help me out with.
> 
> First, I've managed to port the OS libraries, and I'm now trying to
> get the test suite examples to compile. The Makefile structure for
> this project is incredibly complex, and there doesn't appear to be
> any documentation on exactly what needs to be changed and
> where.

Sorry.  As I recall the porting guide does not mention makefiles
but the BSP and Device Drive guide does.  It may not be perfectly
up to date but should have answered some questions.

> Issue #1:
> 
> The most immediate issue is the following: I am trying to get the
> simple hello.exe test program to compile and link. This is the program
> contained in the directory:
> 
> $top/c/src/tests/samples/hello
> 
> The issue appears to be that the $(make-exe) command is not linking
> in the RTEMS libraries, thus I'm getting alot of undefined symbols.
> When I run make, I get the following error:
> 
> /usr3/home/chris/or1k/or32-rtems/bin/ld   -L ../../../../../../
> bender/lib -N -e _start -T../../../../../../bender/lib/linkcmds
> -o o-optimize/hello.exe ../../../../../../bender/lib/start.o  o
> -optimize/init.o ../../../../../../bender/lib/no-dpmem.rel ../.
> ./../../../../bender/lib/no-event.rel ../../../../../../bender/
> lib/no-msg.rel ../../../../../../bender/lib/no-mp.rel ../../../
> ../../../bender/lib/no-part.rel ../../../../../../bender/lib/no
> -signal.rel ../../../../../../bender/lib/no-timer.rel ../../../
> ../../../bender/lib/no-rtmon.rel --start-group      --end-group
> ../../../../../../bender/lib/start.o(.text+0x64):../../../../..
> /../../../../c/src/lib/libbsp/or1k/bender/start/start.S: undefi
> ned reference to `boot_card'
> ...
> 
> followed by alot more undefined references. One of the
> things clearly not linked in this command line, is an RTEMS
> library file, such as librtemsall.a. (Which does define these
> symbols.)

You do not have a board support package.  What is your target board?
a simulator? You have to have some basic code for crt0, init, etc.
There are lots of examples in c/src/lib/libbsp/CPU/BSP.

If you are using the OR1K simulator, then one of the other simulator
BSPs might be a good place to look (powerpc/psim and mips/jmr3904 
being good candidates).  The arm/armulator, i960/i960sim,
h8300/h8300sim,
*/*sim are good but those simualtors tended to not have interrupt
sources for clock ticks.

The undefineds appear to be from there.  Pick any one of those, copy
it, replace HW specific code with a comment.  Then try to compile again.

The BSP is responsible for providing a linker script,startup code,
console IO, clock tick, etc.

> My $(make-exe) (defined in $top/make/custom/bender.cfg)
> has the following entry:
> 
> define make-exe
>         $(LD) $(LDFLAGS) -N -e _start \
>             -T$(PROJECT_RELEASE)/lib/linkcmds\
>             -o $(basename $@).exe \
>             $(START_FILE) $(LINK_OBJS) --start-group $(LINK_LIBS)
> --end-group
>         $(NM) -n $(basename $@).exe > $(basename $@).num
>         $(SIZE) $(basename $@).exe
> endef

Which would be OK if you had a BSP (libbsp/or1k/or1ksim?) which
actually had a linker script.  

> So what appears to missing is the definition of $(LINK_LIBS).
> However I can't find where to set $(LINK_LIBS)!

You should not be tinkering at that level for hello.  You just
need a score/cpu/or1k and a lib/libbsp/or1k/or1ksim.

> I copied this definition from the no_bsp config file, and in fact
> all the .cfg files seem to use this macro. Can someone explain
> to me how this macro gets filled in, or what additional information
> I need to provide to help someone give me some assistance?

As I recall, the LINK_OBJS is built up automatically and LINK_LIBS
is for you to add application specific libraries.  You don't have any
yet
so don't need to set it.

> Thanks.
> 
> Issue #2:
> 
> The size of the binaries that are generated (based on the size of
> the libraries after they have been stripped) are really really large.
> More than 1 MB! Can someone tell me what the final size of the
> binary should be for an equivalent architecture like the SPARC
> or the PowerPC?

What are you looking at to get that size and how are you obtaining
it?  RTEMS has a LOT of functionality that is in librtemsall.a but
is not linked in unless you use it.  The network stack and services,
filesystems, unused portions of the POSIX, uITRON, and Classic APIs,
etc.  The library can be quite large but applications tend to be
smaller.

> A 1MB OS seems excessive. For something that big I might as
> well run embedded Linux. Can someone give me some guidance
> on how to configure my build so I get a small OS on the order
> of 100K? I guess I don't really need everything. Just the
> necessities for multitasking, threads and networking stacks.
> 
> Is 100K a reasonable size for the RTEMS kernel?

With 100K you should be able to have a full application and kernel.
The minimum APPLICATION footprint including reentrancy support for
the C Library, full HW init and shutdown, etc tends to be between
35K and 70K depending on the BSP, CPU, etc. I have seen full fielded
applications that have less than 128K of memory total.

> Thanks for any assistance from the community. I look forward
> to working with all of you to get this port to a new architecture
> complete.

Me too.  :)


> Chris Ziomkowski
> czim at newsguy.com

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985



More information about the users mailing list