Compiling wixel-sdk on Ubuntu Pangolin

I’ve been trying to get the wixel-sdk compiled but having a great deal of trouble.
I have the latest sdcc from SVN

% sdcc --version
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.1.5 #7875 (Jun  8 2012) (Linux)

I downloaded the wixel-sdk from git as suggested and ran make.

...
Packaging apps/example_onewire/example_onewire.wxl
(This app has no params.)
packihx: read 293 lines, wrote 536: OK.
Compiling apps/example_servo_sequence/blocking.rel
Compiling apps/example_servo_sequence/example_servo_sequence.rel
Compiling libraries/src/servo/servo.rel
libraries/src/servo/servo.c:153: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '8963' : code generator internal error 
Contact Author with source code
make: *** [libraries/src/servo/servo.rel] Error 1

I’m not sure what to make of this error and there is nothing astonishing about line 153 in servo.c. It is the closing bracket of the case statement here:

ISR(T1, 0)
{
    uint8 i;

    switch(servoCounter++)
    {
    case 0:
        PERCFG &= ~(1<<6);  // PERCFG.T1CFG = 0:  Move Timer 1 to Alt. 1 location (P0_2, P0_3, P0_4)
        P0SEL |= servoPinsOnPort0;
        T1CC0 = servoData[0].positionReg;  // NOTE: T1CCx is buffered, so these commands
        T1CC1 = servoData[1].positionReg;  // don't take effect until the next timer period.
        T1CC2 = servoData[2].positionReg;
        break;

    case 3:
        PERCFG |= (1<<6);  // PERCFG.T1CFG = 1:  Move Timer 1 to Alt. 2 location (P1_2, P1_1, P1_0)
        P1SEL |= servoPinsOnPort1;
        T1CC0 = servoData[3].positionReg;
        T1CC1 = servoData[4].positionReg;
        T1CC2 = servoData[5].positionReg;
        break;

    case 1:
    case 4:
        // We are producing pulses during THIS period, so disable the pulses for the next timer period.
        T1CC0 = T1CC1 = T1CC2 = 0xFFFF;
        break;

    case 2:
        // The pulses on port 0 just finished, so assign the pins to be GPIO (driving low) again.
        P0SEL &= ~servoPinsOnPort0;
        break;

    case 5:
        // The pulses on port 1 just finished, so assign the pins to be GPIO (driving low) again.
        P1SEL &= ~servoPinsOnPort1;
        break;

    case 6:
        // Set the counter back to zero so that next time we will start over at the beginning.
        servoCounter = 0;

        // Update the positions of all the servos according to their speed limits,
        // and update servosMovingFlag.

        // David measured how long these updates take, and it is only about 70us even if there is
        // a speed limit enabled for all channels.
        // WARNING: The SDCC manual warns that 16-bit division, multiplication, and modulus are implemented
        // using external support routines that are not reentrant, so we can't do any of those operations here!
        // The assembly generated by this ISR in servo.lst should be checked whenever making changes to the ISR.

        servosMovingFlag = 0;

        for(i = 0; i < MAX_SERVOS; i++)
        {
            volatile struct SERVO_DATA XDATA * d = servoData + i;
            uint16 pos = d->position;

            if (d->speed && pos)
            {
                if (d->target > pos)
                {
                    if (d->target - pos < d->speed)
                    {
                        pos = d->target;
                    }
                    else
                    {
                        pos += d->speed;
                        servosMovingFlag = 1;
                    }
                }
                else
                {
                    if (pos - d->target < d->speed)
                    {
                        pos = d->target;
                    }
                    else
                    {
                        pos -= d->speed;
                        servosMovingFlag = 1;
                    }
                }
            }
            else
            {
                pos = d->target;
            }
            d->position = pos;
            d->positionReg = ~pos + 1;
        }

        break;
    }  // this is line 153
}

Hello.

I am sorry you are having trouble compiling the Wixel SDK. Based on the error message you are getting, I think you have stumbled upon a new bug in SDCC. The last stable release of SDCC was SDCC 3.1.0, which was released in November 2011. This is the version I have been using successfully in Windows. I recommend trying that version and seeing if the error goes away. You can download source or binary versions from the SDCC website.

Thank you for letting me know about the bug. I will try to report it and get it fixed.

–David

This bug has already been reported by someone else:
sourceforge.net/tracker/?func=d … tid=100599

–David