Error with naked functions and newer GCC

smithbone wrote on Thursday, November 07, 2013:

I’m trying to compile the LPC2148 demo from here:

http://jcwren.com/arm/

My arm gcc (Version 4.7.3) doesn’t seem to like the way FreeRTOS does ISR functions and throws the following error:

rtcISR.c: In function ‘rtcISR’:
rtcISR.c:66:7: error: local frame unavailable (naked function?)
rtcISR.c:66: confused by earlier errors, bailing out
make[1]: *** [rtcISR.o] Error 1

Looking up that error I found:

http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02321.html

Which suggest that gcc does not like that freeRTOS is using a naked function and then doing its own context saving.

Has anyone sorted this out?

My gcc details:

rsmith@thinko:/usr/local/arm-bobo/bin$ ./arm-elf-gcc -v
Using built-in specs.
COLLECT_GCC=./arm-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/arm-bobo/libexec/gcc/arm-elf/4.7.3/lto-wrapper
Target: arm-elf
Configured with: …/gcc/configure --target=arm-elf --prefix=/usr/local/arm-bobo --enable-interwork --enable-multilib --disable-libssp --disable-werror --with-float=soft --enable-languages=c,c++ --with-newlib --with-headers=…/newlib/newlib/libc/include --enable-obsolete
Thread model: single
gcc version 4.7.3 (GCC)

rtel wrote on Thursday, November 07, 2013:

Sorry - we cannot support third party code - rtcISR.c is not something that is provided from the FreeRTOS website.

However, if you post the lines in that file that are causing the compiler problem then we may be able to suggest how it is corrected.

Regards.

smithbone wrote on Thursday, November 07, 2013:

Ah my bad. The function is so simple that I thought it was a FreeRTOS wrapper function.

Its:

void rtcISR (void) attribute ((naked));
void rtcISR (void)
{
portSAVE_CONTEXT ();
rtcISR_Handler ();
portRESTORE_CONTEXT ();
}

rtel wrote on Thursday, November 07, 2013:

Try changing the line:

rtcISR_Handler();

to

__asm volatile( “bl rtcISR_Handler” );

Regards.

smithbone wrote on Thursday, November 07, 2013:

Thanks. I’ll try that. I was discovering that in the ARM7_LPC2106_GCC code. BTW you may want to check that port. It fails to compile for me.

rsmith@thinko:/home/src/FreeRTOSV7.5.2/FreeRTOS/Demo/ARM7_LPC2106_GCC$ make
/usr/local/arm-bobo/bin/arm-elf-gcc -c -Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wunused -D -D GCC_ARM7 -I. -I…/…/Source/include -I…/Common/include -mcpu=arm7tdmi -T -fomit-frame-pointer -fno-strict-aliasing -fno-dwarf2-cfi-asm …/…/Source/portable/GCC/ARM7_LPC2000/portISR.c -o …/…/Source/portable/GCC/ARM7_LPC2000/portISR.o
arm-elf-gcc: error: GCC_ARM7: No such file or directory
make: *** […/…/Source/portable/GCC/ARM7_LPC2000/portISR.o] Error 1

rtel wrote on Thursday, November 07, 2013:

How did you try to build it? Did you follow the build instructions?

Regards.

smithbone wrote on Thursday, November 07, 2013:

What build instructions are you referring to? The only thing I see is a readme.txt which very minimal and talks about running .bat files. I’m using Linux.

However, looking at the .bat files I see that there needs to be some environment variables defined. If I define some it works. So my bad for not a deep enough inspection, however, I think its a bug type ‘make’ and not have either:

  1. Some defaults defined.
  2. Throw an explicit error indicating the proper variables have not been defined.

smithbone wrote on Thursday, November 07, 2013:

BTW. Thank you. This seems to work. I just have to go fix a lot of them.

rtel wrote on Thursday, November 07, 2013:

What build instructions are you referring to?

Start with the quick start guide, it will tell you how to find the instructions to build the code, if you don’t want to read the readme file that is placed next to the makefile in the directory itself:

Regards.

rtel wrote on Thursday, November 07, 2013:

GCC has never handled interrupt entry in ARM very well, various different versions have contained various different bugs, and over the years all the mixing of C and ASM on interrupt entry was removed from the code.

From your initial post it sounds like they have given up trying to support it at all now, and just throw you out if you attempt use C code there - probably as most focus is on Cortex support in GCC now.

Regards.

smithbone wrote on Thursday, November 07, 2013:

if you don’t want to read the readme file that is placed next to the makefile in the directory itself:

That’s my point. I did read the readme that is placed next to the makefile. It consists of 8 short lines that say run 1 of 4 .bat files. Nothing is mentioned about needing to do anything for Linux.

There are no corresponding shell script(s) for Linux. Barring any information stating otherwise as a Linux developer I expect type ‘make’ and have the makefile sort it out or if I saw a ‘configure’ script I would assume autotools is going to run.

I also took a quick look at the makefile which at a cursory inspection seems to be a self contained makefile.

edwards3 wrote on Thursday, November 07, 2013:

You are looking at one of the original examples. It is very old and originally FreeRTOS was made available as an option for use on windows hosts as all the other open source RTOS out their were just for building on linux hosts.