Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 8, 2006
Hi, I'm trying to compile and debug FreeRTOS port Demo/ARM7_LPC2106_GCC in Keil. I copied all files, including boot.s and lpc2106-rom into a new project. Project compiles fine, saying:

linking...
creating hex file...
"FreeRTOS.elf" - 0 Error(s), 1 Warning(s).

but when I try to upload it via JTAG, error occures:

*** error 59: invalid absolute module
Erase Done.
Programming Done.
Verify OK.

It continues uploading, but program doesn't work at all (I've put some simple blinking on very beginning).

When I use different startup.s and target.ld from 'c:\Keil\ARM\GNU\Examples\Blinky\' I can upload and debug it in Keil, and everything seem fine till I enable a interrupt from TMR0, it hops then to some messy area. I'm pretty sure interrupt initialisation is OK, because I took it from my recent project and it works fine there (the problem is, that that recent project I compiled in Keils native compiler - not using GCC)

So I think it's something to do with .s, or .ld files. Especialy interrupts handling definition. But WHAT???

Thank You in advance.

Mirek Fiala

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 8, 2006
Hi, it's me again, problem solved. There should be a little change in vector table in startup.s.

Thisone is OK:
Vectors: LDR PC, Reset_Addr
LDR PC, Undef_Addr
LDR PC, SWI_Addr
LDR PC, PAbt_Addr
LDR PC, DAbt_Addr
NOP /* Reserved Vector */
# LDR PC, IRQ_Addr
LDR PC, [PC, #-0x0FF0] /* Vector from VicVectAddr */
LDR PC, FIQ_Addr

The before it was like:
...
LDR PC, IRQ_Addr
...

I'll have to have a look on why is this...

Cheers, M.F.

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 8, 2006
Also make sure you are calling main() in Supervisor mode, and have setup the IRQ and Supervisor mode stacks. The user mode stacks get setup by individual tasks so no need to worry about those.

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 9, 2006
Thank You,

I believe I've setup the stacks correctly, but I don't have a clue what do You mean by supervisor mode??? There is nothing about it in LPC2129's datasheet and in forum I haven't found anything useful... I suppose It should be done in startup.s, right, but HOW?

Thanks, Mirek

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Richard on June 9, 2006
You will not be able to disable interrupts unless you are in Supervisor mode. The modes the processor operates in are part of the ARM7 code, which the LPC2129 uses. Its documentation can be found in the ARM manual, rather than the LPC2129 manual which really only tells you about the LPC2129 peripherals.

If you look in the startup.s file that comes with the Keil LPC2129 demo (in the FreeRTOS.org distribution) then you will see the lines:

// Start in supervisor mode
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit

this sets the processor mode prior to main being called.

Regards.

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 12, 2006
Ufff, thanx a lot. It works finally. It seems, that the problem was I tried to enter SVC mode afer I had entered USR mode in startup.s. Like this:

# Enter User Mode and set its Stack Pointer
MSR CPSR_c, #Mode_USR
MOV SP, R0

# Setup a default Stack Limit (when compiled with "-mapcs-stack-check")
SUB SL, SP, #USR_Stack_Size

/* We want to start in supervisor mode. Operation will switch to system
mode when the first task starts. */
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit

It stayed in USR mode even after this... Don't You know why? If I don't setup USR mode, FreeRTOS works fine.

Thank you again for Your support. Mirek

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 12, 2006
User mode is not a privileged mode, so you cannot access the CPSR. As you cannot access the CPSR you cannot switch back to Supervisor mode.

The only way out of user mode once entered is within an exception handler. When an exception occurs you switch to a privileged mode so can access the CPSR again.

Read part A of http://www.cs.helsinki.fi/u/jikorhon/condev/gp32/dl/DDI0100E_ARM_ARM.pdf.zip.

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 12, 2006
Thanx

The document has 811 pages! ARM is as complicated as a motor-pig...

Mirek

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 12, 2006
Just take a look at the programmers model in section A. It tells you about the different modes the processor can be in.

Incidentally you don't need to setup a stack for user mode as each task sets up its own stack when it is created.

RE: GCC .s .ld files vs INTERRUPTS???

Posted by Nobody/Anonymous on June 12, 2006
Yes I know, I've found it. It's why I'm saying ARM is a 'bit' complicated.

:)

Mirek


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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner