This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Context switching fails under LPC22xx/LPC21xx
- From: Sergei Gavrikov <sergei dot gavrikov at gmail dot com>
- To: Sivan Toledo <sivan dot toledo at gmail dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Fri, 22 Feb 2008 12:03:56 +0200
- Subject: Re: [ECOS] Context switching fails under LPC22xx/LPC21xx
- References: <15617613.post@talk.nabble.com>
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
diff -ur A/hal/arm/lpc2xxx/var/current/src/lpc2xxx_misc.c B/hal/arm/lpc2xxx/var/current/src/lpc2xxx_misc.c
--- A/hal/arm/lpc2xxx/var/current/src/lpc2xxx_misc.c
+++ B/hal/arm/lpc2xxx/var/current/src/lpc2xxx_misc.c
@@ -462,12 +462,18 @@
//
if (level < 16)
{
+ int i;
cyg_uint32 addr_offset = level << 2;
cyg_uint32 reg_val;
- HAL_READ_UINT32(CYGARC_HAL_LPC2XXX_REG_VIC_BASE +
- CYGARC_HAL_LPC2XXX_REG_VICVECTCNTL0 +
- addr_offset, reg_val);
+ for (i = level; i < 16; i++) {
+ addr_offset = i << 2;
+ HAL_READ_UINT32(CYGARC_HAL_LPC2XXX_REG_VIC_BASE +
+ CYGARC_HAL_LPC2XXX_REG_VICVECTCNTL0 +
+ addr_offset, reg_val);
+ if ((reg_val == 0) || (reg_val == (vector | 0x20)))
+ break;
+ }
CYG_ASSERT((reg_val == 0) || (reg_val == (vector | 0x20)),
"Priority already used by another vector");
HAL_WRITE_UINT32(CYGARC_HAL_LPC2XXX_REG_VIC_BASE +
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss