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:KeilARMGNUExamplesBlinky’ 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
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.
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.
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
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.
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
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.
Thanx The document has 811 pages! ARM is as complicated as a motor-pig… Mirek
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.
Yes I know, I’ve found it. It’s why I’m saying ARM is a ‘bit’ complicated. :) Mirek
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.