Hi all,

i was testing a linux setitimer to make some led blink,
from following c++ code:

static void timer_handler(int signum)
{
    static unsigned short value = 0xff;

    *((unsigned short *)0x10000248) = (value & 0xff);

    value = ~value;
}

string cmd_parser::on_cmd_blink(const string &state)
{
    stringstream ss;
    struct sigaction sa;
    struct itimerval timer;

    memset(&timer, 0, sizeof(struct itimerval));

    if (state == "on") {
        /* install timer_handler as the signal handler for SIGALRM. */
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = &timer_handler;
        sigaction(SIGALRM, &sa, NULL);

        /* configure the timer to expire after 0,5 sec... */
        timer.it_value.tv_sec = 0;
        timer.it_value.tv_usec = 500000;
        /* ... and every 0,5 sec after that. */
        timer.it_interval.tv_sec = 0;
        timer.it_interval.tv_usec = 500000;

        setitimer(ITIMER_REAL, &timer, NULL);

        ss << "blinking on\r\n";              <<<<<<<<<<<<<

    } else if (state == "off") {
        /* timer stop */
        setitimer(ITIMER_REAL, &timer, NULL);

        ss << "blinking disabled\r\n";
    }

    return ss.str();
}


If i leave the line above marked with "
<<<<<<<<<<<<<"
i get SIGILL on the execution of setitimer

if i comment the line out, timer works properly and led blinks.


I have:
mcf5307
~ # cat /proc/version
uClinux version 3.10.0-uc0amcore-001 (angelo@jerusalem) (gcc version 4.5.1 (GCC) ) #70 Wed May 4 21:37:35 CEST 2016
~ #

makefile:
PREFIX=/opt/toolchains/m68k/Sourcery_CodeBench_Lite_for_ColdFire_uClinux/bin/m68k-uclinux-

CPP=$(PREFIX)g++
STRIP=$(PREFIX)strip
FLTHDR=$(PREFIX)flthdr
LD=$(PREFIX)ld

BINNAME=cfbot

BINDIR=bin
SRCDIR=src
OBJDIR=obj

INCLUDES=-Iinclude

SRCS:= $(wildcard $(SRCDIR)/*.cc)
OBJS:= $(patsubst %.cc,%.o,$(SRCS))
OBJS:= $(patsubst $(SRCDIR)%,$(OBJDIR)%,$(OBJS))

CFLAGS=-Os -s -m5307 -ffunction-sections -fdata-sections
LDFLAGS=-m5307 -Wl,--gc-sections
LIBS=

TFTP="192.168.0.80\\nmode binary\\nput bin/cfbm /tmp"

$(BINDIR)/$(BINNAME): $(OBJS)
    $(CPP) $(OBJS) $(LDFLAGS) -o $@ $(LIBS)
#    $(STRIP) $@
#    $(FLTHDR) -s 65535 $@
#    atftp --option "mode octet" -p -l $(BINDIR)/$(BINNAME) -r /tmp/$(BINNAME) 192.168.0.80

$(OBJDIR)/%.o: $(SRCDIR)/%.cc
    $(CPP) $(CFLAGS) $(INCLUDES) -Wall -c -o $@ $<

clean:
    rm -f bin/*
    rm -f obj/*.o


Every help is appreciated,

thanks,
angelo






_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to