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

Hard Faults in Cortex M3 on unaligned access

Posted by Doug Bailey on June 8, 2011
I am using FreeRTOS V6.1.0 running on a NXP LPC1758 processor (ARM Cortex M3) and compiled using Code Red's LPCxpresso development suite. This uses a toolchain based on GCC V4.4.1.

I have been able to integrate FreeRTOS into my application and all works fine except when I enable the UNALIGN_TRP bit in the System Control Block's Configuration Control Register. This bit enables unaligned access traps as noted in the NXP LPC1758 tech reference (34.4.3.8 Configuration and Control Register).
===================
Enables unaligned access traps:
0 = do not trap unaligned halfword and word accesses
1 = trap unaligned halfword and word accesses.

If this bit is set to 1, an unaligned access generates a usage fault.
Unaligned LDM, STM, LDRD, and STRD instructions always fault irrespective of whether UNALIGN_TRP is set to 1.
===================

When I enable this bit, I get Hard Fault exceptions at different times in the operation. It appears that they occur within the kernel though the location is not always consistent.

When I disable the bit, I see no anomalous behavior and all seems to works as I expect it.

Is this a known issue for the Cortex M3 port? Any suggestions about how to handle it apart from disabling the bit?

Thanks
Doug Bailey


RE: Hard Faults in Cortex M3 on unaligned access

Posted by MEdwards on June 8, 2011
I don't think I have ever enabled that bit so can't say if it is normal. The compiler should ensure everything is aligned. The place where the kernel could get it wrong (but doesn't, at least not in the latest versions) is when the stack is allocated. This should be on an 8 byte boundary. You could check that (check the stack pointer in the task). You could also get a problem if you are packing structures, either explicitly or with a compiler flag. That is something that is often done in protocols such as TCP/IP.


[ 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