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

Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 16, 2005
I have Keil uVision V3.12a. What would be the fastest way to start using FreeRTOS for AT91SAM7 with Keil, or is port for Keil planned soon?
If it will not happen in the near future, what suggestions one can get as a help in his struggles to make such a port.

RE: Keil port for AT91SAM7

Posted by Richard on November 17, 2005
Open the existing Keil demo then:

1) From the Project menu, select "Select device for target FreeRTOS", and select the SAM7.

2) Open the file FreeRTOS\Source\portable\IAR\AtmelSAM7S64\port.c. This is the port.c file for the IAR compiler. It contains the code that will setup the timer for the SAM7 in a function called prvSetupTimerInterrupt(). Overwrite the prvSetupTimerInterrupt() function in the Keil demo port.c (which is configured to setup an LPC2000 timer) with the version from the IAR port (which is configured to setup a SAM7 timer). There may also be a few #defines at the top of the file that are required to compile the function.

3) Open the file FreeRTOS\Demo\ARM7_LPC2129_Keil\FreeRTOSConfig.h. You will notice it includes the header lpc21xx.h. Delete this line for obvious reasons. You may have to replace it with a header file that defines the registers for your processor. This will become obvious when you try to compile.

4) Also in FreeRTOSConfig.h you will see the definitions for configCPU_CLOCK_HZ, configMINIMAL_STACK_SIZE and configTOTAL_HEAP_SIZE. Set these to values appropriate for your hardware. You might like to just copy the values from the IAR SAM7 (SAM7S or SAM7X demo as appropriate) FreeRTOSConfig.h file which can be found in the FreeRTOS\Demo\ARM7_AT91SAM7S64_IAR directory.

5) The serial port drivers will be incorrect. You can transfer the SAM7X drivers from IAR demo, but for now just delete the files serial.c and serialISR.c from the Keil project.

6) To start with the smallest application prevent all tasks other than the simple LED flash tasks from being started. To do this open main.c, and find the lines and commend out all the lines between vStartIntegerMathTasks and vStartDynamicPriorityTasks, EXCEPT the line vStartLEDFlashTasks.

7) The code to set or clear an LED is defined in the file FreeRTOS\Demo\ARM7_AT91SAM7S64_IAR\ParTest. The Keil project is configured to access the LED's on the Keil LPC2000 demo board. You will have to update this to access the correct ports to access the LED's on your hardware. If you are using the Atmel demo board then again you can just copy the files from the IAR SAM7 demo. There are demos for both the SAM7S and SAM7X hardware. Also check the function prvSetupHardware() in the file main.c. This sets the data direction or ports, etc. You will also have to set this appropriately for your hardware.

I'm sure when you compile there will be a few includes, definitions, etc. that need some tweaking, but this should get you 95% of the way.

Regards.

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 17, 2005
Thanks Rischard.

