Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Issue with LPC2368 with IAR

Posted by KFarr on July 29, 2008
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 "FreeRTOS\Source\portable\IAR\LPC2000" 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


RE: Issue with LPC2368 with IAR

Posted by Richard on July 29, 2008
> * 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
> "FreeRTOS\Source\portable\IAR\LPC2000" 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 Source\portable\GCC\ARM7_LPC23xx\port.c and Source\portable\GCC\ARM7_LPC2000\port.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.




RE: Issue with LPC2368 with IAR

Posted by KFarr on July 29, 2008
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

RE: Issue with LPC2368 with IAR

Posted by Richard on July 29, 2008
If you take a look in the file lpc2xxx_cstartup.s that is located in the Demo\ARM7_LPC2129_IAR\SrcIAR 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.

RE: Issue with LPC2368 with IAR

Posted by KFarr on July 29, 2008
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

RE: Issue with LPC2368 with IAR

Posted by robbe on September 16, 2010
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


RE: Issue with LPC2368 with IAR

Posted by frupi on October 4, 2010
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


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists