Issue with LPC2368 with IAR

Hello, I’m working on getting my LPC2368 development board running with FreeRTOS 5.0.2.  I’ve used FreeRTOS in the past with an AT91SAM7XC256 with ease, mostly because the work was already done :).  I see that there are ports available for this processor, just not for this compiler.  I have a Keil MCB2300 development board that IAR has a demo project for.  This demo project works just fine.  I’ll list the steps I performed trying to get this working. * I started with the LPC2129 IAR FreeRTOS project. * I changed the ICF and startup.s files to what IAR supplied for the MCB2300 board, these files work fine in my demo application. * I included LPC230x.h header file instead of the 2129 file.  This required a few semantic changes in the project; mainly IO1CLR to IOCLR1 and the like.  This file was provided by IAR and I’m using it in my other application. * I changed the core under options to a 2368 instead of the 2129. * I also changed the processor speed in FreeRTOSConfig.h to 57600000. * I’m using the PLL setup code from my other application in place of the hardware setup code in main() from the 2129 port.  I’m not setting up the MAM since the version of the chip I have has an errata on it that was fixed in a newer revision, as such I won’t be using it just yet. The original 2129 port uses the "FreeRTOSSourceportableIARLPC2000" port files, which I’m assuming by the name will work with the 2368.  "LPC2000_IAR" is defined so the correct portmacro.h file is included. All of this compiles and loads without warnings.  I’m getting a prefetch abort after the call to "vTaskStartScheduler".  vTaskStartScheduler -> xPortStartScheduler -> vPortStartFirstTask -> portRESTORE_CONTEXT portRESTORE_CONTEXT is located in ISR_Support.h.  "LDR LR, [LR, #+60]" ends up with 0x00 in LR, then the operation after that "SUBS PC, LR, #0x4" results in the prefetch abort. My assembly isn’t terrific, I’m going to figure out what those two operations should actually result in.  If anyone has any input it would be well received.  I can send my project files off to whoever might be interested.  If someone has a project already started and would like to share I would be very grateful. kfarr ^a^t^ infinetix ^dot^ com -Ken

Issue with LPC2368 with IAR

> * I started with the LPC2129 IAR FreeRTOS project. > > * I changed the ICF and startup.s files to what IAR supplied > for the MCB2300 board, these files work fine in my demo application. Make sure that the startup file leaves the processor in Supervisor mode before calling main(). > * I included LPC230x.h header file instead of the 2129 file.  > This required a few semantic changes in the project; mainly > IO1CLR to IOCLR1 and the like. > This file was provided by IAR and I’m using it in my other > application. > > * I changed the core under options to a 2368 instead of the 2129. > > * I also changed the processor speed in FreeRTOSConfig.h to 57600000. > > * I’m using the PLL setup code from my other application in > place of the hardware setup code in main() from the 2129 > port.  I’m not setting up the MAM since the version of the > chip I have has an errata on it that was fixed in a newer > revision, as such I won’t be using it just yet. > > The original 2129 port uses the > "FreeRTOSSourceportableIARLPC2000" port files, which I’m > assuming by the name will work with the 2368.  "LPC2000_IAR" > is defined so the correct portmacro.h file is included. Actually a small change is required to the timer setup.  If you compare the GCC versions, which are SourceportableGCCARM7_LPC23xxport.c and SourceportableGCCARM7_LPC2000port.c you will see the changes that are required. > > All of this compiles and loads without warnings.  I’m getting > a prefetch abort after the call to "vTaskStartScheduler". > vTaskStartScheduler -> xPortStartScheduler -> vPortStartFirstTask > -> portRESTORE_CONTEXT > portRESTORE_CONTEXT is located in ISR_Support.h.  "LDR LR, > [LR, #+60]" ends up with 0x00 in LR, then the operation after > that "SUBS PC, LR, #0x4" results in the prefetch abort. This is most likely because the processor is not in Supervisor mode as per my previous comment. I would be grateful for a copy of your project once its up and running.  r [dot] barry *at* freertos.org. Regards.

Issue with LPC2368 with IAR

Barry, I would be more than willing to provide you with a copy of the project once it’s working.  I will compare the GCC version of port.c and make the required changes to the IAR’s port.c file. This is my first time working with this processor and after scanning the datasheet/user manual I did not find a supervisor mode.  Do you know what register it’s in and are you certain that this processor supports this feature?  I figured I’d ask in case someone gets a chance to reply before I find it myself.  I’ll look at the other startup files and see what they do for this bit. Thanks -Ken

Issue with LPC2368 with IAR

If you take a look in the file lpc2xxx_cstartup.s that is located in the DemoARM7_LPC2129_IARSrcIAR directory you will see the lines: ; ; Add more initialization here ;         BIC     r0, r0, #MODE_BITS      ; Clear the mode bits         ORR     r0, r0, #SVC_MODE       ; Set SVC mode bits         MSR     cpsr_c, r0              ; Change the mode         ; Continue to ?main for C-level initialization.         LDR     r0, =?main         BX      r0         END This changes the mode before calling main.  It might be that you can just use the same file.  If you are not familiar with this then also note also that the file sets up a stack for each processor mode.  You must set up an IRQ stack and Supervisor stack as a minimum. You need to look in the ARM7 core documentation for information on the CPU modes, rather than the device data sheet.  Search for a document called "ddi0100e", often referred to as the "ARM ARM". Regards.

Issue with LPC2368 with IAR

Okay, I compared the timing setup differences and made mine work identical to the GCC version for the 2368.  I actually went through all the port files to make sure the IAR 2368 code was doing equivalent work.  This lead me to notice that in the 2368 IAR file the SPSR register was being set to System Mode but THUMB mode was not enabled.  Originally the portINITIAL_SPSR was defined as 0x1f in both GCC versions but 0x3f in the IAR version.  I have an ARM Architect Reference Manual, Second Edition, and in section A2-10 it defines the bits for this register.  bits 0-4 – MODE bits bit  5   – T Bit, 1=THUMB 0=ARM bit  6   – FIQ, 0=enabled, 1=disabled bit  7   – IRQ, 0=enabled, 1=disabled So, 0x1F would put the system into non-thumb mode.  This might be a bug in the GCC version, that’s why I mention it, I’m compiling for thumb mode so I left it. I added a software interrupt handler (branch to vPortYieldProcessor) and everything appears to be working now as expected.  I’ll perform more tests and see what I can do to make the actual project function on this board with this hardware.  After I clean up my work I’ll send you the project so you can add it to your demo lists. -Ken

Issue with LPC2368 with IAR

hello, i am trying to run freeRTOS on an lpc2368 using the IAR tools, when i found this forum it seems as i am facing the same problem as ken did i looks like ken already made the port work for the lpc2368, but i can’t find this port in the supported ports or in the unsupported ports so dis this story end well ?
it would greatly help me if i there was a port available for the lpc2368 using the iar compiler

Issue with LPC2368 with IAR

Hi which version of IAR are you using? If it may help I have a port of the latest FreeRTOS version for IAR 4.42A version, the last one with xlink linker.
Just get in touch with me I will send an sample project. Franco