Making a port for LPC2378 on MCB2300

karelvergauwe wrote on Thursday, October 04, 2007:

Hello,

I want to make a port for LPC2378 on the Keil MCB2300 for the Keil uVision development tool. I have a full version. From where can I start so that I can do it fast. I tried starting from the ARM7_LPC2129_Keil example who came with version 4.5.0 but I keep having errors (like portable files who are not included (…\…\Source\include\portable.h(188): error:  #20: identifier "portSTACK_TYPE" is undefined)). I also tried starting from the SAM7 example, but had the same linking problems.

Can I build a complete project from scratch, just with copying the necesery files?

If I have it working i’ll send it to include it in a next version. Lot’s of people could use a working example for this dev tool i think.

davedoors wrote on Thursday, October 04, 2007:

Have you got the SAM7 Keil demo from Richard?  It uses the ARM compiler and will probably be a good reference to convert to LPC2378.

karelvergauwe wrote on Thursday, October 04, 2007:

Yes I have it, but I cannot get it running. I keep getting errors because some identifiers cannot be found. I tried to search for them myself but didn’t work…

If someone has a working example of SAM7 and is sure it is compiling can you send it to me (karel _at postron dot be). So I can test it. Perhaps my libraries aren’t ok? In the options there weren’t any include paths filled in. I tried to add some, but I think I still miss some…

thanks

biker126 wrote on Thursday, October 04, 2007:

about the portable.h error (and probably a lot of related "identifier" errors) search for the portmacro.h

in that file there’s the include path of the portable.h. but it needs to be enabled with the correct define (to be honest you can just put “portable.h” anywhere inside the project and just make sure the compiler knows where it is ;-)).

in portable.h there are things like "portSTACK_TYPE" or "portBASE_TYPE" etc. defined. so as soon as your compiler finds that header file a lot of errors should be done (and prolly new coming up as its always when porting :-P)

karelvergauwe wrote on Friday, October 05, 2007:

I have include the portable.h and portmacro.h (from keil arm7) in the project; also the AT91SAM7S64_inc.h and lib_AT91SAM7S64.h files. Now almost all my errors are gone but I always have following warning:

…\ARM7_AT91SAM7S64_KEIL_RV\AT91SAM7S64_inc.h(71): warning:  #47-D: incompatible redefinition of macro "AT91C_AIC_PRIOR" (declared at line 192 of "…\…\Source\portable\Keil\SAM7\AT91SAM7S64.h")

This is probably because I include the lib_AT91SAM7S64.h in my AT91SAM7S64_inc.h file wich is linked a couple of times. How can I avoid this problem? Where should I include this file?

I do also have 30 errors with the same fault:

…\ARM7_AT91SAM7S64_KEIL_RV\lib_AT91SAM7S64.h(311): error:  #134: expected a field name

for example in the following code:

308  __inline int AT91F_PDC_IsTxEmpty ( // \return return 1 if transfer is complete
309      AT91PS_PDC pPDC )       // \arg pointer to a PDC controller
310    {
311    return !(pPDC->PDC_TCR);   This gives the error
312    }

What is wrong? It’s code from the SAM7 example who was delivered to me and is normally working with Keil RVDM compiler (I think)

I will be very pleased with any commment

thanks

davedoors wrote on Friday, October 05, 2007:

How is __inline defined?  Do Keil provide their own versions of these files?

karelvergauwe wrote on Friday, October 05, 2007:

I found that the problem lies in the pointer to a variable of the pPDC struct. I also have this with other structures who have been made.

example:
in file: AT91SAM7S64.h is the struct being made, with at the end a pointer *AT91PS_AIC;

typedef struct _AT91S_AIC {
    AT91_REG     AIC_SMR[32];     // Source Mode Register
    AT91_REG     AIC_SVR[32];     // Source Vector Register
    AT91_REG     AIC_IVR;     // IRQ Vector Register
    AT91_REG     AIC_FVR;     // FIQ Vector Register
    AT91_REG     AIC_ISR;     // Interrupt Status Register
    AT91_REG     AIC_IPR;     // Interrupt Pending Register
    AT91_REG     AIC_IMR;     // Interrupt Mask Register
    AT91_REG     AIC_CISR;     // Core Interrupt Status Register
    AT91_REG     Reserved0[2];     //
    AT91_REG     AIC_IECR;     // Interrupt Enable Command Register
    AT91_REG     AIC_IDCR;     // Interrupt Disable Command Register
    AT91_REG     AIC_ICCR;     // Interrupt Clear Command Register
    AT91_REG     AIC_ISCR;     // Interrupt Set Command Register
    AT91_REG     AIC_EOICR;     // End of Interrupt Command Register
    AT91_REG     AIC_SPU;     // Spurious Vector Register
    AT91_REG     AIC_DCR;     // Debug Control Register (Protect)
    AT91_REG     Reserved1[1];     //
    AT91_REG     AIC_FFER;     // Fast Forcing Enable Register
    AT91_REG     AIC_FFDR;     // Fast Forcing Disable Register
    AT91_REG     AIC_FFSR;     // Fast Forcing Status Register
} AT91S_AIC, *AT91PS_AIC;

in file: lib_AT91SAM7S64.h the pointer is being copied to pAic in the first line of Configuration

__inline unsigned int AT91F_AIC_ConfigureIt (
    AT91PS_AIC pAic,  // \arg pointer to the AIC registers
    unsigned int irq_id,     // \arg interrupt number to initialize
    unsigned int priority,   // \arg priority to give to the interrupt
    unsigned int src_type,   // \arg activation and sense of activation
    void (*newHandler) () ) // \arg address of the interrupt handler
{
    unsigned int oldHandler;
    unsigned int mask ;

    oldHandler = pAic->AIC_SVR[irq_id];

    mask = 0x1 << irq_id ;
    //* Disable the interrupt on the interrupt controller
    pAic->AIC_IDCR = mask ;
    //* Save the interrupt handler routine pointer and the interrupt priority
    pAic->AIC_SVR[irq_id] = (unsigned int) newHandler ;
    //* Store the Source Mode Register
    pAic->AIC_SMR[irq_id] = src_type | priority  ;
    //* Clear the interrupt on the interrupt controller
    pAic->AIC_ICCR = mask ;

    return oldHandler;
}

Afterwords we try to get for example AIC_IVR from pAic with code:
pAic->AIC_IVR = …

Does someone know where the problem lies??? My compiler does not recognize the fields in my structure…

suresh_kumar wrote on Thursday, January 31, 2008:

hi
I am also looking for the same ,myself using LPC2378 and want it working wilt keil compiler and i tried to convert using LPC2129 but failed since it gave lot of error but any how i did changes to it and got some of the errors cleared but i have a assembler error
    __asm{ LDR        LR, [LR, #+60]    };

this gives a error asking for macro parameter needed, can any one tel wt is it.

pvPortMalloc is a function related to memory but we have 3 files related to it which one to use do suggest . since this might be usefull for all using LPC2378 controller using keil compiler

Regards
Suresh

jmr1972 wrote on Thursday, January 31, 2008:

Which heap management file you should use depends on you application. I would suggest you read the documentation for FreeRTOS mainly its porting guide. For memory configuration have a look at http://www.freertos.org/a00111.html