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

Cortex-A and Cortex-R irq stack not 8-byte aligned?

Posted by rudi1895 on September 27, 2016

The example files named portASM.s in the FreeRTOS V9.0.0 and earlier demos for Cortex-A and Cortex-R devices contain the following instruction sequence: ~~~ /* Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for future use. */ MOV r2, sp AND r2, r2, #4 SUB sp, sp, r2

/* Call the interrupt handler. */
PUSH	{r0-r3, lr}
LDR		r1, vApplicationIRQHandlerConst
BLX		r1
POP		{r0-r3, lr}
ADD		sp, sp, r2

~~~ The first three instructions adjust the IRQ stack to be 8-byte aligned. But the following instruction pushes five registers on the stack. IMHO this push will result in an unaligned stack for the called handler.

The instruction sequence proposed for this purpose by ARM pushes two registers and thus keeps the alignment. There is a link to a document on the stack alignment from ARM on the mentioned page.

As I just came across looking for a working IRQ handler for my bare metal application without a (Free)RTOS, I cannot check my assumption. But there are questions in this forum on unaligned stacks which indicate problems as discussed in the document from ARM.

BTW: Comparing the IRQ handlers from ARM and from FreeRTOS there seems to be room for some optimization in FreeRTOS IRQ handler.

HTH Rudi


Cortex-A and Cortex-R irq stack not 8-byte aligned?

Posted by rtel on September 27, 2016

Hi Rudi - thanks for your valuable feedback. This will be investigated and corrected if necessary. It is possible that the number of registers being pushed has changed over time, resulting in the issue you highlight.


[ 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