Using CSP on windows and avr studio

1,073 views
Skip to first unread message

ahmed

unread,
Feb 11, 2012, 5:56:48 AM2/11/12
to cubesat-space-protocol
I do not know how to configure the library for that, can I get steps
do to it?
thank you

Johan (GomSpace)

unread,
Feb 13, 2012, 4:12:11 AM2/13/12
to cubesat-space-protocol
You'll need a the avr-gcc + avr-libc compiler and toolchain installed
and in your PATH environment variable

You can either choose to link against the compiled library or you can
include the source files into your project.

I suggest that you compile libcsp separately using the included python
compile script called 'waf'.

The steps to compile is:

python waf --configure
python waf build

This should produce a file called libcsp.a that you should place in a
lib folder within your avrstudio project, and link with your code.
You also need to copy the include files into your avrstudio project.

Use waf --configure help in order to see a list of available options
to libcsp.

If you want the script to automatically install the library and
headers into your project you can do like this

python waf --configure --prefix=c:\path\to\my\project\
python waf build
python waf install

That should do it.

Happy programming.

ahmed

unread,
Feb 14, 2012, 10:13:38 AM2/14/12
to cubesat-space-protocol
OK, thanks, I tried it on linux, and I am getting undefined reference
for functions that are present in .h files in /usr/include

On Feb 13, 11:12 am, "Johan (GomSpace)" <johan.declavi...@gmail.com>
wrote:

Jeppe Ledet-Pedersen

unread,
Feb 16, 2012, 11:54:41 AM2/16/12
to cubesat-space-protocol
Hi Ahmed,

It would help us a lot if you could give a more detailed description
of your problems.
Please describe the steps you've tried so far and exactly the errors
you get.

Regards,
Jeppe

ahmed

unread,
Feb 17, 2012, 7:44:03 AM2/17/12
to cubesat-space-protocol
well, I am actually having trouble installing the avr32 toolchain, so
on linux I am not able to specify avr32 as a toolchain for the waf
configuration,
so this is basically step 1 for me.
I tried to build it for toolchain avr only, and then include the
libcsp.a in avr32 studio 2.6 for linux, and when I build the project I
receive undefined reference for all functions got from the /usr/
include header files.

You do not know how much I would appreciate it if you help me with
this, thank you.
ahmed adel

ahmed

unread,
Feb 17, 2012, 7:48:38 AM2/17/12
to cubesat-space-protocol

ex: undefined reference to `pthread_create'

ahmed

unread,
Feb 17, 2012, 12:52:30 PM2/17/12
to cubesat-space-protocol
/media/DATA/AVRtrials/as4e-ide/ahmed/lololoy/Debug/../lol.c:141:
undefined reference to `usleep'
lol.o: In function `main':
/media/DATA/AVRtrials/as4e-ide/ahmed/lololoy/Debug/../lol.c:193:
undefined reference to `usleep'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_thread.c.1.o): In function `csp_thread_create':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_thread.c:31: undefined reference to `pthread_create'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_route.c.1.o): In function `csp_task_router':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/csp_route.c:
275: undefined reference to `pthread_exit'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_bin_sem_post_isr':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:164: undefined reference to `sem_getvalue'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:164: undefined reference to `sem_post'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_bin_sem_wait':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:143: undefined reference to `sem_wait'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:143: undefined reference to `clock_gettime'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:143: undefined reference to `sem_timedwait'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_bin_sem_remove':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:110: undefined reference to `sem_destroy'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_bin_sem_create':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:103: undefined reference to `sem_init'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_mutex_unlock':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:94: undefined reference to `pthread_mutex_unlock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_mutex_lock':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:86: undefined reference to `pthread_mutex_lock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:86: undefined reference to `clock_gettime'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:86: undefined reference to `pthread_mutex_timedlock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_mutex_remove':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:53: undefined reference to `pthread_mutex_destroy'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_semaphore.c.1.o): In function `csp_mutex_create':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_semaphore.c:45: undefined reference to `pthread_mutex_init'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_system.c.1.o): In function `csp_sys_reboot':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_system.c:59: undefined reference to `sync'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_system.c:59: undefined reference to `reboot'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_system.c:59: undefined reference to `__errno_location'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_system.c.1.o): In function `csp_sys_memfree':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_system.c:46: undefined reference to `sysinfo'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_time.c.1.o): In function `csp_get_s':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_time.c:50: undefined reference to `clock_gettime'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(csp_time.c.1.o): In function `csp_get_ms':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
csp_time.c:37: undefined reference to `clock_gettime'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(pthread_queue.c.1.o): In function `pthread_queue_items':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:169: undefined reference to `pthread_mutex_lock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:169: undefined reference to `pthread_mutex_unlock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(pthread_queue.c.1.o): In function `pthread_queue_dequeue':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:159: undefined reference to `clock_gettime'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:159: undefined reference to `pthread_mutex_lock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:159: undefined reference to `pthread_cond_timedwait'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:159: undefined reference to `pthread_mutex_unlock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:159: undefined reference to `pthread_cond_broadcast'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(pthread_queue.c.1.o): In function `pthread_queue_enqueue':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:117: undefined reference to `clock_gettime'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:117: undefined reference to `pthread_mutex_lock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:117: undefined reference to `pthread_cond_timedwait'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:117: undefined reference to `pthread_mutex_unlock'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:117: undefined reference to `pthread_cond_broadcast'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/
libcsp.a(pthread_queue.c.1.o): In function `pthread_queue_create':
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:62: undefined reference to `pthread_mutex_init'
/media/DATA/AVRtrials/GomSpace-libcsp-206debd/build/../src/arch/posix/
pthread_queue.c:62: undefined reference to `pthread_cond_init'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 311 ms.

