STR912 and Rowley

williamjsell wrote on Friday, February 01, 2008:

I see there is a demo with IAR and STR912 using uIP, has anyone ported this over to Crossworks? 

-Bill

rtel wrote on Friday, February 01, 2008:

Hi - I can’t help with your request directly, but the following page might be of assistance: http://www.freertos.org/porting-a-freertos-demo-to-different-hardware.html.

Regards.

williamjsell wrote on Tuesday, February 05, 2008:

Thanks Richard,
That link does not appear to work, but I can find my way to the hardware port page.  This is not really a hardware port, I am merely trying to use Rowley’s Crossworks instead of IAR for the ARM9 demo.  I am not familiar with the chip (yet) so I am not sure what I have to worry about, but I think I will construct a project in Rowley based on the files in the IAR demo and see what errors I get.  If I get this to work I will post this back onto the site for other users…

Thanks

-Bill

slawc wrote on Tuesday, February 05, 2008:

I’m also trying to use Crossworks. I started with LPC23xx port and STR9 IAR port. At this moment everything stops here
void vPortISRStartFirstTask( void )
{

    /* Simply start the scheduler.  This is included here as it can only be
    called from ARM mode. */
    portRESTORE_CONTEXT();
}

To be more specific at this line of portRESTORE_CONTEXT() macro 

   subs pc, lr, #0x00000004

I get data abort. I think I missed something in configuration (stack, init,…) in the Crossworks because I also peeked into Ben’s gcc port (thanks a lot again!!!) and besides IRQ handling and some macro locations I can’t find differences that could cause troubles.

I prefer LPC23xx port style where all needed functions and macros for the FreeRTOS itself are located in the three files in the portable directory and seperated from crt0.s, IRQ hanlder etc.

BTW -> "ARM7 GCC ports no longer use the IRQ attribute" is true only for ARM7_LPC2000 other ports (such as LPC23xx) still uses "IRQ" attribute.

rtel wrote on Tuesday, February 05, 2008:

>To be more specific at this line of portRESTORE_CONTEXT() macro 
>subs pc, lr, #0x00000004

This is normally a symptom of not being in Supervisor mode when the scheduler is started.   CrossWorks provides a mechanism for this - all you need to do is define SUPERVISOR_START in the pre-processor section of the project options.  Do you have this definition?

With reference to the IRQ comment - thanks for pointing this out.  I actually made the change because the GCC version supplied with my current CrossWorks installation will not even compile the IRQ attribute and I was working on the LPC2138 at the time.

Regards.

slawc wrote on Tuesday, February 05, 2008:

Just checked again in the Register view, micro is in Supervisor mode.

rtel wrote on Tuesday, February 05, 2008:

When you execute the line:
SUBS    PC, LR, #4

what value is in LR?

What values are in the registers R1, R2 and R3?

Regards.

slawc wrote on Tuesday, February 05, 2008:

Hm… ok I got something. Just after the check for Supervisor mode, I commented out some lines that created LCD queue, LCD and LED task (I used that code from the STR9 IAR port) so main function has only hardware init and vTaskStartScheduler(). No more abort, system is running.

It seems that I got corrupted stack (I set up 1024 bytes but this wasn’t enough or did I missed something in the Crossworks project setup?).

rtel wrote on Tuesday, February 05, 2008:

1KByte stack should be much more than enough, unless you are using complex sprintf/printf type calls?

Interrupts will become enabled as the first task starts.  Is it possible that a task or interrupt is writing to a queue/semaphore/mutex that has not been created?

Regards.

slawc wrote on Tuesday, February 05, 2008:

LR is filled with 0x0504
R0 0x0400073c
R1 0x0101…
R2 0x0202…
R3 0x0303…

slawc wrote on Tuesday, February 05, 2008:

No complex type calls. Now I have just a LED flash task provided in the IAR port. Anyway increasing the stack size doesn’t solve the problem.

slawc wrote on Wednesday, February 06, 2008:

Here we go… I have running STR912 Demo for Rowley. I commented out serial com demo and I didn’t test the TCP part yet. Thanks to Ben for his GCC port.

The problem was in the interrupt handling. Originaly I wanted to use VECTORED_IRQ_INTERRUPTS as in LPC2368 demo, but without luck. So I used IRQ wrapper (like Bens GCC and IAR ports):

void irq_handler( void ) __attribute__((naked));

void irq_handler(void)
{
    portSAVE_CONTEXT();

    asm volatile (
    "ldr    r0, = 0xFFFFF030    \n\t"
    "ldr    r0, [r0]            \n\t"            /* Read the routine address */
    "ldr    r1, = 0xFC000030    \n\t"
    "ldr    r1, [r1]            \n\t"
    "mov    lr, pc              \n\t"
    "bx        r0              \n\t"
    "ldr    r0, = 0xFFFFF030    \n\t"        /* Write to the VectorAddress to clear the */
    "str    r0, [r0]            \n\t"                /* respective interrupt in the internal interrupt */
    "ldr    r1, = 0xFC000030    \n\t"   /* Write to the VectorAddressDaisy to clear the */
    "str    r1,[r1]    ");            /* respective interrupt in the internal interrupt*/

    /* Restore the context of the new task. */
    portRESTORE_CONTEXT();   

}

void swi_handler( void ) __attribute__((naked));

void swi_handler(void)
{
    /* Within an IRQ ISR the link register has an offset from the true return
    address, but an SWI ISR does not.  Add the offset manually so the same
    ISR return code can be used in both cases. */
    asm volatile ( "ADD        LR, LR, #4" );

    /* Perform the context switch.  First save the context of the current task. */
    portSAVE_CONTEXT();

    /* Find the highest priority task that is ready to run. */
    vTaskSwitchContext();

    /* Restore the context of the new task. */
    portRESTORE_CONTEXT();   

}

ollowaty wrote on Tuesday, February 19, 2008:

Hi

Would you mind to share your project files?

slawc wrote on Saturday, February 23, 2008:

Sorry for late reply, I didn’t have much time these days. I hope I’ll find more time this week to test whole STR912 demo and send it to Richard (if he is interested to put it on the freertos.org). As I said basic (freertos standard) tasks and LCD are working just fine. TCP and UART were not included (IAR to gcc porting is needed).