[ECOS] Simple compile

Sergei Gavrikov sergei.gavrikov@gmail.com
Wed Apr 8 12:03:00 GMT 2009


On Wed, Apr 08, 2009 at 04:03:55AM -0700, grahamlab wrote:
> 
> 
> 
> Sergei Gavrikov-4 wrote:
> > 
> > On Wed, Apr 08, 2009 at 12:21:27AM -0700, grahamlab wrote:
> >> 
> >> Hello everyone
> >> I am new to ecos and am trying to compile a simple program that uses the
> >> sleep function
> >> My code include <unistd.h> but when I compile i get this error
> >> 
> >> hello.cpp:34: error: ‘sleep’ was not declared in this scope
> >> 
> >> I am compiling using the following command
> >> 
> >> arm-eabi-g++ -c -I ../DevBoardFast_install/include/ -I
> >> /opt/ecos/ecos-3.0/packages/isoinfra/v3_0/include/  -Wall -Wpointer-arith
> >> -Wstrict-prototypes -Wundef -Woverloaded-virtual -Wno-write-strings
> >> -mcpu=cortex-m3 -mthumb -g -O2 -ffunction-sections -fdata-sections
> >> -fno-rtti
> >> -fno-exceptions  hello.cpp
> >> 
> >> The code looks like this
> >> 
> >> #include <unistd.h>
> >> #include <stdio.h>
> >> 
> >> int main(int argc, char** argv)
> >> {
> >>     sleep(10);
> >>     printf("Hello main\n");
> >> }
> >> 
> >> Please tell me why this does not compile
> >> 
> >> Thanks
> >> 
> >> Graham
> > 
> > Graham,
> > 
> > To have sleep() you have to add posix package to default template. Do
> > you really need in the bloat posix stuff? The eCos has own "sleep" --
> > cyg_thread_delay(). Please, start to read eCos documentation. So, a
> > solution is
> > 
> > ecosconfig add posix
> > 
> > IMHO, you have to prepare a good Makefile to play with eCos. Why do you
> > use C++ ?!. There are good examples under eCos `examples' directory. Try
> > the examples, first. Those build_Makefile, build_Make.params are nice
> > script-helpers to get a test farm. build_Make.params is most important
> > then. It rebuilds actual GCC flags for project. Every time when you
> > rebuild eCos, run build_Make.params (U.T.S.L.) in a project directory.
> > 
> > Just a demo about that eCos can do all for you
> > 
> > i. build eCos
> > 
> > ecosconfig new stm3210e
> > ecosconfig add posix
> > ecosconfig tree
> > make -s
> > 
> > ii. Stand up a test farm
> > 
> > mkdir test
> > cd test
> > cp $ECOS_REPOSITORY/../examples/build_Make.params .
> > DST=test SRCS=test.c $ECOS_REPOSITORY/../examples/build_Makefile ..
> > echo -ne 'clean:\n\trm -f test.o test\n' >> Makefile
> > 
> > cat >test.c<<EOF
> > #include <stdio.h>
> > #include <unistd.h>
> > 
> > int
> > main(void)
> > {
> >     sleep(10);
> >     printf("Test done\n");
> >     return 0;
> > }
> > EOF
> > 
> > make -s
> > 
> > I've got
> > 
> > ls
> > Makefile  Make.params  test  test.c  test.o
> > 
> > And there is sleep there
> > 
> > arm-eabi-nm test | grep sleep
> > 68009d98 T _ZN10Cyg_Thread5sleepEv
> > 6800c2a4 T nanosleep
> > 6800c358 T sleep
> > 
> > But, eCos source can look as (no need posix package to compile it)
> > 
> > #include <stdio.h>
> > #include <cyg/kernel/kapi.h>
> > 
> > int
> > main(void)
> > {
> >     while (true) {
> > 	cyg_thread_delay(100);
> > 	printf("I'm still alive\n");
> >     }
> >     return 0;
> > }
> > 
> > 
> > This week read these manuals:
> > http://ecos.sourceware.org/docs.html
> > 
> > 
> > Sergei
> > 
> > -- 
> > Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> > and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> > 
> > 
> > 
> Hi Sergei
> Thanks for the advice and for taking the time
> I have build the test environment as you said and it all works perfectly.
> I was wondering if I can do somethin similar using the config tool, but it
> appears not as the filenames do no match up to those expected by
> build_make.params and build_makefile. The config tool does not produce a
> makefile either.
> 
> Graham

Like `ecosconfig', `configtool' does not generate Makefile for a user (a
project). The eCos configtool is not IDE like eclipse, and others. It's
a tool to generate and build eCos itself. It generates a lot of the
makefiles to bootstrap eCos itself. Look on eCos tools how on the tools
which helps you to configure an stand up a delelopment tree:

.
|-- include
`-- lib

Then you MUST investigate some efforts (if you have not IDE) to organize
new tree

.
|-- include
|-- lib
`-- src

Where `src' is yours ;-) Is it terrible for you? Then you have to spend
a time (perhaps and money) to get IDE. My tools is Linux + GNU, my IDE
is gnome-terminal + vim.

I never exchange my IDE on something like XXX-STUDIO-XXX-WORKS-INSTEAD-YOU.

But seriosly speaking, some guys use IDE (most of them use the different
eclipse clones). I'm sorry, I'm not expert here.


Sergei


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list