Combining ARM and Thumb not possible?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Combining ARM and Thumb not possible?

647 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Felix G on Mon Oct 26 07:13:20 MST 2015
Hello,

i am currently in the process of evaluating LPCXpresso (as a µVision 3 replacement for future projects), but i seem to have hit a major problem regarding interrupts.


First a quick overview of the architecture...
The firmware is divided into several parts, some of which are used in multiple projects:

1. The application project itself, which consists of platform- and compiler-specific code
2. A static library which implements several low-level drivers for the µC and acts as a hardware abstraction layer (again, platform and compiler-specific code)
3. Several static libraries for communication protocols and other general purpose code. These are writen in pure C99, so they can be used without changes on any platform and compiler


Since we are using an LPC2366 microcontroller which doesn't have a lot of memory, i would like to use the Thumb instruction set for increased code density. However, when i first tried to compile a simple test project (which would later become the HAL library), i got the following error message:

interrupt Service Routines cannot be coded in Thumb mode


That's unfortunate, but not a big deal if i can use ARM for my interrupts and Thumb for everything else, so i tried this:

__attribute__ ((target ("arm"), interrupt ("IRQ"))) static void Timer_ISR(void)
{
    ...
}


But the compiler informed me, that the target attribute is not supported. I figured the next best thing would be to use ARM for all files containing interrupts, and Thumb for everything else. So i tried that, and the library itself compiled just fine, but the application project (which uses that library) didn't.

I got the same error as before, but this time it was thrown by the linker.
If it's not possible to combine ARM and Thumb like that, then what's the point of the "Enable Thumb interworking" option?
0 Kudos
2 Replies

465 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Felix G on Tue Oct 27 03:49:50 MST 2015
Problem solved!

It actually was caused by one of the options i had selected, however it had nothing to do with the interworking itself...
The culprit is the link-time optimization option (-flto), which apparently doesn't work correctly in this particular combination (ARM library with interrupt, used in a Thumb project with -flto).

0 Kudos

465 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vtw.433e on Mon Oct 26 11:32:37 MST 2015
Of course it is possible. Exactly which options are you using for the compiler and the linker? Are you using -mthumb and -mthumb-interwork? Suggest you search for arm/thumb interworking with gcc to work out what you are doing wrong.
0 Kudos