[ECOS] Context switching fails under LPC22xx/LPC21xx
Sergei Gavrikov
sergei.gavrikov@gmail.com
Fri Feb 22 10:05:00 GMT 2008
On Thu, Feb 21, 2008 at 10:17:07AM -0800, Sivan Toledo wrote:
>
> Hi,
>
> We successfully built an eCos library (hal and default templates) and
> HAL programs for an LPC2214 board and for an LPC2119 board. I used
> Sergei Gavrilov's code and both work fine when used in HAL-only mode
> without a scheduler.
>
> When we try to run twothreads.c, the program runs cyg_user_start but
> then resets the processor, which causes cyg_user_start to run again,
> and on on indefinitely.
>
> We believe that the problem is that the stack frame is not aligned on
> a 32-bit boundary. This seems to throw an exception that causes the
> HAL to reset. We tried to allocate the stack buffers in different ways
> to fix that, but it does not seem to help.
>
> Any idea what might be causing this and how to fix it?
>
> Thanks, Sivan Toledo and Aviad Zuc.
Hello:
I won't stop on LPC2214. The CPU has an external bus and I hope that you
have enough external RAM to build RAM image and to resolve a problem
using GDB and an eCos tracing.
The LPC2119 hasn't external bus, so you try to manage the example using
16K on-chip RAM only, don't you? The `twothreads.c` is a bloat example
which uses LIBC cats: main(), printf(). It seems for me that you did
modify some things to reduce twotheads's appetite...
Public CVS tree has mcb2100 target (board from Keil with LPC2119 CPU). I
tried to build the twothreads example for the target
chdir <some where>
ecosconfig new mcb2100
ecosconfig tree
make
SRCS=$ECOS_REPOSITORY/../examples/twothreads.c DST=twothreads \
$ECOS_REPOSITORY/../examples/build_Makefile .
make -f Makefile
So far, so good. I got twothreads.o for LPC2119.
make -f Makefile twothreads
arm-elf/bin/ld: address 0x40006e08 of twothreads section .bss is not within region ram
We have a deficit of RAM (> 8K) with the default settings. So, we have
to 1) revise the default ecos settings; 2) revise twothread.c source (no
printf(), no main()).
rm -r *
ecosconfig new mcb2100
ecosconfig remove CYGPKG_LIBC_STARTUP ;# free 8K
ecosconfig tree
make
# remove bloat printf() and reduce the default twothread's stack sizes
sed 's/printf/diag_printf/;s/4096/2048/' \
< $ECOS_REPOSITORY/../examples/twothreads.c > twothreads.c
# build Makefile
SRCS=twothreads.c DST=twothreads \
$ECOS_REPOSITORY/../examples/build_Makefile .
# rude tweak (no main())
echo "ACTUAL_CFLAGS += -Dmain=cyg_user_start" >> Make.params
make -f Makefile
arm-elf-size twothreads
text data bss dec hex filename
25268 828 11980 38076 94bc twothreads
It's seems for me this should work. If it won't. Compare your own
hal_platform_setup.h, mlt* stuff for LPC2129 with the MCB2100' one.
... if that still not working try to apply an attached patch and
_rebuild_ _all_ from scratch:
patch -p1 -d $ECOS_REPOSITORY < lpc2xxx_misc.c.patch
I hope the twothreads example will be run even on your LPC2119 board.
Sergei
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lpc2xxx_misc.c.patch
Type: text/x-diff
Size: 1097 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/ecos-discuss/attachments/20080222/7f977d71/attachment.bin>
-------------- next part --------------
--
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