I was thinking about doing similar things using GCC port (with sintax change where necessary. Hope I will be able to report a success.

Regards,
Emir

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 21, 2005
It took more than I expected, but finally a modified project for Keil LPC2129 along the lines you specified compiles for AT91SAM7S64. Means nothing before I see an LED blinking on my board (which is a little bit different to Atmel demo one for AT91SAM7S64 processor). Thanks again for help.

Regards,
Emir

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 21, 2005
Hi.

While running my "Keil port" for AT91SAM7S64 in simulation mode I am getting error:

Non- aligned Access: ARM instruction at 0010150CH, Memory Access at AAAAAAE6H
Data Abort ...

It happens on the first task switch by scheduler.

My question is:

Is it related to the setup of the task's start address in port.c:

portSTACK_TYPE *pxPortInitialiseStack (...)
{
portSTACK_TYPE *pxOriginalTOS;

/* Setup the initial stack of the task. The stack is set exactly as expected by the portRESTORE_CONTEXT() macro.

...

pxOriginalTOS = pxTopOfStack;

/* First on the stack is the return address - which in this case is the start of the task. The offset is added to make the return address appear
as it would within an IRQ ISR. */

*pxTopOfStack = ( portSTACK_TYPE ) pxCode + portINSTRUCTION_SIZE;

pxTopOfStack--;

*pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaaaaa;/* R14 */

...
}?

If yes, what whould be correct setup?

Thanks,
Emir

RE: Keil port for AT91SAM7

Posted by Richard on November 21, 2005
The processor *MUST* be in supervisor mode when the scheduler is started. Can you please check this is the case - it is very likely that this is your problem.

Check the existing Keil LPC2000 port startup code, you will notice that it switches to supervisor mode prior to main() being called. You need to do the same with your SAM7 port.

Regards.

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 21, 2005
Thanks Richard.

I am not quite sure am I on the right spot but lets gess. Do you mean that I should set to #0 in TST R0 (from startup.s)

// Enter the C code
LDR R0,=?C?INIT
TST R0,#1 ; Bit-0 set: main is Thumb
(set this to 0 i.e. TST R0,#0
LDREQ LR,=exit?A ; ARM Mode
LDRNE LR,=exit?T ; Thumb Mode
BX R0
ENDP

Regards.

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 21, 2005
Ohh, it was stupid from my side. Sorry.

From sturtup.s:

// Enter Supervisor Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #SVC_Stack_Size


where

Mode_SVC EQU 0x13
SVC_Stack_Size EQU 0x00000100

Should it be

Mode_SVC EQU 0x12?

Regards.

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 22, 2005
Please disregard my two previous posts, they justy show the level of my ignorance.

This post will not be sign of my improvement, but (without being 100% sure that I understand all this) I just commented user mode entry in Startup.s as per

// Enter Supervisor Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
MOV SP, R0
SUB R0, R0, #SVC_Stack_Size

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

The program is now running, there are no any abort states, and I can put breakpoint on LED states in:

void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
if( uxLED < ( portBASE_TYPE ) NB_LED )
{
if( AT91F_PIO_GetInput( AT91C_BASE_PIOA ) & led_mask[ uxLED ] )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, led_mask[ uxLED ]);
}
else
{
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, led_mask[ uxLED ] );
}
}
}.

The LED is definitelly going through ON-OFF states.

I would be very grateful Richard if you can give me your judgement for all this gimnastic I tried.

Regards,
Emir

RE: Keil port for AT91SAM7

Posted by Richard on November 22, 2005
If you look in Startup.s that comes with the Keil LPC port you will notice (as you mention) that the processor is placed in a certain mode, then the stack is setup, then this is repeated for all necessary modes.

After this you will see the following code:


------start of code
// Start in supervisor mode
MSR CPSR_c, #Mode_SVC|I_Bit|F_Bit
------end of code

This just ensure that, once all the stacks have been setup, the processor is placed back into supervisor mode, and remains in supervisor mode until main() is called. You will see that the very next line following these two has the comment "// Enter the C code".

You might also like to check the various stack sizes used by your SAM7 port. In the keil demo the stack sizes are set by constants such as "IRQ_Stack_Size" at the top of the .s file.

Regards.

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on November 22, 2005
Thanks Richard.

As I said yesterday the simulation is running happily and now I can proceed with what I have to do. I am glad I was not so far from the solution.

I don't know is this port of any use for anybody else but I will be happy to share it.

Regards,
Emir

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on December 14, 2005
I would be happy if you could send me the code to meta-dresden@gmx.de

If tried to port the code by myself but it didnt work, there is always an error when I try to compile the assembler file.

Thanks in advance
Felix

RE: Keil port for AT91SAM7

Posted by Nobody/Anonymous on December 15, 2005
Another Problem

I can compile RTOS without the serial.c and get a HEX file with a size of 31 KB
Now I use HEX2BIN to get a BIN file. But the Bin file is over 1MB big, I’ve never had this Problem before normally the Bin file is even smaller than the Hex file.

The Problem is the MC has no 1MB Flash and I dont no what to do to get the Bin file smaller
Any suggestions?


Felix


[ 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