fvillasenor wrote on Friday, February 05, 2010:
I am porting freeRTOS to Silicon Labs 8051F125. I used the latest SDCC compiler (2.9.4) and down loaded the libraries from www.freertos.org/reentrant_lib.zip. This did NOT work, so I rebuild the libraries using the following makefile:
#
# Make file to build SDCC libraries for the 8051 processor
# (my target processor is the 8051F125 by Si Labs)
#
# Using 2.9.4 #5582 (Dec 7 2009) version of SDCC
#
# Uses large model, auto stack and are reentrant.
# These libraries are need with the latest (6.0.1) FreeRTOS
# form www.freertos.org
#
# place this Makefile in SDCC/lib/src
# and run make
#
# will place libraries in SDCC/lib/large-stack-auto
#
# MAKE SURE SDCC/lib/large-stack-auto EXISTS BEFORE
# running make!
#
# using make from http://unxutils.sourceforge.net/
#
# by Florencio Villasenor Jr. 2009 Dec
#
CC=sdcc
AS=sdas8051
# Add if needed
NO_OPT= \
--nogcse --noinvariant --noinduction --nojtbound --noloopreverse \
--nolabelopt --nooverlay --peep-asm
#DEBUG=--debug $(NO_OPT)
CFLAGS= \
-DSDCC_CYGNAL $(DEBUG) --less-pedantic --model-large \
--xram-size 8448 --stack-auto --int-long-reent --float-reent \
--no-peep
ASFLAGS=-losgaff
MCS51_DIR = mcs51
LIB_DIR = ../large-stack-auto
INT_NAMES = \
_divsint _divuint _modsint _moduint _mulint
INT_OBJ = $(addsuffix .rel,$(INT_NAMES))
LONG_NAMES = \
_divslong _divulong _modslong _modulong _mullong
LONG_OBJ = $(addsuffix .rel,$(LONG_NAMES))
FLOAT_NAMES = \
_atof _fsadd _fsdiv _fseq _fsgt _fslt _fsmul _fsneq _fssub _uchar2fs \
_uint2fs _ulong2fs _schar2fs _sint2fs _slong2fs _fs2uchar _fs2uint \
_fs2ulong _fs2schar _fs2sint _fs2slong _fsget1arg _fsget2args \
_fsrshift _fsnormalize _fsreturnval _fsswapargs _fscmp fabsf frexpf \
ldexpf expf powf sincosf sinf cosf logf log10f sqrtf tancotf tanf cotf \
asincosf asinf acosf atanf atan2f sincoshf sinhf coshf tanhf floorf \
ceilf modff errno
FLOAT_OBJ = $(addsuffix .rel,$(FLOAT_NAMES))
SDCC_NAMES = \
_iscntrl _isdigit _isgraph _islower _isprint _ispunct _isspace \
_isupper _isxdigit _itoa _ltoa _strchr _strcmp _strcpy _strcspn \
_strlen _strcat _strncat _strncmp _strncpy _strpbrk _strrchr _strspn \
_strstr _strtok _memcmp _memcpy _memmove _memset _gptrget _gptrgetc \
_gptrput _decdptr _bp _spx _atoi _atol _malloc serial _autobaud \
_startup _ser puts gets printfl printf_large printf_fast vprintf \
assert time bpx
SDCC_OBJ = $(addsuffix .rel,$(SDCC_NAMES))
MCS51_NAMES = \
crtstart crtxinit crtxclear crtclear crtxstack crtpagesfr
MCS51_OBJ = $(addprefix $(MCS51_DIR)/, $(addsuffix .rel,$(MCS51_NAMES)))
.PHONY: all
all: $(LIB_DIR)/libint.lib $(LIB_DIR)/liblong.lib \
$(LIB_DIR)/libfloat.lib $(LIB_DIR)/libsdcc.lib $(LIB_DIR)/mcs51.lib
# @echo at $@
# @echo pc $%
# @echo lt $<
# @echo qt $?
# @echo ct $^
# @echo pl $+
# @echo ln $|
# @echo st $*
$(LIB_DIR)/libint.lib: $(INT_OBJ)
sdcclib $@ $?
@echo ----------
$(LIB_DIR)/liblong.lib: $(LONG_OBJ)
sdcclib $@ $?
@echo ----------
$(LIB_DIR)/libfloat.lib: $(FLOAT_OBJ)
sdcclib $@ $?
@echo ----------
$(LIB_DIR)/libsdcc.lib: $(SDCC_OBJ)
sdcclib $@ $?
@echo ----------
$(LIB_DIR)/mcs51.lib: $(MCS51_OBJ)
sdcclib $@ $?
@echo ----------
%.rel: %.c Makefile
$(CC) $(CFLAGS) -c $< -o $*.rel
@echo ----
%.rel: %.asm Makefile
$(AS) $(ASFLAGS) $<
@echo ----
.PHONY: clean
clean: mostlyclean
rm -f *.rel $(LIB_DIR)/*.lib
rm -f $(MCS51_DIR)/*.rel
.PHONY: mostlyclean
mostlyclean:
rm -f *.adb *.asm *.lst *.sym
rm -f $(MCS51_DIR)/*.abd $(MCS51_DIR)/*.lst $(MCS51_DIR)/*.sym
I then downloaded the latest freeRTOS (6.0.2), compiled and linked it. Got the stack start from main.mem (0x21) and put in freeRTOSConfig.h (configSTACK_START). Recompiled and relinked, and loaded to my dev board.
It seems to run, but it fails the RegisterCheck() task, the stack pointer does NOT equal configSTACK_START, it is off by one (0x20).
Should I use another version of the SDCC compiler (2.4.0 or 2.5.0)?
Thanks for nay help,
Florencio