Jeppe Ledet-Pedersen

unread,
Feb 17, 2012, 1:11:09 PM2/17/12
to cubesat-space-protocol
Hi Ahmed,

I'm not completely sure I understand your problems. If you compile for
avr32, you probably need to configure CSP for FreeRTOS. This is how I
build CSP for an AVR system with FreeRTOS:

CFLAGS=-mmcu=at90can128 ./waf configure --toolchain=avr- --with-
os=freertos --with-freertos=../libfreertos/include clean build

If you compile it on Linux, you need to link with libpthread and librt
(add -lpthread -lrt as arguments to gcc), and set --with-os=linux.
This should be mentioned in INSTALL.

I hope this helps you.

Regards,
Jeppe

ahmed

unread,
Feb 18, 2012, 8:30:12 AM2/18/12
to cubesat-space-protocol
./waf configure --toolchain=avr32- --with-os=posix --includes=/usr/
include --prefix=install
./waf build
there I receive warning
In file included from ../src/interfaces/../arch/csp_semaphore.h:35,
from ../src/interfaces/csp_if_lo.c:27:
/usr/include/pthread.h:655: warning: '__regparm__' attribute directive
ignored
/usr/include/pthread.h:667: warning: '__regparm__' attribute directive
ignored
/usr/include/pthread.h:712: warning: '__regparm__' attribute directive
ignored

and then
./waf install
installs successfully

when using avr32 studio on linux, AVR C project ,include libcsp.a,
when I try to include lpthread, it gives me:
skipping incompatible /usr/lib/libpthread.a when searching for -
lpthread
cannot find -lpthread

else when not included gives the errors I mentioned above
thank you

./waf install

Johan Christiansen

unread,
Feb 21, 2012, 7:03:01 AM2/21/12
to cubesat-spa...@googlegroups.com
2012/2/18 ahmed <ahme...@gmail.com>

./waf configure --toolchain=avr32- --with-os=posix --includes=/usr/
include --prefix=install
./waf build
there I receive warning
In file included from ../src/interfaces/../arch/csp_semaphore.h:35,
                from ../src/interfaces/csp_if_lo.c:27:
/usr/include/pthread.h:655: warning: '__regparm__' attribute directive
ignored
/usr/include/pthread.h:667: warning: '__regparm__' attribute directive
ignored
/usr/include/pthread.h:712: warning: '__regparm__' attribute directive
ignored

and then
./waf install
installs successfully

when using avr32 studio on linux, AVR C project ,include libcsp.a,
when I try to include lpthread, it gives me:
skipping incompatible /usr/lib/libpthread.a when searching for -
lpthread
cannot find -lpthread

else when not included gives the errors I mentioned above
thank you


You can not use --with-os=posix on an AVR32. You should use --with-os=freertos instead and then setup freertos for your processor and link your application, freertos and libcsp together.
If you do not want to use FreeRTOS, but another OS, it is possible to port libcsp to be using other OS routines for semaphores, queues and tasks.

Jinesh Ramachandran

unread,
Feb 21, 2012, 7:45:46 AM2/21/12
to cubesat-spa...@googlegroups.com
Hi Johan,

    I have not been following this thread completely, but interesting to note that you can port the lib for other RTOS. What are your thoughts on RTEMS? Is there any integration done on this already? RTEMS is mostly used in all ESA missions and we have been RTEMS for a long time. It would be nice to know whether this is a possibility. 

We have been thinking to buy GOM Space board and this is one of the crucial things. 

Thanks,
Jinesh

Johan (GomSpace)

unread,
Feb 21, 2012, 8:12:47 AM2/21/12
to cubesat-space-protocol
After reading a bit about RTEMS i see that this already supports the
POSIX api which CSP is ported to.
However, in order to be exact CSP is ported to libPthreads. So the
best thing would be to
write a new port for the RTEMS based on the POSIX one, because i'm
sure there will be some differences from Pthreads on linux to RTEMS
although they both claim to be a POSIX standard :)

All in all it should only take a few hours to port the following
files:

csp_malloc.c - Very easy, csp_malloc() should just call malloc()
csp_queue.c - csp_queue_enqueue should call RTEMS queue function
csp_semaphore.c - Same as above
csp_system.c - wrappers for cpu_reset, process list and memfree
csp_thread.c - only simple thread create needed
csp_time.c - report system time and uptime.

The easiest way to get started is to make a github user and fork the
project.
As soon as you have it tested it will be included upstream also, along
with some information on how to build for RTEMS.

Regards,
Johan.

On Feb 21, 1:45 pm, Jinesh Ramachandran <jinesh...@gmail.com> wrote:
> Hi Johan,
>
>     I have not been following this thread completely, but interesting to
> note that you can port the lib for other RTOS. What are your thoughts on
> RTEMS? Is there any integration done on this already? RTEMS is mostly used
> in all ESA missions and we have been RTEMS for a long time. It would be
> nice to know whether this is a possibility.
>
> We have been thinking to buy GOM Space board and this is one of the crucial
> things.
>
> Thanks,
> Jinesh
>
> On 21 February 2012 12:03, Johan Christiansen <johan.declavi...@gmail.com>wrote:
>
>
>
>
>
>
>
> > 2012/2/18 ahmed <ahmedo...@gmail.com>

Jinesh Ramachandran

unread,
Feb 21, 2012, 8:37:21 AM2/21/12
to cubesat-spa...@googlegroups.com
Hi Johan,

    Sorry, I might have misled you. What I exactly wanted to know was whether Nanomind can support rtems operating system? 
I did not mean to ask the question about csp, although I realised I asked the question on the csp groups. Apologies for that. 

Thanks,
Jinesh.

Johan (GomSpace)

unread,
Feb 21, 2012, 8:46:50 AM2/21/12
to cubesat-space-protocol
According to this page:
http://wiki.rtems.org/wiki/index.php/SupportedCPUs

RTEMS has support for running on ARM processors like the one on the
NanoMind.
In order to get RTEMS up and running you would need to adapt the os to
use the
interrupt controller built into the arm. Setup the timer tick and
start the kernel.
You can take a look on how it's done for FreeRTOS. RTEMS should be
very similar.

Regards,
Johan.

On Feb 21, 2:37 pm, Jinesh Ramachandran <jinesh...@gmail.com> wrote:
> Hi Johan,
>
>     Sorry, I might have misled you. What I exactly wanted to know was
> whether Nanomind can support rtems operating system?
> I did not mean to ask the question about csp, although I realised I asked
> the question on the csp groups. Apologies for that.
>
> Thanks,
> Jinesh.
>
Reply all
Reply to author
Forward
0 new messages